npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

practical-astronomy-javascript

v1.0.0

Published

Implementation of algorithms from Practical Astronomy For Your Calculator or Spreadsheet

Downloads

21

Readme

Practical Astronomy - JavaScript (practical-astronomy-javascript)

Algorithms from "Practical Astronomy with your Calculator or Spreadsheet" by Peter Duffett-Smith, implemented in JavaScript.

If you're interested in this topic, please buy the book! It provides far more detail and context.

Installation

npm install practical-astronomy-javascript

Usage

Example 1: Calculate date of Easter for 2024.

Create client.js:

const pa = require('practical-astronomy-javascript');

console.log(pa.paDateTime.getDateOfEaster(2024));

Run it:

node client.js

Result:

[ 3, 31, 2024 ]

Example 2: Get detailed information about the April 8 solar eclipse, for West Alexandria, Ohio

Create client.js:

const pa = require('practical-astronomy-javascript');

// Information about the observer location
var monthOfObservation = 4;
var dayOfObservation = 8;
var yearOfObservation = 2024;
var isDaylightSavings = true;
var zoneCorrectionHours = 5;
var observerLatitude = 39.74722;
var observerLongitude = -84.53639;

var [solarEclipseCertainDateDay, solarEclipseCertainDateMonth, solarEclipseCertainDateYear, utFirstContactHour, utFirstContactMinutes, utMidEclipseHour, utMidEclipseMinutes, utLastContactHour, utLastContactMinutes, eclipseMagnitude] = pa.paEclipses.solarEclipseCircumstances(dayOfObservation, monthOfObservation, yearOfObservation, isDaylightSavings, zoneCorrectionHours, observerLongitude, observerLatitude);

// Results are in universal time, so adjust them for the observer's time zone
utFirstContactHour = utFirstContactHour - ((isDaylightSavings) ? zoneCorrectionHours - 1 : zoneCorrectionHours);
utMidEclipseHour = utMidEclipseHour - ((isDaylightSavings) ? zoneCorrectionHours - 1 : zoneCorrectionHours);
utLastContactHour = utLastContactHour - ((isDaylightSavings) ? zoneCorrectionHours - 1 : zoneCorrectionHours);

console.log(`Date of eclipse:        ${solarEclipseCertainDateMonth}/${solarEclipseCertainDateDay}/${solarEclipseCertainDateYear}`);
console.log(`First contact:          ${utFirstContactHour}:${utFirstContactMinutes}`);
console.log(`Mid-eclipse (totality): ${utMidEclipseHour}:${utMidEclipseMinutes}`);
console.log(`Last contact:           ${utLastContactHour}:${utLastContactMinutes}`);
console.log(`Magnitude of eclipse:   ${eclipseMagnitude}`);

Run it:

node client.js

Result:

Date of eclipse:        4/8/2024
First contact:          13:55
Mid-eclipse (totality): 15:11
Last contact:           16:27
Magnitude of eclipse:   1.006

Links

GitHub

Documentation

NPM page

Library Functions - Status

Date/Time

  • [x] Calculate -> Date of Easter
  • [x] Convert -> Civil Date to Day Number
  • [x] Convert -> Civil Time <-> Decimal Hours
  • [x] Extract -> Hour, Minutes, and Seconds parts of Decimal Hours
  • [x] Convert -> Local Civil Time <-> Universal Time
  • [x] Convert -> Universal Time <-> Greenwich Sidereal Time
  • [x] Convert -> Greenwich Sidereal Time <-> Local Sidereal Time

Coordinates

  • [x] Convert -> Angle <-> Decimal Degrees
  • [x] Convert -> Right Ascension <-> Hour Angle
  • [x] Convert -> Equatorial Coordinates <-> Horizon Coordinates
  • [x] Calculate -> Obliquity of the Ecliptic
  • [x] Convert -> Ecliptic Coordinates <-> Equatorial Coordinates
  • [x] Convert -> Equatorial Coordinates <-> Galactic Coordinates
  • [x] Calculate -> Angle between two objects
  • [x] Calculate -> Rising and Setting times for an object
  • [x] Calculate -> Precession (corrected coordinates between two epochs)
  • [x] Calculate -> Nutation (in ecliptic longitude and obliquity) for a Greenwich date
  • [x] Calculate -> Effects of aberration for ecliptic coordinates
  • [x] Calculate -> RA and Declination values, corrected for atmospheric refraction
  • [x] Calculate -> RA and Declination values, corrected for geocentric parallax
  • [x] Calculate -> Heliographic coordinates
  • [x] Calculate -> Carrington rotation number
  • [x] Calculate -> Selenographic (lunar) coordinates (sub-Earth and sub-Solar)

The Sun

  • [x] Calculate -> Approximate and precise positions of the Sun
  • [x] Calculate -> Sun's distance and angular size
  • [x] Calculate -> Local sunrise and sunset
  • [x] Calculate -> Morning and evening twilight
  • [x] Calculate -> Equation of time
  • [x] Calculate -> Solar elongation

Planets

  • [x] Calculate -> Approximate position of planet
  • [x] Calculate -> Precise position of planet
  • [x] Calculate -> Visual aspects of planet (distance, angular diameter, phase, light time, position angle of bright limb, and apparent magnitude)

Comets

  • [x] Calculate -> Position of comet (elliptical)
  • [x] Calculate -> Position of comet (parabolic)

Binary Stars

  • [x] Calculate -> Binary star orbit data

The Moon

  • [x] Calculate -> Approximate and precise position of Moon
  • [x] Calculate -> Moon phase and position angle of bright limb
  • [x] Calculate -> Times of new Moon and full Moon
  • [x] Calculate -> Moon's distance, angular diameter, and horizontal parallax
  • [x] Calculate -> Local moonrise and moonset

Eclipses

  • [x] Calculate -> Lunar eclipse occurrence and circumstances
  • [x] Calculate -> Solar eclipse occurrence and circumstances