Skip to content

Commit

Permalink
Adding flag for floodscan coverage in config
Browse files Browse the repository at this point in the history
  • Loading branch information
isatotun committed Nov 12, 2024
1 parent 1416abd commit 38f2dec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/config/floodscan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ test:
start_date: 2023-12-01
end_date: 2024-01-31
iso3s: ["ETH"]
coverage: ["DZA", "AGO", "BEN", "BWA", "BFA", "BDI", "CPV", "CMR", "CAF", "TCD", "COM", "COG", "CIV", "CAP", "DJI", "EGY", "GNQ", "ERI", "SWZ", "ETH", "GAB", "GMB", "GHA", "GIN", "GNB", "KEN", "LS0", "LBR", "LBY", "MDG", "MWI", "MLI", "MRT", "MUS", "MAR", "MOZ", "NAM", "NER", "NGA", "RWA", "STP", "SEN", "SYC", "SLE", "SOM", "ZAF", "SSD", "SDN", "TGO", "TUN", "UGA", "TZA", "ZMB", "ZWE"]
22 changes: 18 additions & 4 deletions src/utils/iso3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import requests
from sqlalchemy import text

from src.config.settings import load_pipeline_config
from src.utils.cloud_utils import get_container_client
from src.utils.database_utils import create_iso3_table

Expand Down Expand Up @@ -144,6 +145,19 @@ def determine_max_adm_level(row):
return min(1, row["src_lvl"])


def load_coverage():
pipelines = ["seas5", "era5", "imerg", "floodscan"]
coverage = {}

for dataset in pipelines:
config = load_pipeline_config(dataset)
if "coverage" in config:
dataset_coverage = config["coverage"]
coverage[dataset] = dataset_coverage

return coverage


def create_iso3_df(engine):
"""
Create and populate an ISO3 table in the database with country information.
Expand Down Expand Up @@ -178,9 +192,7 @@ def create_iso3_df(engine):
)
& (df_hrp["endDate"] >= current_date) # noqa
]

# TODO add info on how to retrieve this file
floodscan_iso3_coverage = pd.read_csv("data/floodscan_iso3s.csv")["iso3"].tolist()
dataset_coverage = load_coverage()

iso3_codes = set()
for locations in df_active_hrp["locations"]:
Expand All @@ -190,7 +202,9 @@ def create_iso3_df(engine):
df["has_active_hrp"] = df["iso_3"].isin(iso3_codes)
df["max_adm_level"] = df.apply(determine_max_adm_level, axis=1)
df["stats_last_updated"] = None
df["floodscan"] = df["iso_3"].isin(floodscan_iso3_coverage)

for dataset in dataset_coverage:
df[dataset] = df["iso_3"].isin(dataset_coverage[dataset])

# TODO: This list seems to have some inconsistencies when compared against the
# contents of all polygons
Expand Down

0 comments on commit 38f2dec

Please sign in to comment.