GithubHelp home page GithubHelp logo

coderlee / sunrisesunset Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kelvins/sunrisesunset

0.0 0.0 0.0 27 KB

:sunrise: Go package that provides the sunrise and sunset equation

License: MIT License

Go 100.00%

sunrisesunset's Introduction

⚠️ This project is no longer being maintained ⚠️

Consider using a forked version of this repository or another project like go-sunrise.

Sunrise Sunset Package

License: MIT Build Status Coverage Status Go Report Card

Go package used to calculate the apparent sunrise and sunset times based on latitude, longitude, date and UTC offset.

You can use go get command:

go get github.com/kelvins/sunrisesunset

General

This package was created based on the Corrected Sunrise, Sunset, Noon Times in Seconds - and Solar Angles Matlab function developed by Richard Droste, that was created based on the spreadsheets available in the Earth System Research Laboratory website from the National Oceanic & Atmospheric Administration (NOAA).

Based on the Solar Calculation Details:

The calculations in the NOAA Sunrise/Sunset and Solar Position Calculators are based on equations from Astronomical Algorithms, by Jean Meeus. The sunrise and sunset results are theoretically accurate to within a minute for locations between +/- 72° latitude, and within 10 minutes outside of those latitudes. However, due to variations in atmospheric composition, temperature, pressure and conditions, observed values may vary from calculations.

Apparent Sunrise/Sunset:

Due to atmospheric refraction, sunrise occurs shortly before the sun crosses above the horizon. Light from the sun is bent, or refracted, as it enters earth's atmosphere. See Apparent Sunrise Figure. This effect causes the apparent sunrise to be earlier than the actual sunrise. Similarly, apparent sunset occurs slightly later than actual sunset. The sunrise and sunset times reported in our calculator have been corrected for the approximate effects of atmospheric refraction. However, it should be noted that due to changes in air pressure, relative humidity, and other quantities, we cannot predict the exact effects of atmospheric refraction on sunrise and sunset time. Also note that this possible error increases with higher (closer to the poles) latitudes.

Usage

package main

import (
    "fmt"
    "time"
    "github.com/kelvins/sunrisesunset"
)

func main() {
    // You can use the Parameters structure to set the parameters
    p := sunrisesunset.Parameters{
      Latitude:  -23.545570,
      Longitude: -46.704082,
      UtcOffset: -3.0,
      Date:      time.Date(2017, 3, 23, 0, 0, 0, 0, time.UTC),
    }

    // Calculate the sunrise and sunset times
    sunrise, sunset, err := p.GetSunriseSunset()

    // If no error has occurred, print the results
    if err == nil {
        fmt.Println("Sunrise:", sunrise.Format("15:04:05")) // Sunrise: 06:11:44
        fmt.Println("Sunset:", sunset.Format("15:04:05")) // Sunset: 18:14:27
    } else {
        fmt.Println(err)
    }
}

License

This project was created under the MIT license

sunrisesunset's People

Contributors

kelvins avatar lukasschwab 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.