Inconsistent behaviour of tstart and tseg after using lc.truncate
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
Reproduce the supplied GTI and no-GTI examples, then inspect the truncate method in base.py, especially the assignments to new_ts.tstart and new_ts.tseg. Compare the truncated values with the updated time array and dt in both cases. Done means tstart and tseg behave consistently before and after truncation.
Written by the indexing model from the issue text.
Description
Description of the Bug
If a lightcurve with a gti is truncated, tstart and tseg behave inconsistently before and after the truncation. Prior to truncation, both are defined based on the times and dt e.g. tstart is defined in the usual way time[0] - dt/2.
After truncating tstart is defined by the first GTI starting time and tseg (incorrectly) based on the gti first and last times. I would have reopened #751 but I don't have privileges.
In truncate method of base.py, I don't think this is correct:
new_ts.tstart = new_ts.gti[0, 0]
new_ts.tseg = new_ts.gti[-1, 1] - new_ts.gti[0, 0]
I think the new tstart and tseg should be defined based on the updated times, unless I'm missing something. If we agree on that I could try to fix it myself.
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)
# No GTI
lc = Lightcurve(times, flux, err=flux_err, err_dist="None", dt=1.0, skip_checks=True)
print("No GTI\n=====")
print("Tstart before truncating", lc.tstart)
print("Tseg before truncating", lc.tseg)
newlc = lc.truncate(10, method="time")
print("Tstart after truncating", newlc.tstart)
print("Tstart after truncating", newlc.tseg)
# GTI
gti = [[25, 30], [40, 45]]
lc = Lightcurve(times, flux, err=flux_err, gti=gti, err_dist="None", dt=1.0, skip_checks=True)
print("GTI\n=====")
print("Tstart before truncating", lc.tstart)
print("Tseg tefore truncating", lc.tseg)
newlc = lc.truncate(10, method="time")
print("Tstart after truncating", newlc.tstart)
print("Tseg after truncating", newlc.tseg)
Expected Results
tstart should be defined consistently throughout, as lc.time[0] - lc.dt/2 I would say.
Same thing for tseg, which should be defined based on lc.time and lc.dt and not on the gti.
Actual Results
No GTI
Tstart before truncating -0.5
Tseg before truncating 50.0
Tstart after truncating 9.5
Tstart after truncating 40.0
GTI
Tstart before truncating -0.5
Tseg tefore truncating 50.0
Tstart after truncating 25.0
Tseg after truncating 20.0
- Dominant language
- Python
- Stars
- 229
- Forks
- 196
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 20
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from StingraySoftware/stingray
-
create_gti_mask drops valid points after empty GTIs and crashes with min_length > 0 and dtPossibly taken @Rohan-Dedhia claimed this 5 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
StingraySoftware/stingray#1044 ·
Maintainers usually reply within 3 days
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
StingraySoftware/stingray#1042 · 1 comment ·
Maintainers usually reply within 3 days
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
StingraySoftware/stingray#1039 · 1 comment ·
Maintainers usually reply within 3 days
-
stingray: arbitrary code execution reading a pickle-format data product (read fmt=pickle) (CWE-502)May be free again @yash-8923 claimed this 11 days ago, and no pull request is open. Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
StingraySoftware/stingray#1037 · 3 comments ·
Maintainers usually reply within 3 days
-
AveragedCrossspectrum returns zeros when using simulated light curves with input_counts=False.Possibly taken @VrtxOmega claimed this 176 days ago. Openbug help wanted
Difficulty 4/5 3-5 days Newbie friendliness 52/100
StingraySoftware/stingray#977 · 1 comment ·
Maintainers usually reply within 3 days
All issues in StingraySoftware/stingray
Similar issues
-
accepted
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
future-agi/future-agi#6392 ·
Maintainers usually reply within 1 day
-
memmapped_arange ignores the start value and drops the last point above the memmap thresholdPossibly taken @prathameshfuke claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
StingraySoftware/HENDRICS#213 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
bot-triaged module: decompositions module: edge cases module: int overflow module: primTorch oncall: pt2 triage review
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day