From 9ffd04de94c953bcfb776f8e11b7a7649af6399c Mon Sep 17 00:00:00 2001 From: Zach Date: Sat, 10 Jul 2021 13:09:21 -0400 Subject: [PATCH] fix prediction specification --- packetraven/gui/base.py | 2 ++ packetraven/predicts.py | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packetraven/gui/base.py b/packetraven/gui/base.py index 8d56b5e6..9b610229 100644 --- a/packetraven/gui/base.py +++ b/packetraven/gui/base.py @@ -57,6 +57,8 @@ def __init__( }, 'ssh_tunnel': {'ssh_hostname': None, 'ssh_username': None, 'ssh_password': None}, 'prediction': { + 'prediction_start_time': None, + 'prediction_start_location': None, 'prediction_ascent_rate': None, 'prediction_burst_altitude': None, 'prediction_sea_level_descent_rate': None, diff --git a/packetraven/predicts.py b/packetraven/predicts.py index 5a7686ec..99f541fb 100644 --- a/packetraven/predicts.py +++ b/packetraven/predicts.py @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod from datetime import datetime, timedelta from enum import Enum -from typing import Any, Optional, Tuple, Union +from typing import Any, Generator, Optional, Tuple, Union from dateutil.parser import parse as parse_date import numpy @@ -13,9 +13,7 @@ from packetraven.packets.tracks import LocationPacketTrack, PredictedTrajectory from packetraven.utilities import get_logger -DEFAULT_ASCENT_RATE = 5.5 -DEFAULT_BURST_ALTITUDE = 28000 -DEFAULT_SEA_LEVEL_DESCENT_RATE = 9 +DEFAULT_FLOAT_ALTITUDE_UNCERTAINTY = 500 UTC_TIMEZONE = pytz.utc LOGGER = get_logger('predicts') @@ -375,7 +373,7 @@ def get_predictions( burst_altitude: float = None, sea_level_descent_rate: float = None, float_altitude: float = None, - float_altitude_uncertainty: float = 500, + float_altitude_uncertainty: float = None, float_duration: timedelta = None, api_url: str = None, ) -> [PredictedTrajectory]: @@ -395,6 +393,8 @@ def get_predictions( """ if start_location is not None: + if isinstance(start_location, Generator): + start_location = list(start_location) if len(start_location) == 2: start_location = (*start_location, 0) @@ -404,6 +404,9 @@ def get_predictions( if float_duration is not None and float_altitude is None: float_altitude = burst_altitude + if float_altitude_uncertainty is None: + float_altitude_uncertainty = DEFAULT_FLOAT_ALTITUDE_UNCERTAINTY + if api_url is None: api_url = PredictionAPIURL.cusf