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
@ankitkhushwaha ankitkhushwaha force-pushed the fermi-gbm branch 2 times, most recently from 7bbafa2 to bc55428 Compare April 18, 2025 07:45
Copy link

codecov bot commented Apr 18, 2025

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 ⚠️

❗ 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     

☔ 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.

@ankitkhushwaha
Copy link
Contributor Author

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

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