Skip to content

Plots

LakePlotter

Common plots for the lake.csv output.

Creates time series plots of lake characteristics (e.g., volume, temperature, heat fluxes, etc.) on provided matplotlib Axes objects. Reads daily lake measurement data from the lake.csv file generated by running a GLM simulation.

Examples:

Plot the lake volume (m^3):

>>> from glmpy import plots
>>> import matplotlib.pyplot as plt
>>> lake = plots.LakePlotter("lake.csv")
>>> fig, ax = plt.subplots()
>>> lake.lake_volume(ax)
>>> plt.show()

Change the line colour by providing a dictionary of matplotlib plot parameters:

>>> lake = plots.LakePlotter("lake.csv")
>>> fig, ax = plt.subplots()
>>> lake.lake_volume(ax, {"color": "red"})
>>> plt.show()

__init__(lake_csv_path)

Initialise the LakePlotter with the lake.csv file.

Parameters:

Name Type Description Default
lake_csv_path str

Path to the lake.csv file generated by GLM

required

heat_balance_components(ax, daily_qsw_params={}, daily_qe_params={}, daily_qh_params={}, daily_qlw_params={})

Lake heat fluxes.

Daily line plot of four heat balance components (W/m^2): - Mean shortwave radiation - Mean latent heat - Mean sensible heat - Mean longwave radiation

Parameters:

Name Type Description Default
ax

The matplotlib Axes that the data will be plotted on.

required
daily_qsw_params Union[dict, None]

Plotting parameters for Daily Qsw. If None, nothing will be plotted. Default is {}.

{}
daily_qe_params Union[dict, None]

Plotting parameters for Daily Qe. If None, nothing will be plotted. Default is {}.

{}
daily_qh_params Union[dict, None]

Plotting parameters for Daily Qh. If None, nothing will be plotted. Default is {}.

{}
daily_qlw_params Union[dict, None]

Plotting parameters for Daily Qlw. If None, nothing will be plotted. Default is {}.

{}

Returns:

Type Description
list of Line2D

A list of lines representing the plotted data.

lake_level(ax, param_dict={})

Lake surface height.

Line plot of the lake level (m).

Parameters:

Name Type Description Default
ax Axes

The matplotlib Axes that the data will be plotted on.

required
param_dict dict

Plotting parameters that will be passed to matplotlib.axes.Axes.plot.

{}

Returns:

Type Description
list of Line2D

A list of lines representing the plotted data.

lake_surface_area(ax, param_dict={})

Lake surface area.

Line plot of the lake surface area (m^2).

Parameters:

Name Type Description Default
ax Axes

The matplotlib Axes that the data will be plotted on.

required
param_dict dict

Plotting parameters that will be passed to matplotlib.axes.Axes.plot.

{}

Returns:

Type Description
list of Line2D

A list of lines representing the plotted data.

lake_temp(ax, min_temp_params={}, max_temp_params={})

Min./max. temperature within lake.

Line plot of the minimum and maximum temperature (celsius) within the lake.

Parameters:

Name Type Description Default
ax Axes

The matplotlib Axes that the data will be plotted on.

required
min_temp_params Union[dict, None]

Plotting parameters for Min Temp. If None, nothing will be plotted. Default is {}.

{}
max_temp_params Union[dict, None]

Plotting parameters for Max Temp. If None, nothing will be plotted. Default is {}.

{}

Returns:

Type Description
list of Line2D

A list of lines representing the plotted data.

lake_volume(ax, param_dict={})

Lake volume.

Line plot of the lake volume (m^3).

Parameters:

Name Type Description Default
ax Axes

The matplotlib Axes that the data will be plotted on.

required
param_dict dict

Plotting parameters that will be passed to matplotlib.axes.Axes.plot.

{}

Returns:

Type Description
list of Line2D

A list of lines representing the plotted data.

surface_temp(ax, param_dict={})

Lake surface temperature.

Line plot of the lake surface temperature (celsius).

Parameters:

Name Type Description Default
ax Axes

The matplotlib Axes that the data will be plotted on.

required
param_dict dict

Plotting parameters that will be passed to matplotlib.axes.Axes.plot.

{}

Returns:

Type Description
list of Line2D

A list of lines representing the plotted data.

water_balance(ax, param_dict={})

Lake water balance.

Line plot of the net water balance (m^3/day). Calculated by: Rain + Snowfall + Local Runoff + Tot Inflow Vol + Evaporation - Tot Outflow Vol.

Parameters:

Name Type Description Default
ax Axes

The matplotlib Axes that the data will be plotted on.

required
param_dict dict

Plotting parameters that will be passed to matplotlib.axes.Axes.plot.

{}

Returns:

Type Description
list of Line2D

A list of lines representing the plotted data.

water_balance_components(ax, tot_inflow_vol_params={}, tot_outflow_vol_params={}, overflow_vol_params={}, evaporation_params={}, rain_params={}, local_runoff_params={}, snowfall_params={})

Lake water balance components.

Daily line plot of the water balance components (m^3/day): - Total inflow - Total outflow - Overflow - Evaporation - Rain - Local runoff - Snowfall

Parameters:

Name Type Description Default
ax Axes

The matplotlib Axes that the data will be plotted on.

required
tot_inflow_vol_params Union[dict, None]

Plotting parameters for Tot Inflow Vol. If None, nothing will be plotted. Default is {}.

{}
tot_outflow_vol_params Union[dict, None]

Plotting parameters for Tot Outflow Vol. If None, nothing will be plotted. Default is {}.

{}
overflow_vol_params Union[dict, None]

Plotting parameters for Overflow Vol. If None, nothing will be plotted. Default is {}.

{}
evaporation_params Union[dict, None]

Plotting parameters for Evaporation. If None, nothing will be plotted. Default is {}.

{}
rain_params Union[dict, None]

Plotting parameters for Rain. If None, nothing will be plotted. Default is {}.

{}
local_runoff_params Union[dict, None]

Plotting parameters for Local Runoff. If None, nothing will be plotted. Default is {}.

{}
snowfall_params Union[dict, None]

Plotting parameters for Snowfall. If None, nothing will be plotted. Default is {}.

{}

Returns:

Type Description
list of Line2D

A list of lines representing the plotted data.

NCProfile

Profile timeseries plots for the output.nc file.

Creates a profile plot of a variable for all depths and timesteps of a GLM simulation. Reads the output.nc NetCDF file generated by GLM.

Examples:

Plot the lake temperature and add a colour bar:

>>> from glmpy import plots
>>> import matplotlib.pyplot as plt
>>> nc = plots.NCProfile("output.nc")
>>> fig, ax = plt.subplots()
>>> out = nc.plot_var(ax, "temp")
>>> col_bar = fig.colorbar(out)
>>> col_bar.set_label("Temperature (°C)")
>>> plt.show()

Plot the lake temperature with surface reference (instead of bottom reference) and change the colour map:

>>> nc = plots.NCProfile("plots_module_misc/example_outputs/output.nc")
>>> fig, ax = plt.subplots()
>>> out = nc.plot_var(ax, "temp", "surface", {"cmap": "viridis"})
>>> col_bar = fig.colorbar(out)
>>> col_bar.set_label("Temperature (°C)")
>>> plt.show()

Use get_vars() to return every valid variable name. Set the colour bar label with get_long_name() (the unabbreviated variable name) and get_units():

>>> var = nc.get_vars()[3]
>>> long_name = nc.get_long_name(var)
>>> units = nc.get_units(var)
>>> fig, ax = plt.subplots()
>>> out = nc.plot_var(ax, var)
>>> col_bar = fig.colorbar(out)
>>> col_bar.set_label(f"{long_name} ({units})")
>>> plt.show()

__init__(glm_nc_path, resolution=0.1, remove_ice=False, remove_white_ice=False, remove_snow=False)

Initialise the NCProfile with the output.nc NetCDF file.

Parameters:

Name Type Description Default
glm_nc_path str

Path to the GLM output.nc NetCDF file.

required
resolution float

Vertical resolution of plots in meters. Default is 0.1.

0.1
remove_ice bool

Exclude black ice thickness from surface height. Default is False.

False
remove_white_ice bool

Exclude white ice thickness from surface height. Default is False.

False
remove_snow bool

Exclude snow thickness from surface height. Default is False.

False

get_long_name(var)

Get the long name description of a variable.

Parameters:

Name Type Description Default
var str

Name of the variable.

required

Returns:

Type Description
str

Long name description of the variable.

get_start_datetime()

Get the simulation start time.

Returns:

Type Description
datetime

Start time of the GLM simulation.

get_units(var)

Get the units of a variable.

Parameters:

Name Type Description Default
var str

Name of the variable.

required

Returns:

Type Description
str

Units of the variable.

get_vars()

Get all available variables that can be plotted with plot_var().

Returns:

Type Description
list of str

Names of plottable variables in the NetCDF file

plot_var(ax, var, reference='bottom', param_dict={})

Plot the profile timeseries of a variable on a matplotlib Axes.

Parameters:

Name Type Description Default
ax Axes

The Axes to plot on.

required
var str

Name of the variable to plot. To list valid variables, see the get_vars() method.

required
reference str

Reference frame for depth, either "bottom" or "surface". Default is "bottom".

'bottom'
param_dict dict

Parameters passed to matplotlib.axes.Axes.imshow. Default is {}.

{}

Returns:

Type Description
AxesImage

The plotted image