This repository has been archived by the owner on Apr 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor solar for better caching * get tests to run again * fix lunar tests * fix tests * refactor interface to suck less * fix tests again * refactor lunar to match solar * refactor * fix #4 * bump node version in travis * additions and cleanup * cleanup comments * add tests * cutsify the tests a little more * more tests
- Loading branch information
Jay LaPorte
authored
Apr 4, 2019
1 parent
1d9c262
commit 13b6288
Showing
13 changed files
with
385 additions
and
355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": "@darkskyapp" | ||
"extends": "@darkskyapp", | ||
"rules": { | ||
"max-len": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/.nyc_output | ||
/.package-lock.json | ||
/coverage | ||
/node_modules | ||
/package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- '6' | ||
- '10' | ||
cache: | ||
directories: | ||
- node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,9 @@ | ||
# astro | ||
A library that calculates the position of the sun and moon in the sky. | ||
|
||
Installation | ||
------------ | ||
|
||
Use NPM in the usual way. | ||
|
||
npm install | ||
|
||
|
||
Usage | ||
----- | ||
|
||
## Usage | ||
Methods for calculating positions of the moon are in the `lunar` submodule; | ||
method for calculating positions of the sun, in `solar`. The top-level `astro` | ||
module contains methods for calculating astronomical times. | ||
method for calculating positions of the sun, in `solar`. | ||
|
||
const astro = require("astro"), | ||
lunar = astro.lunar, | ||
solar = astro.solar; | ||
All methods operate in units of degrees (for angles, including latitudes and | ||
longitudes), milliseconds (for timestamps), and AU (for distances). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,3 @@ | ||
"use strict"; | ||
const lunar = require("./lib/lunar"); | ||
const solar = require("./lib/solar"); | ||
|
||
// Convert to/from J2000 dates. | ||
const J1970 = -10957.5; | ||
|
||
function ms_to_julian(ms) { | ||
return J1970 + ms / 86400000; | ||
} | ||
|
||
function unix_to_julian(unix) { | ||
return J1970 + unix / 86400; | ||
} | ||
|
||
function date_to_julian(date) { | ||
return ms_to_julian(date.getTime()); | ||
} | ||
|
||
function julian_to_ms(t) { | ||
return (t - J1970) * 86400000; | ||
} | ||
|
||
function julian_to_unix(t) { | ||
return (t - J1970) * 86400; | ||
} | ||
|
||
function julian_to_date(t) { | ||
return new Date(julian_to_ms(t)); | ||
} | ||
|
||
// Greenwich mean sidereal time, accurate to ~1 second. | ||
// http://aa.usno.navy.mil/faq/docs/GAST.php | ||
const GMST0 = 18.697374558 * Math.PI / 12; | ||
const GMST1 = 24.06570982441908 * Math.PI / 12; | ||
|
||
function greenwich_mean_sidereal_time(jt) { | ||
return GMST0 + GMST1 * jt; | ||
} | ||
|
||
function local_sidereal_time(jt, lon_r) { | ||
return greenwich_mean_sidereal_time(jt) + lon_r; | ||
} | ||
|
||
function hour_angle(jt, lon_r) { | ||
let angle = local_sidereal_time(jt, lon_r) - solar.right_ascension(jt); | ||
angle -= Math.floor(angle / (2 * Math.PI)) * (2 * Math.PI); | ||
if(angle > Math.PI) { | ||
angle -= 2 * Math.PI; | ||
} | ||
return angle; | ||
} | ||
|
||
exports.ms_to_julian = ms_to_julian; | ||
exports.unix_to_julian = unix_to_julian; | ||
exports.date_to_julian = date_to_julian; | ||
exports.julian_to_ms = julian_to_ms; | ||
exports.julian_to_unix = julian_to_unix; | ||
exports.julian_to_date = julian_to_date; | ||
exports.local_sidereal_time = local_sidereal_time; | ||
exports.hour_angle = hour_angle; | ||
exports.solar = solar; | ||
exports.lunar = lunar; | ||
exports.lunar = require("./lib/lunar"); | ||
exports.solar = require("./lib/solar"); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.