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 downscaling large models #145

Merged
merged 14 commits into from
Nov 8, 2023
Merged

Conversation

roeldegoede
Copy link
Collaborator

Note this PR builds upon #144 and it solves issue #127

@roeldegoede roeldegoede marked this pull request as ready for review November 8, 2023 12:33
Copy link
Contributor

@DirkEilander DirkEilander left a comment

Choose a reason for hiding this comment

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

Generally this looks good to me! I've added to minor suggestions and one suggestion for future performance improvements which can perhaps be added an issue or TODO comment in the code.

with rasterio.open(dep) as src:
# Define block size
n1, m1 = src.shape
nrcb = 2000 # nr of cells in a block
Copy link
Contributor

Choose a reason for hiding this comment

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

set as argument?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good one, added an nrmax (similar as in setup_subgrid) argument.

hydromt_sfincs/utils.py Outdated Show resolved Hide resolved
# check for nan-data
if np.all(np.isnan(block_data)):
continue
# Convert row and column indices to pixel coordinates
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to do this now, but since we are working with rasterio (rather than xarray) it would make sense to also directly use the rasterio warp method rather than the raster.reproject method in _downscale_floodmap_da. I think this could provide quite a significant performance improvement. That would affect the whole block of code below this line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Interesting suggestion but let's postpone that for now. I added a TODO to the code

@roeldegoede roeldegoede merged commit cca9d19 into main Nov 8, 2023
1 of 5 checks passed
@roeldegoede roeldegoede deleted the fix_downscaling_large_models branch November 8, 2023 16:51
@roeldegoede roeldegoede linked an issue Nov 9, 2023 that may be closed by this pull request
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.

Downscaling for large rotated models
2 participants