scottransom / presto

Open source pulsar search and analysis toolkit
http://www.cv.nrao.edu/~sransom/presto/
GNU General Public License v2.0
240 stars 177 forks source link

Set `summed_polns = 0` when `fb.sumifs == false` in sigproc_fb.c #173

Closed fxzjshm closed 1 year ago

fxzjshm commented 2 years ago

I'm still learning pulsar things, so please correct me if I'm wrong.

The default value of summed_polns is 1 in backend_common.c, so I think it need to be explicitly set to 0 here, so that readfile gives correct output ( affects this )

Also, the fb.ifstream is accessed in the next lines but seems never read from .fil files, which will affect s->poln_order and finally cause readfile's Polarization order = <some random stack memory data here>. But I cannot find some document about this header, so didn't change this.

scottransom commented 1 year ago

Sorry that it has taken me so long to look at this! I must have either missed the notification or simply forgotten about it!

I think that there might be a problem, but I don't think that this is a correct fix. I think it needs a bit more logic.

The issue is that filterbank-style data, if it only has 1 if in it, is assumed to have summed polarizations. And a filterbank data doesn't need to have the sumifs set for that. So if we make you change, and if a filterbank file is old school with 2 summed polns, but has nifs==1 and no sumifs, then this will tell the user that the data does not have summed polarizations when it really does.

I'm not sure of a good way of handling this assumption of summed polarizations....

Do you have filterbank data where this is an issue? i.e. you have 2 polarizations, for instance, and sumifs is set to False?

fxzjshm commented 1 year ago

Oh, I'm new to pulsar astronomy and didn't know this situation... Thank you for the explanation.

We used to have filterbank data with this issue, our backend used to write data of 2 polarizations into .fil file without summing, then I encountered this issue. So later I summed it in a script and set sumifs = true ( like this ), then it worked.

So ... at least for our workflow there's no issue currently.

May I ask if I want to use these 2 polarizations without summing, what should I do? Maybe just switch to FITS format?

scottransom commented 1 year ago

So if your filterbank data has both polarizations and the header doesn't have the sumifs variable, then you can choose which of the two polarizations to use with the -if option to predata, prepsubband, rfifind, and prepfold. Since this hardly ever gets used, though, there is a chance that there are bugs!

fxzjshm commented 1 year ago

Thank you! I'll try that.

I'm closing this PR to keep that assumption working, also thank you for looking into this!