Skip to content
Open
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 docs/changes/978.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed averaged cross spectra for light curves initialized with ``input_counts=False``.
4 changes: 2 additions & 2 deletions stingray/crossspectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -3068,12 +3068,12 @@ def crossspectrum_from_lightcurve(
error_flux_attr = None

if lc1.err_dist == "gauss":
error_flux_attr = "_counts_err"
error_flux_attr = "counts_err"

return crossspectrum_from_timeseries(
lc1,
lc2,
"_counts",
"counts",
error_flux_attr=error_flux_attr,
segment_size=segment_size,
norm=norm,
Expand Down
13 changes: 13 additions & 0 deletions stingray/tests/test_crossspectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,19 @@ def test_lc_keyword_deprecation(self):
assert np.allclose(cs1.power, cs2.power)
assert np.allclose(cs1.freq, cs2.freq)

def test_input_countrate_matches_pds_for_identical_lightcurves(self):
dt = 1 / 64
time = np.arange(0.5 * dt, 64, dt)
countrate = 100 + 3 * np.sin(2 * np.pi * 4 * time) + 2 * np.cos(2 * np.pi * 7 * time)
err = np.zeros_like(countrate)
lc = Lightcurve(time, countrate, input_counts=False, err=err, err_dist="gauss", dt=dt)

cs = AveragedCrossspectrum(lc, lc, segment_size=1, norm="frac", silent=True)
pds = AveragedPowerspectrum(lc, segment_size=1, norm="frac", silent=True)

assert not np.allclose(cs.power, 0)
assert np.allclose(cs.power.real, pds.power)

def test_make_empty_crossspectrum(self):
cs = AveragedCrossspectrum()
assert cs.freq is None
Expand Down