Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This includes my reworking of the Stokes I fitting to re-scale the model parameters and uncertainties to a new reference frequency. There are 3 major changes:
renormalize_StokesI_model
function has been brought back. This function analytically modifies the parameters and parameter uncertainties of a Stokes I model to a new reference frequency. The parameter changes are analytic and exact; the transformation of the uncertainties requires a first-order approximation that breaks down for large shifts in frequency. This approximation should be fine for pretty much any case of real data (unless there's huge frequency gaps, maybe?), especially for POSSUM.rmsynth1d
tool now automatically converts the Stokes I model to the same reference frequency as lambda^2_0. When the Rudnick and Cotton method is used (lambda^2_0 = 0), the reference frequency is left as-is and the polarization reference frequency is set to be equal to the polarization frequency.rmtools_3DIrescale
/RMtools3D/rescale_I_model_3D.py
. This reads in the coefficient maps created bydo_fitIcube
along with the covariance matrix map (a new output ofdo_fitIcube
) to translate the parameters and uncertainties. This tool provides 3 options: grabbing lambda^2_0 from an FDF cube and rescaling the corresponding frequency, rescalign to a user-supplied frequency, or rescaling to the mean reference frequency (i.e., getting rid of spatial variations in reference frequency).I've confirmed that all of these tools generate the expected outputs. The POSSUM pipelines may need some adaptation to this: the Stokes I reference frequency is removed as an output of the 1D tools, so minor tweaks to the 1D pipeline to remove that; the 3D pipeline will need an extra module to perform the rescaling and create fractional polarization maps (with uncertainties?).
I'm not entirely happy with this solution, but I've spent too much time on this already. There's some changes that I think would improve things, but I don't want to spend more time on this now:
I'm not going to implement these things now -- I don't think anyone really cares about uncertainties in Stokes I models from RM-Tools. So far as the POSSUM pipelines go this solution should be "good enough", and until someone actually cares I'm not investing more effort.
I'll leave this PR for a few days in case anyone wants to comment/look into it, otherwise I'll merge it in, merge everything else, and release v1.4.