UNPKG

@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.56 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("./astrometry.cjs"),f=require("./coordinates.cjs"),z=require("./planets.cjs");// @license Copyright © 2021-2023 observerly const p=3,y=(a,s,h,o={horizon:6,angularSeparationThreshold:p})=>{const[t,r]=h,{horizon:e=6,angularSeparationThreshold:u=p}=o,c=f.convertEclipticToEquatorial(a,z.getPlanetaryGeocentricEclipticCoordinate(a,t)),n=f.convertEclipticToEquatorial(a,z.getPlanetaryGeocentricEclipticCoordinate(a,r)),i=f.convertEquatorialToHorizontal(a,s,c),l=f.convertEquatorialToHorizontal(a,s,n);if(i.alt<e||l.alt<e)return!1;const g=j.getAngularSeparation({θ:i.alt,φ:i.az},{θ:l.alt,φ:l.az});if(g>u)return!1;const d=[{name:t.name,...i,...c},{name:r.name,...l,...n}];return{datetime:a,targets:d,angularSeparation:g,ra:(c.ra+n.ra)/2,dec:(c.dec+n.dec)/2}},C=(a,s,h={horizon:6,angularSeparationThreshold:p})=>{const{horizon:o=6,angularSeparationThreshold:t=p}=h,[r,e]=s;if(r.alt<o||e.alt<o)return!1;const u=j.getAngularSeparation({θ:r.alt,φ:r.az},{θ:e.alt,φ:e.az});return u>t?!1:{datetime:a,targets:s,angularSeparation:u,ra:(r.ra+e.ra)/2,dec:(r.dec+e.dec)/2}},m=(a,s,h,o={horizon:6,angularSeparationThreshold:3,stepMinutes:20})=>{let{from:t,to:r}=a;const{horizon:e=6,angularSeparationThreshold:u=p,stepMinutes:c=20}=o;for(;t<=r;){const n=y(t,s,h,{horizon:e,angularSeparationThreshold:u});if(n)return n;t=new Date(t.getTime()+c*6e4)}},E=(a,s,h={horizon:6,angularSeparationThreshold:p,stepMinutes:20})=>{let{from:o,to:t}=a;const{horizon:r=6,angularSeparationThreshold:e=p,stepMinutes:u=20}=h;for(;o<=t;){const c=C(o,s,{horizon:r,angularSeparationThreshold:e});if(c)return c;o=new Date(o.getTime()+u*6e4)}return!1},M=(a,s,h={horizon:6,angularSeparationThreshold:p,stepMinutes:20})=>{const o=new Map;let{from:t,to:r}=a;const{horizon:e=6,angularSeparationThreshold:u=p,stepMinutes:c=20}=h;for(;t<=r;){const n=z.getPlanetaryPositions(t,s);for(let i=0;i<n.length;i++)for(let l=i+1;l<n.length;l++){if(n[i].alt<e||n[l].alt<e)continue;const g=n[i],d=n[l],S=[g.name,d.name].sort().join("-"),T=j.getAngularSeparation({θ:n[i].alt,φ:n[i].az},{θ:n[l].alt,φ:n[l].az});if(T<=u&&(!o.has(S)||o.get(S).angularSeparation>T)){const P={datetime:t,targets:[g,d],angularSeparation:T,ra:(g.ra+d.ra)/2,dec:(g.dec+d.dec)/2};o.set(S,P)}}t=new Date(t.getTime()+c*6e4)}return o};exports.findConjunction=E;exports.findPlanetaryConjunction=m;exports.findPlanetaryConjunctions=M;exports.isConjunction=C;exports.isPlanetaryConjunction=y; //# sourceMappingURL=conjunction.cjs.map