Giter Site home page Giter Site logo

gosolar's Introduction

gosolar

A Go package with info related to the sun movement

Calculations made by this package are done using NOAA's methods. You can find more information on their website:

Solar calculations details

PDF version

This is still a WIP. Feel free to open PRs, fork and contribute

Usage

You should use the method Calculator() to return a SolarCalculation object that will provide access to all the other methods in the module.

package main

import (
	"fmt"
	"log"
	"github.com/karlsmaranjs/gosolar"
)

func main() {
	latitude := 35.0               // float Degrees
	longitude := -80.37486         // float Degrees
	date := "2023-06-16"           // string "YYYY-MM-DD"
	dayTime := 0.64                // float time of the day/24. 12:00:00 PM = 0.5
	timeZone := "America/New_York" // string Timezone ID

	sun, err := gosolar.Calculator(latitude, longitude, dayTime, timeZone, date)
	if err != nil {
		log.Fatalf("Error calculating sun info: %v", err)
	}
	// Returns the solar declination
	declination := sun.SolarDeclination()

	// Returns the incidence angle on a surface tilted 35 degrees from the ground and pointing south
	tiltedAngle := sun.IncidenceOnTiltedSurface(35, 180)

	fmt.Sprintf("declination: %f, Incidence on roof: %f", declination, tiltedAngle)
}

Please notice that Calculator() expects a valid string as a timeZone e.g. "America/New_York". This allows to determine the current offset for that timeZone including daylight saving time (DST). Calculator() then will determine the timezone offset using TimeZoneOffset() and use this value (float64) to initialize a SolarCalculation object.

Disclaimer

This library is not associated in any way, shape or form with NOAA

gosolar's People

Contributors

karlsmaranjs avatar

Watchers

 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.