Skip to content

Commit

Permalink
Merge pull request #127 from observerly/bugfix/dusk/GetObjectTransit
Browse files Browse the repository at this point in the history
fix: Ensure GetObjectTransit returns correct transit.maximum.
  • Loading branch information
michealroberts authored Jun 17, 2022
2 parents 3151e80 + d1e6c53 commit 587f230
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 100 deletions.
198 changes: 99 additions & 99 deletions coverage.txt
Original file line number Diff line number Diff line change
@@ -1,77 +1,10 @@
mode: atomic
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/transit.go:23.77,31.2 3 27
github.com/observerly/dusk/pkg/dusk/transit.go:42.135,43.43 1 10
github.com/observerly/dusk/pkg/dusk/transit.go:52.2,75.3 9 10
github.com/observerly/dusk/pkg/dusk/transit.go:43.43,49.3 1 0
github.com/observerly/dusk/pkg/dusk/transit.go:87.164,96.16 4 1
github.com/observerly/dusk/pkg/dusk/transit.go:100.2,105.39 3 1
github.com/observerly/dusk/pkg/dusk/transit.go:129.2,129.43 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:96.16,98.3 1 0
github.com/observerly/dusk/pkg/dusk/transit.go:105.39,108.12 2 1442
github.com/observerly/dusk/pkg/dusk/transit.go:126.3,126.25 1 1442
github.com/observerly/dusk/pkg/dusk/transit.go:108.12,116.4 1 1441
github.com/observerly/dusk/pkg/dusk/transit.go:116.9,124.4 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:141.129,142.43 1 6
github.com/observerly/dusk/pkg/dusk/transit.go:150.2,153.62 2 5
github.com/observerly/dusk/pkg/dusk/transit.go:158.2,162.3 1 5
github.com/observerly/dusk/pkg/dusk/transit.go:142.43,148.3 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:153.62,156.3 2 5
github.com/observerly/dusk/pkg/dusk/transit.go:174.134,175.43 1 7
github.com/observerly/dusk/pkg/dusk/transit.go:184.2,189.16 3 4
github.com/observerly/dusk/pkg/dusk/transit.go:193.2,203.8 4 4
github.com/observerly/dusk/pkg/dusk/transit.go:175.43,181.3 1 3
github.com/observerly/dusk/pkg/dusk/transit.go:189.16,191.3 1 0
github.com/observerly/dusk/pkg/dusk/transit.go:215.135,218.16 2 2
github.com/observerly/dusk/pkg/dusk/transit.go:222.2,222.47 1 2
github.com/observerly/dusk/pkg/dusk/transit.go:227.2,236.39 5 1
github.com/observerly/dusk/pkg/dusk/transit.go:255.2,255.20 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:218.16,220.3 1 0
github.com/observerly/dusk/pkg/dusk/transit.go:222.47,224.3 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:236.39,249.91 4 424
github.com/observerly/dusk/pkg/dusk/transit.go:249.91,251.9 2 1
github.com/observerly/dusk/pkg/dusk/transit.go:267.123,270.16 2 2
github.com/observerly/dusk/pkg/dusk/transit.go:274.2,274.47 1 2
github.com/observerly/dusk/pkg/dusk/transit.go:284.2,291.39 4 1
github.com/observerly/dusk/pkg/dusk/transit.go:310.2,315.8 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:270.16,272.3 1 0
github.com/observerly/dusk/pkg/dusk/transit.go:274.47,281.3 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:291.39,304.91 4 424
github.com/observerly/dusk/pkg/dusk/transit.go:304.91,306.9 2 1
github.com/observerly/dusk/pkg/dusk/trigonometry.go:10.30,12.2 1 285160
github.com/observerly/dusk/pkg/dusk/trigonometry.go:14.30,16.2 1 206358
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 13089
github.com/observerly/dusk/pkg/dusk/trigonometry.go:26.31,28.2 1 41274
github.com/observerly/dusk/pkg/dusk/trigonometry.go:30.31,32.2 1 15324
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/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 21
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:103.52,106.2 2 1
github.com/observerly/dusk/pkg/dusk/astrometry.go:14.52,18.12 2 16490
github.com/observerly/dusk/pkg/dusk/astrometry.go:22.2,22.11 1 16490
github.com/observerly/dusk/pkg/dusk/astrometry.go:18.12,20.3 1 3388
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 16488
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 @@ -150,26 +83,79 @@ github.com/observerly/dusk/pkg/dusk/lunar.go:855.30,857.4 1 4
github.com/observerly/dusk/pkg/dusk/lunar.go:874.106,877.16 2 2
github.com/observerly/dusk/pkg/dusk/lunar.go:881.2,884.8 1 2
github.com/observerly/dusk/pkg/dusk/lunar.go:877.16,879.3 1 0
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/astrometry.go:14.52,18.12 2 15275
github.com/observerly/dusk/pkg/dusk/astrometry.go:22.2,22.11 1 15275
github.com/observerly/dusk/pkg/dusk/astrometry.go:18.12,20.3 1 2998
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 15273
github.com/observerly/dusk/pkg/dusk/epoch.go:31.56,33.2 1 22
github.com/observerly/dusk/pkg/dusk/epoch.go:41.48,46.2 2 121602
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/transit.go:23.77,31.2 3 31
github.com/observerly/dusk/pkg/dusk/transit.go:42.135,43.43 1 12
github.com/observerly/dusk/pkg/dusk/transit.go:52.2,75.3 9 12
github.com/observerly/dusk/pkg/dusk/transit.go:43.43,49.3 1 0
github.com/observerly/dusk/pkg/dusk/transit.go:87.164,96.16 4 1
github.com/observerly/dusk/pkg/dusk/transit.go:100.2,105.39 3 1
github.com/observerly/dusk/pkg/dusk/transit.go:129.2,129.43 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:96.16,98.3 1 0
github.com/observerly/dusk/pkg/dusk/transit.go:105.39,108.12 2 1442
github.com/observerly/dusk/pkg/dusk/transit.go:126.3,126.25 1 1442
github.com/observerly/dusk/pkg/dusk/transit.go:108.12,116.4 1 1441
github.com/observerly/dusk/pkg/dusk/transit.go:116.9,124.4 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:141.129,142.43 1 7
github.com/observerly/dusk/pkg/dusk/transit.go:150.2,153.62 2 6
github.com/observerly/dusk/pkg/dusk/transit.go:158.2,162.3 1 6
github.com/observerly/dusk/pkg/dusk/transit.go:142.43,148.3 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:153.62,156.3 2 6
github.com/observerly/dusk/pkg/dusk/transit.go:174.134,175.43 1 8
github.com/observerly/dusk/pkg/dusk/transit.go:184.2,189.16 3 5
github.com/observerly/dusk/pkg/dusk/transit.go:193.2,203.8 4 5
github.com/observerly/dusk/pkg/dusk/transit.go:175.43,181.3 1 3
github.com/observerly/dusk/pkg/dusk/transit.go:189.16,191.3 1 0
github.com/observerly/dusk/pkg/dusk/transit.go:215.135,218.16 2 2
github.com/observerly/dusk/pkg/dusk/transit.go:222.2,222.47 1 2
github.com/observerly/dusk/pkg/dusk/transit.go:227.2,236.39 5 1
github.com/observerly/dusk/pkg/dusk/transit.go:255.2,255.20 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:218.16,220.3 1 0
github.com/observerly/dusk/pkg/dusk/transit.go:222.47,224.3 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:236.39,249.91 4 424
github.com/observerly/dusk/pkg/dusk/transit.go:249.91,251.9 2 1
github.com/observerly/dusk/pkg/dusk/transit.go:267.123,270.16 2 3
github.com/observerly/dusk/pkg/dusk/transit.go:274.2,274.47 1 3
github.com/observerly/dusk/pkg/dusk/transit.go:284.2,291.39 4 2
github.com/observerly/dusk/pkg/dusk/transit.go:309.2,314.8 1 2
github.com/observerly/dusk/pkg/dusk/transit.go:270.16,272.3 1 0
github.com/observerly/dusk/pkg/dusk/transit.go:274.47,281.3 1 1
github.com/observerly/dusk/pkg/dusk/transit.go:291.39,304.91 4 1639
github.com/observerly/dusk/pkg/dusk/transit.go:304.91,306.4 1 464
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 25
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:103.52,106.2 2 1
github.com/observerly/dusk/pkg/dusk/epoch.go:31.56,33.2 1 26
github.com/observerly/dusk/pkg/dusk/epoch.go:41.48,46.2 2 124040
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 15278
github.com/observerly/dusk/pkg/dusk/epoch.go:97.2,97.12 1 15278
github.com/observerly/dusk/pkg/dusk/epoch.go:93.13,95.3 1 5097
github.com/observerly/dusk/pkg/dusk/epoch.go:106.74,114.11 4 15276
github.com/observerly/dusk/pkg/dusk/epoch.go:118.2,118.17 1 15276
github.com/observerly/dusk/pkg/dusk/epoch.go:63.60,93.13 15 16493
github.com/observerly/dusk/pkg/dusk/epoch.go:97.2,97.12 1 16493
github.com/observerly/dusk/pkg/dusk/epoch.go:93.13,95.3 1 5505
github.com/observerly/dusk/pkg/dusk/epoch.go:106.74,114.11 4 16491
github.com/observerly/dusk/pkg/dusk/epoch.go:118.2,118.17 1 16491
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 @@ -182,14 +168,14 @@ github.com/observerly/dusk/pkg/dusk/epoch.go:226.77,248.12 10 3
github.com/observerly/dusk/pkg/dusk/epoch.go:252.2,252.11 1 3
github.com/observerly/dusk/pkg/dusk/epoch.go:248.12,250.3 1 0
github.com/observerly/dusk/pkg/dusk/epoch.go:262.70,267.2 2 34
github.com/observerly/dusk/pkg/dusk/epoch.go:276.95,280.13 2 21
github.com/observerly/dusk/pkg/dusk/epoch.go:284.2,284.12 1 21
github.com/observerly/dusk/pkg/dusk/epoch.go:276.95,280.13 2 25
github.com/observerly/dusk/pkg/dusk/epoch.go:284.2,284.12 1 25
github.com/observerly/dusk/pkg/dusk/epoch.go:280.13,282.3 1 0
github.com/observerly/dusk/pkg/dusk/epoch.go:294.92,312.12 9 21
github.com/observerly/dusk/pkg/dusk/epoch.go:317.2,317.13 1 21
github.com/observerly/dusk/pkg/dusk/epoch.go:321.2,324.11 2 21
github.com/observerly/dusk/pkg/dusk/epoch.go:328.2,328.21 1 21
github.com/observerly/dusk/pkg/dusk/epoch.go:312.12,314.3 1 21
github.com/observerly/dusk/pkg/dusk/epoch.go:294.92,312.12 9 25
github.com/observerly/dusk/pkg/dusk/epoch.go:317.2,317.13 1 25
github.com/observerly/dusk/pkg/dusk/epoch.go:321.2,324.11 2 25
github.com/observerly/dusk/pkg/dusk/epoch.go:328.2,328.21 1 25
github.com/observerly/dusk/pkg/dusk/epoch.go:312.12,314.3 1 25
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
Expand All @@ -209,3 +195,17 @@ 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/trigonometry.go:10.30,12.2 1 291239
github.com/observerly/dusk/pkg/dusk/trigonometry.go:14.30,16.2 1 212437
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 13105
github.com/observerly/dusk/pkg/dusk/trigonometry.go:26.31,28.2 1 42489
github.com/observerly/dusk/pkg/dusk/trigonometry.go:30.31,32.2 1 16543
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
1 change: 0 additions & 1 deletion pkg/dusk/transit.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ func GetObjectTransit(datetime time.Time, eq EquatorialCoordinate, latitude floa
// Since our object's initial direction is rising, we can assume the following comparison:
if (i > 0) && (horizontalCoordinates[i].Altitude < horizontalCoordinates[i-1].Altitude) {
transit.Maximum = &horizontalCoordinates[i-1].Datetime
break
}
}

Expand Down
24 changes: 24 additions & 0 deletions pkg/dusk/transit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,30 @@ func TestGetObjectTransit(t *testing.T) {
}
}

func TestGetObjectTransitForBetelgeuseAtHonolulu(t *testing.T) {
// timezone, _ := time.LoadLocation("Pacific/Honolulu")

var datetime time.Time = time.Date(2022, 5, 14, 0, 0, 0, 0, time.UTC)

got, err := GetObjectTransit(datetime, EquatorialCoordinate{RightAscension: 88.7929583, Declination: 7.4070639}, 19.798484, -155.300288)

if err != nil {
t.Errorf("got %v, wanted nil", err)
}

if got.Rise.After(*got.Set) {
t.Errorf("the object must rise before it sets")
}

if got.Maximum == nil {
t.Errorf("got %v, wanted a maxima time", got)
}

if got.Maximum.Before(*got.Rise) || got.Maximum.After(*got.Set) {
t.Errorf("maxima time must be between rise and set")
}
}

func TestGetObjectTransitNoRiseNoSetNoMaximum(t *testing.T) {
var datetime time.Time = time.Date(2015, 6, 6, 0, 0, 0, 0, time.UTC)

Expand Down

0 comments on commit 587f230

Please sign in to comment.