Inconsistent behaviour of tstart and tseg after using lc.truncate

Aperta
#910 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

  • #962 di @tsharan17 — chiusa senza merge
  • #974 di @swapsha96 — chiusa senza merge

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
data

Direzione di ricerca

Riproduci gli esempi forniti con GTI e no-GTI, quindi esamina il metodo truncate in base.py, in particolare le assegnazioni a new_ts.tstart e new_ts.tseg. Confronta i valori troncati con l'array temporale aggiornato e dt in entrambi i casi. Il lavoro è completato quando tstart e tseg si comportano in modo coerente prima e dopo il troncamento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug help wanted
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

Lingua principale
Python
Stelle
229
Fork
196
Merge medio
4g 12h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di StingraySoftware/stingray

Tutte le issue di StingraySoftware/stingray

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.