Sun calculation js library which is fully based on formula from http://aa.quae.nl/en/reken/zonpositie.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Orion Stark 44a5f36ba9 Docs use added 7 years ago
dist Add docs 7 years ago
node_modules Make a unit test 7 years ago
LICENSE Initial commit 7 years ago
README.md Docs use added 7 years ago
main.js Make a unit test 7 years ago
package-lock.json 1.0.3 7 years ago
package.json 1.0.3 7 years ago
test.js Make a unit test 7 years ago

README.md

Calculation of sun

Inline docs npm version contributions welcome HitCount
Sun calculation fully based on formula from http://aa.quae.nl/en/reken/zonpositie.html

Warning

This program is not really accurate about the calculation. For the sunrise and sunset, the error value is about 2 minutes miss from the actual time. For the Altitude the error value is near 0.6 degrees and the azimuth as well.

Install with npm

npm install calculation-ofsun

Without npm

  1. Clone this project
  2. Create your new js file
  3. Import the solar-calculation.js to your code. You could find the script in dist directory
  4. Then, have fun

Attention

If you didn't understand what I'm saying about how to use it without npm. You could check the main.js. That's it.

How to Use It

    const cls = require('calculation-ofsun')
    console.log(cls.getSunInformation(new Date(), 33, 3))
    /* Get Sun Information expected 3 parameters */
    /* Date, lat, long */
    /* For the other function and it's parameter. You could check on the table below */

How to use another functions that require juliandate as the parameter

    const cls = require('calculation-ofsun');
    const myJD = cls.dateToJD(new Date());
    const lw = -96.555324
    console.log(cls.solarTransit(myJD, lw));

You can also call any function except getSunPosition, because it automatically calls by the getSunInformation function to get sun position according to your input parameters for getSunInformation.

Functions parameter

Function Name Expected Parameter
getSunInformation Date, latitude, longtitude
dateToJD Date
jdTODate JulianDate
equation_of_center JulianDate
earthMeanAnomaly JulianDate
earthTrueAnomaly JulianDate
eclipticLongtitude JulianDate
rightAscension JulianDate
declination JulianDate
sideraltime JulianDate, West Longitude
getHourAngle JulianDate, West Longitude
getSunPosition None, Dont use it
solarTransit JulianDate. West Longitude
sunriseandsunset JulianDate, Latitude, Longitude

Example of return object from getSunInformation functions

Nethereland GMT +1 It'll return time denpend on your local time

{   sun_position: { 
        azimuth: -101.53872252647008, 
        altitude: 57.268164438252526 
    },
    date: 'Sat Apr 14 2018 10:16:32 GMT+0700 (WIB)',
    observe_location: { 
        latitude: 3.597031, 
        longitude: 98.678513
    },
    sunrise: 'Sat Apr 14 2018 06:21:42 GMT+0700 (WIB)',
    sunset: 'Sat Apr 14 2018 18:32:54 GMT+0700 (WIB)',
    solar_transit: 2458222.7272965494,
    hour_angle: 327.53679257420777,
    right_ascension: 
        {   degrees: 22.060782554336377, 
            rad: 0.38503329113969464 
        },
    clientJD: 2458222.6364905904 
}