✨Good Time, Bad Time: GTI/BTI :)

In my continued journey with Stingray.jl During GSoC 2025, this phase focused on a core aspect of high-energy astrophysics: time filtering using GTIs (Good Time Intervals) and BTIs (Bad Time Intervals). After a productive discussion with my mentor @matteobachetti during our meet, I dove into implementing and refining functionality around GTIs—an essential tool in the timing analysis of astrophysical data.

What Are GTIs and BTIs?

  • GTIs define intervals during which the data is considered reliable—free of contamination, instrument artifacts, or observational interruptions.

  • BTIs are the complementary regions—gaps between GTIs that typically represent unusable or noisy time segments.

Correct handling of these intervals is critical, especially in X-ray timing, where even small artifacts can skew power spectra, light curves, and periodograms.


Worked on Features this week

I extended and validated the implementation of GTI filtering in both EventList and LightCurve structures:


apply_gtis(el::EventList, gtis::Matrix)

This function filters photon events using a list of GTIs:

filtered_el = filter_time(t -> gti_start ≤ t ≤ gti_stop, el)

Only events within the GTI boundaries are retained, and only non-empty segments are returned. This helps preserve valid data while preparing segments for further timing analysis.


apply_gtis(lc::LightCurve, gtis::Matrix)

For light curves, bins are included only if their centers fall entirely within a GTI:

bin_mask = (lc.time .≥ gti_start) .& (lc.time .≤ gti_stop)

This strict criterion ensures that bin integrity is preserved—especially important for Fourier-based methods like power spectral density and periodogram calculations. Each resulting segment includes full metadata and is well-formed for downstream analysis.


fill_bad_time_intervals!(el::EventList, gtis::Matrix)

I also implemented an experimental utility for BTI filling. Short gaps (BTIs shorter than a configurable threshold) can be optionally filled with synthetic events to maintain temporal continuity for methods sensitive to uneven sampling.

Highlights:

  • BTIs are computed from GTIs and event time range.

  • Short gaps can be filled with randomly spaced synthetic events.

  • Synthetic events sample from the original energy distribution (if present).

  • Metadata is updated to clearly tag synthetic data.

This feature is useful for methods like Bartlett periodograms or other analyses where continuity is required but small gaps might otherwise bias the results


Stay tuned for the next dive into timing analysis tools in Stingray.jl. Until then—make your time intervals good :)

Comments

Popular posts from this blog

Beginning of GSoC 2025

Black Holes: Nature's Most Mysterious Phenomena

🌟 Things Are Getting Interesting!!