@arcosmos/erfa 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +56 -0
- package/README.md +109 -2
- package/dist/a2af.d.ts +36 -0
- package/dist/a2af.d.ts.map +1 -0
- package/dist/a2af.js +44 -0
- package/dist/a2af.js.map +1 -0
- package/dist/a2tf.d.ts +36 -0
- package/dist/a2tf.d.ts.map +1 -0
- package/dist/a2tf.js +42 -0
- package/dist/a2tf.js.map +1 -0
- package/dist/af2a.d.ts +19 -0
- package/dist/af2a.d.ts.map +1 -0
- package/dist/af2a.js +34 -0
- package/dist/af2a.js.map +1 -0
- package/dist/anp.d.ts +8 -0
- package/dist/anp.d.ts.map +1 -0
- package/dist/anp.js +16 -0
- package/dist/anp.js.map +1 -0
- package/dist/anpm.d.ts +8 -0
- package/dist/anpm.d.ts.map +1 -0
- package/dist/anpm.js +16 -0
- package/dist/anpm.js.map +1 -0
- package/dist/bi00.d.ts +27 -0
- package/dist/bi00.d.ts.map +1 -0
- package/dist/bi00.js +40 -0
- package/dist/bi00.js.map +1 -0
- package/dist/bp06.d.ts +27 -0
- package/dist/bp06.d.ts.map +1 -0
- package/dist/bp06.js +46 -0
- package/dist/bp06.js.map +1 -0
- package/dist/c2s.d.ts +14 -0
- package/dist/c2s.d.ts.map +1 -0
- package/dist/c2s.js +21 -0
- package/dist/c2s.js.map +1 -0
- package/dist/cal2jd.d.ts +27 -0
- package/dist/cal2jd.d.ts.map +1 -0
- package/dist/cal2jd.js +58 -0
- package/dist/cal2jd.js.map +1 -0
- package/dist/constants.d.ts +59 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +60 -0
- package/dist/constants.js.map +1 -0
- package/dist/cp.d.ts +9 -0
- package/dist/cp.d.ts.map +1 -0
- package/dist/cp.js +10 -0
- package/dist/cp.js.map +1 -0
- package/dist/cpv.d.ts +9 -0
- package/dist/cpv.d.ts.map +1 -0
- package/dist/cpv.js +12 -0
- package/dist/cpv.js.map +1 -0
- package/dist/cr.d.ts +9 -0
- package/dist/cr.d.ts.map +1 -0
- package/dist/cr.js +12 -0
- package/dist/cr.js.map +1 -0
- package/dist/d2dtf.d.ts +49 -0
- package/dist/d2dtf.d.ts.map +1 -0
- package/dist/d2dtf.js +142 -0
- package/dist/d2dtf.js.map +1 -0
- package/dist/d2tf.d.ts +36 -0
- package/dist/d2tf.d.ts.map +1 -0
- package/dist/d2tf.js +77 -0
- package/dist/d2tf.js.map +1 -0
- package/dist/dat.d.ts +55 -0
- package/dist/dat.d.ts.map +1 -0
- package/dist/dat.js +168 -0
- package/dist/dat.js.map +1 -0
- package/dist/datini.d.ts +26 -0
- package/dist/datini.d.ts.map +1 -0
- package/dist/datini.js +37 -0
- package/dist/datini.js.map +1 -0
- package/dist/dtdb.d.ts +105 -0
- package/dist/dtdb.d.ts.map +1 -0
- package/dist/dtdb.js +1076 -0
- package/dist/dtdb.js.map +1 -0
- package/dist/dtf2d.d.ts +45 -0
- package/dist/dtf2d.d.ts.map +1 -0
- package/dist/dtf2d.js +112 -0
- package/dist/dtf2d.js.map +1 -0
- package/dist/eceq06.d.ts +24 -0
- package/dist/eceq06.d.ts.map +1 -0
- package/dist/eceq06.js +44 -0
- package/dist/eceq06.js.map +1 -0
- package/dist/ecm06.d.ts +30 -0
- package/dist/ecm06.d.ts.map +1 -0
- package/dist/ecm06.js +45 -0
- package/dist/ecm06.js.map +1 -0
- package/dist/epb.d.ts +24 -0
- package/dist/epb.d.ts.map +1 -0
- package/dist/epb.js +30 -0
- package/dist/epb.js.map +1 -0
- package/dist/epb2jd.d.ts +14 -0
- package/dist/epb2jd.d.ts.map +1 -0
- package/dist/epb2jd.js +20 -0
- package/dist/epb2jd.js.map +1 -0
- package/dist/epj.d.ts +24 -0
- package/dist/epj.d.ts.map +1 -0
- package/dist/epj.js +29 -0
- package/dist/epj.js.map +1 -0
- package/dist/epj2jd.d.ts +14 -0
- package/dist/epj2jd.d.ts.map +1 -0
- package/dist/epj2jd.js +20 -0
- package/dist/epj2jd.js.map +1 -0
- package/dist/eqec06.d.ts +24 -0
- package/dist/eqec06.d.ts.map +1 -0
- package/dist/eqec06.js +44 -0
- package/dist/eqec06.js.map +1 -0
- package/dist/era00.d.ts +29 -0
- package/dist/era00.d.ts.map +1 -0
- package/dist/era00.js +51 -0
- package/dist/era00.js.map +1 -0
- package/dist/fw2m.d.ts +51 -0
- package/dist/fw2m.d.ts.map +1 -0
- package/dist/fw2m.js +61 -0
- package/dist/fw2m.js.map +1 -0
- package/dist/g2icrs.d.ts +33 -0
- package/dist/g2icrs.d.ts.map +1 -0
- package/dist/g2icrs.js +69 -0
- package/dist/g2icrs.js.map +1 -0
- package/dist/gmst06.d.ts +32 -0
- package/dist/gmst06.d.ts.map +1 -0
- package/dist/gmst06.js +49 -0
- package/dist/gmst06.js.map +1 -0
- package/dist/icrs2g.d.ts +33 -0
- package/dist/icrs2g.d.ts.map +1 -0
- package/dist/icrs2g.js +69 -0
- package/dist/icrs2g.js.map +1 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +106 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +23 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +32 -0
- package/dist/internal.js.map +1 -0
- package/dist/ir.d.ts +9 -0
- package/dist/ir.d.ts.map +1 -0
- package/dist/ir.js +14 -0
- package/dist/ir.js.map +1 -0
- package/dist/jd2cal.d.ts +31 -0
- package/dist/jd2cal.d.ts.map +1 -0
- package/dist/jd2cal.js +106 -0
- package/dist/jd2cal.js.map +1 -0
- package/dist/jdcalf.d.ts +28 -0
- package/dist/jdcalf.d.ts.map +1 -0
- package/dist/jdcalf.js +84 -0
- package/dist/jdcalf.js.map +1 -0
- package/dist/leap-seconds.d.ts +30 -0
- package/dist/leap-seconds.d.ts.map +1 -0
- package/dist/leap-seconds.js +42 -0
- package/dist/leap-seconds.js.map +1 -0
- package/dist/obl06.d.ts +19 -0
- package/dist/obl06.d.ts.map +1 -0
- package/dist/obl06.js +32 -0
- package/dist/obl06.js.map +1 -0
- package/dist/pap.d.ts +19 -0
- package/dist/pap.d.ts.map +1 -0
- package/dist/pap.js +45 -0
- package/dist/pap.js.map +1 -0
- package/dist/pas.d.ts +17 -0
- package/dist/pas.d.ts.map +1 -0
- package/dist/pas.js +24 -0
- package/dist/pas.js.map +1 -0
- package/dist/pdp.d.ts +8 -0
- package/dist/pdp.d.ts.map +1 -0
- package/dist/pdp.js +9 -0
- package/dist/pdp.js.map +1 -0
- package/dist/pfw06.d.ts +43 -0
- package/dist/pfw06.d.ts.map +1 -0
- package/dist/pfw06.js +73 -0
- package/dist/pfw06.js.map +1 -0
- package/dist/pm.d.ts +8 -0
- package/dist/pm.d.ts.map +1 -0
- package/dist/pm.js +9 -0
- package/dist/pm.js.map +1 -0
- package/dist/pmat06.d.ts +26 -0
- package/dist/pmat06.d.ts.map +1 -0
- package/dist/pmat06.js +34 -0
- package/dist/pmat06.js.map +1 -0
- package/dist/pmp.d.ts +10 -0
- package/dist/pmp.d.ts.map +1 -0
- package/dist/pmp.js +11 -0
- package/dist/pmp.js.map +1 -0
- package/dist/pmpx.d.ts +29 -0
- package/dist/pmpx.d.ts.map +1 -0
- package/dist/pmpx.js +59 -0
- package/dist/pmpx.js.map +1 -0
- package/dist/pmsafe.d.ts +60 -0
- package/dist/pmsafe.d.ts.map +1 -0
- package/dist/pmsafe.js +91 -0
- package/dist/pmsafe.js.map +1 -0
- package/dist/pn.d.ts +12 -0
- package/dist/pn.d.ts.map +1 -0
- package/dist/pn.js +25 -0
- package/dist/pn.js.map +1 -0
- package/dist/ppp.d.ts +10 -0
- package/dist/ppp.d.ts.map +1 -0
- package/dist/ppp.js +11 -0
- package/dist/ppp.js.map +1 -0
- package/dist/ppsp.d.ts +11 -0
- package/dist/ppsp.d.ts.map +1 -0
- package/dist/ppsp.js +17 -0
- package/dist/ppsp.js.map +1 -0
- package/dist/pv2s.d.ts +19 -0
- package/dist/pv2s.d.ts.map +1 -0
- package/dist/pv2s.js +61 -0
- package/dist/pv2s.js.map +1 -0
- package/dist/pvdpv.d.ts +14 -0
- package/dist/pvdpv.d.ts.map +1 -0
- package/dist/pvdpv.js +24 -0
- package/dist/pvdpv.js.map +1 -0
- package/dist/pvm.d.ts +9 -0
- package/dist/pvm.d.ts.map +1 -0
- package/dist/pvm.js +15 -0
- package/dist/pvm.js.map +1 -0
- package/dist/pvmpv.d.ts +10 -0
- package/dist/pvmpv.d.ts.map +1 -0
- package/dist/pvmpv.js +12 -0
- package/dist/pvmpv.js.map +1 -0
- package/dist/pvppv.d.ts +10 -0
- package/dist/pvppv.d.ts.map +1 -0
- package/dist/pvppv.js +12 -0
- package/dist/pvppv.js.map +1 -0
- package/dist/pvstar.d.ts +51 -0
- package/dist/pvstar.d.ts.map +1 -0
- package/dist/pvstar.js +97 -0
- package/dist/pvstar.js.map +1 -0
- package/dist/pvu.d.ts +15 -0
- package/dist/pvu.d.ts.map +1 -0
- package/dist/pvu.js +19 -0
- package/dist/pvu.js.map +1 -0
- package/dist/pvxpv.d.ts +15 -0
- package/dist/pvxpv.d.ts.map +1 -0
- package/dist/pvxpv.js +29 -0
- package/dist/pvxpv.js.map +1 -0
- package/dist/pxp.d.ts +8 -0
- package/dist/pxp.d.ts.map +1 -0
- package/dist/pxp.js +15 -0
- package/dist/pxp.js.map +1 -0
- package/dist/rx.d.ts +21 -0
- package/dist/rx.d.ts.map +1 -0
- package/dist/rx.js +30 -0
- package/dist/rx.js.map +1 -0
- package/dist/rxp.d.ts +10 -0
- package/dist/rxp.d.ts.map +1 -0
- package/dist/rxp.js +21 -0
- package/dist/rxp.js.map +1 -0
- package/dist/rxr.d.ts +10 -0
- package/dist/rxr.d.ts.map +1 -0
- package/dist/rxr.js +27 -0
- package/dist/rxr.js.map +1 -0
- package/dist/ry.d.ts +21 -0
- package/dist/ry.d.ts.map +1 -0
- package/dist/ry.js +30 -0
- package/dist/ry.js.map +1 -0
- package/dist/rz.d.ts +21 -0
- package/dist/rz.d.ts.map +1 -0
- package/dist/rz.js +30 -0
- package/dist/rz.js.map +1 -0
- package/dist/s2c.d.ts +10 -0
- package/dist/s2c.d.ts.map +1 -0
- package/dist/s2c.js +12 -0
- package/dist/s2c.js.map +1 -0
- package/dist/s2pv.d.ts +14 -0
- package/dist/s2pv.d.ts.map +1 -0
- package/dist/s2pv.js +27 -0
- package/dist/s2pv.js.map +1 -0
- package/dist/s2xpv.d.ts +11 -0
- package/dist/s2xpv.d.ts.map +1 -0
- package/dist/s2xpv.js +13 -0
- package/dist/s2xpv.js.map +1 -0
- package/dist/sepp.d.ts +16 -0
- package/dist/sepp.d.ts.map +1 -0
- package/dist/sepp.js +26 -0
- package/dist/sepp.js.map +1 -0
- package/dist/seps.d.ts +11 -0
- package/dist/seps.d.ts.map +1 -0
- package/dist/seps.js +20 -0
- package/dist/seps.js.map +1 -0
- package/dist/starpm.d.ts +56 -0
- package/dist/starpm.d.ts.map +1 -0
- package/dist/starpm.js +90 -0
- package/dist/starpm.js.map +1 -0
- package/dist/starpv.d.ts +62 -0
- package/dist/starpv.d.ts.map +1 -0
- package/dist/starpv.js +147 -0
- package/dist/starpv.js.map +1 -0
- package/dist/sxp.d.ts +10 -0
- package/dist/sxp.d.ts.map +1 -0
- package/dist/sxp.js +11 -0
- package/dist/sxp.js.map +1 -0
- package/dist/sxpv.d.ts +10 -0
- package/dist/sxpv.d.ts.map +1 -0
- package/dist/sxpv.js +12 -0
- package/dist/sxpv.js.map +1 -0
- package/dist/taitt.d.ts +19 -0
- package/dist/taitt.d.ts.map +1 -0
- package/dist/taitt.js +36 -0
- package/dist/taitt.js.map +1 -0
- package/dist/taiut1.d.ts +20 -0
- package/dist/taiut1.d.ts.map +1 -0
- package/dist/taiut1.js +36 -0
- package/dist/taiut1.js.map +1 -0
- package/dist/taiutc.d.ts +33 -0
- package/dist/taiutc.d.ts.map +1 -0
- package/dist/taiutc.js +73 -0
- package/dist/taiutc.js.map +1 -0
- package/dist/tcbtdb.d.ts +29 -0
- package/dist/tcbtdb.d.ts.map +1 -0
- package/dist/tcbtdb.js +51 -0
- package/dist/tcbtdb.js.map +1 -0
- package/dist/tcgtt.d.ts +18 -0
- package/dist/tcgtt.d.ts.map +1 -0
- package/dist/tcgtt.js +35 -0
- package/dist/tcgtt.js.map +1 -0
- package/dist/tdbtcb.d.ts +29 -0
- package/dist/tdbtcb.d.ts.map +1 -0
- package/dist/tdbtcb.js +55 -0
- package/dist/tdbtcb.js.map +1 -0
- package/dist/tdbtt.d.ts +27 -0
- package/dist/tdbtt.d.ts.map +1 -0
- package/dist/tdbtt.js +43 -0
- package/dist/tdbtt.js.map +1 -0
- package/dist/tf2a.d.ts +19 -0
- package/dist/tf2a.d.ts.map +1 -0
- package/dist/tf2a.js +34 -0
- package/dist/tf2a.js.map +1 -0
- package/dist/tr.d.ts +9 -0
- package/dist/tr.d.ts.map +1 -0
- package/dist/tr.js +22 -0
- package/dist/tr.js.map +1 -0
- package/dist/trxp.d.ts +10 -0
- package/dist/trxp.d.ts.map +1 -0
- package/dist/trxp.js +15 -0
- package/dist/trxp.js.map +1 -0
- package/dist/tttai.d.ts +19 -0
- package/dist/tttai.d.ts.map +1 -0
- package/dist/tttai.js +36 -0
- package/dist/tttai.js.map +1 -0
- package/dist/tttcg.d.ts +18 -0
- package/dist/tttcg.d.ts.map +1 -0
- package/dist/tttcg.js +37 -0
- package/dist/tttcg.js.map +1 -0
- package/dist/tttdb.d.ts +27 -0
- package/dist/tttdb.d.ts.map +1 -0
- package/dist/tttdb.js +43 -0
- package/dist/tttdb.js.map +1 -0
- package/dist/ttut1.d.ts +19 -0
- package/dist/ttut1.d.ts.map +1 -0
- package/dist/ttut1.js +35 -0
- package/dist/ttut1.js.map +1 -0
- package/dist/ut1tai.d.ts +20 -0
- package/dist/ut1tai.d.ts.map +1 -0
- package/dist/ut1tai.js +36 -0
- package/dist/ut1tai.js.map +1 -0
- package/dist/ut1tt.d.ts +19 -0
- package/dist/ut1tt.d.ts.map +1 -0
- package/dist/ut1tt.js +35 -0
- package/dist/ut1tt.js.map +1 -0
- package/dist/ut1utc.d.ts +35 -0
- package/dist/ut1utc.d.ts.map +1 -0
- package/dist/ut1utc.js +107 -0
- package/dist/ut1utc.js.map +1 -0
- package/dist/utctai.d.ts +33 -0
- package/dist/utctai.d.ts.map +1 -0
- package/dist/utctai.js +94 -0
- package/dist/utctai.js.map +1 -0
- package/dist/utcut1.d.ts +34 -0
- package/dist/utcut1.d.ts.map +1 -0
- package/dist/utcut1.js +63 -0
- package/dist/utcut1.js.map +1 -0
- package/dist/zp.d.ts +8 -0
- package/dist/zp.d.ts.map +1 -0
- package/dist/zp.js +9 -0
- package/dist/zp.js.map +1 -0
- package/dist/zpv.d.ts +8 -0
- package/dist/zpv.d.ts.map +1 -0
- package/dist/zpv.js +10 -0
- package/dist/zpv.js.map +1 -0
- package/dist/zr.d.ts +9 -0
- package/dist/zr.d.ts.map +1 -0
- package/dist/zr.js +14 -0
- package/dist/zr.js.map +1 -0
- package/package.json +42 -3
- package/src/a2af.ts +48 -0
- package/src/a2tf.ts +45 -0
- package/src/af2a.ts +38 -0
- package/src/anp.ts +15 -0
- package/src/anpm.ts +15 -0
- package/src/bi00.ts +42 -0
- package/src/bp06.ts +51 -0
- package/src/c2s.ts +23 -0
- package/src/cal2jd.ts +67 -0
- package/src/constants.ts +60 -0
- package/src/cp.ts +12 -0
- package/src/cpv.ts +13 -0
- package/src/cr.ts +13 -0
- package/src/d2dtf.ts +153 -0
- package/src/d2tf.ts +87 -0
- package/src/dat.ts +186 -0
- package/src/datini.ts +49 -0
- package/src/dtdb.ts +1110 -0
- package/src/dtf2d.ts +124 -0
- package/src/eceq06.ts +54 -0
- package/src/ecm06.ts +51 -0
- package/src/epb.ts +31 -0
- package/src/epb2jd.ts +21 -0
- package/src/epj.ts +30 -0
- package/src/epj2jd.ts +21 -0
- package/src/eqec06.ts +54 -0
- package/src/era00.ts +54 -0
- package/src/fw2m.ts +64 -0
- package/src/g2icrs.ts +74 -0
- package/src/gmst06.ts +51 -0
- package/src/icrs2g.ts +74 -0
- package/src/index.ts +108 -0
- package/src/internal.ts +46 -0
- package/src/ir.ts +16 -0
- package/src/jd2cal.ts +117 -0
- package/src/jdcalf.ts +93 -0
- package/src/leap-seconds.ts +47 -0
- package/src/obl06.ts +34 -0
- package/src/pap.ts +54 -0
- package/src/pas.ts +25 -0
- package/src/pdp.ts +11 -0
- package/src/pfw06.ts +78 -0
- package/src/pm.ts +11 -0
- package/src/pmat06.ts +37 -0
- package/src/pmp.ts +13 -0
- package/src/pmpx.ts +75 -0
- package/src/pmsafe.ts +109 -0
- package/src/pn.ts +26 -0
- package/src/ppp.ts +13 -0
- package/src/ppsp.ts +20 -0
- package/src/pv2s.ts +71 -0
- package/src/pvdpv.ts +30 -0
- package/src/pvm.ts +19 -0
- package/src/pvmpv.ts +14 -0
- package/src/pvppv.ts +14 -0
- package/src/pvstar.ts +113 -0
- package/src/pvu.ts +20 -0
- package/src/pvxpv.ts +33 -0
- package/src/pxp.ts +17 -0
- package/src/rx.ts +32 -0
- package/src/rxp.ts +24 -0
- package/src/rxr.ts +29 -0
- package/src/ry.ts +32 -0
- package/src/rz.ts +32 -0
- package/src/s2c.ts +14 -0
- package/src/s2pv.ts +30 -0
- package/src/s2xpv.ts +15 -0
- package/src/sepp.ts +28 -0
- package/src/seps.ts +20 -0
- package/src/starpm.ts +108 -0
- package/src/starpv.ts +167 -0
- package/src/sxp.ts +13 -0
- package/src/sxpv.ts +14 -0
- package/src/taitt.ts +38 -0
- package/src/taiut1.ts +41 -0
- package/src/taiutc.ts +76 -0
- package/src/tcbtdb.ts +54 -0
- package/src/tcgtt.ts +37 -0
- package/src/tdbtcb.ts +59 -0
- package/src/tdbtt.ts +48 -0
- package/src/tf2a.ts +38 -0
- package/src/tr.ts +24 -0
- package/src/trxp.ts +18 -0
- package/src/tttai.ts +38 -0
- package/src/tttcg.ts +40 -0
- package/src/tttdb.ts +48 -0
- package/src/ttut1.ts +40 -0
- package/src/ut1tai.ts +41 -0
- package/src/ut1tt.ts +40 -0
- package/src/ut1utc.ts +115 -0
- package/src/utctai.ts +97 -0
- package/src/utcut1.ts +66 -0
- package/src/zp.ts +11 -0
- package/src/zpv.ts +12 -0
- package/src/zr.ts +16 -0
package/src/taiut1.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTaiut1 (taiut1.c); see LICENSE.
|
|
2
|
+
import { DAYSEC } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Time scale transformation: International Atomic Time, TAI, to Universal Time, UT1.
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* 1. tai1+tai2 is Julian Date, apportioned in any convenient way between the two arguments,
|
|
9
|
+
* for example where tai1 is the Julian Day Number and tai2 is the fraction of a day. The
|
|
10
|
+
* returned ut11,ut12 follow suit.
|
|
11
|
+
* 2. The argument dta, i.e. UT1-TAI, is an observed quantity, and is available from IERS
|
|
12
|
+
* tabulations.
|
|
13
|
+
*
|
|
14
|
+
* Reference: Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann
|
|
15
|
+
* (ed), University Science Books (1992)
|
|
16
|
+
*
|
|
17
|
+
* @param tai1 TAI as a 2-part Julian Date
|
|
18
|
+
* @param tai2 TAI as a 2-part Julian Date
|
|
19
|
+
* @param dta UT1-TAI in seconds
|
|
20
|
+
* @returns [ut11, ut12, status]: UT1 as a 2-part Julian Date, and status: 0 = OK
|
|
21
|
+
*/
|
|
22
|
+
export function taiut1(
|
|
23
|
+
tai1: number,
|
|
24
|
+
tai2: number,
|
|
25
|
+
dta: number,
|
|
26
|
+
): [ut11: number, ut12: number, status: number] {
|
|
27
|
+
let ut11: number, ut12: number
|
|
28
|
+
|
|
29
|
+
// Result, safeguarding precision.
|
|
30
|
+
const dtad = dta / DAYSEC
|
|
31
|
+
if (Math.abs(tai1) > Math.abs(tai2)) {
|
|
32
|
+
ut11 = tai1
|
|
33
|
+
ut12 = tai2 + dtad
|
|
34
|
+
} else {
|
|
35
|
+
ut11 = tai1 + dtad
|
|
36
|
+
ut12 = tai2
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Status (always OK).
|
|
40
|
+
return [ut11, ut12, 0]
|
|
41
|
+
}
|
package/src/taiutc.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTaiutc (taiutc.c); see LICENSE.
|
|
2
|
+
import { utctai } from './utctai.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Time scale transformation: International Atomic Time, TAI, to Coordinated Universal Time,
|
|
6
|
+
* UTC.
|
|
7
|
+
*
|
|
8
|
+
* Notes:
|
|
9
|
+
* 1. tai1+tai2 is Julian Date, apportioned in any convenient way between the two arguments,
|
|
10
|
+
* for example where tai1 is the Julian Day Number and tai2 is the fraction of a day. The
|
|
11
|
+
* returned utc1 and utc2 form an analogous pair, except that a special convention is
|
|
12
|
+
* used, to deal with the problem of leap seconds - see the next note.
|
|
13
|
+
* 2. JD cannot unambiguously represent UTC during a leap second unless special measures are
|
|
14
|
+
* taken. The convention in the present function is that the JD day represents UTC days
|
|
15
|
+
* whether the length is 86399, 86400 or 86401 SI seconds. In the 1960-1972 era there
|
|
16
|
+
* were smaller jumps (in either direction) each time the linear UTC(TAI) expression was
|
|
17
|
+
* changed, and these "mini-leaps" are also included in the ERFA convention.
|
|
18
|
+
* 3. The function d2dtf can be used to transform the UTC quasi-JD into calendar date and
|
|
19
|
+
* clock time, including UTC leap second handling.
|
|
20
|
+
* 4. The warning status "dubious year" flags UTCs that predate the introduction of the time
|
|
21
|
+
* scale or that are too far in the future to be trusted. See dat for further details.
|
|
22
|
+
* 5. Where the status is negative, utc1 and utc2 are NaN.
|
|
23
|
+
*
|
|
24
|
+
* References:
|
|
25
|
+
* - McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32,
|
|
26
|
+
* BKG (2004)
|
|
27
|
+
* - Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann (ed),
|
|
28
|
+
* University Science Books (1992)
|
|
29
|
+
*
|
|
30
|
+
* @param tai1 TAI as a 2-part Julian Date (Note 1)
|
|
31
|
+
* @param tai2 TAI as a 2-part Julian Date (Note 1)
|
|
32
|
+
* @returns [utc1, utc2, status]: UTC as a 2-part quasi Julian Date (Notes 1-3), and status:
|
|
33
|
+
* +1 = dubious year (Note 4), 0 = OK, -1 = unacceptable date
|
|
34
|
+
*/
|
|
35
|
+
export function taiutc(tai1: number, tai2: number): [utc1: number, utc2: number, status: number] {
|
|
36
|
+
let a1: number, a2: number, utc1: number, utc2: number
|
|
37
|
+
let j = 0
|
|
38
|
+
|
|
39
|
+
// Put the two parts of the TAI into big-first order.
|
|
40
|
+
const big1 = Math.abs(tai1) >= Math.abs(tai2)
|
|
41
|
+
if (big1) {
|
|
42
|
+
a1 = tai1
|
|
43
|
+
a2 = tai2
|
|
44
|
+
} else {
|
|
45
|
+
a1 = tai2
|
|
46
|
+
a2 = tai1
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Initial guess for UTC.
|
|
50
|
+
const u1 = a1
|
|
51
|
+
let u2 = a2
|
|
52
|
+
|
|
53
|
+
// Iterate (though in most cases just once is enough).
|
|
54
|
+
for (let i = 0; i < 3; i++) {
|
|
55
|
+
// Guessed UTC to TAI.
|
|
56
|
+
const [g1, g2, jg] = utctai(u1, u2)
|
|
57
|
+
j = jg
|
|
58
|
+
if (j < 0) return [NaN, NaN, j]
|
|
59
|
+
|
|
60
|
+
// Adjust guessed UTC.
|
|
61
|
+
u2 += a1 - g1
|
|
62
|
+
u2 += a2 - g2
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Return the UTC result, preserving the TAI order.
|
|
66
|
+
if (big1) {
|
|
67
|
+
utc1 = u1
|
|
68
|
+
utc2 = u2
|
|
69
|
+
} else {
|
|
70
|
+
utc1 = u2
|
|
71
|
+
utc2 = u1
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Status.
|
|
75
|
+
return [utc1, utc2, j]
|
|
76
|
+
}
|
package/src/tcbtdb.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTcbtdb (tcbtdb.c); see LICENSE.
|
|
2
|
+
import { DAYSEC, DJM0, DJM77, ELB, TDB0, TTMTAI } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
// 1977 Jan 1 00:00:32.184 TT, as two-part JD
|
|
5
|
+
const t77td = DJM0 + DJM77
|
|
6
|
+
const t77tf = TTMTAI / DAYSEC
|
|
7
|
+
|
|
8
|
+
// TDB (days) at TAI 1977 Jan 1.0
|
|
9
|
+
const tdb0 = TDB0 / DAYSEC
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Time scale transformation: Barycentric Coordinate Time, TCB, to Barycentric Dynamical
|
|
13
|
+
* Time, TDB.
|
|
14
|
+
*
|
|
15
|
+
* Notes:
|
|
16
|
+
* 1. tcb1+tcb2 is Julian Date, apportioned in any convenient way between the two arguments,
|
|
17
|
+
* for example where tcb1 is the Julian Day Number and tcb2 is the fraction of a day. The
|
|
18
|
+
* returned tdb1,tdb2 follow suit.
|
|
19
|
+
* 2. The 2006 IAU General Assembly introduced a conventional linear transformation between
|
|
20
|
+
* TDB and TCB. This transformation compensates for the drift between TCB and terrestrial
|
|
21
|
+
* time TT, and keeps TDB approximately centered on TT. Because the relationship between
|
|
22
|
+
* TT and TCB depends on the adopted solar system ephemeris, the degree of alignment
|
|
23
|
+
* between TDB and TT over long intervals will vary according to which ephemeris is used.
|
|
24
|
+
* Former definitions of TDB attempted to avoid this problem by stipulating that TDB and
|
|
25
|
+
* TT should differ only by periodic effects. This is a good description of the nature of
|
|
26
|
+
* the relationship but eluded precise mathematical formulation. The conventional linear
|
|
27
|
+
* relationship adopted in 2006 sidestepped these difficulties whilst delivering a TDB
|
|
28
|
+
* that in practice was consistent with values before that date.
|
|
29
|
+
* 3. TDB is essentially the same as Teph, the time argument for the JPL solar system
|
|
30
|
+
* ephemerides.
|
|
31
|
+
*
|
|
32
|
+
* Reference: IAU 2006 Resolution B3
|
|
33
|
+
*
|
|
34
|
+
* @param tcb1 TCB as a 2-part Julian Date
|
|
35
|
+
* @param tcb2 TCB as a 2-part Julian Date
|
|
36
|
+
* @returns [tdb1, tdb2, status]: TDB as a 2-part Julian Date, and status: 0 = OK
|
|
37
|
+
*/
|
|
38
|
+
export function tcbtdb(tcb1: number, tcb2: number): [tdb1: number, tdb2: number, status: number] {
|
|
39
|
+
let d: number, tdb1: number, tdb2: number
|
|
40
|
+
|
|
41
|
+
// Result, safeguarding precision.
|
|
42
|
+
if (Math.abs(tcb1) > Math.abs(tcb2)) {
|
|
43
|
+
d = tcb1 - t77td
|
|
44
|
+
tdb1 = tcb1
|
|
45
|
+
tdb2 = tcb2 + tdb0 - (d + (tcb2 - t77tf)) * ELB
|
|
46
|
+
} else {
|
|
47
|
+
d = tcb2 - t77td
|
|
48
|
+
tdb1 = tcb1 + tdb0 - (d + (tcb1 - t77tf)) * ELB
|
|
49
|
+
tdb2 = tcb2
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Status (always OK).
|
|
53
|
+
return [tdb1, tdb2, 0]
|
|
54
|
+
}
|
package/src/tcgtt.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTcgtt (tcgtt.c); see LICENSE.
|
|
2
|
+
import { DAYSEC, DJM0, DJM77, ELG, TTMTAI } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
// 1977 Jan 1 00:00:32.184 TT, as MJD
|
|
5
|
+
const t77t = DJM77 + TTMTAI / DAYSEC
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Time scale transformation: Geocentric Coordinate Time, TCG, to Terrestrial Time, TT.
|
|
9
|
+
*
|
|
10
|
+
* Note: tcg1+tcg2 is Julian Date, apportioned in any convenient way between the two
|
|
11
|
+
* arguments, for example where tcg1 is the Julian Day Number and tcg2 is the fraction of a
|
|
12
|
+
* day. The returned tt1,tt2 follow suit.
|
|
13
|
+
*
|
|
14
|
+
* References:
|
|
15
|
+
* - McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32,
|
|
16
|
+
* BKG (2004)
|
|
17
|
+
* - IAU 2000 Resolution B1.9
|
|
18
|
+
*
|
|
19
|
+
* @param tcg1 TCG as a 2-part Julian Date
|
|
20
|
+
* @param tcg2 TCG as a 2-part Julian Date
|
|
21
|
+
* @returns [tt1, tt2, status]: TT as a 2-part Julian Date, and status: 0 = OK
|
|
22
|
+
*/
|
|
23
|
+
export function tcgtt(tcg1: number, tcg2: number): [tt1: number, tt2: number, status: number] {
|
|
24
|
+
let tt1: number, tt2: number
|
|
25
|
+
|
|
26
|
+
// Result, safeguarding precision.
|
|
27
|
+
if (Math.abs(tcg1) > Math.abs(tcg2)) {
|
|
28
|
+
tt1 = tcg1
|
|
29
|
+
tt2 = tcg2 - ((tcg1 - DJM0) + (tcg2 - t77t)) * ELG
|
|
30
|
+
} else {
|
|
31
|
+
tt1 = tcg1 - ((tcg2 - DJM0) + (tcg1 - t77t)) * ELG
|
|
32
|
+
tt2 = tcg2
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// OK status.
|
|
36
|
+
return [tt1, tt2, 0]
|
|
37
|
+
}
|
package/src/tdbtcb.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTdbtcb (tdbtcb.c); see LICENSE.
|
|
2
|
+
import { DAYSEC, DJM0, DJM77, ELB, TDB0, TTMTAI } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
// 1977 Jan 1 00:00:32.184 TT, as two-part JD
|
|
5
|
+
const t77td = DJM0 + DJM77
|
|
6
|
+
const t77tf = TTMTAI / DAYSEC
|
|
7
|
+
|
|
8
|
+
// TDB (days) at TAI 1977 Jan 1.0
|
|
9
|
+
const tdb0 = TDB0 / DAYSEC
|
|
10
|
+
|
|
11
|
+
// TDB to TCB rate
|
|
12
|
+
const elbb = ELB / (1.0 - ELB)
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Time scale transformation: Barycentric Dynamical Time, TDB, to Barycentric Coordinate
|
|
16
|
+
* Time, TCB.
|
|
17
|
+
*
|
|
18
|
+
* Notes:
|
|
19
|
+
* 1. tdb1+tdb2 is Julian Date, apportioned in any convenient way between the two arguments,
|
|
20
|
+
* for example where tdb1 is the Julian Day Number and tdb2 is the fraction of a day. The
|
|
21
|
+
* returned tcb1,tcb2 follow suit.
|
|
22
|
+
* 2. The 2006 IAU General Assembly introduced a conventional linear transformation between
|
|
23
|
+
* TDB and TCB. This transformation compensates for the drift between TCB and terrestrial
|
|
24
|
+
* time TT, and keeps TDB approximately centered on TT. Because the relationship between
|
|
25
|
+
* TT and TCB depends on the adopted solar system ephemeris, the degree of alignment
|
|
26
|
+
* between TDB and TT over long intervals will vary according to which ephemeris is used.
|
|
27
|
+
* Former definitions of TDB attempted to avoid this problem by stipulating that TDB and
|
|
28
|
+
* TT should differ only by periodic effects. This is a good description of the nature of
|
|
29
|
+
* the relationship but eluded precise mathematical formulation. The conventional linear
|
|
30
|
+
* relationship adopted in 2006 sidestepped these difficulties whilst delivering a TDB
|
|
31
|
+
* that in practice was consistent with values before that date.
|
|
32
|
+
* 3. TDB is essentially the same as Teph, the time argument for the JPL solar system
|
|
33
|
+
* ephemerides.
|
|
34
|
+
*
|
|
35
|
+
* Reference: IAU 2006 Resolution B3
|
|
36
|
+
*
|
|
37
|
+
* @param tdb1 TDB as a 2-part Julian Date
|
|
38
|
+
* @param tdb2 TDB as a 2-part Julian Date
|
|
39
|
+
* @returns [tcb1, tcb2, status]: TCB as a 2-part Julian Date, and status: 0 = OK
|
|
40
|
+
*/
|
|
41
|
+
export function tdbtcb(tdb1: number, tdb2: number): [tcb1: number, tcb2: number, status: number] {
|
|
42
|
+
let d: number, f: number, tcb1: number, tcb2: number
|
|
43
|
+
|
|
44
|
+
// Result, preserving date format but safeguarding precision.
|
|
45
|
+
if (Math.abs(tdb1) > Math.abs(tdb2)) {
|
|
46
|
+
d = t77td - tdb1
|
|
47
|
+
f = tdb2 - tdb0
|
|
48
|
+
tcb1 = tdb1
|
|
49
|
+
tcb2 = f - (d - (f - t77tf)) * elbb
|
|
50
|
+
} else {
|
|
51
|
+
d = t77td - tdb2
|
|
52
|
+
f = tdb1 - tdb0
|
|
53
|
+
tcb1 = f - (d - (f - t77tf)) * elbb
|
|
54
|
+
tcb2 = tdb2
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Status (always OK).
|
|
58
|
+
return [tcb1, tcb2, 0]
|
|
59
|
+
}
|
package/src/tdbtt.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTdbtt (tdbtt.c); see LICENSE.
|
|
2
|
+
import { DAYSEC } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Time scale transformation: Barycentric Dynamical Time, TDB, to Terrestrial Time, TT.
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* 1. tdb1+tdb2 is Julian Date, apportioned in any convenient way between the two arguments,
|
|
9
|
+
* for example where tdb1 is the Julian Day Number and tdb2 is the fraction of a day. The
|
|
10
|
+
* returned tt1,tt2 follow suit.
|
|
11
|
+
* 2. The argument dtr represents the quasi-periodic component of the GR transformation
|
|
12
|
+
* between TT and TCB. It is dependent upon the adopted solar-system ephemeris, and can be
|
|
13
|
+
* obtained by numerical integration, by interrogating a precomputed time ephemeris or by
|
|
14
|
+
* evaluating a model such as that implemented in the ERFA function dtdb. The quantity is
|
|
15
|
+
* dominated by an annual term of 1.7 ms amplitude.
|
|
16
|
+
* 3. TDB is essentially the same as Teph, the time argument for the JPL solar system
|
|
17
|
+
* ephemerides.
|
|
18
|
+
*
|
|
19
|
+
* References:
|
|
20
|
+
* - McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32,
|
|
21
|
+
* BKG (2004)
|
|
22
|
+
* - IAU 2006 Resolution 3
|
|
23
|
+
*
|
|
24
|
+
* @param tdb1 TDB as a 2-part Julian Date
|
|
25
|
+
* @param tdb2 TDB as a 2-part Julian Date
|
|
26
|
+
* @param dtr TDB-TT in seconds
|
|
27
|
+
* @returns [tt1, tt2, status]: TT as a 2-part Julian Date, and status: 0 = OK
|
|
28
|
+
*/
|
|
29
|
+
export function tdbtt(
|
|
30
|
+
tdb1: number,
|
|
31
|
+
tdb2: number,
|
|
32
|
+
dtr: number,
|
|
33
|
+
): [tt1: number, tt2: number, status: number] {
|
|
34
|
+
let tt1: number, tt2: number
|
|
35
|
+
|
|
36
|
+
// Result, safeguarding precision.
|
|
37
|
+
const dtrd = dtr / DAYSEC
|
|
38
|
+
if (Math.abs(tdb1) > Math.abs(tdb2)) {
|
|
39
|
+
tt1 = tdb1
|
|
40
|
+
tt2 = tdb2 - dtrd
|
|
41
|
+
} else {
|
|
42
|
+
tt1 = tdb1 - dtrd
|
|
43
|
+
tt2 = tdb2
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Status (always OK).
|
|
47
|
+
return [tt1, tt2, 0]
|
|
48
|
+
}
|
package/src/tf2a.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTf2a (tf2a.c); see LICENSE.
|
|
2
|
+
import { DS2R } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Convert hours, minutes, seconds to radians.
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* 1. The result is computed even if any of the range checks fail.
|
|
9
|
+
* 2. Negative ihour, imin and/or sec produce a warning status, but the absolute value is
|
|
10
|
+
* used in the conversion.
|
|
11
|
+
* 3. If there are multiple errors, the status value reflects only the first, the smallest
|
|
12
|
+
* taking precedence.
|
|
13
|
+
*
|
|
14
|
+
* @param s sign: '-' = negative, otherwise positive
|
|
15
|
+
* @param ihour hours (an integer in C)
|
|
16
|
+
* @param imin minutes (an integer in C)
|
|
17
|
+
* @param sec seconds
|
|
18
|
+
* @returns [rad, status]: angle in radians, and status: 0 = OK, 1 = ihour outside range
|
|
19
|
+
* 0-23, 2 = imin outside range 0-59, 3 = sec outside range 0-59.999...
|
|
20
|
+
*/
|
|
21
|
+
export function tf2a(
|
|
22
|
+
s: string,
|
|
23
|
+
ihour: number,
|
|
24
|
+
imin: number,
|
|
25
|
+
sec: number,
|
|
26
|
+
): [rad: number, status: number] {
|
|
27
|
+
// Compute the interval.
|
|
28
|
+
const rad =
|
|
29
|
+
(s === '-' ? -1.0 : 1.0) *
|
|
30
|
+
(60.0 * (60.0 * Math.abs(ihour) + Math.abs(imin)) + Math.abs(sec)) *
|
|
31
|
+
DS2R
|
|
32
|
+
|
|
33
|
+
// Validate arguments and return status.
|
|
34
|
+
if (ihour < 0 || ihour > 23) return [rad, 1]
|
|
35
|
+
if (imin < 0 || imin > 59) return [rad, 2]
|
|
36
|
+
if (sec < 0.0 || sec >= 60.0) return [rad, 3]
|
|
37
|
+
return [rad, 0]
|
|
38
|
+
}
|
package/src/tr.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTr (tr.c); see LICENSE.
|
|
2
|
+
import { cr } from './cr.ts'
|
|
3
|
+
import type { Mat3 } from './internal.ts'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Transpose an r-matrix.
|
|
7
|
+
*
|
|
8
|
+
* @param r r-matrix
|
|
9
|
+
* @returns rt: transpose
|
|
10
|
+
*/
|
|
11
|
+
export function tr(r: Mat3): Mat3 {
|
|
12
|
+
const wm: [[number, number, number], [number, number, number], [number, number, number]] = [
|
|
13
|
+
[0.0, 0.0, 0.0],
|
|
14
|
+
[0.0, 0.0, 0.0],
|
|
15
|
+
[0.0, 0.0, 0.0],
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
for (let i = 0; i < 3; i++) {
|
|
19
|
+
for (let j = 0; j < 3; j++) {
|
|
20
|
+
wm[i]![j] = r[j]![i]!
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return cr(wm)
|
|
24
|
+
}
|
package/src/trxp.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTrxp (trxp.c); see LICENSE.
|
|
2
|
+
import type { Mat3, Vec3 } from './internal.ts'
|
|
3
|
+
import { rxp } from './rxp.ts'
|
|
4
|
+
import { tr } from './tr.ts'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Multiply a p-vector by the transpose of an r-matrix.
|
|
8
|
+
*
|
|
9
|
+
* @param r r-matrix
|
|
10
|
+
* @param p p-vector
|
|
11
|
+
* @returns trp: r^T * p
|
|
12
|
+
*/
|
|
13
|
+
export function trxp(r: Mat3, p: Vec3): Vec3 {
|
|
14
|
+
// ERFA's local tr, renamed: tr is the function.
|
|
15
|
+
const rt = tr(r)
|
|
16
|
+
|
|
17
|
+
return rxp(rt, p)
|
|
18
|
+
}
|
package/src/tttai.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTttai (tttai.c); see LICENSE.
|
|
2
|
+
import { DAYSEC, TTMTAI } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
// TT minus TAI (days).
|
|
5
|
+
const dtat = TTMTAI / DAYSEC
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Time scale transformation: Terrestrial Time, TT, to International Atomic Time, TAI.
|
|
9
|
+
*
|
|
10
|
+
* Note: tt1+tt2 is Julian Date, apportioned in any convenient way between the two arguments,
|
|
11
|
+
* for example where tt1 is the Julian Day Number and tt2 is the fraction of a day. The
|
|
12
|
+
* returned tai1,tai2 follow suit.
|
|
13
|
+
*
|
|
14
|
+
* References:
|
|
15
|
+
* - McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32,
|
|
16
|
+
* BKG (2004)
|
|
17
|
+
* - Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann (ed),
|
|
18
|
+
* University Science Books (1992)
|
|
19
|
+
*
|
|
20
|
+
* @param tt1 TT as a 2-part Julian Date
|
|
21
|
+
* @param tt2 TT as a 2-part Julian Date
|
|
22
|
+
* @returns [tai1, tai2, status]: TAI as a 2-part Julian Date, and status: 0 = OK
|
|
23
|
+
*/
|
|
24
|
+
export function tttai(tt1: number, tt2: number): [tai1: number, tai2: number, status: number] {
|
|
25
|
+
let tai1: number, tai2: number
|
|
26
|
+
|
|
27
|
+
// Result, safeguarding precision.
|
|
28
|
+
if (Math.abs(tt1) > Math.abs(tt2)) {
|
|
29
|
+
tai1 = tt1
|
|
30
|
+
tai2 = tt2 - dtat
|
|
31
|
+
} else {
|
|
32
|
+
tai1 = tt1 - dtat
|
|
33
|
+
tai2 = tt2
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Status (always OK).
|
|
37
|
+
return [tai1, tai2, 0]
|
|
38
|
+
}
|
package/src/tttcg.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTttcg (tttcg.c); see LICENSE.
|
|
2
|
+
import { DAYSEC, DJM0, DJM77, ELG, TTMTAI } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
// 1977 Jan 1 00:00:32.184 TT, as MJD
|
|
5
|
+
const t77t = DJM77 + TTMTAI / DAYSEC
|
|
6
|
+
|
|
7
|
+
// TT to TCG rate
|
|
8
|
+
const elgg = ELG / (1.0 - ELG)
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Time scale transformation: Terrestrial Time, TT, to Geocentric Coordinate Time, TCG.
|
|
12
|
+
*
|
|
13
|
+
* Note: tt1+tt2 is Julian Date, apportioned in any convenient way between the two arguments,
|
|
14
|
+
* for example where tt1 is the Julian Day Number and tt2 is the fraction of a day. The
|
|
15
|
+
* returned tcg1,tcg2 follow suit.
|
|
16
|
+
*
|
|
17
|
+
* References:
|
|
18
|
+
* - McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32,
|
|
19
|
+
* BKG (2004)
|
|
20
|
+
* - IAU 2000 Resolution B1.9
|
|
21
|
+
*
|
|
22
|
+
* @param tt1 TT as a 2-part Julian Date
|
|
23
|
+
* @param tt2 TT as a 2-part Julian Date
|
|
24
|
+
* @returns [tcg1, tcg2, status]: TCG as a 2-part Julian Date, and status: 0 = OK
|
|
25
|
+
*/
|
|
26
|
+
export function tttcg(tt1: number, tt2: number): [tcg1: number, tcg2: number, status: number] {
|
|
27
|
+
let tcg1: number, tcg2: number
|
|
28
|
+
|
|
29
|
+
// Result, safeguarding precision.
|
|
30
|
+
if (Math.abs(tt1) > Math.abs(tt2)) {
|
|
31
|
+
tcg1 = tt1
|
|
32
|
+
tcg2 = tt2 + ((tt1 - DJM0) + (tt2 - t77t)) * elgg
|
|
33
|
+
} else {
|
|
34
|
+
tcg1 = tt1 + ((tt2 - DJM0) + (tt1 - t77t)) * elgg
|
|
35
|
+
tcg2 = tt2
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Status (always OK).
|
|
39
|
+
return [tcg1, tcg2, 0]
|
|
40
|
+
}
|
package/src/tttdb.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTttdb (tttdb.c); see LICENSE.
|
|
2
|
+
import { DAYSEC } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Time scale transformation: Terrestrial Time, TT, to Barycentric Dynamical Time, TDB.
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* 1. tt1+tt2 is Julian Date, apportioned in any convenient way between the two arguments,
|
|
9
|
+
* for example where tt1 is the Julian Day Number and tt2 is the fraction of a day. The
|
|
10
|
+
* returned tdb1,tdb2 follow suit.
|
|
11
|
+
* 2. The argument dtr represents the quasi-periodic component of the GR transformation
|
|
12
|
+
* between TT and TCB. It is dependent upon the adopted solar-system ephemeris, and can be
|
|
13
|
+
* obtained by numerical integration, by interrogating a precomputed time ephemeris or by
|
|
14
|
+
* evaluating a model such as that implemented in the ERFA function dtdb. The quantity is
|
|
15
|
+
* dominated by an annual term of 1.7 ms amplitude.
|
|
16
|
+
* 3. TDB is essentially the same as Teph, the time argument for the JPL solar system
|
|
17
|
+
* ephemerides.
|
|
18
|
+
*
|
|
19
|
+
* References:
|
|
20
|
+
* - McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32,
|
|
21
|
+
* BKG (2004)
|
|
22
|
+
* - IAU 2006 Resolution 3
|
|
23
|
+
*
|
|
24
|
+
* @param tt1 TT as a 2-part Julian Date
|
|
25
|
+
* @param tt2 TT as a 2-part Julian Date
|
|
26
|
+
* @param dtr TDB-TT in seconds
|
|
27
|
+
* @returns [tdb1, tdb2, status]: TDB as a 2-part Julian Date, and status: 0 = OK
|
|
28
|
+
*/
|
|
29
|
+
export function tttdb(
|
|
30
|
+
tt1: number,
|
|
31
|
+
tt2: number,
|
|
32
|
+
dtr: number,
|
|
33
|
+
): [tdb1: number, tdb2: number, status: number] {
|
|
34
|
+
let tdb1: number, tdb2: number
|
|
35
|
+
|
|
36
|
+
// Result, safeguarding precision.
|
|
37
|
+
const dtrd = dtr / DAYSEC
|
|
38
|
+
if (Math.abs(tt1) > Math.abs(tt2)) {
|
|
39
|
+
tdb1 = tt1
|
|
40
|
+
tdb2 = tt2 + dtrd
|
|
41
|
+
} else {
|
|
42
|
+
tdb1 = tt1 + dtrd
|
|
43
|
+
tdb2 = tt2
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Status (always OK).
|
|
47
|
+
return [tdb1, tdb2, 0]
|
|
48
|
+
}
|
package/src/ttut1.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraTtut1 (ttut1.c); see LICENSE.
|
|
2
|
+
import { DAYSEC } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Time scale transformation: Terrestrial Time, TT, to Universal Time, UT1.
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* 1. tt1+tt2 is Julian Date, apportioned in any convenient way between the two arguments,
|
|
9
|
+
* for example where tt1 is the Julian Day Number and tt2 is the fraction of a day. The
|
|
10
|
+
* returned ut11,ut12 follow suit.
|
|
11
|
+
* 2. The argument dt is classical Delta T.
|
|
12
|
+
*
|
|
13
|
+
* Reference: Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann
|
|
14
|
+
* (ed), University Science Books (1992)
|
|
15
|
+
*
|
|
16
|
+
* @param tt1 TT as a 2-part Julian Date
|
|
17
|
+
* @param tt2 TT as a 2-part Julian Date
|
|
18
|
+
* @param dt TT-UT1 in seconds
|
|
19
|
+
* @returns [ut11, ut12, status]: UT1 as a 2-part Julian Date, and status: 0 = OK
|
|
20
|
+
*/
|
|
21
|
+
export function ttut1(
|
|
22
|
+
tt1: number,
|
|
23
|
+
tt2: number,
|
|
24
|
+
dt: number,
|
|
25
|
+
): [ut11: number, ut12: number, status: number] {
|
|
26
|
+
let ut11: number, ut12: number
|
|
27
|
+
|
|
28
|
+
// Result, safeguarding precision.
|
|
29
|
+
const dtd = dt / DAYSEC
|
|
30
|
+
if (Math.abs(tt1) > Math.abs(tt2)) {
|
|
31
|
+
ut11 = tt1
|
|
32
|
+
ut12 = tt2 - dtd
|
|
33
|
+
} else {
|
|
34
|
+
ut11 = tt1 - dtd
|
|
35
|
+
ut12 = tt2
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Status (always OK).
|
|
39
|
+
return [ut11, ut12, 0]
|
|
40
|
+
}
|
package/src/ut1tai.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraUt1tai (ut1tai.c); see LICENSE.
|
|
2
|
+
import { DAYSEC } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Time scale transformation: Universal Time, UT1, to International Atomic Time, TAI.
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* 1. ut11+ut12 is Julian Date, apportioned in any convenient way between the two arguments,
|
|
9
|
+
* for example where ut11 is the Julian Day Number and ut12 is the fraction of a day. The
|
|
10
|
+
* returned tai1,tai2 follow suit.
|
|
11
|
+
* 2. The argument dta, i.e. UT1-TAI, is an observed quantity, and is available from IERS
|
|
12
|
+
* tabulations.
|
|
13
|
+
*
|
|
14
|
+
* Reference: Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann
|
|
15
|
+
* (ed), University Science Books (1992)
|
|
16
|
+
*
|
|
17
|
+
* @param ut11 UT1 as a 2-part Julian Date
|
|
18
|
+
* @param ut12 UT1 as a 2-part Julian Date
|
|
19
|
+
* @param dta UT1-TAI in seconds
|
|
20
|
+
* @returns [tai1, tai2, status]: TAI as a 2-part Julian Date, and status: 0 = OK
|
|
21
|
+
*/
|
|
22
|
+
export function ut1tai(
|
|
23
|
+
ut11: number,
|
|
24
|
+
ut12: number,
|
|
25
|
+
dta: number,
|
|
26
|
+
): [tai1: number, tai2: number, status: number] {
|
|
27
|
+
let tai1: number, tai2: number
|
|
28
|
+
|
|
29
|
+
// Result, safeguarding precision.
|
|
30
|
+
const dtad = dta / DAYSEC
|
|
31
|
+
if (Math.abs(ut11) > Math.abs(ut12)) {
|
|
32
|
+
tai1 = ut11
|
|
33
|
+
tai2 = ut12 - dtad
|
|
34
|
+
} else {
|
|
35
|
+
tai1 = ut11 - dtad
|
|
36
|
+
tai2 = ut12
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Status (always OK).
|
|
40
|
+
return [tai1, tai2, 0]
|
|
41
|
+
}
|
package/src/ut1tt.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraUt1tt (ut1tt.c); see LICENSE.
|
|
2
|
+
import { DAYSEC } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Time scale transformation: Universal Time, UT1, to Terrestrial Time, TT.
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* 1. ut11+ut12 is Julian Date, apportioned in any convenient way between the two arguments,
|
|
9
|
+
* for example where ut11 is the Julian Day Number and ut12 is the fraction of a day. The
|
|
10
|
+
* returned tt1,tt2 follow suit.
|
|
11
|
+
* 2. The argument dt is classical Delta T.
|
|
12
|
+
*
|
|
13
|
+
* Reference: Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann
|
|
14
|
+
* (ed), University Science Books (1992)
|
|
15
|
+
*
|
|
16
|
+
* @param ut11 UT1 as a 2-part Julian Date
|
|
17
|
+
* @param ut12 UT1 as a 2-part Julian Date
|
|
18
|
+
* @param dt TT-UT1 in seconds
|
|
19
|
+
* @returns [tt1, tt2, status]: TT as a 2-part Julian Date, and status: 0 = OK
|
|
20
|
+
*/
|
|
21
|
+
export function ut1tt(
|
|
22
|
+
ut11: number,
|
|
23
|
+
ut12: number,
|
|
24
|
+
dt: number,
|
|
25
|
+
): [tt1: number, tt2: number, status: number] {
|
|
26
|
+
let tt1: number, tt2: number
|
|
27
|
+
|
|
28
|
+
// Result, safeguarding precision.
|
|
29
|
+
const dtd = dt / DAYSEC
|
|
30
|
+
if (Math.abs(ut11) > Math.abs(ut12)) {
|
|
31
|
+
tt1 = ut11
|
|
32
|
+
tt2 = ut12 + dtd
|
|
33
|
+
} else {
|
|
34
|
+
tt1 = ut11 + dtd
|
|
35
|
+
tt2 = ut12
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Status (always OK).
|
|
39
|
+
return [tt1, tt2, 0]
|
|
40
|
+
}
|