Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ankitkhushwaha
Copy link
Contributor

@ankitkhushwaha ankitkhushwaha commented Mar 2, 2025

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 ankitkhushwaha marked this pull request as draft March 2, 2025 19:00
@ankitkhushwaha ankitkhushwaha marked this pull request as ready for review March 3, 2025 11:13
Copy link

codecov bot commented Apr 18, 2025

Codecov Report

Attention: Patch coverage is 71.87500% with 9 lines in your changes missing coverage. Please review.

Project coverage is 94.15%. Comparing base (cc4c259) to head (bc55428).

Files with missing lines Patch % Lines
stingray/io.py 71.87% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #894      +/-   ##
==========================================
- Coverage   96.03%   94.15%   -1.89%     
==========================================
  Files          48       48              
  Lines        9770     9788      +18     
==========================================
- Hits         9383     9216     -167     
- Misses        387      572     +185     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@ankitkhushwaha
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make EventList.read work on Fermi/GBM data
1 participant