Skip to content

Commit

Permalink
Merge pull request #1637 from pypeit/hotfix_cif_meta
Browse files Browse the repository at this point in the history
Hotfix to allow lists for config_independent_frames
  • Loading branch information
rcooke-ast authored Jul 21, 2023
2 parents 7a1ba03 + 9544606 commit 6b2b85c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Hotfix for GTC/OSIRIS lamp list
- Hotfix for Arc1D stats annotations on the QA
- Hotfix for metadata (correctly set config_independent frames when multiple configurations are being setup)
- Hotfix for metadata (support lists in ``config_independent_frames()``)
- Hotfix for rebin (speed-up and conserves flux)
- Hotfix for skysub regions GUI that used np.bool
- Hotfix to stop pypeit_setup from crashing on data from lbt_luci1, lbt_luci2, magellan_fire,
Expand Down
39 changes: 26 additions & 13 deletions pypeit/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,11 +854,21 @@ def set_configurations(self, configs=None, force=False, fill=None):
for ftype, metakey in ignore_frames.items():

# TODO: For now, use this assert to check that the
# metakey is either not set or a string
assert metakey is None or isinstance(metakey, str), \
# metakey is either not set, or is a string/list
assert metakey is None or isinstance(metakey, str) or isinstance(metakey, list), \
'CODING ERROR: metadata keywords set by config_indpendent_frames are not ' \
'correctly defined for {0}; values must be None or a string.'.format(
self.spectrograph.__class__.__name__)
# If a list is input, check all elements of the list are strings
if isinstance(metakey, list):
for ll in metakey:
assert isinstance(ll, str), \
'CODING ERROR: metadata keywords set by config_indpendent_frames are not ' \
'correctly defined for {0}; values must be None or a string.'.format(
self.spectrograph.__class__.__name__)
elif isinstance(metakey, str):
# If metakey is a string, convert it to a one-element list
metakey = [metakey]

# Get the list of frames of this type without a
# configuration
Expand All @@ -878,17 +888,20 @@ def set_configurations(self, configs=None, force=False, fill=None):
self.table['setup'][indx] = new_cfg_key
continue

# Find the unique values of meta for this configuration
uniq_meta = np.unique(self.table[metakey][in_cfg].data)
# Warn the user that the matching meta values are not
# unique for this configuration.
if uniq_meta.size != 1:
msgs.warn('When setting the instrument configuration for {0} '.format(ftype)
+ 'frames, configuration {0} does not have unique '.format(cfg_key)
+ '{0} values.' .format(meta))
# Find the frames of this type that match any of the
# meta data values
indx &= np.isin(self.table[metakey], uniq_meta)
# Loop through the meta keys
for mkey in metakey:
# Find the unique values of meta for this configuration
uniq_meta = np.unique(self.table[mkey][in_cfg].data)
# Warn the user that the matching meta values are not
# unique for this configuration.
if uniq_meta.size != 1:
msgs.warn('When setting the instrument configuration for {0} '.format(ftype)
+ 'frames, configuration {0} does not have unique '.format(cfg_key)
+ '{0} values.' .format(meta))
# Find the frames of this type that match any of the
# meta data values
indx &= np.isin(self.table[mkey], uniq_meta)

# assign
new_cfg_key = np.full(len(self.table['setup'][indx]), 'None', dtype=object)
for c in range(len(self.table['setup'][indx])):
Expand Down
2 changes: 1 addition & 1 deletion pypeit/spectrographs/not_alfosc.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def default_pypeit_par(cls):
par['calibrations']['wavelengths']['lamps'] = ['HeI', 'NeI', 'ArI']
par['calibrations']['wavelengths']['sigdetect'] = 10.0
# Set the default exposure time ranges for the frame typing
par['calibrations']['biasframe']['exprng'] = [None, 0.001]
par['calibrations']['biasframe']['exprng'] = [None, 1]
par['calibrations']['darkframe']['exprng'] = [999999, None] # No dark frames
par['calibrations']['pinholeframe']['exprng'] = [999999, None] # No pinhole frames
par['calibrations']['arcframe']['exprng'] = [None, None] # Long arc exposures on this telescope
Expand Down

0 comments on commit 6b2b85c

Please sign in to comment.