herbie.accessors.HerbieAccessor#

class herbie.accessors.HerbieAccessor(xarray_obj)[source]#

Accessor for xarray Datasets opened with Herbie.

__init__(xarray_obj)[source]#

Methods

__init__(xarray_obj)

nearest_points(points[, names, verbose])

Get the nearest latitude/longitude points from a xarray Dataset.

plot([ax, common_features_kw, vars])

Plot data on a map.

Attributes

center

Return the geographic center point of this dataset.

crs

Cartopy coordinate reference system (crs) from a cfgrib Dataset.

polygon

Get a polygon of the domain boundary.

Methods:

__init__(xarray_obj)

nearest_points(points[, names, verbose])

Get the nearest latitude/longitude points from a xarray Dataset.

plot([ax, common_features_kw, vars])

Plot data on a map.

Attributes:

center

Return the geographic center point of this dataset.

crs

Cartopy coordinate reference system (crs) from a cfgrib Dataset.

polygon

Get a polygon of the domain boundary.

__init__(xarray_obj)[source]#
property center#

Return the geographic center point of this dataset.

property crs#

Cartopy coordinate reference system (crs) from a cfgrib Dataset.

Projection information is from the grib2 message for each variable.

Parameters:

ds (xarray.Dataset) – An xarray.Dataset from a GRIB2 file opened by the cfgrib engine.

nearest_points(points, names=None, verbose=True)[source]#

Get the nearest latitude/longitude points from a xarray Dataset.

Parameters:
  • ds (xr.Dataset) – A Herbie-friendly xarray Dataset

  • points (tuple, list of tuples, pd.DataFrame) –

    Points to be plucked from the gridded Dataset. There are multiple objects accepted.

    1. Tuple of longitude and latitude (lon, lat) coordinate pair. 1. List of multiple (lon, lat) coordinate pair tuples. 1. Pandas DataFrame with longitude and latitude columns. Index will be used as point names, unless names is specified. 1. Shapeley Point or Points

  • names (list) – A list of names for each point location (i.e., station name). None will not append any names. names should be the same length as points.

Notes

This is much faster than my old “pluck_points” method. For matching 1,948 points: - nearest_points completed in 7.5 seconds. - pluck_points completed in 2 minutes.

TODO: Explore alternatives - Could Shapely nearest_points be used https://shapely.readthedocs.io/en/latest/manual.html#nearest-points - Or possibly scipy BallTree method.

plot(ax=None, common_features_kw={}, vars=None, **kwargs)[source]#

Plot data on a map.

Parameters:

vars (list) – List of variables to plot. Default None will plot all variables in the DataSet.

property polygon#

Get a polygon of the domain boundary.