stingray icon indicating copy to clipboard operation
stingray copied to clipboard

Add support for reading Fermi/gbm fits file in Eventlist.read

Open ankitkhushwaha opened this issue 9 months ago • 3 comments

fixes #614

i have changed my approach to read fermi-gbm data. instead of creating separate function to read fermi-gbm flies, i have made required changes in Eventlist.read to support them as well.

To read gbm files

file used: link

from stingray import EventList
evt = EventList.read('glg_tte_n0_bn210117458_v00.fit', fmt= 'hea')

Reference

def read_gbm_data(filename, emin=None, emax=None):

    hdulist = fits.open(filename)
    header = hdulist[0].header

    elower = hdulist[1].data.field("E_MIN")
    ehigher = hdulist[1].data.field("E_MAX")
    emid = elower + (ehigher - elower) / 2.0

    time = hdulist[2].data.field("TIME")
    channels = hdulist[2].data.field("PHA")

    if emin is None:
        emin = np.min(elower)
    if emax is None:
        emax = np.max(ehigher)
    for c in channels:
        emid[c]

    energy = np.array([emid[c] for c in channels])
    mask = (energy > emin) & (energy < emax)

    time = time[mask]
    energy = energy[mask]
    trigtime = hdulist[0].header["TRIGTIME"]
    hdulist.close()
    evt = EventList(time, energy, header)

    return evt, trigtime

source: @dhuppenkothen

ankitkhushwaha avatar Mar 02 '25 18:03 ankitkhushwaha

Codecov Report

Attention: Patch coverage is 1.85185% with 53 lines in your changes missing coverage. Please review.

Project coverage is 45.47%. Comparing base (c432bd2) to head (f0376f3).

Files with missing lines Patch % Lines
stingray/io.py 1.85% 53 Missing :warning:

:exclamation: There is a different number of reports uploaded between BASE (c432bd2) and HEAD (f0376f3). Click for more details.

HEAD has 15 uploads less than BASE
Flag BASE (c432bd2) HEAD (f0376f3)
16 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #894       +/-   ##
===========================================
- Coverage   96.04%   45.47%   -50.58%     
===========================================
  Files          48       48               
  Lines        9789     9826       +37     
===========================================
- Hits         9402     4468     -4934     
- Misses        387     5358     +4971     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Apr 18 '25 07:04 codecov[bot]

i have added the required tests for this pr. will add more tests in upcoming commits.

i have added a processed version of file. now having size of 80 kb.

@dhuppenkothen , if u can review this it would be beneficial.

ankitkhushwaha avatar Apr 18 '25 13:04 ankitkhushwaha

hello @matteobachetti , @dhuppenkothen please let me know if this assign with your thoughts and do the changes accordingly

ankitkhushwaha avatar Jul 17 '25 11:07 ankitkhushwaha