CIRADA-Tools / RM-Tools

RM-synthesis, RM-clean and QU-fitting on polarised radio spectra
MIT License
42 stars 23 forks source link

Fix for 3D RM Synthesis --- Outputting NaN for pixels without input data #107

Closed jackieykma closed 7 months ago

jackieykma commented 7 months ago

This pull request comes from an action item of the on-going POSSUM Busy Week

It has been identified from the POSSUM 3D pipeline that, for pixels without any valid input data, some of the output data products are set as 0 instead of NaN, which can make it confusing regarding whether those are valid pixels with the output results coincidentally being 0, or that they are actually invalid pixels

This pull request fixes the issue by: (1) Changing util_misc.toscalar: Currently, if a fully masked array (e.g., by passing an array full of NaNs through MAD()) is input to toscalar(), the output will be 0. This can then lead to, for example, the FDF uncertainty being set as 0 instead of NaN (because it can be calculated by toscalar(MAD(...)))

(2) Changing fundamentally how RM-Synthesis is run, through modifying util_RM: If, for any particular pixel, the Q&U data are all 0 across frequency (e.g., the individual SBID of POSSUM data), then RM-Synthesis will still be run and give FDF=0 across FD. This has now been fixed by forcing the output FDF to be NaN throughout FD, if the FDF itself is found to be identical to 0 across FD (which result from input Q=U=0)

jackieykma commented 7 months ago

I have identified that the changes to toscalar() may have broken some things I'll look into it and update here