Skip to content

Commit

Permalink
masked header cards
Browse files Browse the repository at this point in the history
  • Loading branch information
rcooke-ast committed Oct 12, 2024
1 parent e80f42e commit 0056842
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pypeit/spec2dobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,15 @@ def build_primary_hdr(self, raw_header, spectrograph, calib_dir=None,
# Add the spectrograph-specific sub-header
if subheader is not None:
for key in subheader.keys():
hdr[key.upper()] = subheader[key]
# Find the value and check if it is masked
if isinstance(subheader[key], (tuple, list)):
# value + comment
_value = ('', subheader[key][1]) if np.ma.is_masked(subheader[key][0]) else subheader[key]
else:
# value only
_value = '' if np.ma.is_masked(subheader[key]) else subheader[key]
# Update the header card with the corresponding value
hdr[key.upper()] = _value

# PYPEIT
# TODO Should the spectrograph be written to the header?
Expand Down
1 change: 1 addition & 0 deletions pypeit/specobjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ def write_to_fits(self, subheader, outfile, overwrite=True, update_det=None,
for line in str(subheader[key.upper()]).split('\n'):
header[key.upper()] = line
else:
# Find the value and check if it is masked
if isinstance(subheader[key], (tuple, list)):
# value + comment
_value = ('', subheader[key][1]) if np.ma.is_masked(subheader[key][0]) else subheader[key]
Expand Down

0 comments on commit 0056842

Please sign in to comment.