@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/icrs2g.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraIcrs2g (icrs2g.c); see LICENSE.
|
|
2
|
+
import { anp } from './anp.ts'
|
|
3
|
+
import { anpm } from './anpm.ts'
|
|
4
|
+
import { c2s } from './c2s.ts'
|
|
5
|
+
import type { Mat3 } from './internal.ts'
|
|
6
|
+
import { rxp } from './rxp.ts'
|
|
7
|
+
import { s2c } from './s2c.ts'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Transformation from ICRS to Galactic coordinates.
|
|
11
|
+
*
|
|
12
|
+
* Notes:
|
|
13
|
+
* 1. The IAU 1958 system of Galactic coordinates was defined with respect to the now
|
|
14
|
+
* obsolete reference system FK4 B1950.0. When interpreting the system in a modern
|
|
15
|
+
* context, several factors have to be taken into account:
|
|
16
|
+
* - The inclusion in FK4 positions of the E-terms of aberration.
|
|
17
|
+
* - The distortion of the FK4 proper motion system by differential Galactic rotation.
|
|
18
|
+
* - The use of the B1950.0 equinox rather than the now-standard J2000.0.
|
|
19
|
+
* - The frame bias between ICRS and the J2000.0 mean place system.
|
|
20
|
+
*
|
|
21
|
+
* The Hipparcos Catalogue (Perryman & ESA 1997) provides a rotation matrix that
|
|
22
|
+
* transforms directly between ICRS and Galactic coordinates with the above factors
|
|
23
|
+
* taken into account. The matrix is derived from three angles, namely the ICRS
|
|
24
|
+
* coordinates of the Galactic pole and the longitude of the ascending node of the
|
|
25
|
+
* Galactic equator on the ICRS equator. They are given in degrees to five decimal places
|
|
26
|
+
* and for canonical purposes are regarded as exact. In the Hipparcos Catalogue the
|
|
27
|
+
* matrix elements are given to 10 decimal places (about 20 microarcsec). In the present
|
|
28
|
+
* ERFA function the matrix elements have been recomputed from the canonical three angles
|
|
29
|
+
* and are given to 30 decimal places.
|
|
30
|
+
* 2. The inverse transformation is performed by the function g2icrs.
|
|
31
|
+
*
|
|
32
|
+
* Reference: Perryman M.A.C. & ESA, 1997, ESA SP-1200, The Hipparcos and Tycho catalogues.
|
|
33
|
+
* Astrometric and photometric star catalogues derived from the ESA Hipparcos Space Astrometry
|
|
34
|
+
* Mission. ESA Publications Division, Noordwijk, Netherlands.
|
|
35
|
+
*
|
|
36
|
+
* @param dr ICRS right ascension (radians)
|
|
37
|
+
* @param dd ICRS declination (radians)
|
|
38
|
+
* @returns [dl, db]: Galactic longitude and latitude (radians)
|
|
39
|
+
*/
|
|
40
|
+
export function icrs2g(dr: number, dd: number): [dl: number, db: number] {
|
|
41
|
+
/*
|
|
42
|
+
* L2,B2 system of Galactic coordinates in the form presented in the Hipparcos Catalogue.
|
|
43
|
+
* In degrees:
|
|
44
|
+
*
|
|
45
|
+
* P = 192.85948 right ascension of the Galactic north pole in ICRS
|
|
46
|
+
* Q = 27.12825 declination of the Galactic north pole in ICRS
|
|
47
|
+
* R = 32.93192 Galactic longitude of the ascending node of
|
|
48
|
+
* the Galactic equator on the ICRS equator
|
|
49
|
+
*
|
|
50
|
+
* ICRS to Galactic rotation matrix, obtained by computing
|
|
51
|
+
* R_3(-R) R_1(pi/2-Q) R_3(pi/2+P) to the full precision shown:
|
|
52
|
+
*/
|
|
53
|
+
const r: Mat3 = [ [ -0.054875560416215368492398900454,
|
|
54
|
+
-0.873437090234885048760383168409,
|
|
55
|
+
-0.483835015548713226831774175116 ],
|
|
56
|
+
[ +0.494109427875583673525222371358,
|
|
57
|
+
-0.444829629960011178146614061616,
|
|
58
|
+
+0.746982244497218890527388004556 ],
|
|
59
|
+
[ -0.867666149019004701181616534570,
|
|
60
|
+
-0.198076373431201528180486091412,
|
|
61
|
+
+0.455983776175066922272100478348 ] ]
|
|
62
|
+
|
|
63
|
+
// Spherical to Cartesian.
|
|
64
|
+
const v1 = s2c(dr, dd)
|
|
65
|
+
|
|
66
|
+
// ICRS to Galactic.
|
|
67
|
+
const v2 = rxp(r, v1)
|
|
68
|
+
|
|
69
|
+
// Cartesian to spherical.
|
|
70
|
+
const [dl, db] = c2s(v2)
|
|
71
|
+
|
|
72
|
+
// Express in conventional ranges.
|
|
73
|
+
return [anp(dl), anpm(db)]
|
|
74
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// @arcosmos/erfa: ERFA 2.0.1, translated line for line to TypeScript. One module per function,
|
|
2
|
+
// named as pyerfa names them (eraS2c is s2c), so a bundler keeps only the functions used.
|
|
3
|
+
//
|
|
4
|
+
// - Outputs are return values: one output is returned as is; several are a tuple in ERFA's
|
|
5
|
+
// argument order, as pyerfa returns them. A function that rotates its argument in place in
|
|
6
|
+
// C (eraRz) returns the result and leaves the argument as it was.
|
|
7
|
+
// - ERFA's status codes are returned, as the tuple's last element, never thrown. An output C
|
|
8
|
+
// leaves unset when it returns an error status is NaN.
|
|
9
|
+
// - ERFA's own tests (t_erfa_c.c) are ported to test/, with ERFA's tolerances.
|
|
10
|
+
// - The leap-second table dat uses can be replaced at run time (setLeapSeconds), as ERFA's
|
|
11
|
+
// eraSetLeapSeconds allows.
|
|
12
|
+
//
|
|
13
|
+
// Translated from ERFA 2.0.1; see LICENSE.
|
|
14
|
+
export * from './constants.ts'
|
|
15
|
+
export type { LeapSecond } from './datini.ts'
|
|
16
|
+
export type { Mat3, PV, Vec3 } from './internal.ts'
|
|
17
|
+
|
|
18
|
+
export { a2af } from './a2af.ts'
|
|
19
|
+
export { a2tf } from './a2tf.ts'
|
|
20
|
+
export { af2a } from './af2a.ts'
|
|
21
|
+
export { anp } from './anp.ts'
|
|
22
|
+
export { anpm } from './anpm.ts'
|
|
23
|
+
export { bi00 } from './bi00.ts'
|
|
24
|
+
export { bp06 } from './bp06.ts'
|
|
25
|
+
export { c2s } from './c2s.ts'
|
|
26
|
+
export { cal2jd } from './cal2jd.ts'
|
|
27
|
+
export { cp } from './cp.ts'
|
|
28
|
+
export { cpv } from './cpv.ts'
|
|
29
|
+
export { cr } from './cr.ts'
|
|
30
|
+
export { d2dtf } from './d2dtf.ts'
|
|
31
|
+
export { d2tf } from './d2tf.ts'
|
|
32
|
+
export { dat } from './dat.ts'
|
|
33
|
+
export { dtdb } from './dtdb.ts'
|
|
34
|
+
export { dtf2d } from './dtf2d.ts'
|
|
35
|
+
export { eceq06 } from './eceq06.ts'
|
|
36
|
+
export { ecm06 } from './ecm06.ts'
|
|
37
|
+
export { epb } from './epb.ts'
|
|
38
|
+
export { epb2jd } from './epb2jd.ts'
|
|
39
|
+
export { epj } from './epj.ts'
|
|
40
|
+
export { epj2jd } from './epj2jd.ts'
|
|
41
|
+
export { eqec06 } from './eqec06.ts'
|
|
42
|
+
export { era00 } from './era00.ts'
|
|
43
|
+
export { fw2m } from './fw2m.ts'
|
|
44
|
+
export { g2icrs } from './g2icrs.ts'
|
|
45
|
+
export { gmst06 } from './gmst06.ts'
|
|
46
|
+
export { icrs2g } from './icrs2g.ts'
|
|
47
|
+
export { ir } from './ir.ts'
|
|
48
|
+
export { jd2cal } from './jd2cal.ts'
|
|
49
|
+
export { jdcalf } from './jdcalf.ts'
|
|
50
|
+
export { getLeapSeconds, setLeapSeconds } from './leap-seconds.ts'
|
|
51
|
+
export { obl06 } from './obl06.ts'
|
|
52
|
+
export { pap } from './pap.ts'
|
|
53
|
+
export { pas } from './pas.ts'
|
|
54
|
+
export { pdp } from './pdp.ts'
|
|
55
|
+
export { pfw06 } from './pfw06.ts'
|
|
56
|
+
export { pm } from './pm.ts'
|
|
57
|
+
export { pmat06 } from './pmat06.ts'
|
|
58
|
+
export { pmp } from './pmp.ts'
|
|
59
|
+
export { pmpx } from './pmpx.ts'
|
|
60
|
+
export { pmsafe } from './pmsafe.ts'
|
|
61
|
+
export { pn } from './pn.ts'
|
|
62
|
+
export { ppp } from './ppp.ts'
|
|
63
|
+
export { ppsp } from './ppsp.ts'
|
|
64
|
+
export { pv2s } from './pv2s.ts'
|
|
65
|
+
export { pvdpv } from './pvdpv.ts'
|
|
66
|
+
export { pvm } from './pvm.ts'
|
|
67
|
+
export { pvmpv } from './pvmpv.ts'
|
|
68
|
+
export { pvppv } from './pvppv.ts'
|
|
69
|
+
export { pvstar } from './pvstar.ts'
|
|
70
|
+
export { pvu } from './pvu.ts'
|
|
71
|
+
export { pvxpv } from './pvxpv.ts'
|
|
72
|
+
export { pxp } from './pxp.ts'
|
|
73
|
+
export { rx } from './rx.ts'
|
|
74
|
+
export { rxp } from './rxp.ts'
|
|
75
|
+
export { rxr } from './rxr.ts'
|
|
76
|
+
export { ry } from './ry.ts'
|
|
77
|
+
export { rz } from './rz.ts'
|
|
78
|
+
export { s2c } from './s2c.ts'
|
|
79
|
+
export { s2pv } from './s2pv.ts'
|
|
80
|
+
export { s2xpv } from './s2xpv.ts'
|
|
81
|
+
export { sepp } from './sepp.ts'
|
|
82
|
+
export { seps } from './seps.ts'
|
|
83
|
+
export { starpm } from './starpm.ts'
|
|
84
|
+
export { starpv } from './starpv.ts'
|
|
85
|
+
export { sxp } from './sxp.ts'
|
|
86
|
+
export { sxpv } from './sxpv.ts'
|
|
87
|
+
export { taitt } from './taitt.ts'
|
|
88
|
+
export { taiut1 } from './taiut1.ts'
|
|
89
|
+
export { taiutc } from './taiutc.ts'
|
|
90
|
+
export { tcbtdb } from './tcbtdb.ts'
|
|
91
|
+
export { tcgtt } from './tcgtt.ts'
|
|
92
|
+
export { tdbtcb } from './tdbtcb.ts'
|
|
93
|
+
export { tdbtt } from './tdbtt.ts'
|
|
94
|
+
export { tf2a } from './tf2a.ts'
|
|
95
|
+
export { tr } from './tr.ts'
|
|
96
|
+
export { trxp } from './trxp.ts'
|
|
97
|
+
export { tttai } from './tttai.ts'
|
|
98
|
+
export { tttcg } from './tttcg.ts'
|
|
99
|
+
export { tttdb } from './tttdb.ts'
|
|
100
|
+
export { ttut1 } from './ttut1.ts'
|
|
101
|
+
export { ut1tai } from './ut1tai.ts'
|
|
102
|
+
export { ut1tt } from './ut1tt.ts'
|
|
103
|
+
export { ut1utc } from './ut1utc.ts'
|
|
104
|
+
export { utctai } from './utctai.ts'
|
|
105
|
+
export { utcut1 } from './utcut1.ts'
|
|
106
|
+
export { zp } from './zp.ts'
|
|
107
|
+
export { zpv } from './zpv.ts'
|
|
108
|
+
export { zr } from './zr.ts'
|
package/src/internal.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// ERFA's macros and the types the translations share. Not exported from the package, except
|
|
2
|
+
// the vector and matrix types. Translated from ERFA 2.0.1 (erfam.h); see LICENSE.
|
|
3
|
+
|
|
4
|
+
/** A p-vector: three numbers. */
|
|
5
|
+
export type Vec3 = readonly [number, number, number]
|
|
6
|
+
|
|
7
|
+
/** An r-matrix: three rows of three. */
|
|
8
|
+
export type Mat3 = readonly [Vec3, Vec3, Vec3]
|
|
9
|
+
|
|
10
|
+
/** A pv-vector: a position and a velocity. */
|
|
11
|
+
export type PV = readonly [Vec3, Vec3]
|
|
12
|
+
|
|
13
|
+
/** ERFA_DINT: truncate to a whole number, toward zero. */
|
|
14
|
+
export function dint(a: number): number {
|
|
15
|
+
return a < 0.0 ? Math.ceil(a) : Math.floor(a)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** ERFA_DNINT: round to the nearest whole number, halves away from zero. */
|
|
19
|
+
export function dnint(a: number): number {
|
|
20
|
+
return Math.abs(a) < 0.5 ? 0.0 : a < 0.0 ? Math.ceil(a - 0.5) : Math.floor(a + 0.5)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** ERFA_DSIGN: the magnitude of a with the sign of b. */
|
|
24
|
+
export function dsign(a: number, b: number): number {
|
|
25
|
+
return b < 0.0 ? -Math.abs(a) : Math.abs(a)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** C's fmod: the remainder with the sign of the dividend, as JavaScript's % gives it. */
|
|
29
|
+
export function fmod(a: number, b: number): number {
|
|
30
|
+
return a % b
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** ERFA_GMAX: the larger of two numbers, as the macro compares them. */
|
|
34
|
+
export function gmax(a: number, b: number): number {
|
|
35
|
+
return a > b ? a : b
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* C's integer division (int or long operands): the quotient truncated toward zero, so -7/2 is
|
|
40
|
+
* -3. Exact for |a| < 2^53, and never -0. C's long is 32 bits on Windows and 64 elsewhere;
|
|
41
|
+
* this is the 64-bit result.
|
|
42
|
+
*/
|
|
43
|
+
export function idiv(a: number, b: number): number {
|
|
44
|
+
const q = Math.trunc(a / b)
|
|
45
|
+
return q === 0 ? 0 : q
|
|
46
|
+
}
|
package/src/ir.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraIr (ir.c); see LICENSE.
|
|
2
|
+
import type { Mat3 } from './internal.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Initialize an r-matrix to the identity matrix. ERFA sets its argument in place; this
|
|
6
|
+
* returns a new identity matrix.
|
|
7
|
+
*
|
|
8
|
+
* @returns r: r-matrix
|
|
9
|
+
*/
|
|
10
|
+
export function ir(): Mat3 {
|
|
11
|
+
return [
|
|
12
|
+
[1.0, 0.0, 0.0],
|
|
13
|
+
[0.0, 1.0, 0.0],
|
|
14
|
+
[0.0, 0.0, 1.0],
|
|
15
|
+
]
|
|
16
|
+
}
|
package/src/jd2cal.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraJd2cal (jd2cal.c); see LICENSE.
|
|
2
|
+
import { dnint, gmax, idiv } from './internal.ts'
|
|
3
|
+
|
|
4
|
+
/** C's DBL_EPSILON (float.h): 2^-52. */
|
|
5
|
+
const DBL_EPSILON = Number.EPSILON
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Julian Date to Gregorian year, month, day, and fraction of a day.
|
|
9
|
+
*
|
|
10
|
+
* Notes:
|
|
11
|
+
* 1. The earliest valid date is -68569.5 (-4900 March 1). The largest value accepted is 1e9.
|
|
12
|
+
* C computes the day number in a long, which is 32 bits on Windows: there, Julian Dates
|
|
13
|
+
* past about 5.4e8 overflow. This gives the 64-bit result.
|
|
14
|
+
* 2. The Julian Date is apportioned in any convenient way between the arguments dj1 and dj2.
|
|
15
|
+
* For example, JD=2450123.7 could be given as (2450123.7, 0.0), the JD method;
|
|
16
|
+
* (2451545.0, -1421.3), the J2000 method; (2400000.5, 50123.2), the MJD method; or
|
|
17
|
+
* (2450123.5, 0.2), the date and time method. Separating integer and fraction uses the
|
|
18
|
+
* "compensated summation" algorithm of Kahan-Neumaier to preserve as much precision as
|
|
19
|
+
* possible irrespective of the jd1+jd2 apportionment.
|
|
20
|
+
* 3. In early eras the conversion is from the "proleptic Gregorian calendar"; no account is
|
|
21
|
+
* taken of the date(s) of adoption of the Gregorian calendar, nor is the AD/BC numbering
|
|
22
|
+
* convention observed.
|
|
23
|
+
* 4. Where the date is unacceptable (status -1), the outputs are NaN.
|
|
24
|
+
*
|
|
25
|
+
* References:
|
|
26
|
+
* - Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann (ed),
|
|
27
|
+
* University Science Books (1992), Section 12.92 (p604).
|
|
28
|
+
* - Klein, A., A Generalized Kahan-Babuska-Summation-Algorithm. Computing, 76, 279-293
|
|
29
|
+
* (2006), Section 3.
|
|
30
|
+
*
|
|
31
|
+
* @param dj1 Julian Date (Notes 1, 2)
|
|
32
|
+
* @param dj2 Julian Date (Notes 1, 2)
|
|
33
|
+
* @returns [iy, im, id, fd, status]: year, month, day, fraction of day, and status: 0 = OK,
|
|
34
|
+
* -1 = unacceptable date (Note 1)
|
|
35
|
+
*/
|
|
36
|
+
export function jd2cal(
|
|
37
|
+
dj1: number,
|
|
38
|
+
dj2: number,
|
|
39
|
+
): [iy: number, im: number, id: number, fd: number, status: number] {
|
|
40
|
+
// Minimum and maximum allowed JD
|
|
41
|
+
const DJMIN = -68569.5
|
|
42
|
+
const DJMAX = 1e9
|
|
43
|
+
|
|
44
|
+
let jd: number, i: number, l: number, n: number, k: number
|
|
45
|
+
let d: number, s: number, cs: number, x: number, t: number, f: number
|
|
46
|
+
const v: number[] = []
|
|
47
|
+
|
|
48
|
+
// Verify date is acceptable.
|
|
49
|
+
const dj = dj1 + dj2
|
|
50
|
+
if (dj < DJMIN || dj > DJMAX) return [NaN, NaN, NaN, NaN, -1]
|
|
51
|
+
|
|
52
|
+
// Separate day and fraction (where -0.5 <= fraction < 0.5).
|
|
53
|
+
d = dnint(dj1)
|
|
54
|
+
const f1 = dj1 - d
|
|
55
|
+
jd = d
|
|
56
|
+
d = dnint(dj2)
|
|
57
|
+
const f2 = dj2 - d
|
|
58
|
+
jd += d
|
|
59
|
+
|
|
60
|
+
// Compute f1+f2+0.5 using compensated summation (Klein 2006).
|
|
61
|
+
s = 0.5
|
|
62
|
+
cs = 0.0
|
|
63
|
+
v[0] = f1
|
|
64
|
+
v[1] = f2
|
|
65
|
+
for (i = 0; i < 2; i++) {
|
|
66
|
+
x = v[i]!
|
|
67
|
+
t = s + x
|
|
68
|
+
cs += Math.abs(s) >= Math.abs(x) ? (s - t) + x : (x - t) + s
|
|
69
|
+
s = t
|
|
70
|
+
if (s >= 1.0) {
|
|
71
|
+
jd++
|
|
72
|
+
s -= 1.0
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
f = s + cs
|
|
76
|
+
cs = f - s
|
|
77
|
+
|
|
78
|
+
// Deal with negative f.
|
|
79
|
+
if (f < 0.0) {
|
|
80
|
+
// Compensated summation: assume that |s| <= 1.0.
|
|
81
|
+
f = s + 1.0
|
|
82
|
+
cs += (1.0 - f) + s
|
|
83
|
+
s = f
|
|
84
|
+
f = s + cs
|
|
85
|
+
cs = f - s
|
|
86
|
+
jd--
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Deal with f that is 1.0 or more (when rounded to double).
|
|
90
|
+
if ((f - 1.0) >= -DBL_EPSILON / 4.0) {
|
|
91
|
+
// Compensated summation: assume that |s| <= 1.0.
|
|
92
|
+
t = s - 1.0
|
|
93
|
+
cs += (s - t) - 1.0
|
|
94
|
+
s = t
|
|
95
|
+
f = s + cs
|
|
96
|
+
if (-DBL_EPSILON / 2.0 < f) {
|
|
97
|
+
jd++
|
|
98
|
+
f = gmax(f, 0.0)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Express day in Gregorian calendar.
|
|
103
|
+
l = jd + 68569
|
|
104
|
+
n = idiv(4 * l, 146097)
|
|
105
|
+
l -= idiv(146097 * n + 3, 4)
|
|
106
|
+
i = idiv(4000 * (l + 1), 1461001)
|
|
107
|
+
l -= idiv(1461 * i, 4) - 31
|
|
108
|
+
k = idiv(80 * l, 2447)
|
|
109
|
+
const id = l - idiv(2447 * k, 80)
|
|
110
|
+
l = idiv(k, 11)
|
|
111
|
+
const im = k + 2 - 12 * l
|
|
112
|
+
const iy = 100 * (n - 49) + i + l
|
|
113
|
+
const fd = f
|
|
114
|
+
|
|
115
|
+
// Success.
|
|
116
|
+
return [iy, im, id, fd, 0]
|
|
117
|
+
}
|
package/src/jdcalf.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraJdcalf (jdcalf.c); see LICENSE.
|
|
2
|
+
import { dnint } from './internal.ts'
|
|
3
|
+
import { jd2cal } from './jd2cal.ts'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Julian Date to Gregorian Calendar, expressed in a form convenient for formatting messages:
|
|
7
|
+
* rounded to a specified precision.
|
|
8
|
+
*
|
|
9
|
+
* Notes:
|
|
10
|
+
* 1. The Julian Date is apportioned in any convenient way between the arguments dj1 and dj2.
|
|
11
|
+
* For example, JD=2450123.7 could be given as (2450123.7, 0.0), the JD method;
|
|
12
|
+
* (2451545.0, -1421.3), the J2000 method; (2400000.5, 50123.2), the MJD method; or
|
|
13
|
+
* (2450123.5, 0.2), the date and time method.
|
|
14
|
+
* 2. In early eras the conversion is from the "Proleptic Gregorian Calendar"; no account is
|
|
15
|
+
* taken of the date(s) of adoption of the Gregorian Calendar, nor is the AD/BC numbering
|
|
16
|
+
* convention observed.
|
|
17
|
+
* 3. See also the function jd2cal.
|
|
18
|
+
* 4. The number of decimal places ndp should be 4 or less if internal overflows are to be
|
|
19
|
+
* avoided on platforms which use 16-bit integers.
|
|
20
|
+
* 5. Where the date is out of range (status -1), iymdf is NaN.
|
|
21
|
+
*
|
|
22
|
+
* Reference: Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann
|
|
23
|
+
* (ed), University Science Books (1992), Section 12.92 (p604).
|
|
24
|
+
*
|
|
25
|
+
* @param ndp number of decimal places of days in fraction
|
|
26
|
+
* @param dj1 dj1+dj2 = Julian Date (Note 1)
|
|
27
|
+
* @param dj2 dj1+dj2 = Julian Date (Note 1)
|
|
28
|
+
* @returns [iymdf, status]: year, month, day, fraction in Gregorian calendar, and status:
|
|
29
|
+
* -1 = date out of range, 0 = OK, +1 = ndp not 0-9 (interpreted as 0)
|
|
30
|
+
*/
|
|
31
|
+
export function jdcalf(
|
|
32
|
+
ndp: number,
|
|
33
|
+
dj1: number,
|
|
34
|
+
dj2: number,
|
|
35
|
+
): [iymdf: [number, number, number, number], status: number] {
|
|
36
|
+
let j: number, denom: number, d1: number, d2: number, d: number, f: number
|
|
37
|
+
|
|
38
|
+
// Denominator of fraction (e.g. 100 for 2 decimal places).
|
|
39
|
+
if (ndp >= 0 && ndp <= 9) {
|
|
40
|
+
j = 0
|
|
41
|
+
denom = Math.pow(10.0, ndp)
|
|
42
|
+
} else {
|
|
43
|
+
j = 1
|
|
44
|
+
denom = 1.0
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Copy the date, big then small.
|
|
48
|
+
if (Math.abs(dj1) >= Math.abs(dj2)) {
|
|
49
|
+
d1 = dj1
|
|
50
|
+
d2 = dj2
|
|
51
|
+
} else {
|
|
52
|
+
d1 = dj2
|
|
53
|
+
d2 = dj1
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Realign to midnight (without rounding error).
|
|
57
|
+
d1 -= 0.5
|
|
58
|
+
|
|
59
|
+
// Separate day and fraction (as precisely as possible).
|
|
60
|
+
d = dnint(d1)
|
|
61
|
+
const f1 = d1 - d
|
|
62
|
+
let djd = d
|
|
63
|
+
d = dnint(d2)
|
|
64
|
+
const f2 = d2 - d
|
|
65
|
+
djd += d
|
|
66
|
+
d = dnint(f1 + f2)
|
|
67
|
+
f = (f1 - d) + f2
|
|
68
|
+
if (f < 0.0) {
|
|
69
|
+
f += 1.0
|
|
70
|
+
d -= 1.0
|
|
71
|
+
}
|
|
72
|
+
djd += d
|
|
73
|
+
|
|
74
|
+
// Round the total fraction to the specified number of places.
|
|
75
|
+
const rf = dnint(f * denom) / denom
|
|
76
|
+
|
|
77
|
+
// Re-align to noon.
|
|
78
|
+
djd += 0.5
|
|
79
|
+
|
|
80
|
+
// Convert to Gregorian calendar.
|
|
81
|
+
const [iy, im, id, fd, js] = jd2cal(djd, rf)
|
|
82
|
+
let iymdf: [number, number, number, number]
|
|
83
|
+
if (js === 0) {
|
|
84
|
+
f = fd
|
|
85
|
+
iymdf = [iy, im, id, dnint(f * denom)]
|
|
86
|
+
} else {
|
|
87
|
+
j = js
|
|
88
|
+
iymdf = [NaN, NaN, NaN, NaN]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Return the status.
|
|
92
|
+
return [iymdf, j]
|
|
93
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraGetLeapSeconds and eraSetLeapSeconds (erfadatextra.c, not
|
|
2
|
+
// derived from SOFA); see LICENSE. pyerfa uses these to load newer leap seconds
|
|
3
|
+
// (erfa.leap_seconds), as Astropy does from the IERS.
|
|
4
|
+
import { dat } from './dat.ts'
|
|
5
|
+
import { getTable, setTable } from './datini.ts'
|
|
6
|
+
import type { LeapSecond } from './datini.ts'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get the current leap second table: the one dat uses, as a copy.
|
|
10
|
+
*
|
|
11
|
+
* Each row is a year, a month and TAI minus UTC in seconds from the start of that month.
|
|
12
|
+
* The built-in table (dat's) starts with the 14 expressions of 1960 to 1968, to which dat
|
|
13
|
+
* adds a drift, and ends with the leap second of 2016 December 31 (37 s from 2017 January).
|
|
14
|
+
*
|
|
15
|
+
* In C, the table is initialized by calling eraDat if no call has yet, and -1 is returned if
|
|
16
|
+
* that fails, which can't happen with the built-in table.
|
|
17
|
+
*
|
|
18
|
+
* @returns the rows in use, copied: changing them changes nothing
|
|
19
|
+
*/
|
|
20
|
+
export function getLeapSeconds(): LeapSecond[] {
|
|
21
|
+
if (getTable()[0] <= 0) {
|
|
22
|
+
dat(2000, 1, 1, 0.0)
|
|
23
|
+
}
|
|
24
|
+
const [NDAT, changes] = getTable()
|
|
25
|
+
return changes.slice(0, NDAT).map(({ iyear, month, delat }) => ({ iyear, month, delat }))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Set the current leap second table: dat, and everything that calls it, uses it from the
|
|
30
|
+
* next call.
|
|
31
|
+
*
|
|
32
|
+
* Notes:
|
|
33
|
+
* 1. No sanity checks are performed, as in ERFA. The rows must be in date order, each the
|
|
34
|
+
* start of a month. dat applies its pre-1972 drift to the first 14 rows whatever they
|
|
35
|
+
* hold, and treats years before the first row's as before UTC, so a new table should
|
|
36
|
+
* keep the built-in table's rows and add to them (pyerfa's leap_seconds.update does).
|
|
37
|
+
* 2. An empty table, or none, causes a reset of the table to the built-in version.
|
|
38
|
+
* 3. The rows are copied: changing them afterwards changes nothing.
|
|
39
|
+
*
|
|
40
|
+
* @param leapseconds rows of year, month, TAI minus UTC (seconds)
|
|
41
|
+
*/
|
|
42
|
+
export function setLeapSeconds(leapseconds: readonly LeapSecond[] = []): void {
|
|
43
|
+
setTable(
|
|
44
|
+
leapseconds.map(({ iyear, month, delat }) => ({ iyear, month, delat })),
|
|
45
|
+
leapseconds.length,
|
|
46
|
+
)
|
|
47
|
+
}
|
package/src/obl06.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraObl06 (obl06.c); see LICENSE.
|
|
2
|
+
import { DAS2R, DJ00, DJC } from './constants.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mean obliquity of the ecliptic, IAU 2006 precession model.
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* 1. The TT date date1+date2 is a Julian Date, apportioned in any convenient way between
|
|
9
|
+
* the two arguments. For example, JD(TT)=2450123.7 could be given as (2450123.7, 0.0),
|
|
10
|
+
* the JD method; (2451545.0, -1421.3), the J2000 method; (2400000.5, 50123.2), the MJD
|
|
11
|
+
* method; or (2450123.5, 0.2), the date and time method. The J2000 method is best matched
|
|
12
|
+
* to the way the argument is handled internally and will deliver the optimum resolution.
|
|
13
|
+
* 2. The result is the angle between the ecliptic and mean equator of date date1+date2.
|
|
14
|
+
*
|
|
15
|
+
* Reference: Hilton, J. et al., 2006, Celest.Mech.Dyn.Astron. 94, 351
|
|
16
|
+
*
|
|
17
|
+
* @param date1 TT as a 2-part Julian Date (Note 1)
|
|
18
|
+
* @param date2 TT as a 2-part Julian Date (Note 1)
|
|
19
|
+
* @returns obliquity of the ecliptic (radians, Note 2)
|
|
20
|
+
*/
|
|
21
|
+
export function obl06(date1: number, date2: number): number {
|
|
22
|
+
// Interval between fundamental date J2000.0 and given date (JC).
|
|
23
|
+
const t = ((date1 - DJ00) + date2) / DJC
|
|
24
|
+
|
|
25
|
+
// Mean obliquity.
|
|
26
|
+
const eps0 = (84381.406 +
|
|
27
|
+
(-46.836769 +
|
|
28
|
+
( -0.0001831 +
|
|
29
|
+
( 0.00200340 +
|
|
30
|
+
( -0.000000576 +
|
|
31
|
+
( -0.0000000434) * t) * t) * t) * t) * t) * DAS2R
|
|
32
|
+
|
|
33
|
+
return eps0
|
|
34
|
+
}
|
package/src/pap.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraPap (pap.c); see LICENSE.
|
|
2
|
+
import type { Vec3 } from './internal.ts'
|
|
3
|
+
import { pdp } from './pdp.ts'
|
|
4
|
+
import { pm } from './pm.ts'
|
|
5
|
+
import { pmp } from './pmp.ts'
|
|
6
|
+
import { pn } from './pn.ts'
|
|
7
|
+
import { pxp } from './pxp.ts'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Position-angle from two p-vectors.
|
|
11
|
+
*
|
|
12
|
+
* Notes:
|
|
13
|
+
* 1. The result is the position angle, in radians, of direction b with respect to direction
|
|
14
|
+
* a. It is in the range -pi to +pi. The sense is such that if b is a small distance
|
|
15
|
+
* "north" of a the position angle is approximately zero, and if b is a small distance
|
|
16
|
+
* "east" of a the position angle is approximately +pi/2.
|
|
17
|
+
* 2. The vectors a and b need not be of unit length.
|
|
18
|
+
* 3. Zero is returned if the two directions are the same or if either vector is null.
|
|
19
|
+
* 4. If vector a is at a pole, the result is ill-defined.
|
|
20
|
+
*
|
|
21
|
+
* @param a direction of reference point
|
|
22
|
+
* @param b direction of point whose PA is required
|
|
23
|
+
* @returns position angle of b with respect to a (radians)
|
|
24
|
+
*/
|
|
25
|
+
export function pap(a: Vec3, b: Vec3): number {
|
|
26
|
+
let st: number, ct: number
|
|
27
|
+
|
|
28
|
+
const [am, au] = pn(a)
|
|
29
|
+
|
|
30
|
+
const bm = pm(b)
|
|
31
|
+
|
|
32
|
+
if (am === 0.0 || bm === 0.0) {
|
|
33
|
+
st = 0.0
|
|
34
|
+
ct = 1.0
|
|
35
|
+
} else {
|
|
36
|
+
const xa = a[0]
|
|
37
|
+
const ya = a[1]
|
|
38
|
+
const za = a[2]
|
|
39
|
+
const eta: Vec3 = [-xa * za, -ya * za, xa * xa + ya * ya]
|
|
40
|
+
|
|
41
|
+
const xi = pxp(eta, au)
|
|
42
|
+
|
|
43
|
+
const a2b = pmp(b, a)
|
|
44
|
+
|
|
45
|
+
st = pdp(a2b, xi)
|
|
46
|
+
ct = pdp(a2b, eta)
|
|
47
|
+
|
|
48
|
+
if (st === 0.0 && ct === 0.0) ct = 1.0
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const pa = Math.atan2(st, ct)
|
|
52
|
+
|
|
53
|
+
return pa
|
|
54
|
+
}
|
package/src/pas.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraPas (pas.c); see LICENSE.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Position-angle from spherical coordinates.
|
|
5
|
+
*
|
|
6
|
+
* Notes:
|
|
7
|
+
* 1. The result is the bearing (position angle), in radians, of point B with respect to
|
|
8
|
+
* point A. It is in the range -pi to +pi. The sense is such that if B is a small distance
|
|
9
|
+
* "east" of point A, the bearing is approximately +pi/2.
|
|
10
|
+
* 2. Zero is returned if the two points are coincident.
|
|
11
|
+
*
|
|
12
|
+
* @param al longitude of point A (e.g. RA) in radians
|
|
13
|
+
* @param ap latitude of point A (e.g. Dec) in radians
|
|
14
|
+
* @param bl longitude of point B
|
|
15
|
+
* @param bp latitude of point B
|
|
16
|
+
* @returns position angle of B with respect to A
|
|
17
|
+
*/
|
|
18
|
+
export function pas(al: number, ap: number, bl: number, bp: number): number {
|
|
19
|
+
const dl = bl - al
|
|
20
|
+
const y = Math.sin(dl) * Math.cos(bp)
|
|
21
|
+
const x = Math.sin(bp) * Math.cos(ap) - Math.cos(bp) * Math.sin(ap) * Math.cos(dl)
|
|
22
|
+
const pa = x !== 0.0 || y !== 0.0 ? Math.atan2(y, x) : 0.0
|
|
23
|
+
|
|
24
|
+
return pa
|
|
25
|
+
}
|
package/src/pdp.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Translated from ERFA 2.0.1 eraPdp (pdp.c); see LICENSE.
|
|
2
|
+
import type { Vec3 } from './internal.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* p-vector inner (=scalar=dot) product.
|
|
6
|
+
*
|
|
7
|
+
* @returns a . b
|
|
8
|
+
*/
|
|
9
|
+
export function pdp(a: Vec3, b: Vec3): number {
|
|
10
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
|
|
11
|
+
}
|