Skip to content

Commit

Permalink
Merge pull request #24 from observerly/feature/solar/GetEclipticCoord…
Browse files Browse the repository at this point in the history
…inate

feat: add GetEclipticCoordinate(datetime time.Time) to sun module in @observerly/sidera.
  • Loading branch information
michealroberts authored May 2, 2024
2 parents 8f98ff5 + db4d0ef commit fcc4e4c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/solar/sun.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,26 @@ func GetEclipticLongitude(datetime time.Time) float64 {
}

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

/*
the Ecliptic Coordinate of the Sun for a given datetime
The Solar Ecliptic Coordinate is the position of the Sun in the sky relative to the vernal equinox.
The Solar Ecliptic 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 Ecliptic 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 GetEclipticCoordinate(datetime time.Time) common.EclipticCoordinate {
// get the solar ecliptic longitude:
λ := GetEclipticLongitude(datetime)

// return the solar ecliptic coordinate:
// the solar ecliptic coordinate is the solar ecliptic longitude and zero latitude:
return common.EclipticCoordinate{
Longitude: λ,
Latitude: 0,
}
}

/*****************************************************************************************************************/
20 changes: 20 additions & 0 deletions pkg/solar/sun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"testing"
"time"

"github.com/observerly/sidera/pkg/common"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -55,3 +56,22 @@ func TestGetSolarEclipticLongitude(t *testing.T) {
}

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

func TestGetSolarEclipticCoordinate(t *testing.T) {
var got = GetEclipticCoordinate(datetime)

var want = common.EclipticCoordinate{
Longitude: 51.96564888161902,
Latitude: 0,
}

if got.Longitude-want.Longitude > 0.0001 {
t.Errorf("got %f, wanted %f", got.Longitude, want.Longitude)
}

if got.Latitude-want.Latitude > 0.0001 {
t.Errorf("got %f, wanted %f", got.Latitude, want.Latitude)
}
}

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

0 comments on commit fcc4e4c

Please sign in to comment.