nanograv / enterprise_extensions

A set of extension codes, utilities, and scripts for the enterprise PTA analysis framework.
MIT License
26 stars 59 forks source link

Add a toggle to scale and shift pulsar distances in the CW delay model #238

Open blarsen10 opened 1 month ago

blarsen10 commented 1 month ago

enterprise_extensions.deterministic.cw_delay uses the p_dist keyword argument to take in pulsar distance parameters, which are necessary for correctly including the pulsar term in the model. Currently, the model is hard-coded to scale and shift the input pulsar distance parameters by the mean and uncertainty of the pulsar distance attribute within the enterprise Pulsar object.

This functionality makes sense if you want to use a generic parameter as input, e.g. a Gaussian prior with zero mean and unit variance, and then scale that prior distribution by the values in the Pulsar object. However, with more sophisticated priors such as those in QuickCW it might be easier for users to calibrate all the initial prior distributions with pulsar distance means and variances in a separate script instead of using the distances in the Pulsar object itself. In this case there is no need to scale and shift the input prior. However, this scaling and shifting is hard coded, so the input distance parameters might be unintentionally affected depending on what is in the Pulsar.

The current workaround to avoid incorrect pulsar distance priors is to assign zero-mean and unit-variance values to the pulsar distance attribute in the Pulsar object. While this works, this PR implements a simpler and more user-friendly solution, which is to include a toggle allow users to turn off the scaling-and-shifting behavior in the cw_delay. Specifically, setting scale_shift_pdists=False will just use the input pulsar distance priors without any additional changes, while scale_shift_pdists=True will keep the old behavior, and is kept as the default so this change is backwards compatible.