Bbox forcings def - #235
Conversation
This PR sets the number of workers based on either an env variable configuration fix or via command line
Just applied black formatter to PEP 8 compliance
Raw forcings can be clipped by a custom bbox (with CRS definition if needed). If the bbox is smaller than the catchment's bbox, it will force to use catchment's bbox to avoid issues with the zonal statistics process
saving the raw forcing was failing while using Dask multiprocessor
quinnylee
left a comment
There was a problem hiding this comment.
Successfully ran the new bounding box feature with uv run cli -i cat-1555522 -sfr --start 2022-01-01 --end 2022-01-02 --source aorc --bbox -100 40 -90 35
Interesting feature idea! Overall I think it can get included, but the PR's scope is too large, since it also includes some dask changes.
Also, please update the README with documentation on the new CLI flags. Tests would also be nice
| try: | ||
| tol_x = abs(float(cached_data.x.values[1] - cached_data.x.values[0])) | ||
| tol_y = abs(float(cached_data.y.values[1] - cached_data.y.values[0])) | ||
| except (IndexError, ValueError): |
There was a problem hiding this comment.
When would these exceptions show up? When the cached data is a 1x1 grid?
There was a problem hiding this comment.
Exactly, if the cached area was small enough. This is unlikely to happen due to the NWM and AORC pixel size, but there are divides small enough to trigger it (for example, cat-108690 with an area of 0.001799 km^2)
There was a problem hiding this comment.
Ok cool! A clarifying comment there would be great!
Addition of `--bbox`, `--bbox_crs` and `--dask-workers` to documentation
|
Documentation added. I will let you know after I add the tests |
New feature: bbox definition for raw forcings download
Context: evaluation of storm-displacement scenarios using NGIAB. Since storm displacement is part of the analysis, one way to generate new scenarios is to displace one or all forcings (here using NWM or AORC data sources) as a way to displace a storm spatially via affine transformation plus any interpolation method to compute the new pixel values. Since the bounding box of the raw forcing equals the polygon bounding box, using current library functions could lead to some gaps in the borders.
The approach overcomes this limitation by taking a larger bbox like:
Schematically, the change looks like:
New features:
The CLI incorporates two new arguments:
--bbox: min, ymin, xmax and ymax coordinates of the custom boundary box to download. By default, the boundary box CRS is WGS84 geographical (EPSG:4326).--bbox_crs: EPSG code to define the CRS of the bounding boxImportant note: if the custom bbox is smaller than the vector's bbox, a
ValueErrorwill raise (key function here:bbox_contains)How it was implemented
By setting the bounds for
clip_dataset_to_boundsfunction.Testing
Just add the custom bbox and the CRS to the command line: