API Reference#
This page provides an auto-generated summary of xugrid’s API.
Xugrid also almost completely exposes the attributes and methods of xarray DataArrays and Datasets. Refer to the Xarray documentation.
Top-level functions#
|
Open an DataArray from a file or file-like object containing a single data variable. |
|
Open and decode a dataset from a file or file-like object. |
|
Open multiple files as a single dataset. |
|
Load and decode a dataset from a Zarr store. |
Return a new object with the same shape and type as a given object. |
|
Return a new object of ones with the same shape and type as a given dataarray or dataset. |
|
Return a new object of zeros with the same shape and type as a given dataarray or dataset. |
|
|
Concatenate xarray objects along a new or existing dimension. |
|
Merge any number of xarray objects into a single Dataset as variables. |
|
Merge topology and data, partitioned along UGRID dimensions, into a single UgridDataset. |
|
Burn vector geometries (points, lines, polygons) into a Ugrid2d mesh. |
|
Break down polygons using mapbox_earcut, and create a mesh from the resulting triangles. |
|
Polygonize a UgridDataArray. |
UgridDataArray#
|
|
UGRID Accessor. |
|
|
Create a UgridDataArray from a (structured) xarray DataArray. |
|
Create a UgridDataArray from a grid and a 1D array of values. |
UgridDataset#
|
|
UGRID Accessor. |
|
|
Convert a geodataframe into the appropriate Ugrid topology and dataset. |
|
Create a UgridDataset from a (structured) xarray Dataset. |
UGRID Accessor#
These methods and attributes are available under the .ugrid
attribute of a
UgridDataArray or UgridDataset.
|
|
Assign node coordinates from the grid to the object. |
|
Assign edge coordinates from the grid to the object. |
|
Assign face coordinates from the grid to the object. |
|
|
Given names of x and y coordinates of the nodes of an object, set them as the coordinates in the grid. |
Returns the single UGRID topology in this dataset. |
|
Returns name of the single UGRID topology in this dataset. |
|
Names of all the UGRID topologies in the dataset. |
|
Mapping from names to UGRID topologies. |
|
Mapping from grid name to tuple containing |
|
Returns a tuple containing |
|
The Coordinate Reference System (CRS) represented as a |
|
Give a new name to the UGRID topology and update the associated coordinate and dimension names in the Dataset. |
|
|
Set the Coordinate Reference System (CRS) of a UGRID topology. |
|
Transform geometries to a new coordinate reference system. |
|
|
|
Select points in the unstructured grid. |
|
Rasterize all face data on 2D unstructured grids by sampling. |
Rasterize unstructured all face data on 2D unstructured grids by sampling on the x and y coordinates of |
|
Convert every grid to a periodic grid, where the rightmost boundary shares its nodes with the leftmost boundary. |
|
Convert the grid from a periodic grid (where the rightmost boundary shares its nodes with the leftmost boundary) to an aperiodic grid, where the leftmost nodes are separate from the rightmost nodes. |
|
|
Intersect a line with the grid of this data, and fetch the values of the intersected faces. |
Intersect the grid along a collection of linestrings. |
|
|
Partition a grid into a given number of parts. |
Partition a grid by labels. |
|
|
Conform this object to match the topology of another object. |
|
Convert data and topology of one facet (node, edge, face) of the grid to a geopandas GeoDataFrame. |
Convert this UgridDataset into a standard xarray.Dataset. |
|
|
Write dataset contents to a UGRID compliant netCDF file. |
|
Write dataset contents to a UGRID compliant Zarr file. |
|
This "accessor" makes operations using the UGRID topology available via the |
Assign node coordinates from the grid to the object. |
|
Assign edge coordinates from the grid to the object. |
|
Assign face coordinates from the grid to the object. |
|
Given names of x and y coordinates of the nodes of an object, set them as the coordinates in the grid. |
|
The UGRID topology of this DataArry, as a list. |
|
Name of the UGRID topology of this DataArray. |
|
Name of the UGRID topology, as a list. |
|
Mapping from name to UGRID topology. |
|
Mapping from grid name to tuple containing |
|
Returns a tuple containing |
|
The Coordinate Reference System (CRS) represented as a |
|
Give a new name to the UGRID topology and update the associated coordinate and dimension names in the DataArray. |
|
|
Set the Coordinate Reference System (CRS) of a UGRID topology. |
|
Transform geometries to a new coordinate reference system. |
|
Return a new object, a subselection in the UGRID x and y coordinates. |
|
Select points in the unstructured grid. |
|
Intersect a line with the grid of this data, and fetch the values of the intersected faces. |
Intersect the grid along a collection of linestrings. |
|
|
Partition a grid into a given number of parts. |
Partition a grid by labels. |
|
|
Rasterize unstructured grid by sampling. |
Rasterize unstructured grid by sampling on the x and y coordinates of |
|
|
Conform this object to match the topology of another object. |
Convert this grid to a periodic grid, where the rightmost boundary shares its nodes with the leftmost boundary. |
|
Convert this grid from a periodic grid (where the rightmost boundary shares its nodes with the leftmost boundary) to an aperiodic grid, where the leftmost nodes are separate from the rightmost nodes. |
|
Convert data and topology of one facet (node, edge, face) of the grid to a geopandas GeoDataFrame. |
|
Binary dilation can be used on a boolean array to expand the "shape" of features. |
|
Binary erosion can be used on a boolean array to shrink the "shape" of features. |
|
Every edge or face is given a component number. |
|
Reduces bandwith of the connectivity matrix. |
|
Fill in NaNs by interpolating. |
|
Fill in NaNs by using Laplace interpolation. |
|
Convert this UgridDataArray or UgridDataset into a standard xarray.Dataset. |
|
|
Write dataset contents to a UGRID compliant netCDF file. |
|
Write dataset contents to a UGRID compliant Zarr file. |
Snapping#
Snapping is the process of moving nodes/edges/faces to other nodes/edges/faces if within a certain range.
|
Snap neigbhoring vertices together that are located within a maximum snapping distance from each other. |
|
Snap a collection of lines to a grid. |
|
Create a dataframe required to snap line geometries to a Ugrid2d topology. |
Regridding#
Regridding is the process of converting gridded data from one grid to another grid. Xugrid provides tools for 2D and 3D regridding of structured gridded data, represented as xarray objects, as well as (layered) unstructured gridded data, represented as xugrid objects.
|
The BaryCentricInterpolator searches the centroid of every face of the target grid in the source grid. |
|
The CentroidLocatorRegridded regrids by searching the source grid for the centroids of the target grid. |
|
The OverlapRegridder regrids by computing which target faces overlap with which source faces. |
|
The RelativeOverlapRegridder regrids by computing which target faces overlap with which source faces. |
Plotting#
These methods are also available under the .ugrid.plot
attribute of a
UgridDataArray.
|
Create a contour plot of a 2D UgridDataArray. |
|
Create a filled contour plot of a 2D UgridDataArray. |
|
Image plot of 2D DataArray. |
|
None |
|
Create a pseudocolor mesh plot of a 2D UgridDataArray. |
|
None |
|
Create a surface plot of a 2D UgridDataArray. |
|
None |
UGRID1D Topology#
|
This class stores the topological data of a "1-D unstructured grid": a collection of connected line elements, such as a river network. |
1 |
|
node dimension, edge dimension. |
|
Dictionary for grid coordinates. |
|
Fill value for UGRID connectivity arrays. |
|
Start index for UGRID connectivity arrays. |
|
Number of nodes (vertices) in the UGRID topology |
|
Name of node dimension |
|
Coordinates (x, y) of the nodes (vertices) |
|
|
Given names of x and y coordinates of the nodes of an object, set them as the coordinates in the grid. |
Assign node coordinates from the grid to the object. |
|
Assign node coordinates from the grid to the object. |
|
Return the coordinates for the specified UGRID dimension. |
|
Number of edges in the UGRID topology |
|
Name of edge dimension |
|
Centroid (x,y) coordinates of every edge in the UGRID topology |
|
x-coordinate of every edge in the UGRID topology |
|
y-coordinate of every edge in the UGRID topology |
|
xmin, ymin, xmax, ymax |
|
Returns a numpy array with columns |
|
Node to edge connectivity. |
|
Node to node connectivity. |
|
|
Return the connectivity matrix for the specified UGRID dimension. |
Create a deepcopy. |
|
|
Create a new grid with all variables named according to the default naming conventions. |
|
Select based on node or edge. |
|
Select a selection of edges, based on edge centroids. |
|
Create a new UGRID1D topology for a subset of this topology. |
|
Merge grid partitions into a single whole. |
Return an array of vertices in topological order. |
|
|
Return a simplified network topology by removing all nodes that are not listed in |
|
Conform a DataArray or Dataset to match the topology of another Ugrid1D topology. |
|
Create a 1D UGRID topology from a MeshKernel Mesh1d object. |
Create if needed, and return meshkernel Mesh1d object. |
|
Create if needed, and return meshkernel MeshKernel instance. |
|
|
Set the Coordinate Reference System (CRS) of a UGRID topology. |
|
Transform geometries to a new coordinate reference system. |
|
Extract the 1D UGRID topology information from an xarray Dataset. |
|
|
|
Convert geodataframe of linestrings into a UGRID1D topology. |
|
Convert an array of shapely linestrings to UGRID1D topology. |
|
Convert UGRID topology to shapely objects. |
|
Create a UgridDataArray from this grid and a 1D array of values. |
|
Plot the edges of the mesh. |
UGRID2D Topology#
|
This class stores the topological data of a 2-D unstructured grid. |
2 |
|
node dimension, edge dimension, face_dimension. |
|
Dictionary for grid coordinates. |
|
Fill value for UGRID connectivity arrays. |
|
Start index for UGRID connectivity arrays. |
|
Number of nodes (vertices) in the UGRID topology |
|
Name of node dimension |
|
Coordinates (x, y) of the nodes (vertices) |
|
|
Given names of x and y coordinates of the nodes of an object, set them as the coordinates in the grid. |
Assign node coordinates from the grid to the object. |
|
Assign node coordinates from the grid to the object. |
|
Assign face coordinates from the grid to the object. |
|
Return the coordinates for the specified UGRID dimension. |
|
Number of edges in the UGRID topology |
|
Name of edge dimension |
|
Centroid (x,y) coordinates of every edge in the UGRID topology |
|
x-coordinate of every edge in the UGRID topology |
|
y-coordinate of every edge in the UGRID topology |
|
Return the number of faces in the UGRID2D topology. |
|
Return the name of the face dimension. |
|
Centroid (x, y) of every face. |
|
Centroid (x, y) of every face. |
|
Circumenter (x, y) of every face; only works for fully triangular grids. |
|
Area of every face. |
|
Perimeter length of every face. |
|
x-coordinate of centroid of every face |
|
y-coordinate of centroid of every face |
|
xmin, ymin, xmax, ymax |
|
Returns a numpy array with columns |
|
Returns a numpy array with columns |
|
Construct the bounding polygon of the grid. |
|
Node to node connectivity. |
|
Node to edge connectivity. |
|
Node to face connectivity. |
|
Edge to node connectivity. |
|
Face to edge connectivity. |
|
Face to face connectivity. |
|
|
Return the connectivity matrix for the specified UGRID dimension. |
Mark valid edges, by comparing face_node_connectivity and edge_node_connectivity. |
|
Get all exterior edges, i.e. edges with no other face. |
|
Get all exterior faces, i.e. faces with an unshared edge. |
|
Create a deepcopy. |
|
|
Create a new grid with all variables named according to the default naming conventions. |
Triangulate this UGRID2D topology, breaks more complex polygons down into triangles. |
|
Triangulation of the UGRID2D topology. |
|
Centroidal Voronoi tesselation of this UGRID2D topology. |
|
Triangulation of centroidal voronoi tesselation. |
|
Create a centroidal Voronoi tesselation of this UGRID2D topology. |
|
Create a circumcenter Voronoi tesselation of this UGRID2D topology. |
|
|
Reduces bandwith of the connectivity matrix. |
Find in which face the points are located, and compute the barycentric weight for every vertex of the face. |
|
|
Select based on node, edge, or face. |
|
Find selection in the UGRID x and y coordinates. |
|
Select points in the unstructured grid. |
|
Intersect a line with this grid, and fetch the values of the intersected faces. |
|
Intersect linestrings with this grid, and fetch the values of the intersected faces. |
Initializes the celltree if needed, and returns celltree. |
|
|
Find in which face points are located. |
|
Find in which face edges are located and compute the intersection with the face edges. |
|
Find which faces are located in the bounding box. |
|
Rasterize unstructured grid by sampling. |
|
Rasterize unstructured grid by sampling on the x and y coordinates. |
|
Convert this grid to a periodic grid, where the rightmost nodes are equal to the leftmost nodes. |
|
Convert this grid from a periodic grid (where the rightmost boundary shares its nodes with the leftmost boundary) to an aperiodic grid, where the leftmost nodes are separate from the rightmost nodes. |
|
Create a new UGRID1D topology for a subset of this topology. |
|
Generate partition labesl for this grid topology using METIS: KarypisLab/METIS |
|
Partition this grid topology using METIS: KarypisLab/METIS |
|
Merge grid partitions into a single whole. |
|
Conform a DataArray or Dataset to match the topology of another Ugrid2D topology. |
|
Create a 2D UGRID topology from a MeshKernel Mesh2d object. |
Create if needed, and return meshkernel Mesh2d object. |
|
Create if needed, and return meshkernel MeshKernel instance. |
|
|
Set the Coordinate Reference System (CRS) of a UGRID topology. |
|
Transform geometries to a new coordinate reference system. |
|
Extract the 2D UGRID topology information from an xarray Dataset. |
|
|
|
Convert a geodataframe of polygons to UGRID2D topology. |
|
Create a Ugrid2d topology from a structured topology axis-aligned rectilinear, rotated or (approximated) curvilinear topologies. |
|
Create a Ugrid2d topology from a structured topology based on 1D bounds. |
|
Create a Ugrid2d topology from a structured topology based on 1D intervals. |
|
Create a Ugrid2d topology from a structured topology based on 2D intervals. |
|
Convert an array of shapely polygons to UGRID2D topology. |
|
Convert UGRID topology to shapely objects. |
|
Break down polygons using mapbox_earcut, and create a mesh from the resulting triangles. |
|
Create a UgridDataArray from this grid and a 1D array of values. |
|
Plot the edges of the mesh. |
UGRID Roles Accessor#
Xarray Dataset "accessor" to retrieve the names of UGRID variables. |
|
Get the names of the topology dummy variables, marked by a CF-role of |
|
Get the names of the variables containing the UGRID connectivity data. |
|
Get the names of the coordinate variables from the topology attributes. |
|
Get the dimension names from the topology attributes and infer them from connectivity arrays or coordinates. |