1.0.4 • Published 6 years ago

meeusjs v1.0.4

Weekly downloads
167
License
MIT
Repository
github
Last release
6 years ago

MeeusJs

MeeusJs is an implementation of some algorithms of the Book 'Astronomical Algorithms of Jean Meeus' in Javascript. It follows the second edition, copyright 1998, with corrections as of August 10, 2009.

The library can be used to calculate sun and moon positions and their phases (rise, transmit, set) on a high accuracy.

The library is about 20kb (minimized) and licensed under MIT. It includes various unit tests against the data of http://ssd.jpl.nasa.gov/horizons.cgi.

The sourcecode is written by Fabio Soldati (@fabiz) from http://www.peakfinder.org.

Package contents

Currently the following chapters are implemented:

ChapterModule
3. InterpolationA.Interp
7. Julian DayA.JulianDay
10. Dynamical Time and Universal TimeA.DeltaT
11. The Earth's GlobeA.Globe
12. Sidereal Time at GreenwichA.Sidereal
13. Transformation of CoordinatesA.Coord
14. The Parallactic Angle, and three other TopicsA.Moon
15. Rising, Transit, and SettingA.Rise
16. Atmospheric RefractionA.Refraction
22. Nutation and the Obliquity of the EclipticA.Nutation
23. Apparent Place of a StarA.Nutation
25. Solar CoordinatesA.Solar
27. Equinoxes and SolsticesA.Solstice
40. Correction for ParallaxA.Parallax
47. Position of the MoonA.Moon
48. Illuminated Fraction of the Moon's DiskA.MoonIllum
49. Phases of the MoonA.MoonPhase

Usage example

Sun

// gets sun position and times for zurich
var jdo = new A.JulianDay(new Date()); // now
var coord = A.EclCoord.fromWgs84(47.3957, 8.4867, 440); // zurich

// gets the position of the sun		
var tp = A.Solar.topocentricPosition(jdo, coord, true);
// print azi and alt
console.log(tp.hz.toString()); 

// gets the rise, transit and set time of the sun for today
var times = A.Solar.times(jdo, coord);
	
// print rise, transit and set in universal time	
console.log("rise:" + A.Coord.secondsToHMSStr(times.rise) + 
          ", transit:" + A.Coord.secondsToHMSStr(times.transit) + 
          ", set:" +  A.Coord.secondsToHMSStr(times.set));

Moon

// gets the moon position and times for zurich
var jdo = new A.JulianDay(new Date()); // now
var coord = A.EclCoord.fromWgs84(47.3957, 8.4867, 440); // zurich

// gets the position of the moon		
var tp = A.Moon.topocentricPosition(jdo, coord, true);
// print azi and alt
console.log(tp.hz.toString() + ", dist:" + tp.delta); 

// gets the rise, transit and set time of the moon for today
var times = A.Moon.times(jdo, coord);
	
// print rise, transit and set in universal time	
console.log("rise:" + A.Coord.secondsToHMSStr(times.rise) + 
          ", transit:" + A.Coord.secondsToHMSStr(times.transit) + 
          ", set:" +  A.Coord.secondsToHMSStr(times.set));
		  

// print moon phase and illuminated
var suneq = A.Solar.apparentTopocentric(jdo, coord);
var i = A.MoonIllum.phaseAngleEq2(tp.eq, suneq);
var k = A.MoonIllum.illuminated(i);
var chi =  A.MoonIllum.positionAngle(moontp.eq, suneq);

console.log("phase:" + i + ", illuminated:" + k + ", angle:" + chi);		

Changelog

1.0.3 Jan 18, 2017

  • Fixed bug on A.JulianDay.jdToDate

1.0.2 Mar 18, 2016

  • Added solistice

1.0.1 Mar 04, 2016

  • Fixed bug of MoonIllum
  • Added approxTransit to Moon and Solar
  • Added toDate method the JulianDay

1.0.0 Mar 02, 2016

  • First commit.