Subsetting of datasets with 2d coordinates#12
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12 +/- ##
==========================================
- Coverage 98.85% 98.81% -0.05%
==========================================
Files 21 21
Lines 1924 2021 +97
==========================================
+ Hits 1902 1997 +95
- Misses 22 24 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
forman
left a comment
There was a problem hiding this comment.
Please also check API of xcube.core.geom for commonalities.
| return target_bbox | ||
|
|
||
|
|
||
| def bbox_overlap(source_bbox, target_bbox): |
| & (ds[y_coord] >= bbox[1]) | ||
| & (ds[y_coord] <= bbox[3]) | ||
| ) | ||
| mask = mask.load() |
There was a problem hiding this comment.
load will modify the original dataset which is not always wanted, i.e., users loose chunking. Either make it an option, but preferrably we should stay in dask world if it is a dask array. If this isn't possible, please comment in code, but anyway, use DataArray.compute() or DataArray.values to not modify the original dataset.
There was a problem hiding this comment.
Keeping it in dask array, will load the coordinates twice in
rows = np.any(mask, axis=1)
cols = np.any(mask, axis=0)
also when this is implemented in dask. I therefore wanted to specifically load the mask and get the indices using purely numpy.
I change to mask = mask.values, since the array is used in numpy functions only. Further, I added a comment into the code.
There was a problem hiding this comment.
You should add required type aliases from constants so the documentation can refer to them.
There was a problem hiding this comment.
I looked at it shortly. I will not be able to work on this this week. I put it on my list and will merge this module with the utils.py in xcube-resampling in the next release. |
xcube_resampling.utils.clip_dataset_by_bboxto support datasets with2D coordinates. This function is also used internally by
xcube_resampling.rectify.rectify_dataset.reproject_bbox, a utility to reproject a bounding box from one CRS to another.bbox_overlap, a utility that computes the fraction of the source bounding boxoverlapped by the target bounding box.
Closes Implent subsetting of a irregular dataset #3
Checklist:
docs/CHANGES.md