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)

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

Base.getMethod
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.

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.is_z_1DMethod
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.

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.windowMethod
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)
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.seconds_to_prettystrMethod
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"
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)