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

Loading MSWEP for area small areas might result in an empty array #27

Open
maawoo opened this issue Dec 4, 2023 · 1 comment
Open
Labels
bug Something isn't working

Comments

@maawoo
Copy link
Member

maawoo commented Dec 4, 2023

from sdc.load import load_product

mswep = load_product(product="mswep", vec="site03")

bounds = (24.385, -29.124, 24.392, -29.111)
mswep.sel(longitude=slice(bounds[0], bounds[2]), latitude=slice(bounds[3], bounds[1]))

This will result in an empty DataArray:
image

This combination of .sel and using index slicing is how I've implemented it in the load_mswep function:

ds = ds.sel(longitude=slice(bounds[0], bounds[2]),
latitude=slice(bounds[3], bounds[1]))

@maawoo maawoo added the bug Something isn't working label Dec 4, 2023
@maawoo
Copy link
Member Author

maawoo commented Dec 5, 2023

Something like method='nearest' can't be used with index slicing. An alternative way to index is the following:

mswep.sel(longitude=[bounds[0], bounds[2]], 
          latitude=[bounds[3], bounds[1]], 
          method='nearest')

However, this results in duplicate latitude/longitude values, which has also been described in pydata/xarray#7042. The conclusion from this discussion is to adjust the area of interest so that it contains or is closer to a grid point (pixel center).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant