From 6c31304189d6c16f33d3a51c758ed9a377944f8b Mon Sep 17 00:00:00 2001 From: Jona Date: Thu, 19 Dec 2024 23:45:20 -0500 Subject: [PATCH] Streamline the SR checks, and add Beam Mode --- .../cloud_function_scene_relevancy/main.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/cerulean_cloud/cloud_function_scene_relevancy/main.py b/cerulean_cloud/cloud_function_scene_relevancy/main.py index 2cd9554f..6b276e10 100644 --- a/cerulean_cloud/cloud_function_scene_relevancy/main.py +++ b/cerulean_cloud/cloud_function_scene_relevancy/main.py @@ -141,16 +141,23 @@ def handle_notification(request_json, ocean_poly): for r in request_json.get("Records"): sns = r["Sns"] msg = json.loads(sns["Message"]) - scene_poly = sh.polygon.Polygon(msg["footprint"]["coordinates"][0][0]) - is_highdef = msg["id"][10] == "H" - is_vv = ( - msg["id"][15] == "V" - ) # we don't want to process any polarization other than vv XXX This is hardcoded in the server, where we look for a vv.grd file - is_oceanic = scene_poly.intersects(ocean_poly) - print(is_highdef, is_vv, is_oceanic) - if is_highdef and is_vv and is_oceanic: - filtered_scenes.append(msg["id"]) + if not (msg["id"][4:6] == "IW"): + # Check Beam Mode + # XXX This is workaround a bug in Titiler.get_bounds (404 not found) that fails if the beam mode is not IW + continue + if not (msg["id"][10] == "H"): + # Check High Definition + continue + if not (msg["id"][15] == "V"): + # Check Polarization + # XXX This is hardcoded in the server, where we look for a vv.grd file + continue + scene_poly = sh.polygon.Polygon(msg["footprint"]["coordinates"][0][0]) + if not (scene_poly.intersects(ocean_poly)): + # Check Oceanic + continue + filtered_scenes.append(msg["id"]) return filtered_scenes