;+ ; NAME: ; TDB2TDT ; ; AUTHOR: ; Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770 ; craigm@lheamail.gsfc.nasa.gov ; UPDATED VERSIONs can be found on my WEB PAGE: ; http://cow.physics.wisc.edu/~craigm/idl/idl.html ; ; PURPOSE: ; Relativistic clock corrections due to Earth motion in solar system ; ; MAJOR TOPICS: ; Planetary Orbits ; ; CALLING SEQUENCE: ; corr = TDB2TDT(JD, TBASE=, DERIV=deriv) ; ; DESCRIPTION: ; ; The function TDB2TDT computes relativistic corrections that must ; be applied when performing high precision absolute timing in the ; solar system. ; ; According to general relativity, moving clocks, and clocks at ; different gravitational potentials, will run at different rates ; with respect to each other. A clock placed on the earth will run ; at a time-variable rate because of the non-constant influence of ; the sun and other planets. Thus, for the most demanding ; astrophysical timing applications -- high precision pulsar timing ; -- times in the accelerating earth observer's frame must be ; corrected to an inertial frame, such as the solar system ; barycenter (SSB). This correction is also convenient because the ; coordinate time at the SSB is the ephemeris time of the JPL ; Planetary Ephemeris. ; ; In general, the difference in the rate of Ti, the time kept by an ; arbitrary clock, and the rate of T, the ephemeris time, is given ; by the expression (Standish 1998): ; ; dTi/dT = 1 - (Ui + vi^2/2) / c^2 ; ; where Ui is the potential of clock i, and vi is the velocity of ; clock i. However, when integrated, this expression depends on the ; position of an individual clock. A more convenient approximate ; expression is: ; ; T = Ti + (robs(Ti) . vearth(T))/c^2 + dtgeo(Ti) + TDB2TDT(Ti) ; ; where robs is the vector from the geocenter to the observer; ; vearth is the vector velocity of the earth; and dtgeo is a ; correction to convert from the observer's clock to geocentric TT ; time. TDB2TDT is the value computed by this function, the ; correction to convert from the geocenter to the solar system ; barycenter. ; ; As the above equation shows, while this function provides an ; important component of the correction, the user must also be ; responsible for (a) correcting their times to the geocenter (ie, ; by maintaining atomic clock corrections); (b) estimating the ; observatory position vector; and and (c) estimating earth's ; velocity vector (using JPLEPHINTERP). ; ; Users may note a circularity to the above equation, since ; vearth(T) is expressed in terms of the SSB coordinate time. This ; appears to be a chicken and egg problem since in order to get the ; earth's velocity, the ephemeris time is needed to begin with. ; However, to the precision of the above equation, < 25 ns, it is ; acceptable to replace vearth(T) with vearth(TT). ; ; The method of computation of TDB2TDT in this function is based on ; the analytical formulation by Fairhead, Bretagnon & Lestrade, 1988 ; (so-called FBL model) and Fairhead & Bretagnon 1990, in terms of ; sinusoids of various amplitudes. TDB2TDT has a dominant periodic ; component of period 1 year and amplitude 1.7 ms. The set of 791 ; coefficients used here were drawn from the Princeton pulsar timing ; program TEMPO version 11.005 (Taylor & Weisberg 1989). ; ; Because the TDB2TDT quantity is rather expensive to compute but ; slowly varying, users may wish to also retrieve the time ; derivative using the DERIV keyword, if they have many times to ; convert over a short baseline. ; ; Verification ; ; This implementation has been compared against a set of FBL test ; data found in the 1996 IERS Conventions, Chapter 11, provided by ; T. Fukushima. It has been verified that this routine reproduces ; the Fukushima numbers to the accuracy of the table, within ; 10^{-14} seconds. ; ; Fukushima (1995) has found that the 791-term Fairhead & Bretagnon ; analytical approximation use here has a maximum error of 23 ns and ; rms error of 14 ns in the time range 1980-2000, compared to a ; numerical integration (see Table 12). In comparison the truncated ; 127-term approximation has a maximum error of ~130 ns and rms ; error of 26 ns. ; ; ; PARAMETERS: ; ; JD - Geocentric time TT, scalar or vector, expressed in Julian ; days. The actual time used is (JD + TBASE). For maximum ; precision, TBASE should be used to express a fixed epoch in ; whole day numbers, and JD should express fractional offset ; days from that epoch. ; ; ; KEYWORD PARAMETERS: ; ; TBASE - Julian day of a fixed epoch, which provides the ; origin for times passed in JD. Either a scalar, which ; applies to all items, or a vector of same size as JD. ; Default: 0 ; ; DERIV - upon return, contains the derivative of TDB2TDT in units ; of seconds per day. As many derivatives are returned as ; values passed in JD. ; ; NTERMS - number of terms to use in the computation, in case the ; full series accuracy is not required. ; Default: all terms. ; ; ; RETURNS: ; The correction offset(s) in units of seconds, to be applied as ; noted above. ; ; ; EXAMPLE: ; ; Find the correction at ephemeris time 2451544.5 (JD): ; IDL> print, tdb2tdt(2451544.5d) ; -0.00011376314 ; or 0.11 ms. ; ; ; REFERENCES: ; ; Princeton TEMPO Program ; http://pulsar.princeton.edu/tempo/ ; ; FBL Test Data Set ; ftp://maia.usno.navy.mil/conventions/chapter11/fbl.results ; ; Fairhead, L. & Bretagnon, P. 1990, A&A, 229, 240 ; (basis of this routine) ; ; Fairhead, L. Bretagnon, P. & Lestrade, J.-F. 1988, in *The Earth's ; Rotation and Reference Frames for Geodesy and Geodynamics*, ; ed. A. K. Babcock and G. A. Wilkins, (Dordrecht: Kluwer), p. 419 ; (original "FBL" paper) ; ; Fukushima, T. 1995, A&A, 294, 895 (error analysis) ; ; Irwin, A. W. & Fukushima, T. 1999, A&A, 348, 642 (error analysis) ; ; Standish, E. M. 1998, A&A, 336, 381 (description of time scales) ; ; Taylor, J. H. & Weisberg, J. M. 1989, ApJ, 345, 434 (pulsar timing) ; ; ; SEE ALSO ; JPLEPHREAD, JPLEPHINTERP, JPLEPHTEST ; ; MODIFICATION HISTORY: ; Original logic from Fairhead & Bretagnon, 1990 ; Drawn from TEMPO v. 11.005, copied 20 Jun 2001 ; Documented and vectorized, 30 Jun 2001 ; Added helpful usage message, CM, 15 Mar 2002 ; Add NTERMS keyword, CM, 07 Mar 2007 ; NTERMS was having no effect, now fixed, CM, 16 Jul 2008 ; Documentation about 'verification' was enhanced, CM, 27 Feb 2009 ; TBASE may be a vector, CM, 2012-04-09 ; Bug fix in case TBASE is not a vector, CM, 2013-09-29 ; ; $Id: tdb2tdt.pro,v 1.10 2013/09/30 02:27:05 cmarkwar Exp $ ; ;- ; Copyright (C) 2001, 2002, 2007, 2009, 2012, 2013, Craig Markwardt ; This software is provided as is without any warranty whatsoever. ; Permission to use, copy and distribute unmodified copies for ; non-commercial purposes, and to modify and use for personal or ; internal use, is granted. All other rights are reserved. ;- ; T**1 fbldata = [ fbldata, $ 102.156724d, 6283.075849991d, 4.249032005d, $ 1.706807d, 12566.151699983d, 4.205904248d, $ 0.269668d, 213.299095438d, 3.400290479d, $ 0.265919d, 529.690965095d, 5.836047367d, $ 0.210568d, -3.523118349d, 6.262738348d, $ 0.077996d, 5223.693919802d, 4.670344204d, $ 0.054764d, 1577.343542448d, 4.534800170d, $ 0.059146d, 26.298319800d, 1.083044735d, $ 0.034420d, -398.149003408d, 5.980077351d, $ 0.032088d, 18849.227549974d, 4.162913471d, $ 0.033595d, 5507.553238667d, 5.980162321d, $ 0.029198d, 5856.477659115d, 0.623811863d, $ 0.027764d, 155.420399434d, 3.745318113d, $ 0.025190d, 5746.271337896d, 2.980330535d, $ 0.022997d, -796.298006816d, 1.174411803d, $ 0.024976d, 5760.498431898d, 2.467913690d, $ 0.021774d, 206.185548437d, 3.854787540d, $ 0.017925d, -775.522611324d, 1.092065955d, $ 0.013794d, 426.598190876d, 2.699831988d, $ 0.013276d, 6062.663207553d, 5.845801920d, $ 0.011774d, 12036.460734888d, 2.292832062d, $ 0.012869d, 6076.890301554d, 5.333425680d, $ 0.012152d, 1059.381930189d, 6.222874454d, $ 0.011081d, -7.113547001d, 5.154724984d, $ 0.010143d, 4694.002954708d, 4.044013795d ] fbldata = [ fbldata, $ 0.009357d, 5486.777843175d, 3.416081409d, $ 0.010084d, 522.577418094d, 0.749320262d, $ 0.008587d, 10977.078804699d, 2.777152598d, $ 0.008628d, 6275.962302991d, 4.562060226d, $ 0.008158d, -220.412642439d, 5.806891533d, $ 0.007746d, 2544.314419883d, 1.603197066d, $ 0.007670d, 2146.165416475d, 3.000200440d, $ 0.007098d, 74.781598567d, 0.443725817d, $ 0.006180d, -536.804512095d, 1.302642751d, $ 0.005818d, 5088.628839767d, 4.827723531d, $ 0.004945d, -6286.598968340d, 0.268305170d, $ 0.004774d, 1349.867409659d, 5.808636673d, $ 0.004687d, -242.728603974d, 5.154890570d, $ 0.006089d, 1748.016413067d, 4.403765209d, $ 0.005975d, -1194.447010225d, 2.583472591d, $ 0.004229d, 951.718406251d, 0.931172179d, $ 0.005264d, 553.569402842d, 2.336107252d, $ 0.003049d, 5643.178563677d, 1.362634430d, $ 0.002974d, 6812.766815086d, 1.583012668d, $ 0.003403d, -2352.866153772d, 2.552189886d, $ 0.003030d, 419.484643875d, 5.286473844d, $ 0.003210d, -7.046236698d, 1.863796539d, $ 0.003058d, 9437.762934887d, 4.226420633d, $ 0.002589d, 12352.852604545d, 1.991935820d, $ 0.002927d, 5216.580372801d, 2.319951253d ] fbldata = [ fbldata, $ 0.002425d, 5230.807466803d, 3.084752833d, $ 0.002656d, 3154.687084896d, 2.487447866d, $ 0.002445d, 10447.387839604d, 2.347139160d, $ 0.002990d, 4690.479836359d, 6.235872050d, $ 0.002890d, 5863.591206116d, 0.095197563d, $ 0.002498d, 6438.496249426d, 2.994779800d, $ 0.001889d, 8031.092263058d, 3.569003717d, $ 0.002567d, 801.820931124d, 3.425611498d, $ 0.001803d, -71430.695617928d, 2.192295512d, $ 0.001782d, 3.932153263d, 5.180433689d, $ 0.001694d, -4705.732307544d, 4.641779174d, $ 0.001704d, -1592.596013633d, 3.997097652d, $ 0.001735d, 5849.364112115d, 0.417558428d, $ 0.001643d, 8429.241266467d, 2.180619584d, $ 0.001680d, 38.133035638d, 4.164529426d, $ 0.002045d, 7084.896781115d, 0.526323854d, $ 0.001458d, 4292.330832950d, 1.356098141d, $ 0.001437d, 20.355319399d, 3.895439360d, $ 0.001738d, 6279.552731642d, 0.087484036d, $ 0.001367d, 14143.495242431d, 3.987576591d, $ 0.001344d, 7234.794256242d, 0.090454338d, $ 0.001438d, 11499.656222793d, 0.974387904d, $ 0.001257d, 6836.645252834d, 1.509069366d, $ 0.001358d, 11513.883316794d, 0.495572260d, $ 0.001628d, 7632.943259650d, 4.968445721d ] fbldata = [ fbldata, $ 0.001169d, 103.092774219d, 2.838496795d, $ 0.001162d, 4164.311989613d, 3.408387778d, $ 0.001092d, 6069.776754553d, 3.617942651d, $ 0.001008d, 17789.845619785d, 0.286350174d, $ 0.001008d, 639.897286314d, 1.610762073d, $ 0.000918d, 10213.285546211d, 5.532798067d, $ 0.001011d, -6256.777530192d, 0.661826484d, $ 0.000753d, 16730.463689596d, 3.905030235d, $ 0.000737d, 11926.254413669d, 4.641956361d, $ 0.000694d, 3340.612426700d, 2.111120332d, $ 0.000701d, 3894.181829542d, 2.760823491d, $ 0.000689d, -135.065080035d, 4.768800780d, $ 0.000700d, 13367.972631107d, 5.760439898d, $ 0.000664d, 6040.347246017d, 1.051215840d, $ 0.000654d, 5650.292110678d, 4.911332503d, $ 0.000788d, 6681.224853400d, 4.699648011d, $ 0.000628d, 5333.900241022d, 5.024608847d, $ 0.000755d, -110.206321219d, 4.370971253d, $ 0.000628d, 6290.189396992d, 3.660478857d, $ 0.000635d, 25132.303399966d, 4.121051532d, $ 0.000534d, 5966.683980335d, 1.173284524d, $ 0.000543d, -433.711737877d, 0.345585464d, $ 0.000517d, -1990.745017041d, 5.414571768d, $ 0.000504d, 5767.611978898d, 2.328281115d, $ 0.000485d, 5753.384884897d, 1.685874771d ] fbldata = [ fbldata, $ 0.000463d, 7860.419392439d, 5.297703006d, $ 0.000604d, 515.463871093d, 0.591998446d, $ 0.000443d, 12168.002696575d, 4.830881244d, $ 0.000570d, 199.072001436d, 3.899190272d, $ 0.000465d, 10969.965257698d, 0.476681802d, $ 0.000424d, -7079.373856808d, 1.112242763d, $ 0.000427d, 735.876513532d, 1.994214480d, $ 0.000478d, -6127.655450557d, 3.778025483d, $ 0.000414d, 10973.555686350d, 5.441088327d, $ 0.000512d, 1589.072895284d, 0.107123853d, $ 0.000378d, 10984.192351700d, 0.915087231d, $ 0.000402d, 11371.704689758d, 4.107281715d, $ 0.000453d, 9917.696874510d, 1.917490952d, $ 0.000395d, 149.563197135d, 2.763124165d, $ 0.000371d, 5739.157790895d, 3.112111866d, $ 0.000350d, 11790.629088659d, 0.440639857d, $ 0.000356d, 6133.512652857d, 5.444568842d, $ 0.000344d, 412.371096874d, 5.676832684d, $ 0.000383d, 955.599741609d, 5.559734846d, $ 0.000333d, 6496.374945429d, 0.261537984d, $ 0.000340d, 6055.549660552d, 5.975534987d, $ 0.000334d, 1066.495477190d, 2.335063907d, $ 0.000399d, 11506.769769794d, 5.321230910d, $ 0.000314d, 18319.536584880d, 2.313312404d, $ 0.000424d, 1052.268383188d, 1.211961766d ] fbldata = [ fbldata, $ 0.000307d, 63.735898303d, 3.169551388d, $ 0.000329d, 29.821438149d, 6.106912080d, $ 0.000357d, 6309.374169791d, 4.223760346d, $ 0.000312d, -3738.761430108d, 2.180556645d, $ 0.000301d, 309.278322656d, 1.499984572d, $ 0.000268d, 12043.574281889d, 2.447520648d, $ 0.000257d, 12491.370101415d, 3.662331761d, $ 0.000290d, 625.670192312d, 1.272834584d, $ 0.000256d, 5429.879468239d, 1.913426912d, $ 0.000339d, 3496.032826134d, 4.165930011d, $ 0.000283d, 3930.209696220d, 4.325565754d, $ 0.000241d, 12528.018664345d, 3.832324536d, $ 0.000304d, 4686.889407707d, 1.612348468d, $ 0.000259d, 16200.772724501d, 3.470173146d, $ 0.000238d, 12139.553509107d, 1.147977842d, $ 0.000236d, 6172.869528772d, 3.776271728d, $ 0.000296d, -7058.598461315d, 0.460368852d, $ 0.000306d, 10575.406682942d, 0.554749016d, $ 0.000251d, 17298.182327326d, 0.834332510d, $ 0.000290d, 4732.030627343d, 4.759564091d, $ 0.000261d, 5884.926846583d, 0.298259862d, $ 0.000249d, 5547.199336460d, 3.749366406d, $ 0.000213d, 11712.955318231d, 5.415666119d, $ 0.000223d, 4701.116501708d, 2.703203558d, $ 0.000268d, -640.877607382d, 0.283670793d ] fbldata = [ fbldata, $ 0.000209d, 5636.065016677d, 1.238477199d, $ 0.000193d, 10177.257679534d, 1.943251340d, $ 0.000182d, 6283.143160294d, 2.456157599d, $ 0.000184d, -227.526189440d, 5.888038582d, $ 0.000182d, -6283.008539689d, 0.241332086d, $ 0.000228d, -6284.056171060d, 2.657323816d, $ 0.000166d, 7238.675591600d, 5.930629110d, $ 0.000167d, 3097.883822726d, 5.570955333d, $ 0.000159d, -323.505416657d, 5.786670700d, $ 0.000154d, -4136.910433516d, 1.517805532d, $ 0.000176d, 12029.347187887d, 3.139266834d, $ 0.000167d, 12132.439962106d, 3.556352289d, $ 0.000153d, 202.253395174d, 1.463313961d, $ 0.000157d, 17267.268201691d, 1.586837396d, $ 0.000142d, 83996.847317911d, 0.022670115d, $ 0.000152d, 17260.154654690d, 0.708528947d, $ 0.000144d, 6084.003848555d, 5.187075177d, $ 0.000135d, 5756.566278634d, 1.993229262d, $ 0.000134d, 5750.203491159d, 3.457197134d, $ 0.000144d, 5326.786694021d, 6.066193291d, $ 0.000160d, 11015.106477335d, 1.710431974d, $ 0.000133d, 3634.621024518d, 2.836451652d, $ 0.000134d, 18073.704938650d, 5.453106665d, $ 0.000134d, 1162.474704408d, 5.326898811d, $ 0.000128d, 5642.198242609d, 2.511652591d ] fbldata = [ fbldata, $ 0.000160d, 632.783739313d, 5.628785365d, $ 0.000132d, 13916.019109642d, 0.819294053d, $ 0.000122d, 14314.168113050d, 5.677408071d, $ 0.000125d, 12359.966151546d, 5.251984735d, $ 0.000121d, 5749.452731634d, 2.210924603d, $ 0.000136d, -245.831646229d, 1.646502367d, $ 0.000120d, 5757.317038160d, 3.240883049d, $ 0.000134d, 12146.667056108d, 3.059480037d, $ 0.000137d, 6206.809778716d, 1.867105418d, $ 0.000141d, 17253.041107690d, 2.069217456d, $ 0.000129d, -7477.522860216d, 2.781469314d, $ 0.000116d, 5540.085789459d, 4.281176991d, $ 0.000116d, 9779.108676125d, 3.320925381d, $ 0.000129d, 5237.921013804d, 3.497704076d, $ 0.000113d, 5959.570433334d, 0.983210840d, $ 0.000122d, 6282.095528923d, 2.674938860d, $ 0.000140d, -11.045700264d, 4.957936982d, $ 0.000108d, 23543.230504682d, 1.390113589d, $ 0.000106d, -12569.674818332d, 0.429631317d, $ 0.000110d, -266.607041722d, 5.501340197d, $ 0.000115d, 12559.038152982d, 4.691456618d, $ 0.000134d, -2388.894020449d, 0.577313584d, $ 0.000109d, 10440.274292604d, 6.218148717d, $ 0.000102d, -543.918059096d, 1.477842615d, $ 0.000108d, 21228.392023546d, 2.237753948d ] fbldata = [ fbldata, $ 0.000101d, -4535.059436924d, 3.100492232d, $ 0.000103d, 76.266071276d, 5.594294322d, $ 0.000104d, 949.175608970d, 5.674287810d, $ 0.000101d, 13517.870106233d, 2.196632348d, $ 0.000100d, 11933.367960670d, 4.056084160d ] i2terms = n_elements(fbldata)/3 ; T**2 fbldata = [ fbldata, $ 4.322990d, 6283.075849991d, 2.642893748d, $ 0.406495d, 0.000000000d, 4.712388980d, $ 0.122605d, 12566.151699983d, 2.438140634d, $ 0.019476d, 213.299095438d, 1.642186981d, $ 0.016916d, 529.690965095d, 4.510959344d, $ 0.013374d, -3.523118349d, 1.502210314d, $ 0.008042d, 26.298319800d, 0.478549024d, $ 0.007824d, 155.420399434d, 5.254710405d, $ 0.004894d, 5746.271337896d, 4.683210850d, $ 0.004875d, 5760.498431898d, 0.759507698d, $ 0.004416d, 5223.693919802d, 6.028853166d, $ 0.004088d, -7.113547001d, 0.060926389d, $ 0.004433d, 77713.771467920d, 3.627734103d, $ 0.003277d, 18849.227549974d, 2.327912542d, $ 0.002703d, 6062.663207553d, 1.271941729d, $ 0.003435d, -775.522611324d, 0.747446224d, $ 0.002618d, 6076.890301554d, 3.633715689d, $ 0.003146d, 206.185548437d, 5.647874613d, $ 0.002544d, 1577.343542448d, 6.232904270d, $ 0.002218d, -220.412642439d, 1.309509946d, $ 0.002197d, 5856.477659115d, 2.407212349d, $ 0.002897d, 5753.384884897d, 5.863842246d, $ 0.001766d, 426.598190876d, 0.754113147d, $ 0.001738d, -796.298006816d, 2.714942671d, $ 0.001695d, 522.577418094d, 2.629369842d ] fbldata = [ fbldata, $ 0.001584d, 5507.553238667d, 1.341138229d, $ 0.001503d, -242.728603974d, 0.377699736d, $ 0.001552d, -536.804512095d, 2.904684667d, $ 0.001370d, -398.149003408d, 1.265599125d, $ 0.001889d, -5573.142801634d, 4.413514859d, $ 0.001722d, 6069.776754553d, 2.445966339d, $ 0.001124d, 1059.381930189d, 5.041799657d, $ 0.001258d, 553.569402842d, 3.849557278d, $ 0.000831d, 951.718406251d, 2.471094709d, $ 0.000767d, 4694.002954708d, 5.363125422d, $ 0.000756d, 1349.867409659d, 1.046195744d, $ 0.000775d, -11.045700264d, 0.245548001d, $ 0.000597d, 2146.165416475d, 4.543268798d, $ 0.000568d, 5216.580372801d, 4.178853144d, $ 0.000711d, 1748.016413067d, 5.934271972d, $ 0.000499d, 12036.460734888d, 0.624434410d, $ 0.000671d, -1194.447010225d, 4.136047594d, $ 0.000488d, 5849.364112115d, 2.209679987d, $ 0.000621d, 6438.496249426d, 4.518860804d, $ 0.000495d, -6286.598968340d, 1.868201275d, $ 0.000456d, 5230.807466803d, 1.271231591d, $ 0.000451d, 5088.628839767d, 0.084060889d, $ 0.000435d, 5643.178563677d, 3.324456609d, $ 0.000387d, 10977.078804699d, 4.052488477d, $ 0.000547d, 161000.685737473d, 2.841633844d ] fbldata = [ fbldata, $ 0.000522d, 3154.687084896d, 2.171979966d, $ 0.000375d, 5486.777843175d, 4.983027306d, $ 0.000421d, 5863.591206116d, 4.546432249d, $ 0.000439d, 7084.896781115d, 0.522967921d, $ 0.000309d, 2544.314419883d, 3.172606705d, $ 0.000347d, 4690.479836359d, 1.479586566d, $ 0.000317d, 801.820931124d, 3.553088096d, $ 0.000262d, 419.484643875d, 0.606635550d, $ 0.000248d, 6836.645252834d, 3.014082064d, $ 0.000245d, -1592.596013633d, 5.519526220d, $ 0.000225d, 4292.330832950d, 2.877956536d, $ 0.000214d, 7234.794256242d, 1.605227587d, $ 0.000205d, 5767.611978898d, 0.625804796d, $ 0.000180d, 10447.387839604d, 3.499954526d, $ 0.000229d, 199.072001436d, 5.632304604d, $ 0.000214d, 639.897286314d, 5.960227667d, $ 0.000175d, -433.711737877d, 2.162417992d, $ 0.000209d, 515.463871093d, 2.322150893d, $ 0.000173d, 6040.347246017d, 2.556183691d, $ 0.000184d, 6309.374169791d, 4.732296790d, $ 0.000227d, 149854.400134205d, 5.385812217d, $ 0.000154d, 8031.092263058d, 5.120720920d, $ 0.000151d, 5739.157790895d, 4.815000443d, $ 0.000197d, 7632.943259650d, 0.222827271d, $ 0.000197d, 74.781598567d, 3.910456770d ] fbldata = [ fbldata, $ 0.000138d, 6055.549660552d, 1.397484253d, $ 0.000149d, -6127.655450557d, 5.333727496d, $ 0.000137d, 3894.181829542d, 4.281749907d, $ 0.000135d, 9437.762934887d, 5.979971885d, $ 0.000139d, -2352.866153772d, 4.715630782d, $ 0.000142d, 6812.766815086d, 0.513330157d, $ 0.000120d, -4705.732307544d, 0.194160689d, $ 0.000131d, -71430.695617928d, 0.000379226d, $ 0.000124d, 6279.552731642d, 2.122264908d, $ 0.000108d, -6256.777530192d, 0.883445696d ] i3terms = n_elements(fbldata)/3 ; T**3 fbldata = [ fbldata, $ 0.143388d, 6283.075849991d, 1.131453581d, $ 0.006671d, 12566.151699983d, 0.775148887d, $ 0.001480d, 155.420399434d, 0.480016880d, $ 0.000934d, 213.299095438d, 6.144453084d, $ 0.000795d, 529.690965095d, 2.941595619d, $ 0.000673d, 5746.271337896d, 0.120415406d, $ 0.000672d, 5760.498431898d, 5.317009738d, $ 0.000389d, -220.412642439d, 3.090323467d, $ 0.000373d, 6062.663207553d, 3.003551964d, $ 0.000360d, 6076.890301554d, 1.918913041d, $ 0.000316d, -21.340641002d, 5.545798121d, $ 0.000315d, -242.728603974d, 1.884932563d, $ 0.000278d, 206.185548437d, 1.266254859d, $ 0.000238d, -536.804512095d, 4.532664830d, $ 0.000185d, 522.577418094d, 4.578313856d, $ 0.000245d, 18849.227549974d, 0.587467082d, $ 0.000180d, 426.598190876d, 5.151178553d, $ 0.000200d, 553.569402842d, 5.355983739d, $ 0.000141d, 5223.693919802d, 1.336556009d, $ 0.000104d, 5856.477659115d, 4.239842759d ] i4terms = n_elements(fbldata)/3 ; T**4 fbldata = [ fbldata, $ 0.003826d, 6283.075849991d, 5.705257275d, $ 0.000303d, 12566.151699983d, 5.407132842d, $ 0.000209d, 155.420399434d, 1.989815753d ] nterms = n_elements(fbldata)/3 fbldata = reform(fbldata, 3, nterms, /overwrite) const0 = reform(fbldata(0,*), nterms) freq0 = reform(fbldata(1,*), nterms) phase0 = reform(fbldata(2,*), nterms) texp = dblarr(nterms) + 0 texp(i1terms:i2terms-1) = 1 texp(i2terms:i3terms-1) = 2 texp(i3terms:i4terms-1) = 3 texp(i4terms:* ) = 4 endif if n_elements(tbase) EQ 0 then tbase = 0D t = ((tbase(0)-2451545D) + jd(0))/365250.0D if t EQ 0 then t = 1d-100 if n_elements(nt0) EQ 0 then begin nt = n_elements(const0) endif else begin nt = round(nt0(0))>1 endelse ph = freq0(0:nt-1) * t + phase0(0:nt-1) sint = sin( ph ) sinf = const0(0:nt-1) * t^texp(0:nt-1) dt = total(sinf*sint)*1d-6 if arg_present(deriv) then $ deriv = total(sinf*(texp(0:nt-1)*sint/t + freq0(0:nt-1)*cos(ph)))*(1d-6/365250.0D) return, dt end function tdb2tdt, jd, deriv=deriv, tbase=tbase0, nterms=nt if n_params() EQ 0 OR n_elements(jd) EQ 0 then begin message, 'USAGE: ', /info message, ' TDB = TDT + TDB2TDT(JD)', /info message, ' ;; All units in seconds', /info message, ' ;; JD is julian day number referred to TDT or TDB', /info message, '', /info message, 'Other timescales (all units in seconds; JD=Julian date):', $ /info message, ' TT = TAI + 32.184d ;; TAI to Terrestrial Time', /info message, ' TDT = TAI + 32.184d ;; TAI to Terrestrial Dynamical Time',$ /info message, ' TDB = TDT + TDB2TDT(JD) ;; TDT to Barycentric Dynamical Time',$ /info message, ' ;; (JD referred to TDT or TDB)', /info message, ' TAI = UTC + TAI_UTC(JD) ;; UTC to TAI (JD referred to UTC)', $ /info message, ' UTC = TAI + TAI_UTC(JD, /INV) ;; UTC to TAI (JD referred to TAI)', /info return, 0 endif sz = size(jd) n = n_elements(jd) ntb = n_elements(tbase0) ;; Expand dimensions of TBASE to match JD if ntb GT 0 then begin if ntb GT 1 AND ntb LT n then $ message, 'ERROR: JD and TBASE dimensions must match' tbase = jd*0 + tbase0 endif else begin tbase = jd*0 endelse if n EQ 1 then $ return, tdb2tdt_calc(jd, deriv=deriv, tbase=tbase) result = reform(double(jd), sz(1:sz(0))) if arg_present(deriv) then begin deriv = reform(double(jd), sz(1:sz(0))) for i = 0L, n-1 do begin result(i) = tdb2tdt_calc(jd(i), deriv=dd, tbase=tbase(i), nterms=nt) deriv(i) = dd endfor endif else begin for i = 0L, n-1 do begin result(i) = tdb2tdt_calc(jd(i), tbase=tbase(i), nterms=nt) endfor endelse return, result end