Giter VIP home page Giter VIP logo

node-astronomy's Introduction

node-astronomy

Build Status

Calculate 3D orbits of planets and comets given orbital elements

This Javascript code is fronting as a Node module, but is really meant to be loaded into a browser environment using Browserify

Installation

git clone https://github.com/TimeMagazine/node-astronomy.git
cd node-astronomy
npm install

The data

The orbital info for the planets and the comets come from JPL. We've already converted these fixed-width tables into JSON files found at data/planets.json and data/comets.json. If you want to rebuild these files to make sure they're current, run the followed commands:

./update_comets_and_planets.js planets
./update_comets_and_planets.js planets --pluto #if you want poor Pluto
./update_comets_and_planets.js comets

This will overwrite the files from the repo with the most recent data from JPL, though for planets it does not appear to change often.

Usage

var astronomy = require("./index");

var earth = astronomy.planets.planet("Earth");
var halley = astronomy.comets.comet("Halley (1986)");

If you give earth the old console.log, you'll see it has an element called positions:

{
  "key": "Earth",
  "info": {
    "color": "#66CCFF",
    "diameter": 12756,
    "rotation_period": 1,
    "orbital_period": 365.26
  },
  "positions": [
    {
      "date": "2014-12-31T05:00:00.000Z",
      "position": {
        "ecliptic": [
          -0.14530893602582962,
          0.9725529260974349,
          0.00003321337538343582
        ]
      }
    },
    {
      "date": "2015-01-03T05:00:00.000Z",
      "position": {
        "ecliptic": [
          -0.19696827172231163,
          0.9633741996434886,
          0.000032917795100756254
        ]
      }
    },
    /* and so forth */
  ]
}

The positions represent the planet's place in the solar system at each date. The solar system is three dimensional, so it makes sense that we would have three positional points for each date.

But you only have two dimensions to work with, most likely, so you'll want to project the solar system onto a surface. For that, you can use the project method:

var Earth_xy = astronomy.project(earth, 30, 200);

The second argument is the angle from which to view the solar system (in degrees) and the second is how many pixels one astronomical unit should equal.

Here's an R plot of the output of the project method for the inner solar system and Haley's comet:

Inner Solar System

node-astronomy's People

Contributors

wilson428 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.