Skip to content

Fix tieredScheduler JEZ compatibility and EXOCAT1 NumPy scalar assignment - #478

Open
MDamiano wants to merge 1 commit into
masterfrom
tieredScheduler_bugfixes
Open

MDamiano wants to merge 1 commit into
masterfrom
tieredScheduler_bugfixes

Conversation

@MDamiano

Copy link
Copy Markdown
Collaborator

Describe your changes

Fix compatibility and indexing issues in tieredScheduler and EXOCAT1:

  • Replace np.any() where used as an emptiness check, preserving valid index 0.
  • Correct JEZ units and star/planet indexing in integration-time calculations, characterization, completeness, and DRM output.
  • Store inflection curves in the cache directory using mode-specific keys and a JEZ-specific filename.
  • Handle t_det=None as zero days so no-target returns do not cause a multiplication error.
  • Use .item() for EXOCAT1 scalar index assignment to support newer NumPy versions.

Type of change

  • Bug fix

Validation

Targeted checks passed for JEZ units, planet subsets, inflection caching, and a short simulation. EXOCAT1 scalar assignment was also checked with NumPy 2.5.

No new test files are included.

Checklist before requesting a review

  • Verify all unit tests pass in a clean virtual environment -> 237 passed, 17 skipped, 2 errors (two errors are bout Roman observatory module querying Horizons for spacecraft orbit data. Tests failed because that request returned an error - missing required file LTKERNL and Var not declared: IP_ADDR - preventing the observatory from initializing.).
  • Run e2eTests -> all 14 scripts passed.

… and performance in EXOCAT1 and tieredScheduler classes
# fZ = ZL.fZ(Obs, TL, sInds, TK.currentTimeAbs.copy(), char_mode)
# Walker previous version.
JEZ = TL.JEZ0[char_mode["hex"]][sInds][self.known_earths]
JEZ = TL.JEZ0[char_mode["hex"]][sInds]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this changing the logic? or was self.known_earths guaranteed to be a completely full array?

@MDamiano MDamiano Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sInds = SU.plan2star[self.known_earths] (4 lines above this change) already selects the host star for each known Earth. Therefore, TL.JEZ0[...][sInds] already contains the selected values. Applying global planet indices again is incorrect. For example, known planets [1, 4] produce two selected sInds values; indexing those with [1, 4] raises an out-of-bounds error.

# PERFORM DETECTION and populate revisit list attribute.
# First store dMag, WA
if np.any(pInds):
if pInds.size:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what numpy behavior change is leading to all these changes of np.any to a test on .size?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes an existing logic bug, not a NumPy behavior change: np.any([0]) is false even though the index array contains one valid element. .size checks whether elements exist.

The EXOCAT1 .item() change is the separate NumPy compatibility fix (this preserves the intended behavior when there is exactly one matching HIP entry.).


fZ = ZL.fZ(Obs, TL, sInd, startTime, mode)
JEZ = JEZs[tochar]
JEZ = JEZs

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this also a logical change from before? won't the resulting array be a different size?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of lines below, calc_intTime() call applies the filtering consistently to all the quantities of interest.

see OS.calc_intTime(TL, sInd, fZ, JEZ[tochar], dMag[tochar], WAp[tochar], mode).

Suppose a star has three planets, but only the first and third should be characterized:
tochar = [True, False, True]
Previously, JEZ was filtered immediately:
JEZ = JEZs[tochar] # 2 entries
But dMag and WAp still contained three entries. The call then mixed these sizes:

OS.calc_intTime(TL, sInd, fZ, JEZ, dMag, WAp, mode)
#                          JEZ -> 2    dMag -> 3    Was -> 3 entries

Calculations combining those arrays could fail because their elements no longer aligned.
The fix keeps all arrays at three entries while preparing the planet properties, then selects the same planets from every input:

OS.calc_intTime(
    TL, sInd, fZ,
    JEZ[tochar], dMag[tochar], WAp[tochar], mode
)

Previously, WAp and dMag were never filtered / shortened with tochar.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants