cositools / cosipy

The COSI high-level data analysis tools
Apache License 2.0
3 stars 16 forks source link

Error when converting tra to .h5 #90

Closed Yong2Sheng closed 8 months ago

Yong2Sheng commented 9 months ago

The simulated tra file is attached.

The issue comes from the tra file with extra headers:

Type tra Version 1 Geometry /home/sheng2/astrohe_yong/COSI/MassModel/ComptonSphere/ComptonSphere.geo.setup

Date 2023-10-18 22:10:48 MEGAlib 3.99.01

SE ET CO ID 1 TI 0.001442000 GX 0 -90 GZ 180 0 SQ 3 CT 0.0380275 0.149116 TL 1 TE 254.705 CE 182.004 0.639403 254.705 0.509696

GRB100100010_3.inc1.id1.tra.gz

ckarwin commented 9 months ago

Hi Yong, Can you be a bit more specific? What are you running and what is the error?

Yong2Sheng commented 9 months ago

Hi Chris, here is the error I got (see the attachment) Xnip2023-10-18_22-41-35

I thinks it might be caused by the lines at the start of the tra file.

ckarwin commented 9 months ago

Ok, thanks. It looks like I just need to account for the possibility of empty lines. I'm about to make a PR with a number of updates to the DataIO. I'll make sure this is fixed.

Yong2Sheng commented 9 months ago

Thanks Chris!

Yong2Sheng commented 9 months ago

I have one more question here: are tmin and tmax necessary parameters in inputs.yaml?

For example, I simulated a random GRB for 2s without orientation. I just need to extract and convert the whole dataset to a .h5 file. But in this case I don't know the tmin and tmax unless I load and check the tra file mimrec, which requires extra steps using MEGAlib.

ckarwin commented 9 months ago

Ok I think I fixed it. For now, can you try the following in your branch to see if it works for you: line 143 in https://github.com/cositools/cosipy/blob/main/cosipy/data_io/UnBinnedData.py add the following: if len(this_line) == 0: continue

make sure continue is properly indented.

ckarwin commented 9 months ago

For now you need to specify all the parameters in the inputs.yaml file. If you don't use them then just put in arbitrary values. This is another thing I need to fix, and I'll be doing it soon. The parameters tmin and tmax are actually only used if you're making a time cut.

Yong2Sheng commented 9 months ago

Thanks! The reading issue caused by the empty line is fixed now!

ckarwin commented 9 months ago

Great. It will be included in the next dataIO PR. I will keep this issue open until then.