nanograv / enterprise

ENTERPRISE (Enhanced Numerical Toolbox Enabling a Robust PulsaR Inference SuitE) is a pulsar timing analysis code, aimed at noise analysis, gravitational-wave searches, and timing model analysis.
https://enterprise.readthedocs.io
MIT License
67 stars 67 forks source link

Allow efac/log10_tneqad to be None in ndiag functions #379

Closed mattpitkin closed 8 months ago

mattpitkin commented 8 months ago

In white_signals.py, the *_ndiag functions fail if they get passed None values. This happens, for example, if the white_noise_block in enterprise_extensions has vary=False, and therefore efac/equad/ecorr are set to Constant parameters, which have default values of None.

The two potential fixes are the one in this PR, i.e., allow None values, which for efac_ndiag is equivalent to having efac=1.0, and set tneqad_ndiag to zeros if passed None. The other fix would be to specify values for theConstantsin thewhite_noise_block` in enterprise_extensions, e.g.,:

        efac = parameter.Constant(1.0)
        equad = parameter.Constant(-np.inf)
        if inc_ecorr:
            ecorr = parameter.Constant(-np.inf)
vallis commented 8 months ago

These functions expect numerical values, and they have even defaults for them. I am not sure it's appropriate to give them flow branches to handle None. (Doing so, among other things, may prevent code compilation in some frameworks.) I would prefer a fix in e_e.

mattpitkin commented 8 months ago

@vallis No problem. I'll close this and submit a PR for enterprise_extensions.