Skip to content

Commit

Permalink
feat: add GetEquatorialCoordinate(datetime time.Time) to coordinates …
Browse files Browse the repository at this point in the history
…module in @observerly/sidera.

feat: add GetEquatorialCoordinate(datetime time.Time) to coordinates module in @observerly/sidera.
  • Loading branch information
michealroberts committed May 3, 2024
1 parent 10286fc commit 9f02eb2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/solar/sun.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"time"

"github.com/observerly/sidera/pkg/common"
"github.com/observerly/sidera/pkg/coordinates"
"github.com/observerly/sidera/pkg/epoch"
)

Expand Down Expand Up @@ -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)
}

/*****************************************************************************************************************/
19 changes: 19 additions & 0 deletions pkg/solar/sun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

/*****************************************************************************************************************/

0 comments on commit 9f02eb2

Please sign in to comment.