hydromt_delft3dfm.workflows.mesh2d_refine#

hydromt_delft3dfm.workflows.mesh2d_refine(mesh2d: ~xugrid.ugrid.ugrid2d.Ugrid2d, res: float, gdf_polygon: ~geopandas.geodataframe.GeoDataFrame = None, da_sample: ~xarray.core.dataarray.DataArray = None, steps: int = 1, logger: ~logging.Logger = <Logger hydromt_delft3dfm.workflows.mesh (WARNING)>) Tuple[UgridDataArray | UgridDataset, float][source]#

Refine mesh2d by adding new nodes and faces.

If a polygon is provided, the mesh is refined within the polygon. The number of steps determines the number of times the mesh is refined when using polygon.

If a sample array is provided, the mesh is refined based on the sample array. The sample array should contain values between 0 and 1, where 0 is not refined and 1 is refined. The sample array is interpolated to the mesh2d and the mesh is refined at the locations where the sample array is larger than 0.5. The number of steps is determined by the maximum value in the sample array and the new face size based on the previous resolution of the mesh.

Parameters:
  • mesh2d (xu.Ugrid2d) – Mesh2d object to be refined.

  • gdf_polygon (gpd.GeoDataframe, optional) – Polygon to refine mesh within. Defaults to None.

  • da_sample (xr.DataArray, optional) – Sample array to refine mesh based on. Defaults to None.

  • steps (int, optional) – Number of steps to refine mesh when using polygon. Defaults to 1.

  • res (float, optional) – Resolution of the mesh used to get the minimum face size when refining with samples. Defaults to None.

Returns:

mesh2d – Refined mesh2d object.

Return type:

xu.UgridDataArray or xu.UgridDataset