Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config for testing and add dates to error handling #18

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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