Functions in the toolbox module¶
(Content automatically geneated from the source code)¶
KOBBE.TOOLBOX
Various useful functions for plotting and examining the data.
- kobbe.toolbox.histogram(ds: Dataset, varnm: str, hrange: Tuple[float, float] | None = None, nbins: int = 50, return_figure: bool = False) Figure | None¶
Plot a histogram showing the distribution of a variable (1D or 2D) in a Signature dataset, with optional statistical summary.
This function generates a histogram for a specified variable in an xarray Dataset. It also displays quick statistics about the distribution, including mean, median, min, max, and standard deviation.
- Parameters:
ds (xr.Dataset) – The xarray Dataset containing the variable of interest.
varnm (str) – The name of the variable in the Dataset to plot.
hrange (Optional[Tuple[float, float]], optional) – The range of values to include in the histogram. If None, the range is determined from the data. Default is None.
nbins (int, optional) – The number of bins for the histogram. Default is 50.
return_figure (bool, optional) – If True, the function returns the matplotlib Figure object. Default is False.
- Returns:
The matplotlib Figure object if return_figure is True, otherwise None.
- Return type:
Optional[plt.Figure]
Example
>>> ds = xr.Dataset({"temperature": (["time"], np.random.randn(1000))}) >>> histogram(ds, "temperature", nbins=30)
- kobbe.toolbox.plot_ellipse_icevel(ds, lp_days: int = 5, ax: Axes | None = None, return_ax: bool = True) Axes | None¶
Plot of ice drift components (u and v) low pass filtered with a running mean of lp_days.
Showing the mean current vector, the low-pass-filtered and subsampled currents, and the semi-major and -minor axes of the variance ellipse. Args:
- ds: xarray.Dataset
The dataset containing ice drift data, specifically “UICE” and “VICE” fields.
- lp_days (int, optional):
The number of days over which to apply the low-pass filter. Default is 5 days.
- ax (matplotlib.axes.Axes, optional):
An existing matplotlib Axes to plot on. If None, a new figure and axes are created.
- return_ax (bool, optional):
If True, returns the matplotlib Axes object used for the plot. Default is True.
- Returns:
The Axes object containing the plot if return_ax is True, otherwise None.
- Return type:
Optional[plt.Axes]
- Raises:
AssertionError – If the dataset does not have the required “UICE” field.
Example
>>> ds = xr.Dataset({"UICE": ..., "VICE": ...}) >>> plot_ellipse_icevel(ds, lp_days=3)