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

Floodscan stats #11

Merged
merged 28 commits into from
Nov 15, 2024
Merged

Floodscan stats #11

merged 28 commits into from
Nov 15, 2024

Conversation

hannahker
Copy link
Collaborator

@hannahker hannahker commented Oct 24, 2024

WIP to generate raster stats for new Floodscan COG outputs. Since the Floodscan COGs include bands for both SFED and MFED data, I've generalized a bunch of functionality initially developed to handle the SEAS5 leadtime dimension. With these changes, the raster stats pipeline should be able to handle any generic 4th dimension (eg. band or leadtime) coming from the input data. To properly create the Postgres table, this dimension just needs to be specified in the dataset's config.yml file (see the extra_dims property).

To do:

  • Handle the fact that Floodscan data only covers Africa. I think we'll want to add a new boolean column (could just call it floodscan) to the iso3 table, which will tell us which ISO3s are covered. So any future datasets that have non-global coverage could get their own similar column.
  • Rename the band dimension. This is currently just being pulled from the source COG, where values are either 1 or 2. We need to map these to SFED and MFED so that the output table is more informative.
  • SEAS5 regression testing. Some of these changes may impact the SEAS5 pipeline, so we need to do some validation to make sure that is still working appropriately.

src/utils/cog_utils.py Outdated Show resolved Hide resolved
@hannahker hannahker marked this pull request as ready for review November 14, 2024 19:40
"""Test basic upsampling of a 2D dataset."""
target_res = 0.5 # Upsample from 1.0 to 0.5 degrees
result = upsample_raster(simple_dataset, resampled_resolution=target_res)
result = upsample_raster(dataset_with_time, resampled_resolution=target_res)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good fix!

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"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a nice way to do this!

dim = next(iter(extra_dim))
if extra_dim[dim] == "str":
parsed_extra_dims[dim] = VARCHAR
else:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, we'll probably want to have other data types, but can leave as is for now

@@ -9,7 +9,7 @@ def cli_args():
parser.add_argument(
"dataset",
help="Dataset for which to calculate raster stats",
choices=["seas5", "era5", "imerg"],
choices=["seas5", "era5", "imerg", "floodscan"],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also as discussed, in the future it'd be good to think about how we can avoid the hard-coding of each dataset (since this happens in numerous places throughout the code). Although really more of a note for myself since I set it up this way...


for dataset in pipelines:
config = load_pipeline_config(dataset)
if "coverage" in config:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be worth adding at least a comment in here to remind ourselves that we're assuming that the coverage is specified in ISO3 values.

@hannahker
Copy link
Collaborator Author

@isatotun looks good to merge to me!

@isatotun isatotun merged commit 8c2c576 into main Nov 15, 2024
1 check passed
@hannahker hannahker deleted the floodscan-stats branch November 28, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants