UXARRAY / uxarray

Xarray extension for unstructured climate and global weather data analysis and visualization.
https://uxarray.readthedocs.io/
Apache License 2.0
158 stars 32 forks source link

Add `UxDataset.integrate()` and `UxDataArray.integrate()` over region #526

Closed erogluorhan closed 1 month ago

erogluorhan commented 1 year ago

np.float64 UxDataset.integrate(self, [quadrature_rule, order, Grid region]) that integrates the dataset variables and np.float64 UxDataArray.integrate(self, [quadrature_rule, order, Grid region]) that integrates the data array over a region, if specified.

Note: Existing UxDataset.integrate() and UxDataArray.integrate() integrate over all the faces of the given mesh.

philipc2 commented 1 year ago

Essentially, much of our integrate and other functionality would remain unchanged, since we would need to implement a way of obtaining a "subset" of our grid.

For example

# global integral 
uxds['v1'].integrate()

# regional integral from a bounding box
uxds['v1'].bound(lon=(-80, 80), lat=(-20,20)).integrate()

# regional integral using nearest neighbors
uxds['v1'].nearest_neighbor(center=(0, 0), r=15).integrate()

Obtaining a subset of our grid while interfacing with our UxDataArray and UxDataset and Grid should be a top priority.

erogluorhan commented 10 months ago

Just an FYI: With this over-a-region functionality, the edge-faces may be expected to change to fit into the region in the newer Grid, so the subsetting implementation in PR #616 may not be sufficient for the ask here (cc @philipc2)

philipc2 commented 2 months ago

Just an FYI: With this over-a-region functionality, the edge-faces may be expected to change to fit into the region in the newer Grid, so the subsetting implementation in PR #616 may not be sufficient for the ask here (cc @philipc2)

@erogluorhan

Any new thoughts on this?

erogluorhan commented 1 month ago

Any new thoughts on this?

I think our subsetting feature works to some extent for this. I am not sure what I exactly meant with my comment on Jan 2, but I believe it was referring to the precise "trimming" of the faces around the borders of a grid, which can happen with lat-lon boxes. In any case, I think our integrate function itself would remain unchanged, and we can close this issue. Does that help?

philipc2 commented 1 month ago

Any new thoughts on this?

I think our subsetting feature works to some extent for this. I am not sure what I exactly meant with my comment on Jan 2, but I believe it was referring to the precise "trimming" of the faces around the borders of a grid, which can happen with lat-lon boxes. In any case, I think our integrate function itself would remain unchanged, and we can close this issue. Does that help?

Thanks for the clarification! I believe the case about "trimming" should be covered when we incorporate "exclusive" grid indexing. I'll close this issue!

https://github.com/UXARRAY/uxarray/issues/644