nanograv / PINT

PINT is not TEMPO3 -- Software for high-precision pulsar timing
Other
121 stars 101 forks source link

Timing model derivatives are mean-subtracted #1275

Open aarchiba opened 2 years ago

aarchiba commented 2 years ago

model.d_phase_d_param() returns a derivative whose mean is zero. This is wrong if one is working with absolute phases - if the model contains TZRMJD, all derivatives should be exactly zero there. This arose in #1261, where test_derivative_equals_numerical began failing when comparing returned phases to numerical derivatives.

aarchiba commented 2 years ago

Here's a notebook that demonstrates the problem - sorry it's a PDF, I can't upload notebooks directly. absphase.pdf

aarchiba commented 2 years ago

How this interacts with Fitter objects is not so clear - I think we treat TZRMJD differently from every other parameter, so the Fitter might or might not care whether the derivative there is zero.

aarchiba commented 2 years ago

The way PINT computes phase (relative or absolute) is complicated and confusing and poses real challenges for handling pulse numbers (see issues #1034, #589, #512 and PR #443 for examples).

paulray commented 2 years ago

Here's a notebook that demonstrates the problem - sorry it's a PDF, I can't upload notebooks directly.

Yeah, I've been working on a similar notebook. Note that there is also model.d_phase_d_param_num() so you don't have to use numdifftools.

aarchiba commented 2 years ago

I trust numdifftools to give accurate but slow answers. Also not to have the same assumptions baked into it as our analytic derivatives.

abhisrkckl commented 1 year ago

Is this still a problem?

TODO: Investigate further if this issue still persists. TODO: AD with JAX instead of numdifftools

abhisrkckl commented 1 year ago

Related #1303