Skip to content

Commit

Permalink
Merge pull request #118 from observerly/feature/dusk/GetRelativeAirMass
Browse files Browse the repository at this point in the history
feat: Added GetRelativeAirMass().
  • Loading branch information
michealroberts authored Jun 15, 2022
2 parents 074548f + 4d11ed9 commit 8b5970a
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 51 deletions.
103 changes: 52 additions & 51 deletions coverage.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
mode: atomic
github.com/observerly/dusk/pkg/dusk/astrometry.go:14.52,18.12 2 12983
github.com/observerly/dusk/pkg/dusk/astrometry.go:22.2,22.11 1 12983
github.com/observerly/dusk/pkg/dusk/astrometry.go:18.12,20.3 1 1793
github.com/observerly/dusk/pkg/dusk/astrometry.go:34.73,42.2 4 4
github.com/observerly/dusk/pkg/dusk/lawrence.go:15.59,24.12 3 3
github.com/observerly/dusk/pkg/dusk/lawrence.go:28.2,28.11 1 3
github.com/observerly/dusk/pkg/dusk/lawrence.go:24.12,26.3 1 0
github.com/observerly/dusk/pkg/dusk/lawrence.go:37.62,50.11 5 12991
github.com/observerly/dusk/pkg/dusk/lawrence.go:54.2,54.10 1 12991
github.com/observerly/dusk/pkg/dusk/lawrence.go:50.11,52.3 1 12991
github.com/observerly/dusk/pkg/dusk/lawrence.go:64.78,80.11 7 12980
github.com/observerly/dusk/pkg/dusk/lawrence.go:85.2,92.3 3 12980
github.com/observerly/dusk/pkg/dusk/lawrence.go:80.11,82.3 1 4328
github.com/observerly/dusk/pkg/dusk/lawrence.go:101.82,111.12 5 0
github.com/observerly/dusk/pkg/dusk/lawrence.go:116.2,121.3 2 0
github.com/observerly/dusk/pkg/dusk/lawrence.go:111.12,113.3 1 0
github.com/observerly/dusk/pkg/dusk/lawrence.go:130.62,144.2 5 25984
github.com/observerly/dusk/pkg/dusk/lawrence.go:152.58,160.2 3 12996
github.com/observerly/dusk/pkg/dusk/lawrence.go:170.70,178.14 3 12995
github.com/observerly/dusk/pkg/dusk/lawrence.go:182.2,182.11 1 12995
github.com/observerly/dusk/pkg/dusk/lawrence.go:178.14,180.3 1 0
github.com/observerly/dusk/pkg/dusk/coordinates.go:101.108,124.2 10 12982
github.com/observerly/dusk/pkg/dusk/coordinates.go:136.149,151.2 6 12982
github.com/observerly/dusk/pkg/dusk/solar.go:23.45,26.2 1 42
github.com/observerly/dusk/pkg/dusk/solar.go:35.50,38.2 1 32
github.com/observerly/dusk/pkg/dusk/solar.go:47.62,50.2 1 31
Expand All @@ -37,38 +18,18 @@ github.com/observerly/dusk/pkg/dusk/solar.go:189.70,200.2 4 4
github.com/observerly/dusk/pkg/dusk/solar.go:208.74,222.12 6 2
github.com/observerly/dusk/pkg/dusk/solar.go:226.2,229.3 1 2
github.com/observerly/dusk/pkg/dusk/solar.go:222.12,224.3 1 2
github.com/observerly/dusk/pkg/dusk/utils.go:15.34,17.2 1 7
github.com/observerly/dusk/pkg/dusk/utils.go:26.55,31.12 2 12986
github.com/observerly/dusk/pkg/dusk/utils.go:35.2,35.11 1 12986
github.com/observerly/dusk/pkg/dusk/utils.go:31.12,33.3 1 0
github.com/observerly/dusk/pkg/dusk/utils.go:47.84,49.2 1 4
github.com/observerly/dusk/pkg/dusk/utils.go:60.84,62.2 1 12986
github.com/observerly/dusk/pkg/dusk/utils.go:72.85,74.2 1 5
github.com/observerly/dusk/pkg/dusk/utils.go:83.57,85.2 1 1
github.com/observerly/dusk/pkg/dusk/trigonometry.go:10.30,12.2 1 273679
github.com/observerly/dusk/pkg/dusk/trigonometry.go:14.30,16.2 1 194880
github.com/observerly/dusk/pkg/dusk/trigonometry.go:18.44,20.2 1 541
github.com/observerly/dusk/pkg/dusk/trigonometry.go:22.30,24.2 1 13020
github.com/observerly/dusk/pkg/dusk/trigonometry.go:26.31,28.2 1 38982
github.com/observerly/dusk/pkg/dusk/trigonometry.go:30.31,32.2 1 13016
github.com/observerly/dusk/pkg/dusk/trigonometry.go:34.31,36.2 1 1
github.com/observerly/dusk/pkg/dusk/trigonometry.go:38.36,40.2 1 25976
github.com/observerly/dusk/pkg/dusk/twilight.go:38.163,49.16 5 9
github.com/observerly/dusk/pkg/dusk/twilight.go:53.2,57.18 1 9
github.com/observerly/dusk/pkg/dusk/twilight.go:49.16,51.3 1 0
github.com/observerly/dusk/pkg/dusk/twilight.go:69.139,74.2 2 3
github.com/observerly/dusk/pkg/dusk/twilight.go:85.142,90.2 2 3
github.com/observerly/dusk/pkg/dusk/twilight.go:101.146,106.2 2 3
github.com/observerly/dusk/pkg/dusk/coordinates.go:101.108,124.2 10 12982
github.com/observerly/dusk/pkg/dusk/coordinates.go:136.149,151.2 6 12981
github.com/observerly/dusk/pkg/dusk/astrometry.go:14.52,18.12 2 12984
github.com/observerly/dusk/pkg/dusk/astrometry.go:22.2,22.11 1 12984
github.com/observerly/dusk/pkg/dusk/astrometry.go:18.12,20.3 1 1794
github.com/observerly/dusk/pkg/dusk/astrometry.go:34.73,42.2 4 4
github.com/observerly/dusk/pkg/dusk/epoch.go:31.56,33.2 1 6
github.com/observerly/dusk/pkg/dusk/epoch.go:41.48,46.2 2 116986
github.com/observerly/dusk/pkg/dusk/epoch.go:41.48,46.2 2 116988
github.com/observerly/dusk/pkg/dusk/epoch.go:53.45,55.2 1 79
github.com/observerly/dusk/pkg/dusk/epoch.go:63.60,93.13 15 12986
github.com/observerly/dusk/pkg/dusk/epoch.go:97.2,97.12 1 12986
github.com/observerly/dusk/pkg/dusk/epoch.go:93.13,95.3 1 4585
github.com/observerly/dusk/pkg/dusk/epoch.go:106.74,114.11 4 12984
github.com/observerly/dusk/pkg/dusk/epoch.go:118.2,118.17 1 12984
github.com/observerly/dusk/pkg/dusk/epoch.go:63.60,93.13 15 12987
github.com/observerly/dusk/pkg/dusk/epoch.go:97.2,97.12 1 12987
github.com/observerly/dusk/pkg/dusk/epoch.go:93.13,95.3 1 4586
github.com/observerly/dusk/pkg/dusk/epoch.go:106.74,114.11 4 12985
github.com/observerly/dusk/pkg/dusk/epoch.go:118.2,118.17 1 12985
github.com/observerly/dusk/pkg/dusk/epoch.go:114.11,116.3 1 0
github.com/observerly/dusk/pkg/dusk/epoch.go:127.65,138.2 4 36
github.com/observerly/dusk/pkg/dusk/epoch.go:146.76,154.2 3 77943
Expand All @@ -91,6 +52,23 @@ github.com/observerly/dusk/pkg/dusk/epoch.go:328.2,328.21 1 5
github.com/observerly/dusk/pkg/dusk/epoch.go:312.12,314.3 1 5
github.com/observerly/dusk/pkg/dusk/epoch.go:317.13,319.3 1 0
github.com/observerly/dusk/pkg/dusk/epoch.go:324.11,326.3 1 1
github.com/observerly/dusk/pkg/dusk/lawrence.go:15.59,24.12 3 3
github.com/observerly/dusk/pkg/dusk/lawrence.go:28.2,28.11 1 3
github.com/observerly/dusk/pkg/dusk/lawrence.go:24.12,26.3 1 0
github.com/observerly/dusk/pkg/dusk/lawrence.go:37.62,50.11 5 12991
github.com/observerly/dusk/pkg/dusk/lawrence.go:54.2,54.10 1 12991
github.com/observerly/dusk/pkg/dusk/lawrence.go:50.11,52.3 1 12991
github.com/observerly/dusk/pkg/dusk/lawrence.go:64.78,80.11 7 12980
github.com/observerly/dusk/pkg/dusk/lawrence.go:85.2,92.3 3 12980
github.com/observerly/dusk/pkg/dusk/lawrence.go:80.11,82.3 1 4328
github.com/observerly/dusk/pkg/dusk/lawrence.go:101.82,111.12 5 0
github.com/observerly/dusk/pkg/dusk/lawrence.go:116.2,121.3 2 0
github.com/observerly/dusk/pkg/dusk/lawrence.go:111.12,113.3 1 0
github.com/observerly/dusk/pkg/dusk/lawrence.go:130.62,144.2 5 25984
github.com/observerly/dusk/pkg/dusk/lawrence.go:152.58,160.2 3 12996
github.com/observerly/dusk/pkg/dusk/lawrence.go:170.70,178.14 3 12995
github.com/observerly/dusk/pkg/dusk/lawrence.go:182.2,182.11 1 12995
github.com/observerly/dusk/pkg/dusk/lawrence.go:178.14,180.3 1 0
github.com/observerly/dusk/pkg/dusk/lunar.go:32.47,37.11 2 13006
github.com/observerly/dusk/pkg/dusk/lunar.go:41.2,41.10 1 13006
github.com/observerly/dusk/pkg/dusk/lunar.go:37.11,39.3 1 16
Expand Down Expand Up @@ -178,3 +156,26 @@ github.com/observerly/dusk/pkg/dusk/transit.go:95.2,100.16 3 1
github.com/observerly/dusk/pkg/dusk/transit.go:104.2,114.8 4 1
github.com/observerly/dusk/pkg/dusk/transit.go:87.43,92.3 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:100.16,102.3 1 0
github.com/observerly/dusk/pkg/dusk/trigonometry.go:10.30,12.2 1 273687
github.com/observerly/dusk/pkg/dusk/trigonometry.go:14.30,16.2 1 194885
github.com/observerly/dusk/pkg/dusk/trigonometry.go:18.44,20.2 1 541
github.com/observerly/dusk/pkg/dusk/trigonometry.go:22.30,24.2 1 13020
github.com/observerly/dusk/pkg/dusk/trigonometry.go:26.31,28.2 1 38983
github.com/observerly/dusk/pkg/dusk/trigonometry.go:30.31,32.2 1 13017
github.com/observerly/dusk/pkg/dusk/trigonometry.go:34.31,36.2 1 1
github.com/observerly/dusk/pkg/dusk/trigonometry.go:38.36,40.2 1 25976
github.com/observerly/dusk/pkg/dusk/twilight.go:38.163,49.16 5 9
github.com/observerly/dusk/pkg/dusk/twilight.go:53.2,57.18 1 9
github.com/observerly/dusk/pkg/dusk/twilight.go:49.16,51.3 1 0
github.com/observerly/dusk/pkg/dusk/twilight.go:69.139,74.2 2 3
github.com/observerly/dusk/pkg/dusk/twilight.go:85.142,90.2 2 3
github.com/observerly/dusk/pkg/dusk/twilight.go:101.146,106.2 2 3
github.com/observerly/dusk/pkg/dusk/utils.go:15.34,17.2 1 7
github.com/observerly/dusk/pkg/dusk/utils.go:26.55,31.12 2 12986
github.com/observerly/dusk/pkg/dusk/utils.go:35.2,35.11 1 12986
github.com/observerly/dusk/pkg/dusk/utils.go:31.12,33.3 1 0
github.com/observerly/dusk/pkg/dusk/utils.go:47.84,49.2 1 4
github.com/observerly/dusk/pkg/dusk/utils.go:60.84,62.2 1 12986
github.com/observerly/dusk/pkg/dusk/utils.go:72.85,74.2 1 5
github.com/observerly/dusk/pkg/dusk/utils.go:83.57,85.2 1 1
github.com/observerly/dusk/pkg/dusk/utils.go:93.51,95.2 1 3
10 changes: 10 additions & 0 deletions pkg/dusk/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,13 @@ func GetArgumentOfLocalSiderealTimeForTransit(latitude float64, δ float64) floa
func GetAtmosphericRefraction(altitude float64) float64 {
return (1.02 / tanx(altitude+(10.3/(altitude+5.11)))) / 60
}

/*
GetRelativeAirMass()
@param altitude - is the altitude of the object in degrees
@returns the relative air mass, the ratio of absolute air masses (as defined above) at oblique incidence relative to that at zenith.
*/
func GetRelativeAirMass(altitude float64) float64 {
return 1 / sinx(altitude+(244/(165+47*math.Pow(altitude, 1.1))))
}
44 changes: 44 additions & 0 deletions pkg/dusk/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,47 @@ func TestGetAtmosphericRefraction(t *testing.T) {
t.Errorf("The atmospheric refraction must be between 0.0 and 0.5")
}
}

func TestGetRelativeAirMass(t *testing.T) {
var hz HorizontalCoordinate = ConvertEquatorialCoordinateToHorizontal(datetime, longitude, latitude, EquatorialCoordinate{RightAscension: 88.7929583, Declination: 7.4070639})

var got float64 = GetRelativeAirMass(hz.Altitude)

var want float64 = 1.046558

if math.Abs(got-want) > 0.00001 {
t.Errorf("got %f, wanted %f", got, want)
}

if got < 1 || got > 40.0 {
t.Errorf("The relative air mass must be a value bewteen 1 and approx. 40 at the observer's horizon")
}
}

func TestGetRelativeAirMassAtZenith(t *testing.T) {
var got float64 = GetRelativeAirMass(90)

var want float64 = 1.0

if math.Abs(got-want) > 0.00001 {
t.Errorf("got %f, wanted %f", got, want)
}

if got < 1 || got > 40.0 {
t.Errorf("The relative air mass must be a value bewteen 1 and approx. 40 at the observer's horizon")
}
}

func TestGetRelativeAirMassAtHorizon(t *testing.T) {
var got float64 = GetRelativeAirMass(0)

var want float64 = 38

if math.Abs(got-want) > 2 {
t.Errorf("The relative air mass must be approximately ~37 - 39 at the observer's horizon")
}

if got < 1 || got > 40.0 {
t.Errorf("The relative air mass must be a value bewteen 1 and approx. 40 at the observer's horizon")
}
}

0 comments on commit 8b5970a

Please sign in to comment.