From 95f525ef005b203456fed14a7f26f62d299a0b9c Mon Sep 17 00:00:00 2001 From: Chris Leaman Date: Mon, 4 Mar 2019 15:44:59 +1100 Subject: [PATCH] Add better error detection when calculating slope from profile --- src/analysis/forecast_twl.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/analysis/forecast_twl.py b/src/analysis/forecast_twl.py index 23ec730..c4c84bf 100644 --- a/src/analysis/forecast_twl.py +++ b/src/analysis/forecast_twl.py @@ -337,10 +337,16 @@ def slope_from_profile( ] if len(end_point_btm) == 0: # If there doesn't seem to be an intersection seaward of the top elevation, return none. + logger.warning("No intersections found seaward of top elevation") return None else: end_points[end_type]["x"] = end_point_btm[0] + # Ensure that top point is landward of bottom point + if end_points["top"]["x"] > end_points["btm"]["x"]: + logger.warning("Top point is not landward of bottom point") + return None + if method == "end_points": x_top = end_points["top"]["x"] x_btm = end_points["btm"]["x"]