gerg_plotting#

A module for standardized plotting at GERG

Submodules#

Package Contents#

class gerg_plotting.Animator#

A class for creating animations (GIFs) from a sequence of images generated by a plotting function.

This class handles both in-memory and disk-based frame generation depending on the number of frames, optimizing memory usage for larger animations.

Parameters#

image_dpiint, optional

Resolution (dots per inch) for saved images, default is 300

Attributes#

plotting_functionCallable

Function used to generate each frame

param_listlist[dict]

List of parameter dictionaries for each frame

num_iterationsint

Total number of frames to generate

durationint | float

Duration of each frame in milliseconds

frameslist

List to store generated frames in memory

gif_filenamePath

Output path for the generated GIF

images_pathPath

Directory for temporary image storage

image_fileslist

List of generated image file paths

function_kwargsdict

Additional arguments for the plotting function

animate(plotting_function, param_dict, gif_filename: str, fps=24, **kwargs) None#

Create and save a GIF animation.

Parameters#

plotting_functionCallable

Function that generates each frame

param_dictdict

Dictionary of parameters for frame generation

gif_filenamestr

Output path for the GIF

fpsint, optional

Frames per second, default is 24

**kwargs

Additional arguments passed to plotting_function

duration: int | float#
frames: list#
function_kwargs: dict#
gif_filename: pathlib.Path#
image_dpi: int#
image_files: list#
images_path: pathlib.Path#
iteration_param: str#
num_iterations: int#
param_list: list[dict]#
plotting_function: Callable#
class gerg_plotting.Bathy#

Bathy class for handling bathymetry data and visualization.

Attributes#

latIterable | Variable | None

Latitude values or Variable object containing latitude data

lonIterable | Variable | None

Longitude values or Variable object containing longitude data

depthIterable | Variable | None

Depth values or Variable object containing depth data

timeIterable | Variable | None

Time values or Variable object containing temporal data

boundsBounds

Object containing spatial and vertical boundaries for the dataset.

resolution_levelfloat or int, optional

Degree resolution for coarsening the dataset, default is 5.

contour_levelsint, optional

Number of contour levels for visualization, default is 50.

land_colorlist

RGBA color values for representing land, default is [231/255, 194/255, 139/255, 1].

vminfloat or int, optional

Minimum value for the colormap, default is 0.

cmapColormap

Colormap for bathymetry visualization, default is ‘Blues’.

cbar_showbool

Whether to display a colorbar, default is True.

cbarmatplotlib.colorbar.Colorbar

Colorbar for the bathymetry visualization.

cbar_nbinsint

Number of bins for colorbar ticks, default is 5.

cbar_kwargsdict

Additional keyword arguments for the colorbar.

center_of_masstuple

Center of mass of the bathymetry data (longitude, latitude, depth).

labelstr

Label for the bathymetry data, default is ‘Bathymetry’.

add_colorbar(fig: matplotlib.figure.Figure, divider, mappable: matplotlib.axes.Axes, nrows: int) None#

Add a colorbar to the figure.

Parameters#

figmatplotlib.figure.Figure

The figure to which the colorbar is added.

dividerAxesDivider

Divider to place the colorbar appropriately.

mappablematplotlib.axes.Axes

The mappable object (e.g., image or contour plot).

nrowsint

Number of rows in the figure layout.

Returns#

matplotlib.colorbar.Colorbar

The created colorbar instance.

adjust_cmap() None#

Adjust the colormap by cropping and adding land color.

bounds: gerg_plotting.data_classes.bounds.Bounds#
cbar: matplotlib.colorbar.Colorbar#
cbar_kwargs: dict#
cbar_nbins: int#
cbar_show: bool#
property center_of_mass#

Property to compute and return center of mass.

property cmap#

Property to return adjusted colormap.

contour_levels: int#
copy()#

Creates a deep copy of the instrument object.

property depth#

Property to handle scaled depth values.

get_bathy() tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]#

Load and process bathymetry data.

Returns#

tuple of np.ndarray

Longitude, latitude, and depth values.

Raises#

ValueError

If the bounds attribute is not provided.

get_vars() list#

Gets a list of all available variables.

property label#

Property to handle label with units.

land_color: list#
property lat#

Property to handle latitude values.

property lon#

Property to handle longitude values.

resolution_level: float | int | None#
vmin: int | float#
class gerg_plotting.Bounds#

Represents geographic and depth bounds for a spatial dataset.

Attributes#

lat_minfloat | int | None

Minimum latitude of the bounds. Must be smaller than lat_max.

lat_maxfloat | int | None

Maximum latitude of the bounds.

lon_minfloat | int | None

Minimum longitude of the bounds. Must be smaller than lon_max.

lon_maxfloat | int | None

Maximum longitude of the bounds.

depth_bottomfloat | int | None

Maximum depth value (positive, in meters). Represents the bottom of the range.

depth_topfloat | int | None

Minimum depth value (positive, in meters). Represents the top of the range (e.g., surface).

vertical_scalarfloat | int | None

A scaling factor applied to depth values. Default is 1.

vertical_unitsstr | None

Units for the vertical depth values. Default is “m”.

depth_bottom: float | int | None#
depth_top: float | int | None#
lat_max: float | int | None#
lat_min: float | int | None#
lon_max: float | int | None#
lon_min: float | int | None#
vertical_scalar: float | int | None#
vertical_units: str | None#
class gerg_plotting.CoveragePlot#

Bases: Base

A class for creating and managing plots showing multiple coverage areas.

Parameters#

figFigure, optional

Matplotlib figure object.

axAxes, optional

Matplotlib axes object.

figsizetuple, optional

Size of the figure (width, height).

horizontal_paddingfloat

Padding on left and right of plot. Default is 0.25.

vertical_paddingfloat

Padding on top and bottom of plot. Default is 0.75.

xlabelslist

Labels for x-axis ticks.

ylabelslist

Labels for y-axis ticks.

cmapstr or Colormap

Colormap for coverage areas.

coverage_color_defaultstr or tuple

Default color for coverages if specified.

Attributes#

color_iteratoritertools.cycle

Iterator for cycling through colors.

coverageslist

List of Coverage objects.

gridGrid

Grid object for the plot.

plotting_kwargsdict

Default keyword arguments for plotting.

add_coverage(xrange, yrange, label=None, **kwargs)#

Add a new coverage area to the plot.

Parameters#

xrangelist or scalar

Range or single value for x-axis coverage.

yrangelist or scalar

Range or single value for y-axis coverage.

labelstr, optional

Label for the coverage area.

**kwargs

Additional keyword arguments for coverage customization.

Raises#

ValueError

If xrange and yrange are not the same length.

add_grid(show_grid: bool)#

Add grid to the plot if requested.

Parameters#

show_gridbool

Whether to show the grid.

ax: matplotlib.axes.Axes#
cmap: str | matplotlib.colors.Colormap#
color_iterator: itertools.cycle#
coverage_color()#

Get the next color for a coverage area.

Returns#

tuple or str

RGBA color tuple or specified default color.

coverage_color_default#
coverages: list[Coverage]#
custom_ticks(labels, axis: str)#

Set custom tick labels for specified axis.

Parameters#

labelslist

List of tick labels.

axisstr

Axis to customize (‘x’ or ‘y’).

fig: matplotlib.figure.Figure#
figsize: tuple#
grid: Grid#
handle_ranges(xrange, yrange)#

Convert string labels to numeric indices for plotting.

Parameters#

xrangelist

Range values for x-axis.

yrangelist

Range values for y-axis.

Returns#

tuple

Processed (xrange, yrange) with numeric values.

horizontal_padding: float#
init_figure() None#

Initialize figure and axes if not provided.

plot(show_grid=True)#

Create the complete coverage plot.

Parameters#

show_gridbool, optional

Whether to show grid lines. Default is True.

plot_coverages()#

Plot all coverage areas on the figure.

plotting_kwargs: dict#
save(filename, **kwargs)#

Save the current figure to a file.

Parameters#

filenamestr

Path to save the figure.

**kwargs

Additional keyword arguments passed to savefig.

Raises#

ValueError

If no figure exists to save.

set_padding()#

Set plot limits with padding.

set_up_plot(show_grid: bool = True)#

Configure the plot with all necessary components.

Parameters#

show_gridbool, optional

Whether to show grid lines. Default is True.

show(**kwargs)#

Display the plot.

Parameters#

**kwargs

Additional keyword arguments passed to plt.show().

vertical_padding: float#
xlabels: list#
ylabels: list#
class gerg_plotting.Data#

Represents a spatial dataset with various oceanographic or atmospheric variables.

Attributes#

latIterable | Variable | None

Latitude values or Variable object containing latitude data

lonIterable | Variable | None

Longitude values or Variable object containing longitude data

depthIterable | Variable | None

Depth values or Variable object containing depth data

timeIterable | Variable | None

Time values or Variable object containing temporal data

boundsBounds, optional

Geographic and depth bounds for the dataset

custom_variablesdict

Dictionary to store additional custom variables

temperatureIterable, Variable, or None, optional

Temperature data, in °C, with optional colormap and range specifications.

salinityIterable, Variable, or None, optional

Salinity data with optional colormap and range specifications.

densityIterable, Variable, or None, optional

Density data, in kg/m³, with optional colormap and range specifications.

uIterable, Variable, or None, optional

Zonal velocity (u-component) in m/s, with optional colormap and range specifications.

vIterable, Variable, or None, optional

Meridional velocity (v-component) in m/s, with optional colormap and range specifications.

wIterable, Variable, or None, optional

Vertical velocity (w-component) in m/s, with optional colormap and range specifications.

speedIterable, Variable, or None, optional

Speed data, derived or directly assigned, in m/s, with optional colormap and range specifications.

chlorIterable, Variable, or None, optional

Chlorophyll data, in μg/L, with optional colormap and range specifications.

cdomIterable, Variable, or None, optional

CDOM data, in ppb, with optional colormap and range specifications.

turbidityIterable, Variable, or None, optional

Turbidity data, dimensionless, with optional colormap and range specifications.

boundsBounds

Spatial bounds of the data.

add_custom_variable(variable: gerg_plotting.data_classes.variable.Variable, exist_ok: bool = False) None#

Add a custom Variable object accessible via both dot and dict syntax.

Parameters#

variableVariable

The Variable object to add

exist_okbool, optional

If True, replace existing variable if it exists, by default False

Raises#

TypeError

If provided object is not a Variable instance

AttributeError

If variable name already exists and exist_ok is False

property bounds: gerg_plotting.data_classes.bounds.Bounds#

Get or set the bounds of the data.

bounds_padding#
buoyancy_frequency: Iterable | gerg_plotting.data_classes.variable.Variable | None#
calcluate_PSD(sampling_freq, segment_length, theta_rad=None) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] | tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray]#

Calculate the power spectral density (PSD) using Welch’s method.

Parameters#

sampling_freqfloat

Sampling frequency of the data in Hz.

segment_lengthint

Length of each segment for Welch’s method.

theta_radfloat, optional

Angle of rotation in radians. Rotates the u and v components if specified.

Returns#

tuple

A tuple containing the frequency array and PSD values for the velocity components. If the vertical component (w) is available, it is also included in the tuple.

calculate_speed(include_w: bool = False) None#

Calculate the speed from velocity components.

Parameters#

include_wbool, optional

If True, includes the vertical velocity (w-component) in the speed calculation. Defaults to False.

cdom: Iterable | gerg_plotting.data_classes.variable.Variable | None#
chlor: Iterable | gerg_plotting.data_classes.variable.Variable | None#
copy()#

Creates a deep copy of the instrument object.

custom_variables: dict#
date2num() list#

Converts time values to numerical values.

density: Iterable | gerg_plotting.data_classes.variable.Variable | None#
depth: Iterable | gerg_plotting.data_classes.variable.Variable | None#
detect_bounds(bounds_padding=0) gerg_plotting.data_classes.bounds.Bounds#

Detect the geographic bounds of the data, applying padding if specified.

An intentional effect of this function:

will only calculate the bounds when self.bounds is None, so that it does not overwrite the user’s custom bounds, this will also ensure that the bounds is not repeatedly calculated unless desired, can recalculate self.bounds using a new bounds_padding value if self.bounds is set to None

The depth bounds are not affected by the bounds padding, therfore the max and min values of the depth data are used

Parameters#

bounds_paddingfloat, optional

Padding to add to the detected bounds, by default 0

Returns#

Bounds

Object containing the detected geographic and depth bounds

get_vars(have_values: bool | None = None) list#

Gets a list of all available variables.

lat: Iterable | gerg_plotting.data_classes.variable.Variable | None#
lon: Iterable | gerg_plotting.data_classes.variable.Variable | None#
oxygen: Iterable | gerg_plotting.data_classes.variable.Variable | None#
remove_custom_variable(variable_name) None#

Remove a custom variable from the instrument.

Parameters#

variable_namestr

Name of the variable to remove

salinity: Iterable | gerg_plotting.data_classes.variable.Variable | None#
speed: Iterable | gerg_plotting.data_classes.variable.Variable | None#
temperature: Iterable | gerg_plotting.data_classes.variable.Variable | None#
time: Iterable | gerg_plotting.data_classes.variable.Variable | None#
turbidity: Iterable | gerg_plotting.data_classes.variable.Variable | None#
u: Iterable | gerg_plotting.data_classes.variable.Variable | None#
v: Iterable | gerg_plotting.data_classes.variable.Variable | None#
w: Iterable | gerg_plotting.data_classes.variable.Variable | None#
class gerg_plotting.Histogram#

Bases: gerg_plotting.plotting_classes.plotter.Plotter

A class for plotting histograms from instrument data using matplotlib.

This class provides methods for creating 1D, 2D, and 3D histograms from data. Inherits from Plotter class for basic plotting functionality.

plot(var: str, fig=None, ax=None, **kwargs) None#

Plot a 1D histogram of the given variable.

Parameters#

varstr

Name of the variable to plot

figmatplotlib.figure.Figure, optional

Figure object to use for plotting

axmatplotlib.axes.Axes, optional

Axes object to use for plotting

**kwargsdict

Additional keyword arguments passed to matplotlib.pyplot.hist

plot2d(x: str, y: str, fig=None, ax=None, **kwargs) None#

Plot a 2D histogram for the x and y variables.

Parameters#

xstr

Name of the x-axis variable

ystr

Name of the y-axis variable

figmatplotlib.figure.Figure, optional

Figure object to use for plotting

axmatplotlib.axes.Axes, optional

Axes object to use for plotting

**kwargsdict

Additional keyword arguments passed to matplotlib.pyplot.hist2d

plot3d(x: str, y: str, fig=None, ax=None, **kwargs) None#

Plot a 3D surface plot based on a 2D histogram.

Parameters#

xstr

Name of the x-axis variable

ystr

Name of the y-axis variable

figmatplotlib.figure.Figure, optional

Figure object to use for plotting

axmatplotlib.axes.Axes, optional

Axes object to use for plotting

**kwargsdict

Additional keyword arguments passed to numpy.histogram2d

class gerg_plotting.MapPlot#

Bases: gerg_plotting.plotting_classes.plotter.Plotter

A class for plotting geographic data on maps using Cartopy and Matplotlib.

Parameters#

bathyBathy, optional

Bathymetric data object

grid_spacingint, optional

Spacing between gridlines in degrees, default is 1

Attributes#

scmatplotlib.collections.PathCollection

Scatter plot collection

glcartopy.mpl.gridliner.Gridliner

Gridliner for map coordinates

cbar_varmatplotlib.colorbar.Colorbar

Colorbar for plotted variable

cbar_bathymatplotlib.colorbar.Colorbar

Colorbar for bathymetry

bathy: gerg_plotting.data_classes.bathy.Bathy#
property bathy_initialized#

Check if bathymetry is properly initialized

cbar_bathy: matplotlib.colorbar.Colorbar#
cbar_var: matplotlib.colorbar.Colorbar#
property coordinate_labels#

Configure coordinate label formatting

get_color_settings(var: str | None) tuple[str | numpy.ndarray, matplotlib.colors.Colormap]#

Get color and colormap settings for specified variable.

Parameters#

varstr or None

Variable name for color mapping

Returns#

tuple

(color, cmap) where color is str or ndarray and cmap is Colormap

gl: cartopy.mpl.gridliner.Gridliner#
grid_spacing: int#
property gridlines#

Configure and return gridlines based on current settings

property map_extent#

Get map extent from data bounds

quiver(x: str = 'lon', y: str = 'lat', quiver_density: int = None, quiver_scale: float = None, grid: bool = True, show_bathy: bool = True, show_coastlines: bool = True, fig=None, ax=None) None#

Create quiver plot for vector data.

Parameters#

xstr, optional

X-axis variable name, default ‘lon’

ystr, optional

Y-axis variable name, default ‘lat’

quiver_densityint, optional

Density of quiver arrows

quiver_scalefloat, optional

Scaling factor for arrow length

gridbool, optional

Whether to show grid, default True

show_bathybool, optional

Whether to show bathymetry, default True

show_coastlinesbool, optional

Whether to show coastlines, default True

figmatplotlib.figure.Figure, optional

Figure to plot on

axmatplotlib.axes.Axes, optional

Axes to plot on

property quiver_step#

Step size for quiver plot density based on data length

sc: matplotlib.collections.PathCollection#
scatter(var: str | None = None, show_bathy: bool = True, show_coastlines: bool = True, pointsize=3, linewidths=0, grid=True, show_coords=True, fig=None, ax=None) None#

Create scatter plot of points on map.

Parameters#

varstr or None, optional

Variable name for color mapping

show_bathybool, optional

Whether to show bathymetry, default True

show_coastlinesbool, optional

Whether to show coastlines, default True

pointsizeint, optional

Size of scatter points, default 3

linewidthsint, optional

Width of point edges, default 0

gridbool, optional

Whether to show grid, default True

show_coordsbool, optional

Whether to show coordinates, default True

figmatplotlib.figure.Figure, optional

Figure to plot on

axmatplotlib.axes.Axes, optional

Axes to plot on

class gerg_plotting.ScatterPlot#

Bases: gerg_plotting.plotting_classes.plotter.Plotter

Class for creating scatter plots from Data objects.

Inherits from Plotter class for basic plotting functionality. Provides methods for various scatter plot types including T-S diagrams, hovmoller plots, and velocity vector plots.

TS(color_var=None, fig=None, ax=None, contours: bool = True, scatter_kwargs=None, contour_kwargs=None) None#

Create temperature-salinity diagram.

Parameters#

color_varstr or None, optional

Variable name for color mapping

figmatplotlib.figure.Figure, optional

Figure to plot on

axmatplotlib.axes.Axes, optional

Axes to plot on

contoursbool, optional

Whether to show sigma-theta contours, default True

scatter_kwargsdict, optional

Additional arguments to pass to scatter plot (see matplotlib.pyplot.scatter)

contour_kwargsdict, optional

Additional arguments to pass to contour plot (see matplotlib.pyplot.contour)

calculate_quiver_step(num_points, quiver_density) int#

Calculate step size for quiver plot density.

Parameters#

num_pointsint

Total number of data points

quiver_densityint

Desired density of quiver arrows

Returns#

int

Step size for data sampling

abstract cross_section(longitude, latitude) None#

Method placeholder for plotting cross-sections.

Args:

longitude: Longitude line for the cross-section. latitude: Latitude line for the cross-section.

Raises:

NotImplementedError: Indicates that the method is not yet implemented.

get_density_color_data(color_var: str) numpy.ndarray#

Get color data for density plotting.

Parameters#

color_varstr

Variable name for color data

Returns#

np.ndarray

Array of color values

hovmoller(var: str, fig=None, ax=None, **scattter_kwargs) None#

Create depth vs time plot colored by variable.

Parameters#

varstr

Variable name for color mapping

figmatplotlib.figure.Figure, optional

Figure to plot on

axmatplotlib.axes.Axes, optional

Axes to plot on

**scattter_kwargs

Additional arguments for scatter plot (see matplotlib.pyplot.scatter)

power_spectra_density(psd_freq=None, psd=None, var_name: str = None, sampling_freq=None, segment_length=None, theta_rad=None, highlight_freqs: list = None, fig=None, ax=None) None#

Create power spectral density plot.

Parameters#

psd_freqarray-like, optional

Frequency values

psdarray-like, optional

Power spectral density values

var_namestr, optional

Variable name for PSD calculation

sampling_freqfloat, optional

Sampling frequency

segment_lengthint, optional

Length of segments for PSD calculation

theta_radfloat, optional

Angle in radians

highlight_freqslist, optional

Frequencies to highlight

figmatplotlib.figure.Figure, optional

Figure to plot on

axmatplotlib.axes.Axes, optional

Axes to plot on

Raises#

ValueError

If neither PSD values nor calculation parameters are provided

quiver1d(x: str, quiver_density: int = None, quiver_scale: float = None, fig=None, ax=None) None#

Create 1D quiver plot for velocity data.

Parameters#

xstr

Variable name for x-axis

quiver_densityint, optional

Density of quiver arrows

quiver_scalefloat, optional

Scaling factor for arrow length

figmatplotlib.figure.Figure, optional

Figure to plot on

axmatplotlib.axes.Axes, optional

Axes to plot on

quiver2d(x: str, y: str, quiver_density: int = None, quiver_scale: float = None, fig=None, ax=None) None#

Create 2D quiver plot for velocity data.

Parameters#

xstr

Variable name for x-axis

ystr

Variable name for y-axis

quiver_densityint, optional

Density of quiver arrows

quiver_scalefloat, optional

Scaling factor for arrow length

figmatplotlib.figure.Figure, optional

Figure to plot on

axmatplotlib.axes.Axes, optional

Axes to plot on

scatter(x: str, y: str, color_var: str | None = None, invert_yaxis: bool = False, fig=None, ax=None, **scattter_kwargs) None#

Create scatter plot of two variables with optional color mapping.

Parameters#

xstr

Variable name for x-axis

ystr

Variable name for y-axis

color_varstr or None, optional

Variable name for color mapping

invert_yaxisbool, optional

Whether to invert y-axis

figmatplotlib.figure.Figure, optional

Figure to plot on

axmatplotlib.axes.Axes, optional

Axes to plot on

**scattter_kwargs

Additional arguments for scatter plot (see matplotlib.pyplot.scatter)

Returns#

matplotlib.collections.PathCollection

Scatter plot object

scatter3d(x: str, y: str, z: str, color_var: str | None = None, invert_yaxis: bool = False, fig=None, ax=None, **scattter_kwargs) None#

Create scatter plot of two variables with optional color mapping.

Parameters#

xstr

Variable name for x-axis

ystr

Variable name for y-axis

color_varstr or None, optional

Variable name for color mapping

invert_yaxisbool, optional

Whether to invert y-axis

figmatplotlib.figure.Figure, optional

Figure to plot on

axmatplotlib.axes.Axes, optional

Axes to plot on

**scattter_kwargs

Additional arguments for scatter plot (see matplotlib.pyplot.scatter)

Returns#

matplotlib.collections.PathCollection

Scatter plot object

tricontourf(x: str, y: str, z: str, fig=None, ax=None, levels=None)#

Create filled contour plot of irregular grid data.

Parameters#

xstr

Variable name for x-axis

ystr

Variable name for y-axis

zstr

Variable name for contour values

figmatplotlib.figure.Figure, optional

Figure to plot on

axmatplotlib.axes.Axes, optional

Axes to plot on

levelsint, optional

Number of contour levels

class gerg_plotting.ScatterPlot3D#

Bases: gerg_plotting.plotting_classes.plotter_3d.Plotter3D

make_points_3d(x: str, y: str, z: str) numpy.ndarray#

A helper to make a 3D NumPy array of points (n_points by 3)

map(var: str | None = None, show_var_cbar: bool = True, show_bathy_cbar: bool = True, show_plot=False) None#
scatter(x: str, y: str, z: str, var: str | None = None, show_var_cbar: bool = True, show_plot: bool = False) None#
property scatter_scalar_bar_defaults: dict#

Returns the default settings for the scatter plot.

class gerg_plotting.Variable#

A class representing a scientific variable with its values and visualization properties.

This class handles values arrays along with their metadata and visualization settings, providing methods for values access and label generation.

Parameters#

valuesnp.ndarray

The numerical values for the variable

namestr

Name identifier for the variable

cmapColormap, optional

Matplotlib colormap for visualization

unitsstr, optional

Units of measurement

vminfloat, optional

Minimum value for visualization scaling

vmaxfloat, optional

Maximum value for visualization scaling

labelstr, optional

Custom label for plotting

Attributes#

valuesnp.ndarray

Flat numpy array containing the variable values

namestr

Variable name identifier

cmapColormap

Colormap for visualization

unitsstr

Units of measurement

vminfloat

Minimum value for visualization

vmaxfloat

Maximum value for visualization

labelstr

Display label for plots

property attrs: list#

List of all attributes for the variable.

cmap: matplotlib.colors.Colormap#
get_attrs() list#

Get list of all attributes for the variable.

Returns#

list

List of attribute names

property label: str#

Formatted label including variable name and units if available.

name: str#
units: str#
values: numpy.ndarray#
property vmax: float#

Maximum value for visualization. Using 98th percentile for numeric data.

property vmin: float#

Minimum value for visualization, using 2nd percentile for numeric data.

gerg_plotting.data_from_csv(filename: str, mapped_variables: dict | None = None, custom_vars: str | list[str] | None = None, **kwargs)#

Create Data object from CSV file.

Parameters#

filenamestr

Path to CSV file

mapped_variablesdict, optional

Custom variable mapping

custom_varsstr | list[str], optional

Additional variable name(s) to include from DataFrame

**kwargs

Additional arguments for Data initialization

Returns#

Data

Initialized Data object

gerg_plotting.data_from_df(df: pandas.DataFrame, mapped_variables: dict | None = None, custom_vars: str | list[str] | None = None, **kwargs)#

Create Data object from DataFrame with optional custom variables.

Parameters#

dfpandas.DataFrame

Source DataFrame

mapped_variablesdict, optional

Custom variable mapping

custom_varsstr | list[str], optional

Additional variable name(s) to include from DataFrame

**kwargsdict

Additional arguments for Data initialization

Returns#

Data

Initialized Data object

gerg_plotting.data_from_ds(ds: xarray.Dataset, interp_glider: bool = False, mapped_variables: dict | None = None, custom_vars: str | list[str] | None = None, **kwargs)#

Create Data object from xarray Dataset with optional custom variables.

Parameters#

dsxarray.Dataset

Input dataset to convert

interp_gliderbool, optional

Whether to interpolate glider positions

mapped_variablesdict, optional

Dictionary mapping variable names to dataset variables

custom_varsstr | list[str], optional

Additional variable name(s) to include from Dataset

**kwargsdict

Additional arguments for Data initialization

Returns#

Data

New Data object containing the dataset variables

gerg_plotting.data_from_netcdf(filename: str, mapped_variables: dict | None = None, interp_glider: bool = False, custom_vars: str | list[str] | None = None, **kwargs)#

Create Data object from NetCDF file.

Parameters#

filenamestr

Path to NetCDF file

mapped_variablesdict or None, optional

Dictionary mapping variable names to dataset variables

interp_gliderbool, optional

Whether to interpolate glider lat/lon positions

custom_varsstr | list[str], optional

Additional variable name(s) to include from Dataset

**kwargs

Additional keyword arguments passed to Data constructor

Returns#

Data

New Data object containing the NetCDF variables

gerg_plotting.interp_glider_lat_lon(ds: xarray.Dataset) xarray.Dataset#

Interpolate all glider data variables that use m_time as their dimension.

Parameters#

dsxarray.Dataset

Dataset containing glider data

Returns#

xarray.Dataset

Dataset with all m_time variables interpolated to time dimension