You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a suggested tool to perform efficient subset of a large ugrid data set to a new ugrid (xarray) with the consistent connectivity given a bbox or polygon as an input using xugrid tool set? I would like to retain all the properties of the parent mesh such as node coordinates and connectivity and values.
something like:
new_ugrid = subset (large_input_ugrid, bbox)
Thanks.
The text was updated successfully, but these errors were encountered:
The .ugrid.sel method will return subsets with valid topologies.
Note that this currently selects by the face coordinates, which may not be what you desire. See issue #182 for a workaround (although to be clear: we should tackle it with a proper solution so it doesn't require a workaround).
Selecting by polygon can be done relatively easily, but also requires more on than step. I'll open an issue for the functionality.
For now, one could use this multi-step approach:
importxugridasxuimportgeopandasasgpd# Read a polygon into a geodataframegdf=gdp.read_file("my-polygon.shp")
# Read the ugrid file containing a single variableuda=xu.open_dataarray("my-ugrid.nc")
# Burn the vector geometry in to the unstructured topologyburned=xu.burn_vector_geometry(gdf, uda, column="id") # let's assume there's an id colum with a value of 1# Use the burned result to select only the values in the polygon, then drop the faces outside of the polygonselection=uda.where(burned==1).dropna(uda.ugrid.grid.face_dimension)
In all cases, this results in a new, consistent, geometry. In case you want to preserve the original topology, you would use .where instead and "mask" all values outside of the selection by NaN.
Hi There,
Is there a suggested tool to perform efficient subset of a large ugrid data set to a new ugrid (xarray) with the consistent connectivity given a bbox or polygon as an input using xugrid tool set? I would like to retain all the properties of the parent mesh such as node coordinates and connectivity and values.
something like:
Thanks.
The text was updated successfully, but these errors were encountered: