From 9b4552e43062e065f5e7a48872e6b7a94c4df0e2 Mon Sep 17 00:00:00 2001 From: Kyle Westfall Date: Mon, 1 Jul 2024 08:07:46 -0700 Subject: [PATCH 1/2] calib group hotfix --- pypeit/metadata.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/pypeit/metadata.py b/pypeit/metadata.py index 3fc1d1b17d..d9955d8550 100644 --- a/pypeit/metadata.py +++ b/pypeit/metadata.py @@ -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 = [] @@ -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)) From bd00631a10b996f76d40b550cb4586cc3732dd87 Mon Sep 17 00:00:00 2001 From: Kyle Westfall Date: Mon, 1 Jul 2024 08:16:34 -0700 Subject: [PATCH 2/2] changes --- doc/releases/1.16.1dev.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/releases/1.16.1dev.rst b/doc/releases/1.16.1dev.rst index 33b59d4259..06bda74e28 100644 --- a/doc/releases/1.16.1dev.rst +++ b/doc/releases/1.16.1dev.rst @@ -40,5 +40,6 @@ 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.