
Plot a variable from model output – an Aeme object or a raw output list
Source: R/plot_model_output.R
plot_model_output.RdA lightweight ggplot2 plotting helper that works either directly on the
list returned by read_glm_output(), read_gotm_output(),
read_simstrat_output(), or read_model_outputs() – for when you don't
have (or don't want to build) a full Aeme object – or on an Aeme
object itself, in which case get_var()/plot_var() do the work for
you. Dispatches on the shape of the requested variable: a depth x time
tile plot for (z, time) variables (same rendering as plot_output()'s
default backend), a simple time series for (time)-only variables (e.g.
evaporation), and a line plot (one line per combination of its non-time
dimensions) for a new_grouped_var() variable, i.e. one with dimensions
other than (time)/(z, time) – e.g. one line per sediment zone for a
GLM-AED (nzones, time) AED flux variable.
Usage
plot_model_output(
x,
var_sim,
model = NULL,
ens_n = 1,
remove_spin_up = TRUE,
var_lims = NULL,
ylim = NULL
)Arguments
- x
either an
Aemeobject, or a list as returned byread_glm_output()/read_gotm_output()/read_simstrat_output()/read_model_outputs().- var_sim
character; name of the variable to plot, as it appears in
names(x)(or in the model output list, ifxis anAemeobject) – avar_aemename if key_naming has a translation for it, otherwise its raw model/netCDF name.- model
character; model to plot, when
xis anAemeobject with more than one model. Ignored (and unnecessary) whenxis already a raw output list. Defaults to the first model inlist_models()if not supplied.- ens_n
integer; ensemble member to plot, when
xis anAemeobject. Default1.- remove_spin_up
logical; when
xis anAemeobject, drop the spin-up period before plotting (seeget_date_index()). DefaultTRUE. Ignored whenxis already a raw output list – trim it yourself first if needed.- var_lims
numeric vector of length 2; colour scale limits for a depth x time plot. Default
NULL(ranged to the data).- ylim
numeric vector of length 2; y-axis limits for a line plot. Default
NULL(ranged to the data).
Value
A ggplot2 object (the long-format data frame instead, with a
warning, for a grouped variable that has no Date dimension at all).
Details
For observation overlay, faceting across multiple models/variables at
once, or the base-graphics backend, use plot_output() instead – this
function is intentionally minimal, and does not (yet) support
aeme_grouped_var variables when called on an Aeme object through
plot_output()/plot_output_base().
Examples
if (FALSE) { # \dontrun{
# On a raw output list
out <- read_glm_output(file = outfile)
plot_model_output(out, "HYD_temp") # depth x time tile plot
plot_model_output(out, "LKE_lvlwtr") # simple time series
plot_model_output(out, "SDF_Fsed_oxy_Z") # one line per sediment zone
# On an Aeme object directly
plot_model_output(aeme, "HYD_temp", model = "glm_aed")
} # }