StingraySoftware / stingray

Anything can happen in the next half hour (including spectral timing made easy)!
https://stingray.science/stingray
MIT License
172 stars 141 forks source link

Error reading the event file #813

Closed tugbabztp closed 6 months ago

tugbabztp commented 6 months ago

Hi Stingray Development Team,

When analyzing a NICER X-ray data, I got an error when reading the event file:

File /data/software/anaconda/envs/tugbabztp/lib/python3.12/site-packages/stingray/events.py:625, in EventList.read(cls, filename, fmt, **kwargs) 622 setattr(evt, key.lower(), evtdata.additional_data[key]) 623 return evt --> 625 return super().read(filename=filename, fmt=fmt)

File /data/software/anaconda/envs/tugbabztp/lib/python3.12/site-packages/stingray/base.py:647, in StingrayObject.read(cls, filename, fmt) 643 ts[col_strip] += new_value 645 ts.remove_column(col) --> 647 return cls.from_astropy_table(ts)

File /data/software/anaconda/envs/tugbabztp/lib/python3.12/site-packages/stingray/base.py:425, in StingrayObject.from_astropy_table(cls, ts) 422 setattr(cls, attr.lower(), np.array(ts[attr])) 424 for key, val in ts.meta.items(): --> 425 setattr(cls, key.lower(), val) 427 return cls

AttributeError: property 'exposure' of 'EventList' object has no setter

but I realized that I only get this error when we use the most recent version distributed by conda which I installed just a few days ago (stingray version: 2.0.0). The same code works just fine with the previous version (stingray version: 1.1.1) again installed earlier from conda.

Thanks !

matteobachetti commented 6 months ago

Hello @tugbabztp, thanks for reporting the issue.

So, I could reproduce this issue by loading the event file using fmt="fits". Even though this should not happen and this is indeed a bug, please note that the recommended format key for FITS files from HEASARC is fmt="ogip" (or "hea"). The "fits" format assumes a generic FITS file, that could be, e.g., produced by saving an Astropy table, not necessarily following the OGIP specifications. So, for the time being you should be fine using fmt="ogip".