-
Notifications
You must be signed in to change notification settings - Fork 15
Conversation
Original extents information is preserved in subset_spatial implementation if a tuple or a string giving four values is used for PolygonLike. Plotting extents are fixed accordingly. Closes #541
Switch the dataset implementations to use the new spatial subsetting implementation letting the user select and retrieve 'long' rectangles.
Don't create a dis-joint longitude when making subsets over anti-meridian. Cate framework (making a workflow) relays on equi-distant longitude.
Adjust attributes in ds implementations using the common utility function to ensure correct extents being used when subsetting over the antimeridian. Fix subset tests
Let the user use complex polygons that cross anti-meridian if masking is False. Crop the dataset before masking.
A drastic improvement in performance from 4s -> 0.1s Fixes #508
Switch plotting to using meshgrid(plot pixels) instead of making a contour plot. Pad the subset bounding box to include crossed pixels
When an arbitrary polygon is provided as input to subset_spatial() and mask==True, the resulting dataset will feature all pixels that are crossed by the given polygon.
Add tests for new edge cases, clean-up implementation from debug messages
Codecov Report
@@ Coverage Diff @@
## master #563 +/- ##
=========================================
Coverage ? 76.65%
=========================================
Files ? 78
Lines ? 11278
Branches ? 0
=========================================
Hits ? 8645
Misses ? 2633
Partials ? 0
Continue to review full report at Codecov.
|
Thanks Janis. What a PR. Could you next time please limit PRs to one per issue, otherwise review takes too much time. |
|
||
# Validate the bounding box | ||
if (not (-90 <= lat_min <= 90)) or \ | ||
(not (-90 <= lat_max <= 90)) or \ | ||
(not (-180 <= lon_min <= 180)) or \ | ||
(not (-180 <= lon_max <= 180)): | ||
raise ValueError('Provided polygon extent outside of geospatial' | ||
raise ValueError('Provided polygon extends outside of geospatial' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use "extent", see http://www.dictionary.com/browse/extent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah... I don't agree. :)
The depends if you want a statement, or a description. But even if it's a statement, just 'extent' would be wrong-ish. So it's either:
'The provided polygon extent is outside of bounds'
Or with a verb (http://www.dictionary.com/browse/extend)
'The provided polygon extends outside of bounds'
Sorry for the PR being so big feature wise. It's just that the issues were very interconnected. Forgot to update CHANGES.md... Doing it now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, looks good!
@kbernat It'd be cool if you can take a look at the changes this brings to If you're too busy today, I'll merge it anyway at the end of day and help you fix things in case this messes anything up (it shouldn't). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job!
Quite important changes to
subset_spatial_impl
. Also some rather minor changes inds
implementations to make sure we use the same implementation methods for the same tasks.Closes #541
We can now select as well as plot 'long' polygons. Using explicit coordinates instead of polygons should now 'always' work as expected.
Closes #508
Performance of
subset_spatial()
is dramatically improved. Non-masked polygons will always use xarray selection machinery, Masked polygons first subset the dataset to polygon extents and then performs fast masking.Closes #560
subset_spatial()
now selects all pixels crossed by a given polygon. Both when xarray select is used, as well as with masking enabled.Closes #507
subset_spatial()
Now works with polygons smaller than pixels. Selecting either a single pixel, or in case it includes a pixel vertice or edge - crossed pixels. It also works when the provided dataset contains only a single pixel. Ifsubset_spatial()
is invoked with a polygon that does not cross the spatial extents of the given dataset, it will raise an appropriate error message.Closes #559
plot_map()
now by default produces a 'pixel' instead of a 'contour' plot. It is still possible to plot contours, by setting the appropriate parameter to 'True'.Maybe something else I have forgotten.