From a8a811d467f7175cc3c6a570f0c86e12b93101f7 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 10 Dec 2024 12:23:46 -0600 Subject: [PATCH 1/3] fixed find_empty_masks --- CHANGELOG-unreleased.md | 1 + src/pint/models/timing_model.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-unreleased.md b/CHANGELOG-unreleased.md index 7579adb51..51545be13 100644 --- a/CHANGELOG-unreleased.md +++ b/CHANGELOG-unreleased.md @@ -26,6 +26,7 @@ the released changes. - When EQUAD is created from TNEQ, has proper TCB->TDB conversion info - TOA selection masks will work when only TOA is the first one - Condense code in Glitch model and add test coverage. +- `find_empty_masks` will now search through `CMX` parameters ### Removed - macOS 12 CI diff --git a/src/pint/models/timing_model.py b/src/pint/models/timing_model.py index 68fe886bf..0d3d99431 100644 --- a/src/pint/models/timing_model.py +++ b/src/pint/models/timing_model.py @@ -109,6 +109,9 @@ ignore_prefix = {"DMXF1_", "DMXF2_", "DMXEP_"} +# prefixes of parameters that may need to be checked for empty ranges +prefixes = ["DM", "SW", "CM"] + DEFAULT_ORDER = [ "astrometry", "jump_delay", @@ -2901,7 +2904,7 @@ def find_empty_masks(self, toas, freeze=False): if freeze: log.info(f"'{maskpar}' has no TOAs so freezing") getattr(self, maskpar).frozen = True - for prefix in ["DM", "SW"]: + for prefix in prefixes: mapping = pint.utils.xxxselections(self, toas, prefix=prefix) for k in mapping: if len(mapping[k]) == 0: From 9994a0c55f2738373bcaf3650dbfe2262b3a8499 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Tue, 10 Dec 2024 14:59:40 -0600 Subject: [PATCH 2/3] validation allows for R1<=toa and R2>=toa; warns when R1==R2 --- src/pint/models/dispersion_model.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pint/models/dispersion_model.py b/src/pint/models/dispersion_model.py index 5262795ce..218a9bec7 100644 --- a/src/pint/models/dispersion_model.py +++ b/src/pint/models/dispersion_model.py @@ -627,6 +627,10 @@ def validate(self): r2[j] = getattr(self, f"DMXR2_{index:04d}").quantity.mjd indices[j] = index for j, index in enumerate(DMXR1_mapping): + if (r1[j] == r2[j]) and (r1[j] > 0): + log.warning( + f"Start of DMX_{index:04d} ({r1[j]}) equal to end of DMX_{index:04d} ({r2[j]})" + ) if np.any((r1[j] > r1) & (r1[j] < r2)): k = np.where((r1[j] > r1) & (r1[j] < r2))[0] for kk in k.flatten(): @@ -651,7 +655,7 @@ def validate_toas(self, toas): b = self._parent[DMXR1_mapping[k]].quantity.mjd * u.d e = self._parent[DMXR2_mapping[k]].quantity.mjd * u.d mjds = toas.get_mjds() - n = np.sum((b <= mjds) & (mjds < e)) + n = np.sum((b <= mjds) & (mjds <= e)) if n == 0: bad_parameters.append(DMX_mapping[k]) if bad_parameters: From 6b9c61f599da70cdbfb9630512430a3022dce3e0 Mon Sep 17 00:00:00 2001 From: David Kaplan Date: Wed, 11 Dec 2024 11:46:57 -0600 Subject: [PATCH 3/3] initialization of dmx_selector now in validate() --- src/pint/models/dispersion_model.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pint/models/dispersion_model.py b/src/pint/models/dispersion_model.py index 218a9bec7..595379717 100644 --- a/src/pint/models/dispersion_model.py +++ b/src/pint/models/dispersion_model.py @@ -643,6 +643,8 @@ def validate(self): log.warning( f"End of DMX_{index:04d} ({r1[j]}-{r2[j]}) overlaps with DMX_{indices[kk]:04d} ({r1[kk]}-{r2[kk]})" ) + if not hasattr(self, "dmx_toas_selector"): + self.dmx_toas_selector = TOASelect(is_range=True) def validate_toas(self, toas): DMX_mapping = self.get_prefix_mapping_component("DMX_")