Skip to content

Commit

Permalink
Merge pull request #119 from observerly/feature/dusk/GetApparentAltitude
Browse files Browse the repository at this point in the history
feat: Added GetApparentAltitude().
  • Loading branch information
michealroberts authored Jun 15, 2022
2 parents 8b5970a + 6e4cb5d commit 3690880
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 60 deletions.
121 changes: 61 additions & 60 deletions coverage.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,12 @@
mode: atomic
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
github.com/observerly/dusk/pkg/dusk/solar.go:60.74,62.2 1 27
github.com/observerly/dusk/pkg/dusk/solar.go:73.46,75.2 1 28
github.com/observerly/dusk/pkg/dusk/solar.go:83.47,88.11 2 12990
github.com/observerly/dusk/pkg/dusk/solar.go:92.2,92.10 1 12990
github.com/observerly/dusk/pkg/dusk/solar.go:88.11,90.3 1 10
github.com/observerly/dusk/pkg/dusk/solar.go:108.110,114.2 2 27
github.com/observerly/dusk/pkg/dusk/solar.go:125.146,133.16 4 3
github.com/observerly/dusk/pkg/dusk/solar.go:137.2,141.8 1 3
github.com/observerly/dusk/pkg/dusk/solar.go:133.16,135.3 1 0
github.com/observerly/dusk/pkg/dusk/solar.go:153.142,181.2 12 26
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/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 116988
github.com/observerly/dusk/pkg/dusk/epoch.go:41.48,46.2 2 116990
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 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:63.60,93.13 15 12988
github.com/observerly/dusk/pkg/dusk/epoch.go:97.2,97.12 1 12988
github.com/observerly/dusk/pkg/dusk/epoch.go:93.13,95.3 1 4587
github.com/observerly/dusk/pkg/dusk/epoch.go:106.74,114.11 4 12986
github.com/observerly/dusk/pkg/dusk/epoch.go:118.2,118.17 1 12986
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 @@ -52,23 +29,6 @@ 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 @@ -156,12 +116,62 @@ 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/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 2
github.com/observerly/dusk/pkg/dusk/utils.go:93.51,95.2 1 3
github.com/observerly/dusk/pkg/dusk/utils.go:100.52,103.2 2 1
github.com/observerly/dusk/pkg/dusk/astrometry.go:14.52,18.12 2 12985
github.com/observerly/dusk/pkg/dusk/astrometry.go:22.2,22.11 1 12985
github.com/observerly/dusk/pkg/dusk/astrometry.go:18.12,20.3 1 1795
github.com/observerly/dusk/pkg/dusk/astrometry.go:34.73,42.2 4 4
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 12983
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/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
github.com/observerly/dusk/pkg/dusk/solar.go:60.74,62.2 1 27
github.com/observerly/dusk/pkg/dusk/solar.go:73.46,75.2 1 28
github.com/observerly/dusk/pkg/dusk/solar.go:83.47,88.11 2 12990
github.com/observerly/dusk/pkg/dusk/solar.go:92.2,92.10 1 12990
github.com/observerly/dusk/pkg/dusk/solar.go:88.11,90.3 1 10
github.com/observerly/dusk/pkg/dusk/solar.go:108.110,114.2 2 27
github.com/observerly/dusk/pkg/dusk/solar.go:125.146,133.16 4 3
github.com/observerly/dusk/pkg/dusk/solar.go:137.2,141.8 1 3
github.com/observerly/dusk/pkg/dusk/solar.go:133.16,135.3 1 0
github.com/observerly/dusk/pkg/dusk/solar.go:153.142,181.2 12 26
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/trigonometry.go:10.30,12.2 1 273692
github.com/observerly/dusk/pkg/dusk/trigonometry.go:14.30,16.2 1 194890
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:22.30,24.2 1 13021
github.com/observerly/dusk/pkg/dusk/trigonometry.go:26.31,28.2 1 38984
github.com/observerly/dusk/pkg/dusk/trigonometry.go:30.31,32.2 1 13018
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
Expand All @@ -170,12 +180,3 @@ 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
11 changes: 11 additions & 0 deletions pkg/dusk/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,14 @@ func GetAtmosphericRefraction(altitude float64) float64 {
func GetRelativeAirMass(altitude float64) float64 {
return 1 / sinx(altitude+(244/(165+47*math.Pow(altitude, 1.1))))
}

/*
GetApparentAltitude()
@param altitude - is the altitude of the object in degrees
@returns the apparent altitude in degrees
*/
func GetApparentAltitude(altitude float64) float64 {
R := GetAtmosphericRefraction(altitude)
return altitude + R
}
10 changes: 10 additions & 0 deletions pkg/dusk/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,13 @@ func TestGetRelativeAirMassAtHorizon(t *testing.T) {
t.Errorf("The relative air mass must be a value bewteen 1 and approx. 40 at the observer's horizon")
}
}

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

var got float64 = GetApparentAltitude(hz.Altitude)

if math.Abs(got-hz.Altitude) > 0.0053 {
t.Errorf("got %f, wanted %f", got, hz.Altitude)
}
}

0 comments on commit 3690880

Please sign in to comment.