Skip to content

Commit

Permalink
wrap prediction retrieval in try block so a single failure doesn't fa…
Browse files Browse the repository at this point in the history
…il all predicts
  • Loading branch information
zacharyburnett committed Jul 24, 2021
1 parent 06d44ab commit 16b6457
Showing 1 changed file with 42 additions and 32 deletions.
74 changes: 42 additions & 32 deletions packetraven/predicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,27 +478,32 @@ def get_predictions(
prediction_float_end_time = None
descent_only = packet_track.falling or packet_track.ascent_rates[-1] < 0

prediction_query = CUSFBalloonPredictionQuery(
launch_site=prediction_start_location,
launch_time=prediction_start_time,
ascent_rate=prediction_ascent_rate,
burst_altitude=prediction_burst_altitude,
sea_level_descent_rate=prediction_sea_level_descent_rate,
float_altitude=float_altitude,
float_end_time=prediction_float_end_time,
api_url=api_url,
name=name,
descent_only=descent_only,
)
try:
prediction_query = CUSFBalloonPredictionQuery(
launch_site=prediction_start_location,
launch_time=prediction_start_time,
ascent_rate=prediction_ascent_rate,
burst_altitude=prediction_burst_altitude,
sea_level_descent_rate=prediction_sea_level_descent_rate,
float_altitude=float_altitude,
float_end_time=prediction_float_end_time,
api_url=api_url,
name=name,
descent_only=descent_only,
)

prediction = prediction_query.predict
prediction = prediction_query.predict

if packet_track.time_to_ground >= timedelta(seconds=0):
LOGGER.info(
f'{packet_track.name:<9} - predicted landing location: {prediction.coordinates[-1]} - https://www.google.com/maps/place/{prediction.coordinates[-1][1]},{prediction.coordinates[-1][0]}'
)
if packet_track.time_to_ground >= timedelta(seconds=0):
LOGGER.info(
f'{packet_track.name:<9} - predicted landing location: {prediction.coordinates[-1]} - https://www.google.com/maps/place/{prediction.coordinates[-1][1]},{prediction.coordinates[-1][0]}'
)

prediction_tracks[name] = prediction
prediction_tracks[name] = prediction
except Exception as error:
LOGGER.warning(
f'error retrieving prediction trajectory - {error.__class__.__name__} - {error}'
)

if all(
value is not None
Expand All @@ -521,20 +526,25 @@ def get_predictions(
else:
float_end_time = None

prediction_query = CUSFBalloonPredictionQuery(
launch_site=start_location,
launch_time=start_time,
ascent_rate=ascent_rate,
burst_altitude=burst_altitude,
sea_level_descent_rate=sea_level_descent_rate,
float_altitude=float_altitude,
float_end_time=float_end_time,
api_url=api_url,
name=name,
descent_only=False,
)
try:
prediction_query = CUSFBalloonPredictionQuery(
launch_site=start_location,
launch_time=start_time,
ascent_rate=ascent_rate,
burst_altitude=burst_altitude,
sea_level_descent_rate=sea_level_descent_rate,
float_altitude=float_altitude,
float_end_time=float_end_time,
api_url=api_url,
name=name,
descent_only=False,
)

prediction = prediction_query.predict
prediction_tracks[name] = prediction
prediction = prediction_query.predict
prediction_tracks[name] = prediction
except Exception as error:
LOGGER.warning(
f'error retrieving prediction trajectory - {error.__class__.__name__} - {error}'
)

return prediction_tracks

0 comments on commit 16b6457

Please sign in to comment.