Skip to content

Commit 514e5e3

Browse files
add tests for lightcurve.shift
1 parent 44e5048 commit 514e5e3

2 files changed

Lines changed: 19 additions & 21 deletions

File tree

stingray/lightcurve.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,13 @@ class Lightcurve(StingrayTimeseries):
8484
They will be used by other methods to have an indication of the
8585
"safe" time intervals to use during analysis.
8686
87-
err_dist: str, optional, None, default ``poisson``
87+
err_dist: str, optional, default ``None``
8888
Statistical distribution used to calculate the
8989
uncertainties and other statistical values appropriately.
9090
Default makes no assumptions and keep errors equal to zero.
9191
92-
At the moment Stingray only uses ``poisson`` err_dist.
93-
All analysis in the light curve will assume Poisson errors.
94-
92+
Stingray currently supports only Poisson error distribution.
93+
All light curve analyses will assume Poisson errors.
9594
bg_counts: iterable,`:class:numpy.array` or `:class:List` of floats, optional, default ``None``
9695
A list or array of background counts detected in the background extraction region
9796
in each bin corresponding to the bins defined in `time`.
@@ -279,20 +278,19 @@ def __init__(
279278
if not skip_checks:
280279
time, counts, err = self.initial_optional_checks(time, counts, err, gti=gti)
281280

282-
if err_dist is not None:
283-
if err_dist.lower() not in valid_statistics:
284-
# err_dist set can be increased with other statistics
285-
raise StingrayError(
286-
"Statistic not recognized." "Please select one of these: ",
287-
"{}".format(valid_statistics),
288-
)
289-
elif not err_dist.lower() == "poisson":
290-
simon(
291-
"Stingray only uses poisson err_dist at the moment. "
292-
"All analysis in the light curve will assume Poisson "
293-
"errors. "
294-
"Sorry for the inconvenience."
295-
)
281+
if err_dist.lower() not in valid_statistics:
282+
# err_dist set can be increased with other statistics
283+
raise StingrayError(
284+
"Statistic not recognized." "Please select one of these: ",
285+
"{}".format(valid_statistics),
286+
)
287+
elif not err_dist.lower() == "poisson":
288+
simon(
289+
"Stingray only uses poisson err_dist at the moment. "
290+
"All analysis in the light curve will assume Poisson "
291+
"errors. "
292+
"Sorry for the inconvenience."
293+
)
296294

297295
self._time = time
298296

@@ -311,7 +309,6 @@ def __init__(
311309
dt = 1.0
312310

313311
self.dt = dt
314-
315312
if isinstance(dt, Iterable):
316313
warnings.warn(
317314
"Some functionalities of Stingray Lightcurve will not work when `dt` is Iterable"
@@ -1192,10 +1189,8 @@ def shift(self, time_shift: float, inplace=False):
11921189

11931190
if isinstance(self.dt, Iterable):
11941191
ts.tstart = ts._time[0] - 0.5 * self.dt[0]
1195-
ts.tseg = ts._time[-1] - ts._time[0] + self.dt[-1] / 2 + self.dt[0] / 2
11961192
else:
11971193
ts.tstart = ts._time[0] - 0.5 * self.dt
1198-
ts.tseg = ts._time[-1] - ts._time[0] + self.dt
11991194
# Pay attention here: if the GTIs are created dynamically while we
12001195
# access the property,
12011196
if ts._gti is not None:

stingray/tests/test_lightcurve.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,12 +1329,15 @@ def test_shift(self):
13291329
lc = Lightcurve(times, counts, input_counts=True)
13301330
lc2 = lc.shift(1)
13311331
assert np.allclose(lc2.time - 1, times)
1332+
assert np.allclose(lc2.tstart - 1, lc.tstart)
13321333
lc2 = lc.shift(-1)
13331334
assert np.allclose(lc2.time + 1, times)
1335+
assert np.allclose(lc2.tstart + 1, lc.tstart)
13341336
assert np.allclose(lc2.counts, lc.counts)
13351337
assert np.allclose(lc2.countrate, lc.countrate)
13361338
lc = Lightcurve(times, counts, input_counts=False)
13371339
lc2 = lc.shift(1)
1340+
assert np.allclose(lc2.tstart - 1, lc.tstart)
13381341
assert np.allclose(lc2.counts, lc.counts)
13391342
assert np.allclose(lc2.countrate, lc.countrate)
13401343

0 commit comments

Comments
 (0)