Skip to content

Fix AveragedCrossspectrum for input_counts=False light curves#978

Open
VrtxOmega wants to merge 2 commits into
StingraySoftware:mainfrom
VrtxOmega:fix-stingray-avg-crossspectrum-977
Open

Fix AveragedCrossspectrum for input_counts=False light curves#978
VrtxOmega wants to merge 2 commits into
StingraySoftware:mainfrom
VrtxOmega:fix-stingray-avg-crossspectrum-977

Conversation

@VrtxOmega

@VrtxOmega VrtxOmega commented Jun 11, 2026

Copy link
Copy Markdown

Relevant Issue(s)/PR(s)

Fixes #977.

Provide an overview of the implemented solution or the fix and elaborate on the modifications.

AveragedCrossspectrum was passing the private light-curve storage fields
(_counts and _counts_err) into the shared time-series cross-spectrum helper.
For light curves created with input_counts=False, the public counts and
counts_err accessors provide the countrate-derived arrays, while the private
counts fields can remain unsuitable for this path. That made the cross spectrum
return zero powers for countrate light curves even though AveragedPowerspectrum
worked.

This updates the light-curve path to pass public counts and counts_err,
matching the existing AveragedPowerspectrum and iterable cross-spectrum paths.
It also adds a regression test for identical input_counts=False light curves
and the PR-numbered changelog fragment required by the repository gate.

Is there a new dependency introduced by your contribution? If so, please specify.

No.

Any other comments?

I personally re-checked this before updating the branch:

  • Live issue/PR audit: issue AveragedCrossspectrum returns zeros when using simulated light curves with input_counts=False. #977 is open, labeled bug and help wanted,
    unassigned, and the only open overlapping PR is this one.
  • Before/after edge audit: against origin/main at 840569c6,
    input_counts=False Gaussian countrate cases with zero and nonzero errors
    returned zero/non-matching cross spectra. Against this branch at c16b3f1c,
    both cases became nonzero and matched AveragedPowerspectrum.
  • Unchanged behavior audit: input_counts=True Gaussian zero-error and default
    Poisson counts cases still match AveragedPowerspectrum.
  • PR_NUMBER=978 ... docs/changes/$PR_NUMBER.*.rst
  • .venv/bin/python -m pytest stingray/tests/test_crossspectrum.py::TestAveragedCrossspectrum::test_input_countrate_matches_pds_for_identical_lightcurves -q
  • .venv/bin/python -m pytest stingray/tests/test_crossspectrum.py -q (260 passed, 9 skipped)
  • git diff --check origin/main...HEAD

Known CI note: local uvx tox -e linkcheck fails on external documentation
links already present on origin/main (join.slack.com returns 403 and
pyopensci.org/badges/peer-reviewed.svg returns 404 after redirect). This
branch does not touch those links.

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.

AveragedCrossspectrum returns zeros when using simulated light curves with input_counts=False.

1 participant