From 43953340a5389a67fc9a66526f626d63e120eea7 Mon Sep 17 00:00:00 2001 From: Jona Date: Mon, 25 Nov 2024 17:16:17 -0500 Subject: [PATCH] Switch to GFW infra API from csv --- .../utils/analyzer.py | 4 ++-- notebooks/ASA_test_environment.py | 17 ++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/cerulean_cloud/cloud_function_ais_analysis/utils/analyzer.py b/cerulean_cloud/cloud_function_ais_analysis/utils/analyzer.py index ed301676..1bfca7a3 100644 --- a/cerulean_cloud/cloud_function_ais_analysis/utils/analyzer.py +++ b/cerulean_cloud/cloud_function_ais_analysis/utils/analyzer.py @@ -124,10 +124,10 @@ def __init__(self, s1_scene, **kwargs): if self.infra_gdf is None: self.infra_api_token = os.getenv("INFRA_API_TOKEN") - self.infra_gdf = self.load_infrastructure_data() + self.infra_gdf = self.load_infrastructure_data_api() self.coincidence_scores = np.zeros(len(self.infra_gdf)) - def load_infrastructure_data(self, only_oil=True): + def load_infrastructure_data_csv(self, only_oil=True): """ Loads infrastructure data from a CSV file. """ diff --git a/notebooks/ASA_test_environment.py b/notebooks/ASA_test_environment.py index 87be0c6b..4ff0575d 100644 --- a/notebooks/ASA_test_environment.py +++ b/notebooks/ASA_test_environment.py @@ -243,19 +243,13 @@ def plot_coincidence( s1_scene = get_s1_scene(slick_gdf.s1_scene_id.iloc[0]) source_types = [] - # source_types += [1] # ais + source_types += [1] # ais source_types += [2] # infra if not ( # If the last analyzer is for the same scene, reuse it analyzers and next(iter(analyzers.items()))[1].s1_scene.scene_id == s1_scene.scene_id ): - analyzers = { - s_type: ASA_MAPPING[s_type]( - s1_scene, - gfw_infra_filepath="/Users/jonathanraphael/git/cerulean-cloud/cerulean_cloud/cloud_function_ais_analysis/SAR Fixed Infrastructure 202407 DENOISED UNIQUE.csv", - ) - for s_type in source_types - } + analyzers = {s_type: ASA_MAPPING[s_type](s1_scene) for s_type in source_types} ranked_sources = pd.DataFrame(columns=["type", "st_name", "collated_score"]) for s_type, analyzer in analyzers.items(): @@ -275,12 +269,13 @@ def plot_coincidence( ] ) - if 2 in analyzers: + if 2 in analyzers.keys(): plot_coincidence(analyzers[2], slick_id) - print(ranked_sources[["type", "st_name", "collated_score"]].head()) + print( + ranked_sources[["type", "ext_id", "coincidence_score", "collated_score"]].head() + ) - print(ranked_sources.head()) # print(accumulated_sources) # %% fake_infra_gdf = generate_infrastructure_points(slick_gdf, 50000)