Help us shape the future of Go! Take the 2026 Go Developer Survey

gosolarpos

package module
v0.0.0-...-e8040e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2023 License: MIT Imports: 2 Imported by: 0

README

gosolarpos

Package gosolarpos contains functions to find topocentric solar coordinates, i.e. the sun’s position on the sky at a given date, latitude, and longitude (and other parameters).

This is a partial Golang port of https://github.com/KlausBrunner/solarpositioning. Currently, only the Grena/ENEA #3 algorithm is included - which should be fine for most applications, and preferable to many of the unattributed sun position calculation snippets floating around the Web.

Usage

To use this module:

import (
    "github.com/KlausBrunner/gosolarpos"
)

azimuthDegrees, zenithDegrees := gosolarpos.Grena3(time.Now(),
		52.521667, // latitude (degrees)
		13.413333, // longitude (degrees)
		68,        // Delta T (s) - if unknown, use EstimateDeltaT()
		1000,      // air pressure (hPa)
		20)        // air temperature (°C)

println(azimuthDegrees, zenithDegrees)

A simple CLI is also available:

$ cd cmd/sol
$ go install
$ sol --lat 48.266667 --lon -116.566667                 
 using current time: 2023-01-22 09:46:27.86356 +0100 CET m=+0.000386917
 estimating delta-T: 70.81
 using standard sea-level pressure: 1013.25 hPa
azimuth: 23.252482°   zenith: 149.786614°

Documentation

Overview

Package gosolarpos contains functions to find topocentric solar coordinates. That is, the position of the sun on the sky for a given latitude/longitude, time, and other parameters.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateDeltaT

func EstimateDeltaT(forDate time.Time) (deltaTSeconds float64)

EstimateDeltaT returns an inter- or extrapolated estimate of Delta T for the given time. This is based on Espenak and Meeus, "Five Millennium Canon of Solar Eclipses: -1999 to +3000" (NASA/TP-2006-214141) and an update by Espenak in 2014 on EclipseWise.com.

func Grena3

func Grena3(date time.Time,
	latitudeDegrees float64, longitudeDegrees float64,
	deltaTSeconds float64,
	pressureHPa float64, temperatureCelsius float64) (azimuthDegrees, zenithDegrees float64)

Grena3 calculates topocentric solar position following algorithm number 3 described in Grena, 'Five new algorithms for the computation of sun position from 2010 to 2110', Solar Energy 86 (2012) pp. 1323-1337.

Example
date := time.Date(2015, 6, 23, 10, 30, 12, 0, time.UTC)

azimuth, zenithAngle := Grena3(date,
	52.521667, // latitude (degrees)
	13.413333, // longitude (degrees)
	68,        // Delta T (s)
	1000,      // air pressure (hPa)
	20)        // air temperature (°C)

fmt.Printf("azimuth: %.2f°, zenith: %.2f°\n", azimuth, zenithAngle)
Output:
azimuth: 162.23°, zenith: 29.99°

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL