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/9999.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lightcurve's shift method now properly updates the tstart attribute to remain consistent with the shifted time array.
30 changes: 30 additions & 0 deletions stingray/lightcurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,36 @@ def plot(
axis_limits=axis_limits,
)

def shift(self, time_shift, inplace=False):
"""
Shift the light curve and correctly update tstart.

Parameters
----------
time_shift: float
The time interval by which the light curve will be shifted (in
the same units as the time array in :class:`Lightcurve`

Other parameters
----------------
inplace : bool
If True, overwrite the current light curve. Otherwise, return a new one.

Returns
-------
lc_new : :class:`Lightcurve` object
The new light curve shifted by ``time_shift``
"""
lc_new = super().shift(time_shift, inplace=inplace)

# Update tstart to be consistent with the shifted time
if isinstance(lc_new.dt, Iterable):
lc_new.tstart = lc_new.time[0] - 0.5 * lc_new.dt[0]
else:
lc_new.tstart = lc_new.time[0] - 0.5 * lc_new.dt

return lc_new

@classmethod
def read(
cls, filename, fmt=None, format_=None, err_dist="gauss", skip_checks=False, **fits_kwargs
Expand Down