-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstarfixdata_sea_1.py
88 lines (67 loc) · 3.36 KB
/
starfixdata_sea_1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
''' Simple sample representing a trip at sea with supporting celestial navigation
© August Linnman, 2024, email: august@linnman.net
MIT License (see LICENSE file)
'''
from time import time
from starfix import Sight, SightTrip, get_representation, get_google_map_string,\
LatLonGeodetic, IntersectError, spherical_distance, km_to_nm
def main ():
''' Main body of script '''
starttime = time ()
# We are sailing from point s1 to point s2, in the Baltic Sea.
# We have a rough estimate of an initial position of 59N;18E to start with
# This estimate is used for selecting the correct intersection point on Earth.
s1_latlon = LatLonGeodetic (59, 18)
#This is the star fix for s1, the starting point
s1 = Sight ( object_name = "Sun",
set_time = "2024-06-20 06:14:38+00:00",
gha_time_0 = "269:35.2",
gha_time_1 = "284:35.1",
decl_time_0 = "23:26.2",
measured_alt = "30:51:27.1",
estimated_position = s1_latlon
)
# Point s2 is located roughly 20 nautical miles out in the sea.
# We take a sight here and get this.
s2 = Sight ( object_name = "Sun",
set_time = "2024-06-20 07:13:38+00:00",
gha_time_0 = "284:35.1",
gha_time_1 = "299:35.0",
decl_time_0 = "23:26.2",
measured_alt = "38:34:21.6"
)
# We reach s2 by applying about 175 degrees with a speed of 20 knots.
c_course = 175
speed = 20
st = SightTrip (sight_start = s1,\
sight_end = s2,\
estimated_starting_point = s1_latlon,\
course_degrees = c_course,\
speed_knots = speed)
try:
intersections, _, _ = st.get_intersections (return_geodetic=True)
except IntersectError as ve:
print ("Cannot perform a sight reduction. Bad sight data.\n" + str(ve))
print ("Check the circles! " + st.get_map_developers_string())
exit ()
endtime = time ()
taken_ms = round((endtime-starttime)*1000,2)
print ("--------- Sight Reduction --------- ")
assert isinstance (intersections, tuple)
print ("Starting point = " + str(get_representation(intersections[1],1)))
print ("End point = " + str(get_representation(intersections[0],1)))
print ("Distance travelled = " +\
str(round(km_to_nm(spherical_distance (intersections[0], intersections[1])),2)) +\
" nm")
print ("--------- Mapping --------- ")
print ("MD = " + st.get_map_developers_string ())
print ("--------- Some diagnostics --------- ")
print ("S1 radius = " + str(round(s1.get_circle(geodetic=False).get_radius (),1)))
print ("S1 GP = " + get_google_map_string(s1.gp,4))
print ("S2 radius = " + str(round(s2.get_circle(geodetic=False).get_radius (),1)))
print ("S2 GP = " + get_google_map_string(s2.gp,4))
print ("Starting point GM = " + get_google_map_string (intersections[1],4))
print ("Ending point GM = " + get_google_map_string (intersections[0],4))
print ("Time taken = " +str(taken_ms)+" ms")
if __name__ == '__main__':
main()