ClimaAnalysis.OutputVar
— TypeRepresenting an output variable
ClimaAnalysis.SimDir
— TypeSimDir(simulation_path::String)
Object that describes all the ClimaAtmos
output found in the given simulation_path
.
Base.get
— Methodget(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_over
— Method_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_periods
— Methodavailable_periods(simdir::SimDir, short_name::String, reduction::String)
Return the periods associated to the given variable and reduction.
ClimaAnalysis.available_reductions
— Methodavailable_reductions(simdir::SimDir, short_name::String)
Return the reductions available for the given variable in the given simdir
.
ClimaAnalysis.available_vars
— Methodavailable_vars(simdir::SimDir)
Return the short names of the variables found in the given simdir
.
ClimaAnalysis.average_lat
— Methodaverage_lat(var::OutputVar)
Return a new OutputVar where the values on the latitudes are averaged arithmetically.
ClimaAnalysis.average_lon
— Methodaverage_lon(var::OutputVar)
Return a new OutputVar where the values on the longitudes are averaged arithmetically.
ClimaAnalysis.average_time
— Methodaverage_time(var::OutputVar)
Return a new OutputVar where the values are averaged arithmetically in time.
ClimaAnalysis.read_var
— Methodread_var(path::String)
Read a variable in the given NetCDF file.
Example
simdir = SimDir("my_output")
read_var(simdir.variable_paths["hu"]["inst"])
ClimaAnalysis.slice
— Methodslice(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_general
— Methodslice_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_lat
— Methodslice_lat(var::OutputVar, lat)
Return a new OutputVar by selecting the available date closest to the given lat
.
ClimaAnalysis.slice_lon
— Methodslice_lon(var::OutputVar, lon)
Return a new OutputVar by selecting the available date closest to the given lon
.
ClimaAnalysis.slice_time
— Methodslice_time(var::OutputVar, time)
Return a new OutputVar by selecting the available snapshot closest to the given time
.
ClimaAnalysis.slice_x
— Methodslice_x(var::OutputVar, x)
Return a new OutputVar by selecting the available date closest to the given x
.
ClimaAnalysis.slice_y
— Methodslice_y(var::OutputVar, y)
Return a new OutputVar by selecting the available date closest to the given y
.
ClimaAnalysis.slice_z
— Methodslice_z(var::OutputVar, z)
Return a new OutputVar by selecting the available date closest to the given z
.
ClimaAnalysis.Utils.kwargs
— Methodkwargs(; kwargs...)
Convert keyword arguments in a dictionary that maps Symbol
s 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_filename
— Methodmatch_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_index
— Methodnearest_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.squeeze
— Methodsqueeze(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 dim
ensions.
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)