FRBs / sigpyproc3

Python3 version of Ewan Barr's sigpyproc library
https://sigpyproc3.readthedocs.io
MIT License
14 stars 11 forks source link

Incorrect key name in the header class #25

Closed sujaymate closed 7 months ago

sujaymate commented 1 year ago

Hi,

I think the standard key for source name is source_name but here the class uses source. This conflicts while writing a processed file using an old file. I can change and submit a pull request. Let me know.

https://github.com/FRBs/sigpyproc3/blob/8c2103c0194e254019fa94b765e65b66f10f58b0/sigpyproc/header.py#L506

pravirkr commented 1 year ago

Hi, can you provide an example of this conflict? the source key is for internal use in the class. So, while writing a new file, the to_sigproc() method writes the key source_name in the header using this internal key source.

sujaymate commented 1 year ago

Hi, I was not able to reproduce this. I was trying a bunch of stuff as two keys refdm and I think signed were not compatible with IQRM codes so I was trying to re-dump processed data without writing those keywords. I managed it a following way:


header_dict = sigproc.parse_header(filfile.filename)
data = filfile.read_block(0, filfile.header.nsamples)
>> process data <<
fil_fileobj = FileWriter(outfname, mode="w", tsamp=filfile.header.tsamp, nchans=filfile.header.nchans, nbits=8)
fil_fileobj.write(sigproc.encode_header(header_dict))
fil_fileobj.cwrite(data.transpose().ravel())
fil_fileobj.close()```
pravirkr commented 1 year ago

Hi,

Yes, that was the case in the earlier version of sigpyproc or other filterbank readers. Even though the sigproc header parameters are well-defined, it was never enforced in codes. Most sigproc-related packages use a dynamic header class (read whatever is available in the file and write the same). I think this is what you are doing in the above snippet.

My aim was to have some rigid structure, at least while writing files (reading is fine with some default values). This was helpful while writing test cases for the header class.

Anyway, I cannot see the issue with IQRM because the keywords refdm and signed are standard sigproc keywords, so they should be compatible!