xarray accessor

Contents

xarray accessor#

The chm extension on the xarray object can be used access various commonly used functionality after loading a ugrid file via Uxarray.

Examples#

Provides a Dataset.chm accessor for uxarray-backed VTU/UGRID datasets. Common helpers:

  • df.chm.uxgrid_to_netcdf("mesh.nc"): export mesh scaffolding and global ids.

  • df.chm.vars_to_netcdf("all_vars.nc"): dump all variables to NetCDF, without mesh scaffolding.

  • df.chm.clip(lat=[ymin, ymax], lon=[xmin, xmax]): subset to a bounding box or supply a shapefile/geojson via shp_file_path.

  • df.chm.regrid(dxdy=0.01): bilinear regrid face-centered variables to a structured lat/lon grid (single-node meshes only).

Run accessor methods from Python after loading data with xarray/uxarray; this module is not a standalone CLI.

Accessor#

CHM.xarray_accessor.GeoAccessor.uxgrid_to_netcdf(outpath)

Export mesh topology and global IDs from an uxarray dataset to NetCDF.

CHM.xarray_accessor.GeoAccessor.vars_to_netcdf(outpath)

Write all variables from the dataset (excluding mesh scaffolding) to NetCDF.

CHM.xarray_accessor.GeoAccessor.clip([lat, ...])

Subset face-centered variables to a lat/lon bounding box or a geometry extent.

CHM.xarray_accessor.GeoAccessor.regrid([...])

Regrid face-centered variables to a structured grid via uxarray bilinear remap.