Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed find_empty_masks for CMX #1872

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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
- Fixed some docstrings for binary models.
### Removed
- macOS 12 CI
Expand Down
8 changes: 7 additions & 1 deletion src/pint/models/dispersion_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -639,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_")
Expand All @@ -651,7 +657,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:
Expand Down
5 changes: 4 additions & 1 deletion src/pint/models/timing_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down
Loading