Merge pull request #28 from dbrooke/fixes

Normalise longitude range for tawhiri predictions
pull/29/head
Mark Jessop 2021-01-28 07:15:04 +10:30 zatwierdzone przez GitHub
commit 15bb7d70c0
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 8 dodań i 0 usunięć

Wyświetl plik

@ -40,6 +40,10 @@ def get_tawhiri_prediction(
# Create RFC3339-compliant timestamp
_dt_rfc3339 = launch_datetime.isoformat()
# Normalise longitude to range 0 to 360
if launch_longitude < 0:
launch_longitude += 360
_params = {
"launch_latitude": launch_latitude,
"launch_longitude": launch_longitude,
@ -93,6 +97,10 @@ def parse_tawhiri_data(data):
for _point in _trajectory:
# Normalise longitude to range -180 to 180
if _point["longitude"] > 180:
_point["longitude"] -= 360
# Create UTC timestamp without using datetime.timestamp(), for Python 2.7 backwards compatibility.
_dt = parse(_point["datetime"])
_dt_timestamp = (_dt - _epoch).total_seconds()