lc.shift() does not update tstart Lightcurve attribute
Description of the Bug
lc.shift() does not update tstart Lightcurve attribute.
If we agree tstart should be defined as times[0] - dt/2 (see #910 ) I can fix try to fix this. Either we update tstart on the time setter or we just add another line in shift() similar to:
self.tstart = self._time[0] - 0.5 * self.dt[0]
With the new times
Steps/Code to Replicate the Bug
from stingray import Lightcurve
import numpy as np
times = np.arange(50)
mean_flux = 100.0
std_flux = 2.0
flux = np.random.normal(loc=mean_flux, scale=std_flux, size=len(times))
flux_err = np.ones_like(flux) * std_flux
lc = Lightcurve(times, flux, err=flux_err, err_dist="None", dt=1.0, skip_checks=True)
shifted_lc = lc.shift(100)
print("Old tstart", lc.tstart)
print("Shift tstart", shifted_lc.tstart)
np.testing.assert_equal(shifted_lc.time[0] - shifted_lc.dt/2, lc.time[0] - lc.dt/2)
Expected Results
tstart for shifted and lc should differ after the time shifting.
Actual Results
Old tstart -0.5
Shift tstart -0.5
Traceback (most recent call last):
File "/home/andresgur/scripts/pythonscripts/stingray/bug_shift.py", line 17, in
Thanks @andresgur !
As discussed in #910, tstart should be defined from gtis, not the time attribute, but for the rest I agree that this should be fixed!
Hey @matteobachetti , i have a doubt if a lightcurve was shifted then dt should also be changed.
but we are not changing it. correct me if this is bug.
@ankitkhushwaha no, shifting does not affect dt