From 9f02eb2d0f324757fdd3a47c1a92864976bb1202 Mon Sep 17 00:00:00 2001 From: "Michael J. Roberts" Date: Fri, 3 May 2024 10:36:10 +0100 Subject: [PATCH] feat: add GetEquatorialCoordinate(datetime time.Time) to coordinates module in @observerly/sidera. feat: add GetEquatorialCoordinate(datetime time.Time) to coordinates module in @observerly/sidera. --- pkg/solar/sun.go | 20 ++++++++++++++++++++ pkg/solar/sun_test.go | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/pkg/solar/sun.go b/pkg/solar/sun.go index 4fd5cfa..7e4bfa5 100644 --- a/pkg/solar/sun.go +++ b/pkg/solar/sun.go @@ -15,6 +15,7 @@ import ( "time" "github.com/observerly/sidera/pkg/common" + "github.com/observerly/sidera/pkg/coordinates" "github.com/observerly/sidera/pkg/epoch" ) @@ -130,3 +131,22 @@ func GetEclipticCoordinate(datetime time.Time) common.EclipticCoordinate { } /*****************************************************************************************************************/ + +/* +the Equatorial Coordinate of the Sun for a given datetime + +The Solar Equatorial Coordinate is the position of the Sun in the sky relative to the celestial equator. + +The Solar Equatorial Coordinate is an important concept in solar astronomy, as it is used to calculate the position +of the Sun in the sky at any given time. By knowing the Solar Equatorial Coordinate, an observer can determine the +Sun's position relative to the vernal equinox and calculate the time of sunrise, sunset, and other solar events. +*/ +func GetEquatorialCoordinate(datetime time.Time) common.EquatorialCoordinate { + // get the solar ecliptic coordinate: + ecliptic := GetEclipticCoordinate(datetime) + + // convert the solar ecliptic coordinate to the solar equatorial coordinate: + return coordinates.ConvertEclipticToEquatorialCoordinate(datetime, ecliptic) +} + +/*****************************************************************************************************************/ diff --git a/pkg/solar/sun_test.go b/pkg/solar/sun_test.go index 3869d5b..55234a9 100644 --- a/pkg/solar/sun_test.go +++ b/pkg/solar/sun_test.go @@ -75,3 +75,22 @@ func TestGetSolarEclipticCoordinate(t *testing.T) { } /*****************************************************************************************************************/ + +func TestSolarEquatorialCoordinate(t *testing.T) { + var got = GetEquatorialCoordinate(datetime) + + var want = common.EquatorialCoordinate{ + RightAscension: 51.96564888161902, + Declination: 18.256452, + } + + if got.RightAscension-want.RightAscension > 0.0001 { + t.Errorf("got %f, wanted %f", got.RightAscension, want.RightAscension) + } + + if got.Declination-want.Declination > 0.0001 { + t.Errorf("got %f, wanted %f", got.Declination, want.Declination) + } +} + +/*****************************************************************************************************************/