@observerly/astrometry
Version:
observerly's lightweight, zero-dependency, type safe astrometry library written in Typescript for calculating the position of celestial objects in the sky.
4 lines (3 loc) • 2.6 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("./common.cjs"),M=require("./coordinates.cjs"),L=require("./night.cjs"),T=require("./temporal.cjs"),u=require("./utilities-HBcnbrPA.cjs");// @license Copyright © 2021-2023 observerly
const C=n=>{if(typeof n=="boolean"||typeof n!="object"||n===null)return!1;const{datetime:t,LST:e,GST:s,az:o}=n;return!(!(t instanceof Date)||typeof e!="number"||typeof s!="number"||typeof o!="number")},l=(n,t,e=0)=>{const{latitude:s}=n,{dec:o}=t;return s>=e?s+o>90:s+o<-90},f=(n,t,e=0)=>{const{latitude:s}=n,{dec:o}=t;return 90-Math.abs(s-o)>e},g=(n,t,e,s=0)=>{let o=Number.NEGATIVE_INFINITY;return B.isEquatorialCoordinate(e)&&(o=M.convertEquatorialToHorizontal(n,t,e).alt),B.isHorizontalCoordinate(e)&&(o=e.alt),o>s},D=(n,t)=>{const{latitude:e}=n,{dec:s}=t,o=Math.sin(u.convertDegreesToRadians(s))/Math.cos(u.convertDegreesToRadians(e));if(Math.abs(o)>1)return!1;const i=Math.tan(u.convertDegreesToRadians(e))*Math.tan(u.convertDegreesToRadians(s));return Math.abs(i)>1?!1:{Ar:o,H1:i}},m=(n,t)=>{const e=t.ra/15,s=D(n,t);if(!s)return;const{H1:o,Ar:i}=s,a=u.convertRadiansToDegrees(Math.acos(-o))/15,r=u.convertRadiansToDegrees(Math.acos(i)),c=360-r;let d=24+e-a;d>24&&(d-=24);let S=e+a;return S>24&&(S-=24),{LSTr:d,LSTs:S,R:r,S:c}},y=(n,t,e,s=0)=>{const o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()+1,0,0,0,0));if(l(t,e,s)||!f(t,e,s))return!1;const i=m(t,e);if(!i)return y(o,t,e,s);const a=i.LSTr,r=T.convertLocalSiderealTimeToGreenwhichSiderealTime(a,t),c=T.convertGreenwhichSiderealTimeToUniversalTime(r,n);return c.getTime()<n.getTime()?y(o,t,e,s):{datetime:c,LST:i.LSTr,GST:r,az:i.R}},h=(n,t,e,s=0)=>{const o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()+1,0,0,0,0));if(l(t,e,s))return!0;if(!f(t,e,s))return!1;const i=m(t,e);if(!i)return h(o,t,e,s);const a=i.LSTs,r=T.convertLocalSiderealTimeToGreenwhichSiderealTime(a,t),c=T.convertGreenwhichSiderealTimeToUniversalTime(r,n);return c<n?h(o,t,e,s):{datetime:c,LST:i.LSTs,GST:r,az:i.S}},R=(n,t,e,s=0)=>{if(n=new Date(new Date(n.setHours(0,0,0,0)).getTime()),!f(t,e,s))return!1;if(l(t,e,s))return!0;const{start:o,end:i}=L.getNight(n,t);if(!o||!i)return!1;for(;o<=i;){if(g(o,t,e,s))return!0;o.setMinutes(o.getMinutes()+1)}return!1};exports.doesBodyRiseOrSet=D;exports.getBodyNextRise=y;exports.getBodyNextSet=h;exports.getBodyTransit=m;exports.isBodyAboveHorizon=g;exports.isBodyCircumpolar=l;exports.isBodyVisible=f;exports.isBodyVisibleForNight=R;exports.isTransitInstance=C;
//# sourceMappingURL=transit.cjs.map