def test_subpoint_with_wrong_center(ts, angle): t = ts.utc(2020, 12, 31) p = Barycentric([0,0,0], t=t) with assert_raises(ValueError, 'a geographic subpoint can only be' ' calculated for positions measured from 399, the center' ' of the Earth, but this position has center 0'): wgs84.subpoint(p)
def test_subpoint_with_wrong_center(ts, angle): t = ts.utc(2020, 12, 31) p = Barycentric([0, 0, 0], t=t) with assert_raises( ValueError, 'you can only calculate a geographic' ' position from a position which is geocentric' ' .center=399., but this position has a center of 0'): wgs84.subpoint(p)
def test_latlon_and_subpoint_methods(ts, angle): t = ts.utc(2020, 11, 3, 17, 5) g = wgs84.latlon(angle, 2 * angle, elevation_m=1234.0) pos = g.at(t) def check_lat(lat): assert abs(g.latitude.mas() - lat.mas()) < 0.1 def check_lon(lon): assert abs(g.longitude.mas() - lon.mas()) < 0.1 def check_height(h): assert abs(g.elevation.m - h.m) < 1e-7 lat, lon = wgs84.latlon_of(pos) check_lat(lat) check_lon(lon) height = wgs84.height_of(pos) check_height(height) g = wgs84.geographic_position_of(pos) check_lat(g.latitude) check_lon(g.longitude) check_height(g.elevation) g = wgs84.subpoint(pos) # old deprecated method name check_lat(g.latitude) check_lon(g.longitude) check_height(g.elevation) g = wgs84.subpoint_of(pos) check_lat(g.latitude) check_lon(g.longitude) assert g.elevation.m == 0.0
def getLonLatAlt(self): """Get longitude, latitude, and altitude """ pv_list = self.getPV() subpoint = wgs84.subpoint(pv_list[0]) print("Longitude: {}".format(subpoint.longitude)) print("Latitude: {}".format(subpoint.latitude)) print("Altitude (in kilometers): {}".format(subpoint.elevation.km))
def test_wgs84_round_trip_with_polar_motion(ts, angle): t = ts.utc(2018, 1, 19, 14, 37, 55) ts.polar_motion_table = [0.0], [0.003483], [0.358609] top = wgs84.latlon(angle, angle, elevation_m=0.0) p = top.at(t) b = wgs84.subpoint(p) error_degrees = abs(b.latitude.degrees - angle) error_mas = 60.0 * 60.0 * 1000.0 * error_degrees assert error_mas < 0.1 error_degrees = abs(b.longitude.degrees - angle) error_mas = 60.0 * 60.0 * 1000.0 * error_degrees assert error_mas < 0.1
def test_wgs84_subpoint(ts, angle): t = ts.utc(2018, 1, 19, 14, 37, 55) # An elevation of 0 is more difficult for the routine's accuracy # than a very large elevation. top = wgs84.latlon(angle, angle, elevation_m=0.0) p = top.at(t) b = wgs84.subpoint(p) error_degrees = abs(b.latitude.degrees - angle) error_mas = 60.0 * 60.0 * 1000.0 * error_degrees assert error_mas < 0.1 error_degrees = abs(b.longitude.degrees - angle) error_mas = 60.0 * 60.0 * 1000.0 * error_degrees assert error_mas < 0.1
def subpoint(self, target: CelestialObject, time: Time) -> GeographicPosition: return wgs84.subpoint( self.earth.position.at(time).observe(target.position))
print("ISS (ZARYA) catalog #25544 \nepoch 2021-01-15 06:17:01 UTC") #print(satellite.epoch.utc_jpl()) ts = load.timescale() t = ts.now() # datetime object containing current date and time now = datetime.now() dt_string = now.strftime("%d/%m/%Y %H:%M:%S") print() print("date and time =", dt_string) geocentric = satellite.at(t) #print(geocentric.position.km) subpoint = wgs84.subpoint(geocentric) print(subpoint) print('Latitude:', subpoint.latitude) print('Longitude:', subpoint.longitude) print('Elevation (m):', int(subpoint.elevation.m)) print() #(z, e, n) = LLtoUTM(23,subpoint.latitude, subpoint.longitude) me = wgs84.latlon(48.873459, 2.358040) difference = satellite - me #print(difference) topocentric = difference.at(t)
from skyfield.api import EarthSatellite, N, W, wgs84, load ts = load.timescale() t = ts.now() line1 = '1 25544U 98067A 14020.93268519 .00009878 00000-0 18200-3 0 5082' line2 = '2 25544 51.6498 109.4756 0003572 55.9686 274.8005 15.49815350868473' boston = wgs84.latlon(42.3583 * N, 71.0603 * W, elevation_m=43) satellite = EarthSatellite(line1, line2, name='ISS (ZARYA)') # Geocentric geometry = satellite.at(t) # Geographic point beneath satellite subpoint = wgs84.subpoint(geometry) latitude = subpoint.latitude longitude = subpoint.longitude elevation = subpoint.elevation # Topocentric difference = satellite - boston geometry = difference.at(t)
def main(): # Starlink data can be corrupted, let double_scalar warnings go unnoticed warnings.filterwarnings("ignore") ts = load.timescale() t = ts.now() max_range = int(input("Enter the air distance in km: ")) g = nx.Graph() kml = simplekml.Kml() kml_entries = [] get_user_input() starlink_url = 'http://www.celestrak.com/NORAD/elements/starlink.txt' satellites = load.tle_file(starlink_url) # distance between ground and satellite for satellite in satellites: # print(satellite) # prints more info on the satellite if satellite.name != "FALCON 9 DEB": # We don't want to get info about FALCON 9 # Geocentric geometry = satellite.at(t) # Geographic point beneath satellite subpoint = wgs84.subpoint(geometry) latitude = subpoint.latitude longitude = subpoint.longitude satellite_info = { "name": satellite.name, "latitude": latitude.degrees, "longitude": longitude.degrees } kml_entries.append(satellite_info) dist1 = calculate_distance(start_point, satellite_info) dist2 = calculate_distance(end_point, satellite_info) if dist1 < max_range: g.add_edge(start_point["name"], satellite_info["name"], weight=dist1) if dist2 < max_range: g.add_edge(end_point["name"], satellite_info["name"], weight=dist2) # distance between two earth satellite for i in range(0, len(satellites)): for j in range(i + 1, len(satellites) - 1): if satellites[i].name != "FALCON 9 DEB" and satellites[ j].name != "FALCON 9 DEB": distance = (satellites[i].at(t) - satellites[j].at(t)).distance().km if distance < max_range: g.add_edge(satellites[i].name, satellites[j].name, weight=distance) pos = nx.spring_layout(g) # This option can add satellites name into the graph # nx.draw(g, pos, node_color='b', with_labels = True, font_size=10) nx.draw(g, pos, node_color='b') # draw path in red path = nx.shortest_path(g, source="Start Point", target="End Point") print(path) # Generate KML for Google Earth kml_coords = [] kml_coords.append((start_point["longitude"], start_point["latitude"])) for point in path[1:-1]: kml_entry = get_kml_entry(satellite_name=point, kml_entries=kml_entries) kml_coords.append((kml_entry["longitude"], kml_entry["latitude"])) kml_coords.append((end_point["longitude"], end_point["latitude"])) kml.newlinestring(name="Path", description="Shortest path via satellites", coords=kml_coords) kml.save('google_earth_data.kml') path_edges = list(zip(path, path[1:])) nx.draw_networkx_nodes(g, pos, nodelist=path, node_color='r', node_size=400) nx.draw_networkx_edges(g, pos, edgelist=set(path_edges), edge_color='r', width=10) plt.axis('equal') plt.show()