0.0.5 • Published 4 years ago

solar-beam v0.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

solar-beam

CI

General solar position calculator powered with TypeScript. The calculation is based on the spreadsheet from Earth System Research Laboratory.

DISCLAIMER: Please be mindful when using this library, as there is no guarantee that the values are valid. As written on the section "Data for Litigation":

The NOAA Solar Calculator is for research and recreational use only. NOAA cannot certify or authenticate sunrise, sunset or solar position data. The U.S. Government does not collect observations of astronomical data, and due to atmospheric conditions our calculated results may vary significantly from actual observed values.

Installation

# npm
npm install --save solar-beam

# yarn
yarn add solar-beam

Usage

import { getJulianDate } from 'solar-beam';

// May 5th, 2020, 12am o'clock, GMT +7.
const date = new Date(2020, 4, 9);
getJulianDate(date, -420); // 2458978.2083333335.

For more detailed information, please see the test file.

Available functions

Common utils

Function nameParameterDescription
getJulianDate(date: Date) => numberReturns the current Julian day

Fractions

Function nameParameterDescription
getSolarNoonLSTInFractions(params: MainFunctionParams) => numberReturns the solar noon time fraction from the given date and location
getSunriseInFractions(params: MainFunctionParams) => numberReturns the sunrise time fraction from the given date and location
getSunsetInFractions(params: MainFunctionParams) => numberReturns the sunset time fraction from the given date and location

Seconds

Function nameParameterDescription
getSolarNoonLSTInSeconds(params: MainFunctionParams) => numberReturns the solar noon seconds (of a day) from the given date and location
getSunriseInSeconds(params: MainFunctionParams) => numberReturns the sunrise seconds (of a day) from the given date and location
getSunsetInSeconds(params: MainFunctionParams) => numberReturns the sunset seconds (of a day) from the given date and location

Date

Function nameParameterDescription
getSolarNoonLSTDate(params: MainFunctionParams) => stringReturns the solar noon time in HH:mm:ss format from the given date and location
getSunriseDate(params: MainFunctionParams) => stringReturns the sunrise time in HH:mm:ss format from the given date and location
getSunsetDate(params: MainFunctionParams) => stringReturns the sunset time in HH:mm:ss format from the given date and location

Angles

Function nameParameterDescription
getSolarElevationAngle(params: MainFunctionParams) => numberReturns the solar elevation angle in degrees from the given date and location

Trying it locally

# Build first to generate the dist/ folder.
yarn build
# Run the example file.
node example/index.js

Testing

yarn test

Next updates

  • Breakdown functions to separate folders. So, dist/ will contain index.js, index.min.js, and all other functions from src/. Hence, when browsers include it from <script> tag, they can access index.min.js directly, while users who want to use ESM can do, e.g. import getJulianDate from 'solar-beam/getJulianDate';.

LICENSE

MIT

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago