ClimaAnalysis.SimDirType
SimDir(simulation_path::String)

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

Base.getMethod
get(simdir::SimDir;
    short_name,
    reduction = "inst",
    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.

ClimaAnalysis._reduce_overMethod
_reduce_over(reduction::F, dim::String, var::OutputVar)

Apply the given reduction over the given dimension.

reduction has to support the dims key. Additional arguments are passed to reduction.

The return type is an OutputVar with the same attributes, the new data, and the dimension dropped.

Example

Average over latitudes

import Statistics: mean
long = 0.:180. |> collect
lat = 0.:90. |> collect
data = reshape(1.:91*181., (181, 91))
dims = Dict(["lat" => lat, "long" => long])
var = OutputVar(dims, data)
_reduce_over(mean, "lat", var)
ClimaAnalysis.available_periodsMethod
available_periods(simdir::SimDir, short_name::String, reduction::String)

Return the periods associated to the given variable and reduction.

ClimaAnalysis.available_reductionsMethod
available_reductions(simdir::SimDir, short_name::String)

Return the reductions available for the given variable in the given simdir.

ClimaAnalysis.average_latMethod
average_lat(var::OutputVar)

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

ClimaAnalysis.average_lonMethod
average_lon(var::OutputVar)

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

ClimaAnalysis.average_timeMethod
average_time(var::OutputVar)

Return a new OutputVar where the values are averaged arithmetically in time.

ClimaAnalysis.read_varMethod
read_var(path::String)

Read a variable in the given NetCDF file.

Example

simdir = SimDir("my_output")
read_var(simdir.variable_paths["hu"]["inst"])
ClimaAnalysis.sliceMethod
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)
ClimaAnalysis.slice_generalMethod
slice_general(var::OutputVar, val, dim_name)

Return a new OutputVar by selecting the available index closest to the given val for the given dimension

ClimaAnalysis.slice_latMethod
slice_lat(var::OutputVar, lat)

Return a new OutputVar by selecting the available date closest to the given lat.

ClimaAnalysis.slice_lonMethod
slice_lon(var::OutputVar, lon)

Return a new OutputVar by selecting the available date closest to the given lon.

ClimaAnalysis.slice_timeMethod
slice_time(var::OutputVar, time)

Return a new OutputVar by selecting the available snapshot closest to the given time.

ClimaAnalysis.slice_xMethod
slice_x(var::OutputVar, x)

Return a new OutputVar by selecting the available date closest to the given x.

ClimaAnalysis.slice_yMethod
slice_y(var::OutputVar, y)

Return a new OutputVar by selecting the available date closest to the given y.

ClimaAnalysis.slice_zMethod
slice_z(var::OutputVar, z)

Return a new OutputVar by selecting the available date closest to the given z.

ClimaAnalysis.Utils.kwargsMethod
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
ClimaAnalysis.Utils.match_nc_filenameMethod
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.0min_max.nc")
("pfull", "6.0min", "max")
julia> match_nc_filename("hu_inst.nc")
("hu", nothing, "inst")
ClimaAnalysis.Utils.nearest_indexMethod
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
ClimaAnalysis.Utils.squeezeMethod
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)