-
Notifications
You must be signed in to change notification settings - Fork 5
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
Bbox fails when wrapping around dataset boundaries #77
Comments
This is more of a limitation of xclim itself. The way to work around this would be to either split the box into two boxes using positive-only coordinates or to make a polygon based on those coordinates that would be fed to the |
can you include an argument 'evaluation' and appropriate handling in the beginning of the process which is doing the job for the user? |
I'm not sure if I follow you exactly, what do you mean by 'evaluation'? |
To evaluate the input setting. (The arguments or parameter) |
Clipping the data according to boundaries set with negative longitudes is an allowed case (e.g. lon0 = -80, lon1 = -73). The algorithm examines the boundaries of the data and will add the 360 degrees needed to make it consistent with the NetCDF. The issues arise when the bounding box crosses the min and max longitudes of the data (ie: 0 and 360, or -180,180 if the data is organized that way). Like I mentioned online, this subsetting method is a bit hacky. Realigning all the longitudes of a netCDF is costly (0,360 to -180,180) and while this is handled in the I can look into this today to see if I can do something similar, but the code is starting to get really spaghetti-like. I might need to add a new decorator or evaluation process to sort which subsetting algorithm to use. Not ideal. |
Hello guys. We're starting to look at the sample subsetting code from xclim with @tlogan2000 and @davidcaron. I guess problems mentionned here for a bounding box will appear for polygonal subsetting. In the short term, I'm not sure we can solve the general case but let's keep in touch. |
@tomLandry Think you could keep me in the loop on this? I wrote much of the handler logic so I can weigh in on the reasoning behind the decorators and the cases they handle. |
@tomLandry right for polygon subset its necessary to be able to handle meridian and dayline as well |
I hadn't even considered the dayline. That's a whole new can of worms. Definitely worth considering moving forward. |
For the meridian we should be able to apply the same logic as the subset.polygon ... |
To have something functionnal quickly we could simply probably call subset.poly on the bbox rectanlge when this error is raised |
How does ocgis handle this ? |
We was running in similar issues with ocgis bird-house/flyingpigeon#126 |
I think the ocgis wrapper would basically be doing this realignment of the dataset? This is pretty easy to do in xarray but somewhat slow for really big datasets (The reason for why we chose to modify the bounds args instead of the data itself). Bascially we would need to first modify/adjust the xr.dataset lon coordinate values then call a One other question would be the expected output ... |
@tlogan2000 That's exactly how it works. The region is split and treated as multiple features. At the end of the day, since they're being used to build a masking layer, it doesn't really matter if there are multiple parts/features. I'd like to see this type of functionality built into xarray directly since it's starting to feel like it's beyond the scope of xclim (calculating climate indices), but the projects to build out gdal/rasterio-like methods for xarray objects are still very new. Would it be worthwhile reopening this discussion and decide whether there's a project in particular we would want to back? (My recommendation goes to rioxarray or regionmask, but I would need to re-acquaint myself with recent changes) |
Relevant issue concerning this issue for |
Description
a bbox :
failed with:
The text was updated successfully, but these errors were encountered: