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

sidereal

v0.0.7

Published

Sidereal is a JavaScript library designed for astronomical calculations.

Downloads

3

Readme

Sidereal

Sidereal is a JavaScript library designed for astronomical calculations.

It provides a set of APIs for determining the positions of celestial bodies, their celestial observables and performing orbital transfers and other related calculations.

Features

  • Celestial Body Positions: Calculate the positions of planets, stars, and other celestial objects.
  • Celestial Observables: Retrieve various observable attributes of celestial bodies, including apparent magnitudes, rise and set times, and current constellation information.
  • Orbital Transfers: Perform calculations for orbital transfers and related computations.

Installation

To install Sidereal, use npm:

npm install sidereal

Documentation

Comprehensive documentation and API details will be available on the official website in the near future. Stay tuned for updates!

Accuracy

Sidereal provides accurate astronomical calculations using built-in algorithms, but to keep the bundle size small, it does not include precomputed ephemerides. As a result, there may be a modest margin of error in the calculations. See the Basic usage section below to understand the scale of this error.

For higher precision, you can use Sidereal with Sidereal-Ephemeris, which incorporates JPL ephemerides. Together, they can achieve errors as small as 0.0832° as shown in this example.

For more on Sidereal-Ephemeris, visit the GitHub repository.

Basic usage

Here is a basic example of how to use Sidereal to get the position of a celestial body:

import Sidereal from "sidereal";

const sidereal = new Sidereal();

const mars = sidereal.planet('mars');

const date = new sidereal.AstroDate(2024, 6, 22, 0, 0)
const coordinatesCenter = "earth";

const marsPosition = mars.getPositionAtDate(date, coordinatesCenter);

const { spherical, cartesian } = marsPosition.getEquatorialCoords();

console.log('Geocentric equatorial coordinates of Mars on 22th June 2024 at 00:00 UTC');
console.log('Cartesian: (', cartesian.x, ',', cartesian.y, ',', cartesian.z, ')' )
console.log('Spherical: (', spherical.RA.HMS(), ',', spherical.DEC.DMS(), ')' )

Result:

Geocentric equatorial coordinates of Mars on 22th June 2024 at 00:00 UTC
Cartesian: ( 1.3514278051653246 , 1.0349003612244017 , 0.47248222985938937 )
Spherical: ( 02h 29m 47s , +15° 30' 48" )

Expected result [J2000]

RA 02h 28m 04s  Dec  +13° 32' 18"

RA error = 0.5417°
Dec error = 1.975°
Total Angular error: 2.043°

Usage with sidereal-ephemeris


import Sidereal from "sidereal";
import { loadEphemeris } from "sidereal-ephemeris";


const sidereal = new Sidereal();

const venusEphemeris = loadEphemeris('venus');
const earthEphemeris = loadEphemeris("earth");

sidereal.useEphemeris([venusEphemeris, earthEphemeris])

const venus = sidereal.planet('venus');

const date = new sidereal.AstroDate(2020, 6, 22, 0, 0)
const coordinatesCenter = "earth";

const marsPosition = venus.getPositionAtDate(date, coordinatesCenter);

const { spherical } = marsPosition.getEquatorialCoords();


console.log('RA', spherical.RA.HMS(), ', Dec', spherical.DEC.DMS(), ')' )

Result


RA 04h 15m 44s Dec +18° 02' 45" 

Expected result (J2000)

RA 04h 15m 46s  Dec  +18° 02' 46"
RA error: 0.0833°
Dec error: 0.0042°
Total angular error: 0.0832°

License

Sidereal is licensed under the MIT License.