From 0056842d929f782c6c9ad598ffcf73fcd3e793a2 Mon Sep 17 00:00:00 2001 From: rcooke Date: Sat, 12 Oct 2024 20:41:46 +0100 Subject: [PATCH] masked header cards --- pypeit/spec2dobj.py | 10 +++++++++- pypeit/specobjs.py | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pypeit/spec2dobj.py b/pypeit/spec2dobj.py index da076bc98..c065ade57 100644 --- a/pypeit/spec2dobj.py +++ b/pypeit/spec2dobj.py @@ -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? diff --git a/pypeit/specobjs.py b/pypeit/specobjs.py index 2ebcfbb25..1d523ed2a 100644 --- a/pypeit/specobjs.py +++ b/pypeit/specobjs.py @@ -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]