@openwaters/almanac 0.2.1 → 0.3.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/README.md +11 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/transforms.d.ts +12 -0
- package/dist/transforms.js +38 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# Almanac
|
|
2
2
|
|
|
3
3
|
Offline sun & moon engine for the Salish Sea and everywhere else — positions,
|
|
4
|
-
rise/set/twilight, moon phase,
|
|
5
|
-
|
|
4
|
+
rise/set/twilight, moon phase, lunar eclipses (solar planned), and where any fixed
|
|
5
|
+
star stands from a catalog position, computed from pure geometry with zero network
|
|
6
|
+
and zero runtime data files.
|
|
6
7
|
|
|
7
8
|
Twin implementations, one behavior:
|
|
8
9
|
|
|
@@ -73,7 +74,7 @@ npm install @openwaters/almanac
|
|
|
73
74
|
```
|
|
74
75
|
|
|
75
76
|
```ts
|
|
76
|
-
import { nextLunarEclipse, lunarEclipseVisibility, sunEvents } from '@openwaters/almanac';
|
|
77
|
+
import { nextLunarEclipse, lunarEclipseVisibility, sunEvents, starAltAz } from '@openwaters/almanac';
|
|
77
78
|
|
|
78
79
|
const observer = { latitudeDeg: 48.5, longitudeDeg: -123.0 };
|
|
79
80
|
|
|
@@ -86,12 +87,15 @@ const tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000);
|
|
|
86
87
|
for (const { kind, time } of sunEvents(today, tomorrow, observer)) {
|
|
87
88
|
console.log(kind, time.toISOString());
|
|
88
89
|
}
|
|
90
|
+
|
|
91
|
+
// Betelgeuse from its J2000 catalog position: az/alt in degrees, refracted.
|
|
92
|
+
const { azDeg, altDeg } = starAltAz(88.792939, 7.407064, today, observer);
|
|
89
93
|
```
|
|
90
94
|
|
|
91
95
|
### Swift
|
|
92
96
|
|
|
93
97
|
```swift
|
|
94
|
-
.package(url: "https://github.com/openwatersio/almanac.git", exact: "0.
|
|
98
|
+
.package(url: "https://github.com/openwatersio/almanac.git", exact: "0.3.0")
|
|
95
99
|
```
|
|
96
100
|
|
|
97
101
|
```swift
|
|
@@ -109,6 +113,9 @@ let tomorrow = today.addingTimeInterval(24 * 60 * 60)
|
|
|
109
113
|
for event in try sunEvents(from: today, to: tomorrow, observer: observer) {
|
|
110
114
|
print(event.kind, event.time)
|
|
111
115
|
}
|
|
116
|
+
|
|
117
|
+
// Betelgeuse from its J2000 catalog position: az/alt in degrees, refracted.
|
|
118
|
+
let star = try starAltAz(raDeg: 88.792939, decDeg: 7.407064, at: today, observer: observer)
|
|
112
119
|
```
|
|
113
120
|
|
|
114
121
|
### Eclipse searches
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { AlmanacOutOfRangeError } from './types.js';
|
|
|
3
3
|
export type { SunPosition, MoonPosition } from './positions.js';
|
|
4
4
|
export { sunPosition, moonPosition } from './positions.js';
|
|
5
5
|
export type { AltAz } from './transforms.js';
|
|
6
|
-
export { sunAltAz, moonAltAz } from './transforms.js';
|
|
6
|
+
export { sunAltAz, moonAltAz, starAltAz } from './transforms.js';
|
|
7
7
|
export type { MoonIllumination } from './illumination.js';
|
|
8
8
|
export { moonIllumination } from './illumination.js';
|
|
9
9
|
export type { SunEvent, SunEventKind, MoonEvent, MoonEventKind, MoonPhaseEvent, MoonPhaseName } from './events.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { AlmanacOutOfRangeError } from './types.js';
|
|
2
2
|
export { sunPosition, moonPosition } from './positions.js';
|
|
3
|
-
export { sunAltAz, moonAltAz } from './transforms.js';
|
|
3
|
+
export { sunAltAz, moonAltAz, starAltAz } from './transforms.js';
|
|
4
4
|
export { moonIllumination } from './illumination.js';
|
|
5
5
|
export { sunEvents, moonEvents, searchMoonPhases } from './events.js';
|
|
6
6
|
export { nextLunarEclipse, previousLunarEclipse, lunarEclipses, lunarEclipseVisibility } from './eclipse.js';
|
package/dist/transforms.d.ts
CHANGED
|
@@ -59,3 +59,15 @@ export declare function sunAltAz(time: Date, observer: Observer): AltAz;
|
|
|
59
59
|
* refraction (upstream `'normal'` model) both applied.
|
|
60
60
|
*/
|
|
61
61
|
export declare function moonAltAz(time: Date, observer: Observer): AltAz;
|
|
62
|
+
/**
|
|
63
|
+
* Topocentric azimuth/altitude of a fixed star from its J2000 (ICRS)
|
|
64
|
+
* catalog right ascension and declination, both in degrees.
|
|
65
|
+
*
|
|
66
|
+
* Applied: precession and nutation to the equator of date, Greenwich
|
|
67
|
+
* apparent sidereal time, and atmospheric refraction (upstream `'normal'`
|
|
68
|
+
* model, the same as sunAltAz/moonAltAz). Not applied: annual aberration
|
|
69
|
+
* (at most 20.5″ — see the roadmap), proper motion (pass catalog
|
|
70
|
+
* coordinates; fast movers such as Arcturus drift ~1′ in 26 years), and
|
|
71
|
+
* stellar parallax (negligible at the 1000 ly the star is placed at).
|
|
72
|
+
*/
|
|
73
|
+
export declare function starAltAz(raDeg: number, decDeg: number, time: Date, observer: Observer): AltAz;
|
package/dist/transforms.js
CHANGED
|
@@ -196,3 +196,41 @@ export function moonAltAz(time, observer) {
|
|
|
196
196
|
const ut = utDays(time);
|
|
197
197
|
return refract(topoAltAzUnrefracted(moonGeoVectorEqj(ttDaysFromUt(ut)), ut, observer));
|
|
198
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* UPSTREAM: the user-defined star path — `HelioVector` for a `DefineStar`
|
|
201
|
+
* body (astronomy.ts ~4097: `VectorFromSphere(Spherical(dec, 15*ra, dist))`)
|
|
202
|
+
* into `Equator(body, date, observer, ofdate=true, aberration=false)` (~2803)
|
|
203
|
+
* and `Horizon` (~2565): the same topocentric path sunAltAz/moonAltAz take.
|
|
204
|
+
* Upstream floors a star's distance at 1 light-year and suggests 1000 when
|
|
205
|
+
* unknown; the star sits at 1000 ly here (`AU_PER_LY`, astronomy.ts line 52).
|
|
206
|
+
* Upstream's geocentric step (star vector minus Earth's heliocentric
|
|
207
|
+
* position) is skipped: at 1000 ly it moves the star 0.003″.
|
|
208
|
+
*/
|
|
209
|
+
const STAR_DISTANCE_AU = 1000 * 63241.07708807546;
|
|
210
|
+
/**
|
|
211
|
+
* Topocentric azimuth/altitude of a fixed star from its J2000 (ICRS)
|
|
212
|
+
* catalog right ascension and declination, both in degrees.
|
|
213
|
+
*
|
|
214
|
+
* Applied: precession and nutation to the equator of date, Greenwich
|
|
215
|
+
* apparent sidereal time, and atmospheric refraction (upstream `'normal'`
|
|
216
|
+
* model, the same as sunAltAz/moonAltAz). Not applied: annual aberration
|
|
217
|
+
* (at most 20.5″ — see the roadmap), proper motion (pass catalog
|
|
218
|
+
* coordinates; fast movers such as Arcturus drift ~1′ in 26 years), and
|
|
219
|
+
* stellar parallax (negligible at the 1000 ly the star is placed at).
|
|
220
|
+
*/
|
|
221
|
+
export function starAltAz(raDeg, decDeg, time, observer) {
|
|
222
|
+
assertSupported(time);
|
|
223
|
+
assertObserver(observer);
|
|
224
|
+
if (!(raDeg >= 0 && raDeg < 360))
|
|
225
|
+
throw new RangeError(`raDeg out of range: ${raDeg}`);
|
|
226
|
+
if (!(decDeg >= -90 && decDeg <= 90))
|
|
227
|
+
throw new RangeError(`decDeg out of range: ${decDeg}`);
|
|
228
|
+
const ut = utDays(time);
|
|
229
|
+
const rCosDec = STAR_DISTANCE_AU * Math.cos(decDeg * DEG2RAD);
|
|
230
|
+
const eqj = {
|
|
231
|
+
x: rCosDec * Math.cos(raDeg * DEG2RAD),
|
|
232
|
+
y: rCosDec * Math.sin(raDeg * DEG2RAD),
|
|
233
|
+
z: STAR_DISTANCE_AU * Math.sin(decDeg * DEG2RAD),
|
|
234
|
+
};
|
|
235
|
+
return refract(topoAltAzUnrefracted(eqj, ut, observer));
|
|
236
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openwaters/almanac",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Offline sun & moon engine: positions, rise/set, moon phase, lunar eclipses.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": { "type": "git", "url": "git+https://github.com/openwatersio/almanac.git", "directory": "typescript" },
|