Skip to content

Commit

Permalink
Generatorify stringify_dict function (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
teutoburg authored Feb 15, 2025
2 parents 5dcb264 + b8fcfbe commit aa790f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions scopesim/detector/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def reset(self):
@property
def hdu(self):
"""Return internal HDU."""
new_meta = stringify_dict(self.meta)
self._hdu.header.update(new_meta)
self._hdu.header.update(stringify_dict(self.meta))

pixel_scale = from_currsys("!INST.pixel_scale", self.cmds)
plate_scale = from_currsys("!INST.plate_scale", self.cmds)
Expand Down
13 changes: 6 additions & 7 deletions scopesim/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,14 +499,13 @@ def has_needed_keywords(header, suffix=""):
return all(key in header.keys() for key in keys)


def stringify_dict(dic, ignore_types=(str, int, float)):
def stringify_dict(dic, ignore_types=(str, int, float, bool)):
"""Turn a dict entries into strings for addition to FITS headers."""
dic_new = deepcopy(dic)
for key in dic_new:
if not isinstance(dic_new[key], ignore_types):
dic_new[key] = str(dic_new[key])

return dic_new
for key, value in dic.items():
if isinstance(value, ignore_types):
yield key, value
else:
yield key, str(value)


def from_currsys(item, cmds=None):
Expand Down

0 comments on commit aa790f6

Please sign in to comment.