Skip to content

Commit

Permalink
Merge pull request #18 from OCHA-DAP/better-logging
Browse files Browse the repository at this point in the history
Fix config for testing and add dates to error handling
  • Loading branch information
hannahker authored Dec 10, 2024
2 parents f5a52aa + 3ca8737 commit 3a02418
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/config/floodscan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ forecast: False
extra_dims:
- band : str
test:
start_date: 1981-01-01
start_date: 1998-01-12
end_date: Null
iso3s: ["BDI", "NGA", "TCD"]
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"]
2 changes: 1 addition & 1 deletion src/config/imerg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ start_date: 2000-06-01
end_date: Null
forecast: False
test:
start_date: 1981-01-01
start_date: 2000-06-01
end_date: Null
iso3s: ["BDI", "NGA", "TCD"]
9 changes: 6 additions & 3 deletions src/utils/cog_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def process_floodscan(cog_name, mode):
return da_in


def stack_cogs(start_date, end_date, dataset="era5", mode="dev"):
def stack_cogs(start_date, end_date, dataset, mode="dev"):
"""
Stack Cloud Optimized GeoTIFFs (COGs) for a specified date range into an xarray Dataset.
Expand Down Expand Up @@ -173,11 +173,14 @@ def stack_cogs(start_date, end_date, dataset="era5", mode="dev"):
cogs_list = [
x.name
for x in container_client.list_blobs(name_starts_with=prefix)
if (parse_date(x.name) >= start_date) & (parse_date(x.name) <= end_date) # noqa
if (parse_date(x.name) >= start_date)
& (parse_date(x.name) <= end_date) # noqa
]

if len(cogs_list) == 0:
raise Exception("No COGs found to process")
raise Exception(
f"No COGs found to process: {start_date} to {end_date}"
)

das = []

Expand Down

0 comments on commit 3a02418

Please sign in to comment.