diff --git a/cerulean_cloud/cloud_function_ais_analysis/main.py b/cerulean_cloud/cloud_function_ais_analysis/main.py index cd827862..7fb8e1e7 100644 --- a/cerulean_cloud/cloud_function_ais_analysis/main.py +++ b/cerulean_cloud/cloud_function_ais_analysis/main.py @@ -3,6 +3,7 @@ import asyncio import os +from json import loads import geopandas as gpd from shapely import wkb @@ -107,7 +108,7 @@ async def handle_aaa_request(request): slick=slick.id, coincidence_score=traj["total_score"], rank=idx + 1, - geojson_fc=single_track.to_json(), + geojson_fc=loads(single_track.to_json()), geometry=LineString( single_track["geometry"] ).wkt, diff --git a/cerulean_cloud/cloud_function_ais_analysis/utils/constants.py b/cerulean_cloud/cloud_function_ais_analysis/utils/constants.py index 8ac4627e..dbbaf2c7 100644 --- a/cerulean_cloud/cloud_function_ais_analysis/utils/constants.py +++ b/cerulean_cloud/cloud_function_ais_analysis/utils/constants.py @@ -10,8 +10,8 @@ # buffering parameters for AIS trajectories AIS_BUFFER = 5000 # buffer around GRD envelope to capture AIS -SPREAD_RATE = 2000 # meters/hour perpendicular to vessel track -BUF_START = 500 +SPREAD_RATE = 1000 # meters/hour perpendicular to vessel track +BUF_START = 100 BUF_END = BUF_START + SPREAD_RATE * TOTAL_TIME BUF_VEC = np.linspace(BUF_START, BUF_END, NUM_TIMESTEPS) diff --git a/cerulean_cloud/cloud_function_ais_analysis/utils/scoring.py b/cerulean_cloud/cloud_function_ais_analysis/utils/scoring.py index ed21fda0..455a061c 100644 --- a/cerulean_cloud/cloud_function_ais_analysis/utils/scoring.py +++ b/cerulean_cloud/cloud_function_ais_analysis/utils/scoring.py @@ -97,6 +97,7 @@ def compute_overlap_score( float: overlap score between buffered_traj and slick """ overlap_score = slick.intersection(buffered_traj).area / slick.area + # XXX this strongly benefits smaller slicks return overlap_score diff --git a/cerulean_cloud/database_client.py b/cerulean_cloud/database_client.py index cccd9e11..b8b2bf07 100644 --- a/cerulean_cloud/database_client.py +++ b/cerulean_cloud/database_client.py @@ -195,12 +195,15 @@ async def insert_slick_to_source(self, **kwargs): """add a new slick_to_source""" return await insert(self.session, db.SlickToSource, **kwargs) - async def get_slicks_without_sources_from_scene_id(self, scene_id, active=True): + async def get_slicks_without_sources_from_scene_id( + self, scene_id, min_conf=0.5, active=True + ): """ Asynchronously queries the database to fetch slicks without associated sources for a given scene ID. Args: scene_id (str): The ID of the scene for which slicks are needed. + min_conf (float): Minimum machine confidence for slicks to return. Default is 0.5. active (bool): Flag to filter slicks based on their active status. Default is True. Returns: @@ -222,6 +225,7 @@ async def get_slicks_without_sources_from_scene_id(self, scene_id, active=True): db.SlickToSource.slick == None, # noqa db.Sentinel1Grd.scene_id == scene_id, db.Slick.active == active, + db.Slick.machine_confidence > min_conf, ) ) )