thepetabyteproject / your

Your Unified Reader
https://thepetabyteproject.github.io/your/
GNU General Public License v3.0
35 stars 25 forks source link

Overly restrictive is_PSRFITS function when opening .fits files #120

Closed mef51 closed 11 months ago

mef51 commented 1 year ago

Describe the bug I am wanting to open a PSRFITS fits from Gajjar+2018 (Burst 11A of http://seti.berkeley.edu/frb121102/technical.html) with your but I get a File 'data/gajjar2018/11A_16sec.calib.4p.fits' does not appear to be PSRFITS! error, even though the file opens fine in other packages such as pypulse. I would just use pypulse but it currently is broken on newer machines due to dependency issues.

To Reproduce Steps to reproduce the behavior:

  1. Download burst 11A from the above link. Add the '.fits' extension to it so your detects this as a fits file.
  2. Run the following code
    import your
    your_object = your.Your('11A_16sec.calib.4p.fits')

The output is ValueError: File '/11A_16sec.calib.4p.fits' does not appear to be PSRFITS!

Expected behavior Load the file.

Additional context The issue happens because the is_PSRFITS function loads the file then checks if

(hdulist["PRIMARY"].header["FITSTYPE"] == "PSRTFITS" and
hdulist["PRIMARY"].header["OBS_MODE"] = "SEARCH")

For the file in question the first check is true but hdulist["PRIMARY"].header["OBS_MODE"] == "PSR".

I think the "OBS_MODE" check is overkill and my feeling is it can be removed but I'm not familiar enough to be sure.

Versions (please provide the versions of the the following packages):

devanshkv commented 1 year ago

Please correct me if I am wrong but I think the PSR mode is for a fold-mode observation of a pulsar, which is not the same as the SEARCH mode data that is streamed multi-channel data.

mef51 commented 1 year ago

You're probably right. The underlying data is an FRB waterfall but even when I bypass the is_PSRTFITS function it still doesn't load with your (some fields that your uses are missing) so I'm not sure. It could be a quirk of how they saved their data.