Skip to content

Conversation

@taldcroft
Copy link
Member

Hi,

I've recently been working on astropy-based pulsar timing software and ran across a problem with the TDB conversion routines: In the astropy.time._get_delta_tdb_tt() function erfa_time.era_gd2gc() is used to convert the input lat/lon to geocentric XYZ coordinates. The returned values are in meters. These are then passed to erfa_time.d_tdb_tt() which however expects input in km. The resulting TT-TDB is pretty far off, and messes up the pulsar timing results at the few-ms level.

Should be a pretty trivial fix though! I did this locally and got TT-TDB values consistent with TEMPO2 at the us level (may be better, but I'll need to do some more careful tests to say for sure).

Cheers,
Paul

@taldcroft
Copy link
Member

Thanks for tracking down this issue @demorest!

Could you provide your test case with the correct transformation difference?

One thing I want to do is understand why our test case was insufficient. We verify that the transforms match what is shown in the SOFA documentation. The test case is essentially running through all the transforms. Starting from a TT time of '2006-01-15 21:25:42.684000000' we get:

In [18]: t_tt.iso
Out[18]: '2006-01-15 21:25:42.684000000'

In [19]: t_tt.tdb.iso
Out[19]: '2006-01-15 21:25:42.683798890'

In [20]: t_tt.lon, t_tt.lat
Out[20]: (<Longitude -155.933222 deg>, <Latitude 19.48125 deg>)

This matches exactly the SOFA result (page 25 of http://www.iausofa.org/sofa_ts_c.pdf), so maybe there is a bug in SOFA / ERFA?

@demorest
Copy link
Author

Yes, it looks like the SOFA example that you copied your test case from has the same bug: iauGd2gc() returns meters, while iauDtdb() wants km. I don't have any reason so far to think there is a bug in the actual SOFA/ERFA code, just this error in the example usage in the manual.

I'll see if I can come up with a test case you can use for this. However, it's not completely trivial to separate out just this calculation from all the other things TEMPO2 does. Also I'm not yet sure how closely to expect the two TT-TDB versions to agree, as they are using different methods for some parts of the calculation.

@scottransom
Copy link

@taldcroft: I just filed a bug report to the SOFA folks (which I guess includes me!) about their example code.

@ghost ghost assigned taldcroft Dec 28, 2013
@taldcroft
Copy link
Member

OK, thanks for filing the documentation bug report @scottransom. I should be able to patch this here pretty soon. It would be really useful to get some independent transformation test values.

@scottransom
Copy link

Looks like Pat Wallace has already fixed the SOFA documentation, @taldcroft. Here are the new correct values for the results of the SOFA tests on p25 of the document:

TDB 2006/01/15 21:25:42.684372
TCB 2006/01/15 21:25:56.893951

@taldcroft
Copy link
Member

@scottransom @demorest - patch now attached, please have a look.

cc: @mhvk - same issue will need fixing in #1928 for 0.4.

@mhvk
Copy link
Contributor

mhvk commented Dec 28, 2013

Yikes, that is pretty bad. Guess we should take more seriously what we teach our students - check everything independently! Will rebase #1928 on this once you merge.

@scottransom
Copy link

Hey Marten: the cool thing is that this was found with an incredibly independent test. Paul was checking the timing residuals as calculated with PINT for a high-precision MSP, and that showed a big annual term. So a "pulsar time standard" is what uncovered the error! That's pretty cool, IMO....

taldcroft added a commit that referenced this pull request Dec 28, 2013
@taldcroft taldcroft merged commit bd02dad into astropy:master Dec 28, 2013
@taldcroft taldcroft deleted the time-tdb-tt branch December 28, 2013 19:01
@mhvk
Copy link
Contributor

mhvk commented Dec 28, 2013

@scottransom, @demorest - That's great indeed! More generally, great that this is being helpful. Do also not hesitate to let us know missing stuff. E.g., some of the calculations now made in spice and pint should probably be covered by astropy (barycentric correction being a prime example). Feel free to open issues on those, ideally with links to code that implements it.

@taldcroft
Copy link
Member

It will certainly mean a lot if astropy.time gets the millisecond pulsar stamp of approval!

taldcroft added a commit that referenced this pull request Feb 12, 2014
Bug in TDB to TT calculation
Conflicts:

	astropy/time/core.py
taldcroft added a commit that referenced this pull request Feb 12, 2014
Bug in TDB to TT calculation
Conflicts:

	astropy/time/core.py
@mhvk mhvk mentioned this pull request May 2, 2014
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants