meshflow.utility.geom.prepare_mesh_coords
- meshflow.utility.geom.prepare_mesh_coords(coords, cat_dim, hru_dim)[source]
Convert a DataFrame of mesh coordinates to an xarray.Dataset with specified dimension names.
- Parameters:
coords (pandas.DataFrame) – DataFrame containing mesh coordinates. Must include a column for catchment element IDs.
cat_dim (str) – Name of the column representing catchment element IDs (e.g., ‘COMID’).
hru_dim (str) – Desired name for the output dimension (e.g., ‘hru’).
- Returns:
Dataset with coordinates indexed by hru_dim.
- Return type:
xr.Dataset
Examples
>>> import pandas as pd >>> import xarray as xr >>> df = pd.DataFrame({ ... 'COMID': [1, 2], ... 'lat': [45.0, 46.0], ... 'lon': [-75.0, -76.0] ... }) >>> ds = prepare_mesh_coords(df, cat_dim='COMID', hru_dim='hru') >>> print(ds)