API

Sim

ClimaAnalysis.Sim.SimDirType
SimDir(simulation_path::String)

Object that describes all the ClimaAtmos output found in the given simulation_path.

source
Base.getFunction
get(simdir::SimDir;
    short_name,
    reduction = nothing,
    period = nothing)

Return a OutputVar for the corresponding combination of short_name, reduction, and period (if it exists).

The variable is read only once and saved into the simdir.

Keyword arguments

When passing nothing to reduction and period, ClimaAnalysis will try to automatically deduce the value. An error will be thrown if this is not possible.

For instance, if the simulation has only one ta, you do not need to specify short_name, reduction, and period (short_name is enough). Similarly, if there is only one ta_average (ie, not multiple periods), short_name and reduction will be enough.

source
get(simdir::SimDir, short_name)

If only one reduction and period exist for short_name, return the corresponding OutputVar.

source

Var

ClimaAnalysis.Var.read_varFunction
read_var(path::String; short_name = nothing)

Read the short_name variable in the given NetCDF file.

When short_name is nothing, automatically identify the name of the variable. If multiple variables are present, the last one in alphabetical order is chosen.

When units is among the attributes, try to parse it and convert it into an Unitful object. OutputVars with Unitful support automatic unit conversions.

If you want to access units as a string, look at units function.

Example

simdir = SimDir("my_output")
read_var(simdir.variable_paths["hu"]["inst"])

read_var("my_netcdf_file.nc", short_name = "ts")
source
read_var(paths::Vector{String}; short_name = nothing)

Read the short_name variable in the vector of NetCDF files.

This function automatically aggregates the NetCDF files along the time dimension. If this is not possible, then an error is thrown. The attributes of the OutputVar is the same as the attributes of the first NetCDF file.

When short_name is nothing, automatically identify the name of the variable. If multiple variables are present, the last one in alphabetical order is chosen.

When units is among the attributes, try to parse it and convert it into an Unitful object. OutputVars with Unitful support automatic unit conversions.

If you want to access units as a string, look at units function.

Example

simdir = SimDir("my_output")
read_var(simdir.variable_paths["hu"]["inst"])

read_var(["my_netcdf_file1.nc", "my_netcdf_file2.nc"], short_name = "ts")
source
ClimaAnalysis.Var.is_z_1DFunction
is_z_1D(var::OutputVar)

Return whether the given variable has an altitude dimension that is 1D.

When topography is present, the altitude dimension in the output variable is typically multidimensional. The dimensions are (X, Y, Z), where (X, Y) are the horizontal dimensions. In this case, dims["z"] is essentially a map that identifies the physical altitude of the given point.

source
Base.isemptyMethod
isempty(var::OutputVar)

Determine whether an OutputVar is empty.

source
ClimaAnalysis.Var.unitsFunction
units(var::OutputVar)

Return the units of the given var, if available.

If not available, return an empty string.

source
ClimaAnalysis.Var.sliceFunction
slice(var::OutputVar, kwargs...)

Return a new OutputVar by slicing across dimensions as defined by the keyword arguments.

Example

slice(var, lat = 30, lon = 20, time = 100)
source
ClimaAnalysis.Var.average_latFunction
average_lat(var::OutputVar; ignore_nan = true, weighted = false)

Return a new OutputVar where the values on the latitudes are averaged arithmetically.

When weighted is true, weight the average over cos(lat).

source
ClimaAnalysis.Var.weighted_average_latFunction
weighted_average_lat(var::OutputVar; ignore_nan = true)

Return a new OutputVar where the values on the latitudes are averaged arithmetically with weights of cos(lat).

source
ClimaAnalysis.Var.average_lonFunction
average_lon(var::OutputVar; ignore_nan = true)

Return a new OutputVar where the values on the longitudes are averaged arithmetically.

source
ClimaAnalysis.Var.average_xFunction
average_x(var::OutputVar; ignore_nan = true)

Return a new OutputVar where the values along the x dimension are averaged arithmetically.

source
ClimaAnalysis.Var.average_yFunction
average_y(var::OutputVar; ignore_nan = true)

Return a new OutputVar where the values along the y dimension are averaged arithmetically.

source
ClimaAnalysis.Var.average_xyFunction
average_xy(var::OutputVar; ignore_nan = true)

Return a new OutputVar where the values along both horizontal dimensions x and y are averaged arithmetically.

source
ClimaAnalysis.Var.windowFunction
window(var::OutputVar, dim_name; left = nothing, right = nothing)

Return a new OutputVar by selecting the values of the given dimension that are between left and right.

If left and/or right are nothing, assume beginning (or end) of the array.

Example

window(var, 'lat', left = -50, right = 50)
source
ClimaAnalysis.Var.arecompatibleFunction
arecompatible(x::OutputVar, y::OutputVar)

Return whether two OutputVar are defined on the same physical space

This is accomplished by comparing dims and dim_attributes (the latter because they might contain information about the units).

We assume that:

  • dim2index and index2dim where correctly created and they reflect dims
  • data is also consistent with dims,

We also do not check units for data.

source
ClimaAnalysis.Var.center_longitude!Function
center_longitude!(var::OutputVar, lon::Real)

Shift the longitudes in var so that lon is the center one.

This is useful to center the global projection to the 180 meridian instead of the 0.

source
ClimaAnalysis.Var.conventional_dim_nameFunction
conventional_dim_name(dim_name::AbstractString)

Return the type of dimension as a string from longitude, latitude, time, date, or altitude if possible or dim_name as a string otherwise.

source
ClimaAnalysis.Var.dim_unitsFunction
dim_units(var::OutputVar, dim_name)

Return the units of the given dim_name in var, if available.

If not available, return an empty string.

source
ClimaAnalysis.Var.range_dimFunction
range_dim(var::OutputVar, dim_name)

Return the range of the dimension dim_name in var.

Range here is a tuple with the minimum and maximum of dim_name.

source
ClimaAnalysis.Var.reordered_asFunction
reordered_as(src_var::OutputVar, dest_var::OutputVar)

Reorder the dimensions in src_var to match the ordering of dimensions in dest_var.

source
ClimaAnalysis.Var.resampled_asFunction
resampled_as(src_var::OutputVar, dest_var::OutputVar)

Resample data in src_var to dims in dest_var.

The resampling performed here is a 1st-order linear resampling.

source
ClimaAnalysis.Var.convert_unitsFunction
Var.convert_units(var, new_units; conversion_function = nothing)

Return a new OutputVar with converted physical units of var to new_units, if possible.

Automatic conversion happens when the units for var and new_units are both parseable. When var does not have units (see also Var.has_units) or has no parseable units, a conversion function conversion_function is required.

conversion_function has to be a function that takes one data point and returns the transformed value.

Being parseable means that Unitful.uparse can parse the expression. Please, refer to the documentation for Unitful.jl for more information.

Examples

Let us set up a trivial 1D OutputVar with units of meters per second and automatically convert it to centimeters per second.

julia> values = 0:100.0 |> collect;

julia> data = copy(values);

julia> attribs = Dict("long_name" => "speed", "units" => "m/s");

julia> dim_attribs = Dict{String, Any}();

julia> var = ClimaAnalysis.OutputVar(attribs, Dict("distance" => values), dim_attribs, data);

julia> ClimaAnalysis.has_units(var)
true

julia> var_cms = ClimaAnalysis.convert_units(var, "cm/s");

julia> extrema(var_cms.data)
(0.0, 10000.0)

Not all the units can be properly parsed, for example, assuming bob=5lol

julia> attribs = Dict("long_name" => "speed", "units" => "bob/s");

julia> var_bob = ClimaAnalysis.OutputVar(attribs, Dict("distance" => values), dim_attribs, data);

julia> var_lols = ClimaAnalysis.convert_units(var, "lol/s", conversion_function = (x) -> 5x);

julia> extrema(var_lols.data)
(0.0, 500.0)

Failure to specify the conversion_function will produce an error.

source
ClimaAnalysis.Var.set_unitsFunction
set_units(var::OutputVar, units::AbstractString)

Set units for data in var.

Override existing units

If units already exist, this will override the units for data in var. To convert units, see Var.convert_units

source
ClimaAnalysis.Var.integrate_lonlatFunction
integrate_lonlat(var::OutputVar)

Integrate data in var on longitude and latitude with a first-order scheme. data has to be discretized on longitude and latitude.

If the points are equispaced, it is assumed that each point correspond to the midpoint of a cell which results in rectangular integration using the midpoint rule. Otherwise, the integration being done is rectangular integration using the left endpoints for integrating longitude and latitude. The units for longitude and latitude should be degrees.

source
ClimaAnalysis.Var.integrate_latFunction
integrate_lat(var::OutputVar)

Integrate data in var on latitude with a first-order scheme. data has to be discretized on latitude.

If the points are equispaced, it is assumed that each point correspond to the midpoint of a cell which results in rectangular integration using the midpoint rule. Otherwise, the integration being done is rectangular integration using the left endpoints. The unit for latitude should be degrees.

source
ClimaAnalysis.Var.integrate_lonFunction
integrate_lon(var::OutputVar)

Integrate data in var on longitude with a first-order scheme. data has to be discretized on longitude.

If the points are equispaced, it is assumed that each point correspond to the midpoint of a cell which results in rectangular integration using the midpoint rule. Otherwise, the integration being done is rectangular integration using the left endpoints. The unit for longitude should be degrees.

source
ClimaAnalysis.Utils.split_by_seasonMethod
split_by_season(var::OutputVar)

Return a vector of four OutputVars split by season.

The months of the seasons are March to May, June to August, September to November, and December to February. The order of the vector is MAM, JJA, SON, and DJF. If there are no dates found for a season, then the OutputVar for that season will be an empty OutputVar.

The function will use the start date in var.attributes["start_date"]. The unit of time is expected to be second. Also, the interpolations will be inaccurate in time intervals outside of their respective season for the returned OutputVars.

source
ClimaAnalysis.Var.biasFunction
bias(sim::OutputVar, obs::OutputVar; mask = nothing)

Return a OutputVar whose data is the bias (sim.data - obs.data) and compute the global bias of data in sim and obs over longitude and latitude. The result is stored in var.attributes["global_bias"].

This function is currently implemented for OutputVars with only the dimensions longitude and latitude. Units must be supplied for data and dimensions in sim and obs. The units for longitude and latitude should be degrees. Resampling is done automatically by resampling obs on sim. Attributes in sim and obs will be thrown away. The long name and short name of the returned OutputVar will be updated to reflect that a bias is computed.

The parameter mask is a function that masks a OutputVar. See apply_landmask and apply_oceanmask.

See also global_bias, squared_error, global_mse, global_rmse.

source
ClimaAnalysis.Var.global_biasFunction
global_bias(sim::OutputVar, obs::OutputVar; mask = nothing)

Return the global bias of data in sim and obs over longitude and latitude.

This function is currently only implemented for OutputVars with only the dimensions longitude and latitude. Units must be supplied for data and dimensions in sim and obs. The units for longitude and latitude should be degrees. Resampling is done automatically by resampling obs on sim.

The parameter mask is a function that masks a OutputVar. See apply_landmask and apply_oceanmask.

See also bias, squared_error, global_mse, global_rmse.

source
ClimaAnalysis.Var.squared_errorFunction
squared_error(sim::OutputVar, obs::OutputVar; mask = nothing)

Return a OutputVar whose data is the squared error ((sim.data - obs.data)^2) and compute the global mean squared error (MSE) and global root mean squared error (RMSE) of data in sim and obs over longitude and latitude. The result is stored in var.attributes["mse"] and var.attributes["rmse"].

This function is currently implemented for OutputVars with only the dimensions longitude and latitude. Units must be supplied for data and dimensions in sim and obs. The units for longitude and latitude should be degrees. Resampling is done automatically by resampling obs on sim. Attributes in sim and obs will be thrown away. The long name and short name of the returned OutputVar will be updated to reflect that a squared error is computed.

The parameter mask is a function that masks a OutputVar. See apply_landmask and apply_oceanmask.

See also global_mse, global_rmse, bias, global_bias.

source
ClimaAnalysis.Var.global_mseFunction
global_mse(sim::OutputVar, obs::OutputVar; mask = nothing)

Return the global mean squared error (MSE) of data in sim and obs over longitude and latitude.

This function is currently implemented for OutputVars with only the dimensions longitude and latitude. Units must be supplied for data and dimensions in sim and obs. The units for longitude and latitude should be degrees. Resampling is done automatically by resampling obs on sim.

The parameter mask is a function that masks a OutputVar. See apply_landmask and apply_oceanmask.

See also squared_error, global_rmse, bias, global_bias.

source
ClimaAnalysis.Var.global_rmseFunction
global_rmse(sim::OutputVar, obs::OutputVar; mask = nothing)

Return the global root mean squared error (RMSE) of data in sim and obs over longitude and latitude.

This function is currently implemented for OutputVars with only the dimensions longitude and latitude. Units must be supplied for data and dimensions in sim and obs. The units for longitude and latitude should be degrees. Resampling is done automatically by resampling obs on sim.

The parameter mask is a function that masks a OutputVar. See apply_landmask and apply_oceanmask.

See also squared_error, global_mse, bias, global_bias.

source
ClimaAnalysis.Var.shift_to_start_of_previous_monthFunction
shift_to_start_of_previous_month(var::OutputVar)

Shift the times in the time dimension to the start of the previous month.

After applying this function, the start date in the attributes correspond to the first element in the time array.

This function is helpful in ensuring consistency in dates between simulation and observational data. One example of this is when adjusting monthly averaged data. For instance, suppose that data on 2010-02-01 in the OutputVar corresponds to the monthly average for January. This function shifts the times so that 2010-01-01 will correspond to the monthly average for January.

Note that this function only works for the time dimension and will not work for the date dimension.

source

Leaderboard

ClimaAnalysis.Leaderboard.RMSEVariableMethod
RMSEVariable(short_name, model_names::Vector{String})

Construct a RMSEVariable with the short_name of the variable and the names of the models in model_names.

The categories default to "ANN", "DJF", "MAM", "JJA", "SON". The root mean square errors default to NaN. The unit for each model is missing which is denoted by an empty string.

source
ClimaAnalysis.Leaderboard.RMSEVariableMethod
RMSEVariable(short_name, model_names::Vector{String}, units::Dict)

Construct a RMSEVariable with the short_name of the variable, the names of the models in model_names, and provided units in the dictionary units that map model name to unit.

The categories default to "ANN", "DJF", "MAM", "JJA", "SON". The root mean square errors default to NaN. Any missing model in the dictionary units will has missing unit which is denoted by an empty string.

source
ClimaAnalysis.Leaderboard.RMSEVariableMethod
RMSEVariable(short_name,
             model_names::Vector{String},
             category_names::Vector{String},
             units::Dict)

Construct a RMSEVariable with the short_name of the variable, the names of the models in model_names, the categories in category_names, and provided units in the dictionary units that map model name to unit.

The root mean square errors default to NaN. Any missing model in the dictionary units will has missing unit which is denoted by an empty string.

source
ClimaAnalysis.Leaderboard.RMSEVariableMethod
RMSEVariable(short_name::String,
             model_names::Vector{String},
             category_names::Vector{String},
             RMSEs,
             units::Dict)

Construct a RMSEVariable with the short_name of the variable, the names of the models in model_names, the categories in category_names, the root mean squared errors in RMSEs, and units.

source
ClimaAnalysis.Leaderboard.RMSEVariableMethod
RMSEVariable(short_name, model_names::Vector{String}, units::String)

Construct a RMSEVariable with the short_name of the variable, the names of the models in model_names, and units which map each model name to units.

The categories default to "ANN", "DJF", "MAM", "JJA", "SON". The root mean square errors default to NaN.

This is useful if all the models share the same unit.

source
ClimaAnalysis.Leaderboard.RMSEVariableMethod
RMSEVariable(short_name,
             model_names::Vector{String},
             category_names::Vector{String},
             units::String)

Construct a RMSEVariable with the short_name of the variable, the names of the models in model_names, the categories in category_names, and units which map each model name to units.

The root mean square errors default to NaN.

This is useful if all the models share the same unit.

source
ClimaAnalysis.Leaderboard.RMSEVariableMethod
RMSEVariable(short_name::String,
             model_names::Vector{String},
             category_names::Vector{String},
             RMSEs,
             units::String)

Construct a RMSEVariable with the short_name of the variable, the names of the models in model_names, the categories in category_names, the root mean squared errors in RMSEs, and units which map each model name to units.

This is useful if all the models share the same unit.

source
ClimaAnalysis.Leaderboard.read_rmsesFunction
read_rmses(csv_file::String, short_name::String; units = nothing)

Read a CSV file and create a RMSEVariable with the short_name of the variable.

The format of the CSV file should have a header consisting of the entry "model_name" (or any other text as it is ignored by the function) and rest of the entries should be the category names. Each row after the header should start with the model name and the root mean squared errors for each category for that model. The entries of the CSV file should be separated by commas.

The parameter units can be a dictionary mapping model name to unit or a string. If units is a string, then units will be the same across all models. If units is nothing, then the unit is missing for each model which is denoted by an empty string.

source
Base.getindexMethod
Base.getindex(rmse_var::RMSEVariable, model_name, category)

Return a subset of the array holding the root mean square errors as specified by model_name and category. Support indexing by String and Int.

source
Base.getindexMethod
Base.getindex(rmse_var::RMSEVariable, model_name::String)

Return a subset of the array holding the root mean square errors as specified by model_name. Support indexing by String. Do not support linear indexing.

source
Base.setindex!Method
Base.setindex!(rmse_var::RMSEVariable, rmse, model_name, category)

Store a value or values from an array in the array of root mean squared errors in rmse_var. Support indexing by String and Int.

source
Base.setindex!Method
Base.setindex!(rmse_var::RMSEVariable, rmse, model_name::String)

Store a value or values from an array into the array of root mean squared errors in rmse_var. Support indexing by String. Do not support linear indexing.

source
ClimaAnalysis.Leaderboard.add_unit!Function
add_unit!(rmse_var::RMSEVariable, model_name, unit)

Add a unit named unit to a model named model_name in rmse_var.

source
add_unit!(rmse_var::RMSEVariable, model_name2unit::Dict)

Add all model name and unit pairs in the dictionary model_name2unit to rmse_var.

source
ClimaAnalysis.Leaderboard.find_best_single_modelFunction
find_best_single_model(rmse_var::RMSEVariable; category_name = "ANN")

Return a tuple of the best single model and the name of the model. Find the best single model using the root mean squared errors of the category category_name.

source
ClimaAnalysis.Leaderboard.find_worst_single_modelFunction
find_worst_single_model(rmse_var::RMSEVariable; category_name = "ANN")

Return a tuple of the worst single model and the name of the model. Find the worst single model using the root mean squared errors of the category category_name.

source
ClimaAnalysis.Leaderboard.medianFunction
median(rmse_var::RMSEVariable)

Find the median using the root mean squared errors across all categories.

Any NaN is ignored in computing the median.

source

Utilities

For development and not

ClimaAnalysis.Utils.match_nc_filenameFunction
match_nc_filename(filename::String)

Return short_name, period, reduction extracted from the filename, if matching the expected convention.

The convention is: shortname_(period)_reduction.nc, with period being optional.

Examples

julia> match_nc_filename("bob")
julia> match_nc_filename("ta_1d_average.nc")
("ta", "1d", "average")
julia> match_nc_filename("pfull_6.0m_max.nc")
("pfull", "6.0m", "max")
julia> match_nc_filename("hu_inst.nc")
("hu", nothing, "inst")
source
ClimaAnalysis.Utils.squeezeFunction
squeeze(A :: AbstractArray; dims)

Return an array that has no dimensions with size 1.

When an iterable dims is passed, only try to squeeze the given dimensions.

Examples

julia> A = [[1 2] [3 4]];

julia> size(A)
(1, 4)

julia> A_squeezed = squeeze(A);

julia> size(A_squeezed)
(4,)

julia> A_not_squeezed = squeeze(A; dims = (2, ));

julia> size(A_not_squeezed)
(1, 4)
source
ClimaAnalysis.Utils.nearest_indexFunction
nearest_index(A::AbstractArray, val)

Return the index in A closest to the given val.

Examples

julia> A = [-1, 0, 1, 2, 3, 4, 5];

julia> nearest_index(A, 3)
5

julia> nearest_index(A, 0.1)
2
source
ClimaAnalysis.Utils.kwargsFunction
kwargs(; kwargs...)

Convert keyword arguments in a dictionary that maps Symbols to values.

Useful to pass keyword arguments to different constructors in a function.

Examples

julia> kwargs(a = 1)
pairs(::NamedTuple) with 1 entry:
  :a => 1
source
ClimaAnalysis.Utils.seconds_to_prettystrFunction
seconds_to_prettystr(seconds::Real)

Convert the given seconds into a string with rich time information.

One year is defined as having 365 days.

Examples

julia> seconds_to_prettystr(10)
"10s"

julia> seconds_to_prettystr(600)
"10m"

julia> seconds_to_prettystr(86400)
"1d"

julia> seconds_to_prettystr(864000)
"10d"

julia> seconds_to_prettystr(864010)
"10d 10s"

julia> seconds_to_prettystr(24 * 60 * 60 * 365 + 1)
"1y 1s"
source
ClimaAnalysis.Utils.warp_stringFunction
warp_string(str::AbstractString; max_width = 70)

Return a string where each line is at most max_width characters or less or at most one word.

Examples

julia> warp_string("space", max_width = 5)
"space"

julia> warp_string("space", max_width = 4)
"space"

julia> warp_string("\tspace    ", max_width = 4)
"space"

julia> warp_string("space space", max_width = 5)
"space\nspace"

julia> warp_string("space space", max_width = 4)
"space\nspace"

julia> warp_string("\n   space  \n  space", max_width = 4)
"space\nspace"
source

Atmos

ClimaAnalysis.AtmosModule

The Atmos module contains functions that are primarily useful when working with atmospheric simulations.

source
ClimaAnalysis.Atmos.to_pressure_coordinatesFunction
to_pressure_coordinates(var::OutputVar, pressure::OutputVar; target_pressure = nothing)

Change the vertical dimension of var to be in pressure coordinates.

If target_pressure is nothing, the target pressure levels are computed by linearly sampling the interval minimum(pressure), maximum(pressure). Then, for each column in var, the values are linearly interpolate onto this new grid.

target_pressure can be set to a Vector to specify custom pressure levels.

The return value is a new OutputVar where the vertical dimension is pressure.

:important: Values outside of the range are linearly extrapolated, so do not

trust them too much!

source

Makie

ClimaAnalysis.Visualize.heatmap2D!Function
heatmap2D!(fig::Makie.Figure,
           var::ClimaAnalysis.OutputVar;
           p_loc = (1,1),
           more_kwargs)
heatmap2D!(grid_layout::Makie.GridLayout,
           var::ClimaAnalysis.OutputVar;
           p_loc = (1,1),
           more_kwargs)

Plot a heatmap of the given 2D variable in the given place and location. The place can be a Figure or a GridLayout.

The plot comes with labels, units, and a colorbar.

This function assumes that the following attributes are available:

  • long_name
  • short_name
  • units (also for the dimensions)

Additional arguments to the plotting and axis functions

more_kwargs can be a dictionary that maps symbols to additional options for:

  • the axis (:axis)
  • the plotting function (:plot)
  • the colorbar (:cb)

The values are splatted in the relevant functions. Populate them with a Dictionary of Symbols => values to pass additional options.

source
ClimaAnalysis.Visualize.sliced_heatmap!Function
sliced_heatmap!(fig::Makie.Figure,
                var::ClimaAnalysis.OutputVar,
                cut::Union{Nothing, AbstractDict{String, <: Real}};
                p_loc = (1,1),
                more_kwargs,
                )
sliced_heatmap!(grid_layout::Makie.GridLayout,
                var::ClimaAnalysis.OutputVar,
                cut::Union{Nothing, AbstractDict{String, <: Real}};
                p_loc = (1,1),
                more_kwargs,
                )

Take a variable, slice as directed, and plot a 2D heatmap in the given place and location.

The place can be a Figure or a GridLayout.

The plot comes with labels, units, and a colorbar.

Arguments

If the variable is not 2D, cut has to be a dictionary that maps the dimension that has to be sliced and the value where to cut.

For example, if var has four dimensions: time, long, lat, z, this function can be used to plot a lat-long heatmap at fixed time and z. Assuming we want to plot time 100. and altitude 50., cut should be Dict("time" => 100., "z" => 50.).

This function assumes that the following attributes are available:

  • long_name
  • short_name
  • units (also for the dimensions)

Additional arguments to the plotting and axis functions

more_kwargs can be a dictionary that maps symbols to additional options for:

  • the axis (:axis)
  • the plotting function (:plot)
  • the colorbar (:cb)

The values are splatted in the relevant functions. Populate them with a Dictionary of Symbols => values to pass additional options.

source
ClimaAnalysis.Visualize.heatmap!Function
heatmap!(place::MakiePlace,
         var::ClimaAnalysis.OutputVar;
         p_loc = (1,1),
         more_kwargs,
         kwargs...
        )

Syntactic sugar for sliced_heatmap with kwargs instead of cut.

Example

heatmap!(fig, var, time = 100, lat = 70) plots a heatmap by slicing var along the time nearest to 100 and latitude nearest 70.

Additional arguments to the plotting and axis functions

more_kwargs can be a dictionary that maps symbols to additional options for:

  • the axis (:axis)
  • the plotting function (:plot)
  • the colorbar (:cb)

The values are splatted in the relevant functions. Populate them with a Dictionary of Symbols => values to pass additional options.

source
ClimaAnalysis.Visualize.line_plot1D!Function
line_plot1D!(place::Makie.Figure,
             var::ClimaAnalysis.OutputVar;
             p_loc = (1,1),
             more_kwargs
             )
line_plot1D!(place::Makie.GridLayout,
             var::ClimaAnalysis.OutputVar;
             p_loc = (1,1),
             more_kwargs
             )

Plot a line plot of the given 1D variable in the given place and location. The place can be a Figure or a GridLayout.

The plot comes with labels, units.

This function assumes that the following attributes are available:

  • long_name
  • short_name
  • units (also for the dimensions)

Additional arguments to the plotting and axis functions

more_kwargs can be a dictionary that maps symbols to additional options for:

  • the axis (:axis)
  • the plotting function (:plot)

The values are splatted in the relevant functions. Populate them with a Dictionary of Symbols => values to pass additional options.

A special argument that can be passed to :axis is :dim_on_y, which puts the dimension on the y axis instead of the variable. This is useful to plot columns with z on the vertical axis instead of the horizontal one.

source
ClimaAnalysis.Visualize.sliced_line_plot!Function
sliced_line_plot!(place::Makie.Figure,
                  var::ClimaAnalysis.OutputVar,
                  cut::Union{Nothing, AbstractDict{String, <: Real}};
                  p_loc = (1,1),
                  more_kwargs
                  )
sliced_line_plot!(place::Makie.GridLayout,
                  var::ClimaAnalysis.OutputVar,
                  cut::Union{Nothing, AbstractDict{String, <: Real}};
                  p_loc = (1,1),
                  more_kwargs
                  )

Take a variable, slice as directed, and plot a 1D line plot in the given place and location. The place can be a Figure or a GridLayout.

The plot comes with labels, and units.

Arguments

If the variable is not 1D, cut has to be a dictionary that maps the dimension that has to be sliced and the value where to cut.

For example, if var has four dimensions: time, long, lat, z, this function can be used to plot a lat-long heatmap at fixed time and z. Assuming we want to plot time 100. and altitude 50., cut should be Dict("time" => 100., "z" => 50.).

This function assumes that the following attributes are available:

  • long_name
  • short_name
  • units (also for the dimensions)

Additional arguments to the plotting and axis functions

more_kwargs can be a dictionary that maps symbols to additional options for:

  • the axis (:axis)
  • the plotting function (:plot)

The values are splatted in the relevant functions. Populate them with a Dictionary of Symbols => values to pass additional options.

source
ClimaAnalysis.Visualize.sliced_plot!Function
sliced_plot!(place::Makie.Figure,
             var::ClimaAnalysis.OutputVar,
             cut::Union{Nothing, AbstractDict{String, <: Real}};
             p_loc = (1,1),
             more_kwargs
             )
sliced_plot!(place::Makie.GridLayout,
             var::ClimaAnalysis.OutputVar,
             cut::Union{Nothing, AbstractDict{String, <: Real}};
             p_loc = (1,1),
             more_kwargs
             )

Take a variable, slice as directed, and plot a 1D line plot or 2D heatmap in the given place and location. The place can be a Figure or a GridLayout.

The plot comes with labels, and units (and possibly a colorbar).

Arguments

If the variable is not 1D/2D, cut has to be a dictionary that maps the dimension that has to be sliced and the value where to cut.

For example, if var has four dimensions: time, long, lat, z, this function can be used to plot a lat-long heatmap at fixed time and z. Assuming we want to plot time 100. and altitude 50., cut should be Dict("time" => 100., "z" => 50.).

This function assumes that the following attributes are available:

  • long_name
  • short_name
  • units (also for the dimensions)

Additional arguments to the plotting and axis functions

more_kwargs can be a dictionary that maps symbols to additional options for:

  • the axis (:axis)
  • the plotting function (:plot)
  • the colorbar (:cb)

The values are splatted in the relevant functions. Populate them with a Dictionary of Symbols => values to pass additional options.

source
ClimaAnalysis.Visualize.plot!Function
plot!(place::Makie.Figure,
      var::ClimaAnalysis.OutputVar;
      p_loc = (1,1),
      more_kwargs,
      kwargs...
      )
plot!(place::Makie.GridLayout,
      var::ClimaAnalysis.OutputVar;
      p_loc = (1,1),
      more_kwargs,
      kwargs...
      )

Syntactic sugar for sliced_plot with kwargs instead of cut.

Example

line_plot!(fig, var, time = 100, lat = 70) plots a line plot or a heatmap by slicing var along the time nearest to 100 and latitude nearest 70.

Additional arguments to the plotting and axis functions

more_kwargs can be a dictionary that maps symbols to additional options for:

  • the axis (:axis)
  • the plotting function (:plot)
  • the colorbar (:cb)

The values are splatted in the relevant functions. Populate them with a Dictionary of Symbols => values to pass additional options.

source
ClimaAnalysis.Visualize.plot_boxplot!Function
Visualize.plot_boxplot!(fig,
                        rmse_var::ClimaAnalysis.RMSEVariable;
                        model_names = ["CliMA"],
                        ploc = (1, 1),
                        best_and_worst_category_name = "ANN",
                        legend_text_width = 10)

Plot a Tukey style boxplot for each category in rmse_var.

The best and worst single models are found for the category best_and_worst_category_name and are plotted on the boxplot. When finding the best and worst single models, any models in model_names will be excluded. Additionally, any model in model_names will also be plotted on the boxplot.

The parameter ploc determines where to place the plot on the figure. The parameter legend_text_width determines the number of characters on each line in the legend.

source
ClimaAnalysis.Visualize.plot_leaderboard!Function
Visualize.plot_leaderboard!(fig,
                            rmse_vars::ClimaAnalysis.RMSEVariable...;
                            ploc = (1, 1),
                            model_names = ["CliMA"],
                            best_category_name = "ANN")

Plot a heatmap over the categories and models. The models that appear is the best model as found for the category best_category_name and any other models in model_names. The root mean squared errors for each variable of interest is normalized by dividing over the median root mean squared error of each variable.

The parameter ploc determines where to place the plot on the figure.

source

GeoMakie

ClimaAnalysis.Visualize.contour2D_on_globe!Function
contours2D_on_globe!(fig::Makie.Figure,
                    var::ClimaAnalysis.OutputVar;
                    p_loc = (1,1),
                    plot_coastline = true,
                    plot_colorbar = true,
                    plot_contours = true,
                    mask = nothing,
                    more_kwargs)
contours2D_on_globe!(grid_layout::Makie.GridLayout,
                    var::ClimaAnalysis.OutputVar;
                    p_loc = (1,1),
                    plot_coastline = true,
                    plot_colorbar = true,
                    plot_contours = true,
                    mask = nothing,
                    more_kwargs)

Plot discrete contours of the given 2D variable on a projected geoid.

The plot comes with labels, units, and a colorbar.

This function assumes that the following attributes are available:

  • long_name
  • short_name
  • units

The dimensions have to be longitude and latitude.

mask has to be an object that can be plotted by Makie.poly. Typically, an ocean or land mask. ClimaAnalysis comes with predefined masks, check out Visualize.oceanmask and Visualize.landmask.

Additional arguments to the plotting and axis functions

more_kwargs can be a dictionary that maps symbols to additional options for:

  • the axis (:axis)
  • the plotting function (:plot)
  • the colorbar (:cb)
  • the coastline (:coast)
  • the mask (:mask)

The coastline is plotted from GeoMakie.coastline using the lines! plotting function.

The values are splatted in the relevant functions. Populate them with a Dictionary of Symbols => values to pass additional options.

source
ClimaAnalysis.Visualize.heatmap2D_on_globe!Function
heatmap2D_on_globe!(fig::Makie.Figure,
                    var::ClimaAnalysis.OutputVar;
                    p_loc = (1,1),
                    plot_coastline = true,
                    plot_colorbar = true,
                    mask = nothing,
                    more_kwargs)
heatmap2D_on_globe!(grid_layout::Makie.GridLayout,
                    var::ClimaAnalysis.OutputVar;
                    p_loc = (1,1),
                    plot_coastline = true,
                    plot_colorbar = true,
                    mask = nothing,
                    more_kwargs)

Plot a heatmap of the given 2D variable on a projected geoid.

The plot comes with labels, units, and a colorbar.

This function assumes that the following attributes are available:

  • long_name
  • short_name
  • units

The dimensions have to be longitude and latitude.

mask has to be an object that can be plotted by Makie.poly. Typically, an ocean or land mask. ClimaAnalysis comes with predefined masks, check out Visualize.oceanmask and Visualize.landmask.

Additional arguments to the plotting and axis functions

more_kwargs can be a dictionary that maps symbols to additional options for:

  • the axis (:axis)
  • the plotting function (:plot)
  • the colorbar (:cb)
  • the coastline (:coast)
  • the mask (:mask)

The coastline is plotted from GeoMakie.coastline using the lines! plotting function.

The values are splatted in the relevant functions. Populate them with a Dictionary of Symbols => values to pass additional options.

source
ClimaAnalysis.Visualize.plot_bias_on_globe!Function
plot_bias_on_globe!(fig::Makie.Figure,
                    sim::ClimaAnalysis.OutputVar,
                    obs::ClimaAnalysis.OutputVar;
                    cmap_extrema = extrema(ClimaAnalysis.bias(sim, obs).data),
                    p_loc = (1, 1),
                    plot_coastline = true,
                    plot_colorbar = true,
                    mask = nothing,
                    more_kwargs)
plot_bias_on_globe!(grid_layout::Makie.GridLayout,
                    sim::ClimaAnalysis.OutputVar,
                    obs::ClimaAnalysis.OutputVar;
                    cmap_extrema = extrema(ClimaAnalysis.bias(sim, obs).data),
                    p_loc = (1, 1),
                    plot_coastline = true,
                    plot_colorbar = true,
                    mask = nothing,
                    more_kwargs)

Plot the bias (sim.data - var.data) on a projected geoid. The gloal bias and root mean squared error (RMSE) are computed and can be found in the title of the plot. This function plots the returned OutputVar of ClimaAnalysis.bias(sim, obs). See also ClimaAnalysis.bias.

The plot comes with labels, units, and a colorbar. This function uses a constrained colormap based on the values of cmap_extrema.

The dimensions have to be longitude and latitude.

mask has to be an object that can be plotted by Makie.poly. ClimaAnalysis comes with predefined masks, check out Visualize.oceanmask and Visualize.landmask. Also, the corresponding mask is applied to the OutputVars. For instance, using Visualize.landmask means ClimaAnalysis.apply_landmask is applied to the OutputVars when computing the bias.

Additional arguments to the plotting and axis functions

more_kwargs can be a dictionary that maps symbols to additional options for:

  • the axis (:axis)
  • the plotting function (:plot)
  • the colorbar (:cb)
  • the coastline (:coast)
  • the mask (:mask)

The coastline is plotted from GeoMakie.coastline using the lines! plotting function.

The values are splatted in the relevant functions. Populate them with a Dictionary of Symbols => values to pass additional options.

source