herbie.accessors.HerbieAccessor#
- class herbie.accessors.HerbieAccessor(xarray_obj)[source]#
Accessor for xarray Datasets opened with Herbie.
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
Return the geographic center point of this dataset.
Cartopy coordinate reference system (crs) from a cfgrib Dataset.
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:
Return the geographic center point of this dataset.
Cartopy coordinate reference system (crs) from a cfgrib Dataset.
Get a polygon of the domain boundary.
- 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.
Stack Overflow: https://stackoverflow.com/questions/58758480/xarray-select-nearest-lat-lon-with-multi-dimension-coordinates
MetPy Details: https://unidata.github.io/MetPy/latest/tutorials/xarray_tutorial.html?highlight=assign_y_x
- 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
longitudeandlatitudecolumns. Index will be used as point names, unlessnamesis specified. 1. Shapeley Point or Pointsnames (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.