Skip to content

Commit

Permalink
Merge branch 'develop' into combine_refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kbwestfall committed Jul 22, 2024
2 parents 461260f + 9c7bb98 commit 66d5784
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 3 additions & 1 deletion doc/releases/1.16.1dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ Under-the-hood Improvements
Bug Fixes
---------

- None
- Fixed a fault caused when all frames in a pypeit file are identified as being
part of ``all`` calibration groups.
- Allow for empty 2D wavecal solution in HDU extension of WaveCalib file

23 changes: 17 additions & 6 deletions pypeit/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,18 +1033,28 @@ def _set_calib_group_bits(self):
Set the calibration group bit based on the string values of the
'calib' column.
"""
# NOTE: This is a hack to ensure the type of the *elements* of the calib
# column are all strings, but that the type of the column remains as
# "object". I'm calling this a hack because doing this is easier than
# Ensure that the type of the *elements* of the calib column are all
# strings, but that the type of the column remains as "object".
# NOTE: This is effectively a hack because doing this is easier than
# trying to track down everywhere calib is changed to values that may or
# may not be integers instead of strings.
self['calib'] = np.array([str(c) for c in self['calib']], dtype=object)

# Collect and expand any lists
# group_names = np.unique(np.concatenate(
# [s.split(',') for s in self['calib'] if s not in ['all', 'None']]))
# DP changed to below because np.concatenate does not accept an empty list,
# which is the case when calib is None for all frames. This should avoid the code to crash
group_names = np.unique(sum([s.split(',') for s in self['calib'] if s not in ['all', 'None']], []))
# NOTE: The above doesn't always work because np.concatenate does not
# accept an empty list, which is the case when calib is None or 'all'
# for all frames.
group_names = np.unique(sum([s.split(',') for s in self['calib']
if s not in ['all', 'None']], []))

# If all the calibration groups are set to None or 'all', group_names
# can be an empty list. But we need to identify at least one
# calibration group, so I insert a mock value.
if group_names.size == 0:
group_names = np.array(['0'], dtype=object)

# Expand any ranges
keep_group = np.ones(group_names.size, dtype=bool)
added_groups = []
Expand All @@ -1053,6 +1063,7 @@ def _set_calib_group_bits(self):
# Parse the range
keep_group[i] = False
added_groups += [str(n) for n in parse.str2list(name)]

# Combine and find the unique *integer* identifiers
group_names = np.unique(np.asarray(added_groups +
(group_names[keep_group]).tolist()).astype(int))
Expand Down
3 changes: 2 additions & 1 deletion pypeit/wavecalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def from_hdu(cls, hdu, chk_version=True, **kwargs):
# Parse all the WAVE2DFIT extensions
# TODO: It would be good to have the WAVE2DFIT extensions follow the
# same naming convention as the WAVEFIT extensions...
wave2d_fits = [fitting.PypeItFit.from_hdu(hdu[e], chk_version=chk_version)
wave2d_fits = [fitting.PypeItFit() if len(hdu[e].data) == 0
else fitting.PypeItFit.from_hdu(hdu[e], chk_version=chk_version)
for e in ext if 'WAVE2DFIT' in e]
if len(wave2d_fits) > 0:
d['wv_fit2d'] = np.asarray(wave2d_fits)
Expand Down

0 comments on commit 66d5784

Please sign in to comment.