Function and type index
SpeedyWeather.DEFAULT_PRESSURE_LAYERS Constant
Pressure [Pa] of the layers that PressureLayers interpolates onto by default.
Core.Type Method
(L::Type{<:SpeedyWeather.AbstractLandSeaMask})(
spectral_grid::SpectralGrid;
kwargs...
)Generator function pulling the resolution information from spectral_grid.
Core.Type Method
(::Type{S})(
spectral_grid::SpectralGrid;
one_more_degree::Bool=true,
transform_batch::AbstractVector{<:Integer}=spectral_grid.transform_batch,
kwargs...
) where S<:SpeedyTransforms.AbstractSpectralTransformGenerator function for a SpectralTransform struct pulling in parameters from a SpectralGrid struct. transform_batch is forwarded as the list of FFT batch sizes K to pre-plan.
SpeedyWeather.AbstractAlbedo Type
Albedo structs should be defined as MyAlbedo <: AbstractAlbedo and implement the following interface:
initialize!(albedo::MyAlbedo, model)albedo!(ij, albedofield, vars::Variables, albedo::MyAlbedo, model)
initialize! is as for every model component but in contrast to other parameterizations albedos should not implement parameterization! but rather albedo!, which is called from within parameterization!. This is because every albedo needs to be used either as part of OceanLandAlbedo or the same albedo is called over both land and ocean surfaces. If a surface namespace (vars.parameterizations.land or .ocean) contains both black_sky_albedo and white_sky_albedo, a shortwave scheme that knows the direct-beam fraction blends them into that namespace's albedo. Otherwise it leaves albedo alone.
SpeedyWeather.AbstractDryLand Type
Abstract land model type that omits hydrological processes and only includes soil temperature. Can be used with both PrimitiveDry and PrimitiveWet. The default concrete type is DryLandModel.
SpeedyWeather.AbstractFluxIntegration Type
Abstract supertype for the time integration of surface fluxes that relax the lowermost layer towards a surface value, flux = -conductance * (x - x_surface). Subtypes define flux_damping(scheme, z) with z = Δt/τ the ratio of time step to relaxation time scale, a factor that multiplies the explicit flux.
SpeedyWeather.AbstractInitialConditions Type
Initial conditions for SpeedyWeather.jl models, i.e. the state of the atmosphere, ocean, land at the start of a simulation. Implemented as a NamedTuple of elements that are each <: AbstractInitialCondition, which are applied one after another to the model variables via initialize!. Each initial condition MyIC needs to implement the initialize!(::Variables, ::MyIC, ::AbstractModel) function.
SpeedyWeather.AbstractLand Type
Abstract supertype for all land models. Custom land models should subtype AbstractWetLand or AbstractDryLand and implement initialize!, timestep!, and optionally variables and filter!.
SpeedyWeather.AbstractLandComponent Type
Abstract supertype for sub-components of a land model (soil temperature, soil moisture, snow, vegetation, rivers). Each component implements initialize!, timestep!, and optionally variables and filter!.
SpeedyWeather.AbstractLandSeaMask Type
Abstract super type for land-sea masks. Custom land-sea masks have to be defined as
CustomMask{NF, GridVariable2D} <: AbstractLandSeaMaskand need to have at least a field called land_fraction::GridVariable2D that uses a GridVariable2D as defined by the spectral grid object, so of correct size and with the number format NF. All AbstractLandSeaMask have a convenient generator function to be used like mask = CustomMask(spectral_grid, option=argument), but you may add your own or customize by defining CustomMask(args...) which should return an instance of type CustomMask{NF, Grid} with parameters matching the spectral grid. Then the initialize function has to be extended for that new mask
initialize!(mask::CustomMask, model::PrimitiveEquation)which generally is used to tweak the mask.land_fraction grid as you like, using any other options you have included in CustomMask as fields or anything else (preferrably read-only, because this is only to initialize the land-sea mask, nothing else) from model. You can for example read something from file, set some values manually, or use coordinates from model.geometry.
The land-sea mask grid is expected to have values between [0, 1] as we use a fractional mask, allowing for grid points being, e.g. quarter land and three quarters sea for 0.25 with 0 (=sea) and 1 (=land). The surface fluxes will weight proportionally the fluxes e.g. from sea and land surface temperatures. Note however, that the land-sea mask can declare grid points being (at least partially) ocean even though the sea surface temperatures aren't defined (=NaN) in that grid point. In that case, not flux is applied.
sourceSpeedyWeather.AbstractOutputLayers Type
Supertype of the vertical layers that an output writer writes its 3D variables on. A property of the writer (like its output grid), not of the individual output variables, set with the layers keyword argument, e.g. NetCDFOutput(spectral_grid, layers = PressureLayers(spectral_grid)). Subtypes are ModelLayers and PressureLayers.
SpeedyWeather.AbstractParameterization Type
abstract type AbstractParameterization <: SpeedyWeather.AbstractModelComponentAbstract type for all column-based parmaetrizations. Custom parametrizations are expected to subtype this and implement the variables, initialize!, and parameterization! for it. In order to use the parameterization in a model, add it to the parameterizations of the model at definition.
SpeedyWeather.AbstractVariablesOutput Type
Abstract supertype for output writers that save Variables (or subsets thereof) at regular intervals. Subtypes must have fields: active, path, run_prefix, id, run_number, run_digits, overwrite, write_restart, write_parameters_txt, write_progress_txt, interval, groups, and core::OutputWriterCore.
SpeedyWeather.AbstractVerticalCoordinates Type
Abstract supertype for vertical coordinate systems. Subtypes define how model levels are mapped to pressure given a surface pressure. Must implement pressure, pressure_half, pressure_thickness, and sigma (see each for their signatures).
SpeedyWeather.AbstractVerticalExtrapolation Type
Supertype of methods to extrapolate above the top-most or below the bottom-most full model layer, used by interpolate_pressure_layers!. Subtypes extend extrapolate_below and optionally extrapolate_above.
SpeedyWeather.AbstractVerticalInterpolation Type
Supertype of methods to interpolate between two model layers, used by interpolate_pressure_layers! to interpolate from the model's vertical layers onto pressure layers.
SpeedyWeather.AbstractWetLand Type
Abstract land model type that includes hydrological processes (soil moisture, snow, vegetation, rivers). Intended for use with PrimitiveWet. The default concrete type is LandModel.
SpeedyWeather.AbstractZarrOutput Type
Supertype of all output writers that write into a Zarr store. Subtypes share the time-chunk buffering, the time axis and the coordinate helpers implemented in the SpeedyWeatherZarrExt extension and must have the fields zarr_group, time_buffers, time_chunk, compressor and variables. Concrete subtypes are ZarrOutput (rectangular lon/lat layout) and HEALPixOutput (flat HEALPix layout).
SpeedyWeather.AdiabaticConversion Type
Terms used to compute the adiabatic conversion term in the spectral model. Fields are:
σ_lnp_A::Any: σ-related factor A needed for adiabatic conversion termσ_lnp_B::Any: σ-related factor B needed for adiabatic conversion term
SpeedyWeather.AlbedoClimatology Type
Albedo climatology loaded from netcdf file. Fields are
file::String = "albedo.nc": [OPTION] filename of albedopath::String = joinpath("data", "boundary_conditions", file): [OPTION] path to the folder containing the soil moisturefrom_assets::Bool = true: [OPTION] flag to check for soil moisture in SpeedyWeatherAssets or locallyvarname::String = "alb": [OPTION] variable name in netcdf fileversion::VersionNumber = DEFAULT_ASSETS_VERSION: [OPTION] SpeedyWeatherAssets version numberFieldType::Type{<:AbstractField} = FullGaussianField: [OPTION] Grid the albedo file comes onalbedo::Any: Albedo climatology
SpeedyWeather.AquaPlanet Type
AquaPlanet sea surface temperatures that are constant in time and longitude, but vary in latitude following a coslat². To be created like
ocean = AquaPlanet(spectral_grid, temperature_equator=302, temperature_poles=273)Fields and options are
temperature_equator::Any: [OPTION] Temperature on the Equator [K]temperature_poles::Any: [OPTION] Temperature at the poles [K]mask::Bool = true: [OPTION] Mask initial sea surface temperature with land-sea mask?land_temperature::Any = 285: [OPTION] SST over land [K]
SpeedyWeather.AquaPlanetMask Type
Land-sea mask with zero = sea everywhere.
land_fraction::Any: Land-sea mask [1] on grid-point space. Land=1, sea=0, land-area fraction in between.
SpeedyWeather.ArrayOutput Type
Output writer that stores Variables snapshots in memory instead of writing to a file. Access the stored snapshots via output.output after the simulation. Otherwise follows the same logic as JLD2Output. Fields are
active::Bool = falsewrite_restart::Bool = false: [OPTION] also write restart file if output=true?write_parameters_txt::Bool = false: [OPTION] also write parameters txt file if output=true?write_progress_txt::Bool = false: [OPTION] also write progress txt file if output=true?interval::Second = Second(DEFAULT_OUTPUT_INTERVAL): [OPTION] output frequency, time stepgroups::Tuple{Vararg{Symbol}} = (:all,): [OPTION] which variable groups to save, e.g. (:prognostic,) or (:prognostic, :grid). Use (:all,) for all groups.core::OutputWriterCore = OutputWriterCore(): [DERIVED] shared output writer state (run folder, counters, output frequency)output::Vector = []: [DERIVED] vector of stored variable snapshots, populated during the simulation
SpeedyWeather.BackgroundShortwaveTransmissivity Type
BackgroundShortwaveTransmissivity <: AbstractShortwaveTransmissivity
zenith_amplitude::Any: [OPTION] Zenith correction amplitude (SPEEDY azen) [1]zenith_exponent::Any: [OPTION] Zenith correction exponent (SPEEDY nzen)absorptivity_dry_air::Any: [OPTION] Absorptivity of dry air [per 10^5 Pa]aerosols::Bool = true: [OPTION] Constant aerosol concentration?absorptivity_aerosol::Any: [OPTION] Absorptivity of aerosols [per 10^5 Pa]absorptivity_water_vapor::Any: [OPTION] Absorptivity of water vapor [per kg/kg per 10^5 Pa]absorptivity_cloud_base::Any: [OPTION] Base cloud absorptivity [per kg/kg per 10^5 Pa]absorptivity_cloud_limit::Any: [OPTION] Maximum cloud absorptivity [per 10^5 Pa]
.
sourceSpeedyWeather.BalancedZonalState Type
Zonal wind and temperature in thermal wind balance, generalising the Jablonowski and Williamson, 2006 (JW) initial conditions to a vertical wind profile and a global-mean temperature profile close to the equilibrium climate of the PrimitiveWetModel. With the dimensionless log-pressure coordinate z = -ln(σ) (not a height in meters) the zonal wind is
u(φ, σ) = U(σ) sin²(2φ), U(σ) = u₀ tanh(z / H) f(z)
f(z) = exp(-((z - z_jet) / D)²) for z > z_jet = -ln(σ_jet), 1 otherwisewhich is zero at the surface, increases about linearly with z in the troposphere and decays above the jet at about σ_jet with a decay scale D (jet_decay). Useσ_jet = 0 for no decay (f = 1), so that the wind increases monotonically up to the model top. Balance then gives the temperature (JW eq. 6 is the special case U = u₀cos^(3/2)(ηᵥ))
T(φ, σ) = T̄(σ) + (1/R_d) dU/dz (2A(φ)U + B(φ)RΩ)
A(φ) = -2sin⁶(φ)(cos²(φ) + 1/3) + 10/63
B(φ) = 8/5 cos³(φ)(sin²(φ) + 2/3) - π/4A and B have zero global mean, so T̄(σ) = max(T₀ σ^(R_dΓ/g), Tmin) is the global-mean temperature profile, with T₀ = atmosphere.reference_temperatureand Γ =lapse_rate(atmosphere)(the moist lapse rate for wet atmospheres). Sets vorticity (including the JW perturbation to trigger baroclinic instability), divergence (JW perturbation), surface pressure and temperature. The surface pressure is hydrostatic with T₀ - Γh on orography of height h and temperature is evaluated with p/p₀ = σpₛ/p₀ instead of σ, so that both are consistent over orography. Do not combine withPressureOnOrography, which would overwrite the surface pressure. Combine withConstantRelativeHumidity for humidity.
u₀::Any = 56: [OPTION] Zonal wind speed scale, U = u₀ tanh(z / H) f(z), z = -ln(σ) [m/s]H::Any = 2: [OPTION] Vertical scale of the zonal wind in z = -ln(σ), U = u₀ tanh(z / H) f(z) [1]σ_jet::Any = 0.3: [OPTION] σ level above which the zonal wind decays, 0 for no decay [1]jet_decay::Any = 1.5: [OPTION] Decay scale D in z = -ln(σ) above the jet, f(z) = exp(-((z - z_jet) / D)²) [1]Tmin::Any = 226: [OPTION] Minimum global-mean temperature, isothermal stratosphere above [K]perturb_lat::Any = 40: [OPTION] perturbation centred at [˚N]perturb_lon::Any = 20: [OPTION] perturbation centred at [˚E]perturb_uₚ::Any = 1: [OPTION] perturbation strength [m/s]perturb_radius::Any = 1 / 10: [OPTION] radius of Gaussian perturbation in units of Earth's radius [1]
SpeedyWeather.BarotropicModel Type
The BarotropicModel contains all model components needed for the simulation of the barotropic vorticity equations. To be constructed like
model = BarotropicModel(spectral_grid; kwargs...)with spectral_grid::SpectralGrid used to initalize all non-default components passed on as keyword arguments, e.g. planet=Earth(spectral_grid). Fields, representing model components, are
spectral_grid::Anyarchitecture::Any = spectral_grid.architecturegeometry::Anyplanet::Anyatmosphere::Anycoriolis::Anyforcing::Anydrag::Anyparticle_advection::Anyinitial_conditions::Anyrandom_process::Any = nothingtracers::Dict{Symbol, Tracer} = TRACER_DICT()time_stepping::Any = NCycleLorenz(spectral_grid)spectral_transform::Any = WhichTransform(spectral_grid)implicit::Any = nothinghorizontal_diffusion::Any = HyperDiffusion(spectral_grid)output::Any = NetCDFOutput(spectral_grid, Barotropic)callbacks::Dict{Symbol, SpeedyWeather.AbstractCallback} = Dict{Symbol, AbstractCallback}()feedback::Any = Feedback()
SpeedyWeather.BettsMillerConvection Type
The simplified Betts-Miller convection scheme from Frierson, 2007, https://doi.org/10.1175/JAS3935.1. This implements the qref-formulation in their paper. Fields and options are
time_scale::Second = Hour(4): [OPTION] Relaxation time for profile adjustmentrelative_humidity::Any: [OPTION] Relative humidity for reference profile [1]entrainment::SpeedyWeather.AbstractEntrainment: [OPTION] Entrainment profile mixing environmental air into the rising parcelsnow::Bool = true: [OPTION] Convert convective rain below freezing to snow?freezing_threshold::Any: [OPTION] Temperature of the lowermost layer below which convective rain becomes snow [K]
SpeedyWeather.BettsMillerDryConvection Type
The simplified Betts-Miller convection scheme from Frierson, 2007, https://doi.org/10.1175/JAS3935.1 but with humidity set to zero. Fields and options are
time_scale::Second = Hour(4): [OPTION] Relaxation time for profile adjustmententrainment::SpeedyWeather.AbstractEntrainment: [OPTION] Entrainment profile mixing environmental air into the rising parcel
SpeedyWeather.BoundaryLayer Type
Composite boundary layer parameterization computing the drag coefficients for surface fluxes of momentum, heat and humidity. Its subcomponents are executed in the following order:
surface_condition: extrapolates temperature, density and wind to the surfaceneutral_wind_speed: neutral (stability-corrected) surface wind speedsurface_roughness: roughness lengths for momentum, heat and humidity over land and oceandrag: drag coefficients for momentum, heat and humidity over land and ocean
The wind slowdown in the surface condition uses fixed roughness lengths by default, or optionally the surface roughness from the previous time step (see LearnedWindSlowdown). This is not the default to avoid hidden state. Fields are
surface_condition::Anyneutral_wind_speed::Anysurface_roughness::Anydrag::Any
SpeedyWeather.BulkRichardsonDrag Type
Boundary layer drag coefficient from the bulk Richardson number, following Frierson, 2006, Journal of the Atmospheric Sciences.
von_Karman::Any: [OPTION] von Kármán constant [1]critical_Richardson::Any: [OPTION] Critical Richardson number for stable mixing cutoff [1]drag_min::Any: [OPTION] Drag minimum to avoid zero surface fluxes in stable conditions [1]
SpeedyWeather.CO2 Type
CO2{F}(; concentration) where F
CO2(; concentration)
CO2{F}(concentration) where F -> CO2
CO2(concentration::F) where F -> CO2CO2 concentration [ppm] that can be a constant, e.g. CO2(420) or a function of t::DateTime, e.g. CO2(t -> 280 + year(t) - 1850) for a linear (but stepwise) increase by 1ppm per year.
SpeedyWeather.Century Type
Century{IntType} <: PeriodConvenience time type representing a 100-year period. Parametric on IntType for Reactant compatibility.
SpeedyWeather.Charnock Type
Wind-dependent Charnock parameterization using a piecewise polynomial function of neutral wind speed.
The Charnock parameter α is calculated as
α = c1*uₙ^3 + c2*uₙ^2 + c3 for uₙ ≤ Uₜ
α = c4*(uₙ - Uₜ) + c5 for uₙ > Uₜwhere
uₙ: Neutral wind speed [m/s]
Uₜ: Threshold wind speed [m/s]
c1 to c5: Fitted coefficients
The parameterization returns α, which is used as an input to the learned ocean momentum roughness parameterization. Its logarithm is used as a predictor in the learned ocean momentum roughness parameterization.
Fields are
Uₜ::Any: [OPTION] threshold wind speed [m/s] for Charnock parameterizationc1::Any: [OPTION] low wind cubic term coefficientc2::Any: [OPTION] low wind quadratic term coefficientc3::Any: [OPTION] low wind constant term coefficientc4::Any: [OPTION] high wind linear term coefficientc5::Any: [OPTION] high wind constant term coefficientcharnock_min::Any: [OPTION] minimum Charnock parameter value
SpeedyWeather.Clock Type
Clock struct keeps track of the model time, how many days to integrate for and how many time steps this takes.
time::Any = DEFAULT_DATE: current model timestart::Any = DEFAULT_DATE: start time of simulationrotation_time::Any = time: Rotation time for daily cycleorbit_time::Any = time: Orbit time for seasonal cycleperiod::Any = Second(0): period to integrate forrotation_dilation::Any = 1.0f0: Dilation (relative speed wrt time) of rotation time for daily cycle, used for solar zenith calculationsorbit_dilation::Any = 1.0f0: Dilation (relative speed wrt time) of orbit time for seasonal cycle, used for solar zenith calculationsstep_counter::Any = 0: Counting all steps the time stepper takes during simulationtime_step_counter::Any = 0: Counting all time steps of size Δt, ignoring additional spin-up stepsn_steps::Any = 0: Number of time stepper steps, regardless their step sizen_time_steps::Any = 0: Number of time steps of size ΔtΔt::Any = Millisecond(0): Time step
SpeedyWeather.Clock Method
Clock(
time_stepping::SpeedyWeather.AbstractTimeStepper;
kwargs...
) -> Clock{DateTime, Second, Float32, Int64, Millisecond}Create and initialize a clock from time_stepping.
SpeedyWeather.ConstantDrag Type
Constant boundary layer drag coefficient. Fields are
land_drag::Any: [OPTION] Constant land drag coefficient [1]ocean_drag::Any: [OPTION] Constant ocean drag coefficient [1]
SpeedyWeather.ConstantEntrainment Type
Constant entrainment profile: entrainment rate is the same at every model level. Fields are
entrainment_rate::Any: [OPTION] Constant entrainment rate [1]
SpeedyWeather.ConstantEntrainment Method
(E::ConstantEntrainment)(σ)Entrainment rate at sigma level σ for the constant profile.
sourceSpeedyWeather.ConstantExtrapolation Type
Hold the outer-most model layer constant beyond the model layers.
sourceSpeedyWeather.ConstantOceanClimatology Type
Constant ocean climatology that reads monthly sea surface temperature fields from file, and interpolates them only for the initial conditions in time to be stored in the prognostic variables. It is therefore an ocean from climatology but without a seasonal cycle that is constant in time. To be created like
ocean = SeasonalOceanClimatology(spectral_grid)and the ocean time is set with initialize!(model, time=time). Fields and options are
file::String = "sea_surface_temperature.nc": [OPTION] filename of sea surface temperaturespath::String = joinpath("data", "boundary_conditions", file): [OPTION] path to the folder containing the sstfrom_assets::Bool = true: [OPTION] flag to check for sst in SpeedyWeatherAssets or locallyversion::VersionNumber = DEFAULT_ASSETS_VERSION: [OPTION] SpeedyWeatherAssets version numbervarname::String = "sst": [OPTION] Variable name in netcdf fileFieldType::Type{<:AbstractField} = FullGaussianField: [OPTION] Grid the sea surface temperature file comes onmask::Bool = true: [OPTION] Mask initial sea surface temperature with land-sea mask?land_temperature::Any = 285: [OPTION] SST over land [K]
SpeedyWeather.ConstantRelativeHumidity Type
Humidity as a fraction of saturation, relative humidity is relhumid_ref below σ_moist and decreases linearly to zero at σ_dry for a dry stratosphere. σ_moist = σ_dry = 0 for a vertically constant relative humidity, σ_moist = 1, σ_dry = 0.02 for the relative humidity of Manabe and Wetherald, 1967, decreasing linearly with σ. Uses temperature and pressure so has to be applied after those initial conditions.
relhumid_ref::Any = 0.7: [OPTION] Relative humidity as fraction of saturation below σ_moist [1]σ_moist::Any = 0.25: [OPTION] σ below which (towards the surface) relative humidity is relhumid_ref [1]σ_dry::Any = 0.1: [OPTION] σ above which (towards the top) relative humidity is zero [1]
SpeedyWeather.ConstantShortwaveTransmissivity Type
Constant transmissivity for the shortwave, weighted by pressure thickness per layer. (
transmissivity::Any: [OPTION] Transmissivity of the whole atmosphere (0 .. 1)
)
sourceSpeedyWeather.ConstantSurfaceRoughness Type
Surface roughness length parameterization with constant roughness length over land and ocean. Fields are
momentum_roughness_land::Any: [OPTION] constant momentum roughness length over land [m]heat_roughness_land::Any: [OPTION] constant heat roughness length over land [m]humidity_roughness_land::Any: [OPTION] constant humidity roughness length over land [m]momentum_roughness_ocean::Any: [OPTION] constant momentum roughness length over ocean [m]heat_roughness_ocean::Any: [OPTION] constant heat roughness length over ocean [m]humidity_roughness_ocean::Any: [OPTION] constant humidity roughness length over ocean [m]
SpeedyWeather.ConvectiveHeating Type
Convective heating as defined by Lee and Kim, 2003, JAS implemented as convection parameterization. Fields are
time_scale::Second = Hour(12): [OPTION] Q_max heating strength as 1K/time_scalep₀::Any: [OPTION] Pressure of maximum heating [hPa]σₚ::Any: [OPTION] Vertical extent of heating [hPa]θ₀::Any: [OPTION] Latitude of heating [˚N]σθ::Any: [OPTION] Latitudinal width of heating [˚]lat_mask::Any: [DERIVED] Latitudinal mask
SpeedyWeather.Coriolis Type
Model component holding the Coriolis parameter f on the model grid, a vector over the latitude rings.
f::Any: [DERIVED] Coriolis frequency [s^-1], = 2Ω*sin(lat)
SpeedyWeather.DryAdiabaticExtrapolation Type
Extrapolate dry-adiabatically below the lowest model layer, T(p) = T*(p/p_bottom)^κ, to obtain e.g. a 1000 hPa temperature below a model layer that sits above it. Same adiabat as used for the mean sea-level pressure output. Fields are
κ::Any = 2 / 7: [DERIVED] adiabatic exponent κ = R_dry/cₚ, set from the model's atmosphere at initialize!
SpeedyWeather.DryLandModel Type
Simplified land model with only geometry, thermodynamics, and soil temperature, omitting hydrological components, i.e. no soil moisture, snow, vegetation, nor rivers. Fields are
spectral_grid::SpectralGridgeometry::Anythermodynamics::Anytemperature::Any
SpeedyWeather.DynamicsVariable Type
DynamicsVariable{D, U}(;
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U}
DynamicsVariable(; name, dims, units, desc, namespace, fuse)
DynamicsVariable{D, U}(
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U} -> DynamicsVariable
DynamicsVariable(
name::Symbol,
dims::D,
units::U,
desc::String,
namespace::Symbol,
fuse::Symbol
) where {D, U} -> DynamicsVariableA variable defined through its name, dimensions dims and optionally its units, description desc and the namespace it's sorted under within a variable group. Variables sharing the same non-empty fuse symbol (within the same namespace) are allocated as views of a single shared parent buffer, which is exposed in the resulting NamedTuple under the fuse symbol. This definition is only used to return an object to define that a given model component wants to define a variable – allocation and being sorted into the Variables tree happens elsewhere.
SpeedyWeather.Earth Type
Earth{NF, S, DT, B}(;
radius,
rotation,
gravity,
daily_cycle,
length_of_day,
seasonal_cycle,
length_of_year,
equinox,
axial_tilt,
solar_constant
) where {NF, S, DT, B} -> Earth
Earth(;
radius,
rotation,
gravity,
daily_cycle,
length_of_day,
seasonal_cycle,
length_of_year,
equinox,
axial_tilt,
solar_constant
) -> Earth{Float64, Second, DateTime, Bool}
Earth{NF, S, DT, B}(
radius,
rotation,
gravity,
daily_cycle,
length_of_day,
seasonal_cycle,
length_of_year,
equinox,
axial_tilt,
solar_constant
) where {NF, S, DT, B} -> Earth
Earth(
radius::NF,
rotation::NF,
gravity::NF,
daily_cycle::B,
length_of_day::S,
seasonal_cycle::B,
length_of_year::S,
equinox::DT,
axial_tilt::NF,
solar_constant::NF
) where {NF, S, DT, B} -> EarthCreate a struct Earth<:AbstractPlanet, with the following physical/orbital characteristics. Note that radius is not part of it as this should be chosen in SpectralGrid. Keyword arguments are
radius::Any: Earth's radius [m]rotation::Any: angular frequency of Earth's rotation [rad/s]gravity::Any: gravitational acceleration [m/s^2]daily_cycle::Any = true: switch on/off daily cyclelength_of_day::Any = Second(EARTH_DAY): Seconds in a daily rotationseasonal_cycle::Any = true: switch on/off seasonal cyclelength_of_year::Any = Second(EARTH_YEAR): Seconds in an orbit around the sunequinox::Any = EARTH_EQUINOX: time of spring equinox (year irrelevant)axial_tilt::Any: angle [˚] rotation axis tilt wrt to orbitsolar_constant::Any: Total solar irradiance at the distance of 1 AU [W/m²]
SpeedyWeather.EarthAtmosphere Type
EarthAtmosphere{NF}(;
mol_mass_dry_air,
mol_mass_vapor,
heat_capacity,
R_gas,
R_dry,
R_vapor,
mol_ratio,
μ_virt_temp,
κ,
water_density,
latent_heat_condensation,
latent_heat_sublimation,
latent_heat_fusion,
stefan_boltzmann,
reference_pressure,
saturation_vapor_pressure,
reference_temperature,
temperature_freezing,
moist_lapse_rate,
dry_lapse_rate
) where NF -> EarthAtmosphere
EarthAtmosphere(;
mol_mass_dry_air,
mol_mass_vapor,
heat_capacity,
R_gas,
R_dry,
R_vapor,
mol_ratio,
μ_virt_temp,
κ,
water_density,
latent_heat_condensation,
latent_heat_sublimation,
latent_heat_fusion,
stefan_boltzmann,
reference_pressure,
saturation_vapor_pressure,
reference_temperature,
temperature_freezing,
moist_lapse_rate,
dry_lapse_rate
) -> EarthAtmosphere{Float64}
EarthAtmosphere{NF}(
mol_mass_dry_air,
mol_mass_vapor,
heat_capacity,
R_gas,
R_dry,
R_vapor,
mol_ratio,
μ_virt_temp,
κ,
water_density,
latent_heat_condensation,
latent_heat_sublimation,
latent_heat_fusion,
stefan_boltzmann,
reference_pressure,
saturation_vapor_pressure,
reference_temperature,
temperature_freezing,
moist_lapse_rate,
dry_lapse_rate
) where NF -> EarthAtmosphere
EarthAtmosphere(
mol_mass_dry_air::NF,
mol_mass_vapor::NF,
heat_capacity::NF,
R_gas::NF,
R_dry::NF,
R_vapor::NF,
mol_ratio::NF,
μ_virt_temp::NF,
κ::NF,
water_density::NF,
latent_heat_condensation::NF,
latent_heat_sublimation::NF,
latent_heat_fusion::NF,
stefan_boltzmann::NF,
reference_pressure::NF,
saturation_vapor_pressure::NF,
reference_temperature::NF,
temperature_freezing::NF,
moist_lapse_rate::NF,
dry_lapse_rate::NF
) where NF -> EarthAtmosphereCreate a struct EarthAtmosphere <: AbstractAtmosphere, with the following physical/chemical characteristics. Keyword arguments are
mol_mass_dry_air::Any: [OPTION] Molar mass of dry air [g/mol]mol_mass_vapor::Any: [OPTION] Molar mass of water vapor [g/mol]heat_capacity::Any: [OPTION] Specific heat at constant pressure cₚ [J/K/kg]R_gas::Any = 8.3145: [OPTION] Universal gas constant [J/K/mol]R_dry::Any = (1000R_gas) / mol_mass_dry_air: [OPTION] Specific gas constant for dry air [J/kg/K]R_vapor::Any: [OPTION] Specific gas constant for water vapor [J/kg/K]mol_ratio::Any: [OPTION] Ratio of gas constants: dry air / water vapor, often called ε [1]μ_virt_temp::Any: [OPTION] Virtual temperature Tᵥ calculation, Tᵥ = T(1 + μ*q), specific humidity q [kg/kg], absolute tempereature T [K]κ::Any: [OPTION] κ = R_dry/cₚ, gas constant for dry air over heat capacity [1]water_density::Any: [OPTION] Water density [kg/m³]latent_heat_condensation::Any: [OPTION] Latent heat of condensation [J/kg]latent_heat_sublimation::Any: [OPTION] Latent heat of sublimation [J/kg]latent_heat_fusion::Any: [OPTION] Latent heat of freezing/fusion of ice [J/kg]stefan_boltzmann::Any = 5.67e-8: [OPTION] Stefan-Boltzmann constant [W/m²/K⁴]reference_pressure::Any: [OPTION] Surface reference pressure [Pa]saturation_vapor_pressure::Any: [OPTION] Saturation vapor pressure at freezing point (0°C) [Pa]reference_temperature::Any: [OPTION] Surface reference temperature [K]temperature_freezing::Any: [OPTION] Temperature of freezing point of water [K]moist_lapse_rate::Any: [OPTION] Reference moist-adiabatic temperature lapse rate [K/m]dry_lapse_rate::Any: [OPTION] Reference dry-adiabatic temperature lapse rate [K/m]
SpeedyWeather.EarthLandSeaMask Type
Land-sea mask, fractional, read from file.
file::String = "land-sea_mask.nc": filename of land sea maskpath::String = joinpath("data", "boundary_conditions", file): path to the folder containing the orographyfrom_assets::Bool = true: flag to check for land-sea mask in SpeedyWeatherAssets or locallyversion::VersionNumber = DEFAULT_ASSETS_VERSION: [OPTION] SpeedyWeatherAssets version numbervarname::String = "lsm": NCDataset variable nameFieldType::Type{<:AbstractField} = FullClenshawField: Grid the land-sea mask file comes onquantization::Any = 0.01: [OPTION] Quantization to fraction?land_fraction::Any: Land-sea mask [1] on grid-point space. Land=1, sea=0, land-area fraction in between.
SpeedyWeather.EarthOrography Type
Earth's orography read from file, with smoothing.
file::String = "orography.nc": [OPTION] filename of orographypath::String = joinpath("data", "boundary_conditions", file): [OPTION] path to the folder containing the orographyfrom_assets::Bool = true: [OPTION] flag to check for orography in SpeedyWeatherAssets or locallyversion::VersionNumber = DEFAULT_ASSETS_VERSION: [OPTION] SpeedyWeatherAssets version numbervarname::String = "orog": [OPTION] NCDataset variable nameFieldType::Type{<:AbstractField} = FullGaussianField: [OPTION] Grid the orography file comes onscale::Any = 1.0: [OPTION] scale orography by a factorsmoothing::Bool = true: [OPTION] smooth the orography field?smoothing_power::Any = 1.0: [OPTION] ower of Laplacian for smoothingsmoothing_strength::Any = 0.1: [OPTION] highest degree l is multiplied bysmoothing_fraction::Any = 0.05: [OPTION] fraction of highest wavenumbers to smoothorography::Any: [DERIVED] height [m] on grid-point space.surface_geopotential::Any: [DERIVED] surface geopotential, height*gravity [m²/s²]
SpeedyWeather.EulerForward Type
Euler forward time stepping, used by default for the ocean and land namespaces with Leapfrog (see its ocean and land fields). Defined by the following fields
Δt_at_T32::Any: [OPTION] Time step for T32, scale linearly to spectral resolutiontruncationadjust_with_output::Any: [OPTION] AdjustΔt_at_T32with the outputintervalto output exactly after integer time stepsΔt_millisec::Any: [DERIVED] Time step Δt in milliseconds at specified resolutionΔt::Any: [DERIVED] Time step Δt [s] at specified resolution
SpeedyWeather.EulerForward Method
EulerForward(
spectral_grid::SpectralGrid;
Δt_at_T32=Minute(40),
adjust_with_output=true
) -> EulerForward{NF, Second, Bool, Millisecond} where NF<:AbstractFloatGenerator function for an EulerForward struct using spectral_grid for the resolution information.
SpeedyWeather.ExplicitFluxes Type
Explicit (forward) time integration of surface fluxes, unstable for Δt/τ > 2.
SpeedyWeather.ExponentialCO2 Type
ExponentialCO2{NF, DT}(;
base_concentration,
start,
a,
b
) where {NF, DT} -> ExponentialCO2
ExponentialCO2(; base_concentration, start, a, b)
ExponentialCO2{NF, DT}(
base_concentration,
start,
a,
b
) where {NF, DT} -> ExponentialCO2
ExponentialCO2(
base_concentration::NF,
start::DT,
a::NF,
b::NF
) where {NF, DT} -> ExponentialCO2Exponential CO2 concentration with defaults fitted to the Keeling curve, ignoring seasonal variation.
sourceSpeedyWeather.ExponentialFluxes Type
Exponential time differencing of surface fluxes, damping the explicit flux by (1 - exp(-Δt/τ))/(Δt/τ). Exact for a fixed surface value, unconditionally stable.
SpeedyWeather.Feedback Type
Feedback struct that contains options and object for command-line feedback like the progress meter.
verbose::Bool = isinteractive(): [OPTION] print feedback to REPL?, default is isinteractive(), true in interactive REPL modedebug::Bool = true: [OPTION] check for NaNs in the prognostic variablesdescription::String = "": [OPTION] Progress descriptionprogress_bar_length::Union{Nothing, Int64} = 0: [OPTION] Progress bar length in characters,nothingfits it to the terminal width,0shows no barshowspeed::Bool = true: [OPTION] show speed (e.g. in simulated years per day) in progress meter?feedback_dt::Float32 = 0.1: [OPTION] Minimum wallclock time between feedback updatesshow_time::Bool = true: [OPTION] Show simulation time?show_umax::Union{Nothing, Bool} = nothing: [OPTION] Show maximum speed of the simulated flow [m/s],nothing= yes except for Reactant (opt-in there)show_temperature_range::Union{Nothing, Bool} = nothing: [OPTION] Show temperature range of simulation [˚C],nothing= yes except for Reactant (opt-in there)interval::Int64 = 50: [OPTION] Interval in time steps between NaN checks, and between the progress meter diagnostics (maximum speed, temperature range)progress_meter::ProgressMeter.Progress = ProgressMeter.Progress(1, enabled = verbose): [DERIVED] struct containing everything progress relatednans_detected::Bool = false: [DERIVED] did NaNs occur in the simulation?
SpeedyWeather.FusedParent Type
FusedParent{P, S}(
parent,
slot_map
) where {P, S<:NamedTuple} -> SpeedyWeather.FusedParent
FusedParent(
parent::P,
slot_map::S
) where {P, S<:NamedTuple} -> SpeedyWeather.FusedParentWraps a fused parent buffer with the per-member slot map computed at construction.
parent is the underlying LowerTriangularArray or Field. slot_map is a NamedTuple mapping each fuse member's name::Symbol to its UnitRange{Int} along the parent's layer axis (axis 2 of parent.data). E.g. for a :prognostic fuse group on PrimitiveWet with nlayers = 8:
slot_map = (vorticity = 1:8, divergence = 9:16, temperature = 17:24, humidity = 25:32, pressure = 33:33)The slot map is used get_prognostic_step and get_tendency_step to slice the parent directly and by _assert_fuse_alignment to check that two fuse parents agree on member order.
SpeedyWeather.Geometry Type
Geometry{SpectralGridType, IntType, RefValueNF, VectorIntType, VC, VT1, VTLat, VTGrid, VTVert1, VTVert2}(;
spectral_grid,
nlat_half,
nlon_max,
nlat,
nlayers,
npoints,
radius,
whichring,
lond,
latd,
lat,
colat,
londs,
latds,
lons,
lats,
sinlat,
coslat,
coslat⁻¹,
coslat²,
coslat⁻²,
vertical_coordinates,
σ_levels_half,
σ_levels_full,
σ_levels_thick
) where {SpectralGridType, IntType, RefValueNF, VectorIntType, VC, VT1, VTLat, VTGrid, VTVert1, VTVert2}
Geometry(;
spectral_grid,
nlat_half,
nlon_max,
nlat,
nlayers,
npoints,
radius,
whichring,
lond,
latd,
lat,
colat,
londs,
latds,
lons,
lats,
sinlat,
coslat,
coslat⁻¹,
coslat²,
coslat⁻²,
vertical_coordinates,
σ_levels_half,
σ_levels_full,
σ_levels_thick
)
Geometry{SpectralGridType, IntType, RefValueNF, VectorIntType, VC, VT1, VTLat, VTGrid, VTVert1, VTVert2}(
spectral_grid,
nlat_half,
nlon_max,
nlat,
nlayers,
npoints,
radius,
whichring,
lond,
latd,
lat,
colat,
londs,
latds,
lons,
lats,
sinlat,
coslat,
coslat⁻¹,
coslat²,
coslat⁻²,
vertical_coordinates,
σ_levels_half,
σ_levels_full,
σ_levels_thick
) where {SpectralGridType, IntType, RefValueNF, VectorIntType, VC, VT1, VTLat, VTGrid, VTVert1, VTVert2} -> Geometry
Geometry(
spectral_grid::SpectralGridType,
nlat_half::IntType,
nlon_max::IntType,
nlat::IntType,
nlayers::IntType,
npoints::IntType,
radius::RefValueNF,
whichring::VectorIntType,
lond::VT1,
latd::VTLat,
lat::VTLat,
colat::VTLat,
londs::VTGrid,
latds::VTGrid,
lons::VTGrid,
lats::VTGrid,
sinlat::VTLat,
coslat::VTLat,
coslat⁻¹::VTLat,
coslat²::VTLat,
coslat⁻²::VTLat,
vertical_coordinates::VC,
σ_levels_half::VTVert1,
σ_levels_full::VTVert2,
σ_levels_thick::VTVert2
) where {SpectralGridType, IntType, RefValueNF, VectorIntType, VC, VT1, VTLat, VTGrid, VTVert1, VTVert2} -> GeometryConstruct Geometry struct containing parameters and arrays describing an iso-latitude grid <:AbstractGrid and the vertical levels. Pass on SpectralGrid to calculate the following fields
spectral_grid::Any: SpectralGrid that defines spectral and grid resolutionnlat_half::Any = spectral_grid.nlat_half: Resolution parameter nlat_half of Grid, # of latitudes on one hemisphere (incl Equator)nlon_max::Any = get_nlon_max(spectral_grid.Grid, nlat_half): Maximum number of longitudes (at/around Equator)nlat::Any = spectral_grid.nlat: Number of latitude ringsnlayers::Any = spectral_grid.nlayers: Number of vertical levelsnpoints::Any = spectral_grid.npoints: Total number of horizontal grid pointsradius::Any = RefValueNF(DEFAULT_RADIUS): Planet's radius [m], set from model.planet during initialize!whichring::Any = RingGrids.whichring(spectral_grid.grid): Latitude ring index j for every grid point ijlond::Any = get_lond(spectral_grid.Grid, nlat_half): Array of longitudes in degrees (0...360˚), empty for non-full gridslatd::Any = get_latd(spectral_grid.Grid, nlat_half): Array of latitudes in degrees (90˚...-90˚)lat::Any = get_lat(spectral_grid.Grid, nlat_half): Array of latitudes in radians (π...-π)colat::Any = get_colat(spectral_grid.Grid, nlat_half): Array of colatitudes in radians (0...π)londs::Any = (get_londlatds(spectral_grid.Grid, nlat_half))[1]: Longitude (0˚...360˚) for each grid point in ring orderlatds::Any = (get_londlatds(spectral_grid.Grid, nlat_half))[2]: Latitude (-90˚...˚90) for each grid point in ring orderlons::Any = (RingGrids.get_lonlats(spectral_grid.Grid, nlat_half))[1]: Longitude (0...2π) for each grid point in ring orderlats::Any = (RingGrids.get_lonlats(spectral_grid.Grid, nlat_half))[2]: Latitude (-π/2...π/2) for each grid point in ring ordersinlat::Any = sind.(latd): sin of latitudescoslat::Any = cosd.(latd): cos of latitudescoslat⁻¹::Any = 1 ./ coslat: = 1/cos(lat)coslat²::Any = coslat .^ 2: = cos²(lat)coslat⁻²::Any = 1 ./ coslat²: = 1/cos²(lat)vertical_coordinates::Any: Vertical coordinates usedσ_levels_half::Any: σ at half levels, σ_k+1/2σ_levels_full::Any = (σ_levels_half[2:end] + σ_levels_half[1:end - 1]) / 2: σ at full levels, σₖσ_levels_thick::Any = σ_levels_half[2:end] - σ_levels_half[1:end - 1]: σ level thicknesses, σₖ₊₁ - σₖ
SpeedyWeather.Geometry Method
Geometry(
SG::SpectralGrid;
vertical_coordinates=FriersonSigmaCoordinates(SG)
) -> Geometry{SpectralGridType, <:Any, RefValueNF, <:AbstractVector, VC, <:AbstractVector, <:AbstractVector, <:AbstractVector, <:AbstractVector, <:AbstractVector} where {SpectralGridType<:(SpectralGrid{ArchitectureType, SpectrumType, GridType, IntType, NFDealiasing} where {NFDealiasing, IntType, GridType, SpectrumType, ArchitectureType}), RefValueNF<:(Base.RefValue{<:AbstractFloat}), VC<:(SigmaCoordinates{IntType, VectorTypeHalf, VectorTypeFull} where {VectorTypeFull, VectorTypeHalf, IntType})}Generator function for Geometry struct based on spectral_grid.
SpeedyWeather.Geopotential Type
Geopotential calculation component for primitive equation models. Precomputes integration constants for vertical hydrostatic integration from temperature to geopotential on both full and half pressure levels using the hypsometric equation. Fields are
Δp_geopot_half::Any: [DERIVED] Used to compute the geopotential on half layersΔp_geopot_full::Any: [DERIVED] Used to compute the geopotential on full layers
SpeedyWeather.GlobalConstantAlbedo Type
Global constant albedo parameterization. To be used for land and ocean or only one of them within a OceanLandAlbedo. Fields are
albedo::Any = 0.3: [OPTION] Albedo value [1]
SpeedyWeather.GlobalMeanReferenceTemperature Type
GlobalMeanReferenceTemperature{NF}(;
offset
) where NF -> GlobalMeanReferenceTemperature
GlobalMeanReferenceTemperature(;
offset
) -> GlobalMeanReferenceTemperature{Int64}
GlobalMeanReferenceTemperature{NF}(
offset
) where NF -> GlobalMeanReferenceTemperature
GlobalMeanReferenceTemperature(
offset::NF
) where NF -> GlobalMeanReferenceTemperatureGlobal-mean temperature profile plus offset as reference temperature profile for the semi-implicit time stepping, recomputed on the schedule of the implicit solver.
offset::Any = 0: [OPTION] Offset [K] added to the global-mean temperature profile
SpeedyWeather.GlobalSurfaceTemperatureCallback Type
Callback that records the global mean surface temperature on every time step.
step_counter::Int64 = 0temperature::Vector = zeros(DEFAULT_NF, 0)
SpeedyWeather.Grid3D Type
Dimension for 3D grid variables on the horizontal grid with an unspecified 3rd dimension of length n (default 1, a trailing singleton dimension). Carries a neutral tag; prefer GridXYZ or GridXYT when the 3rd dimension is specifically vertical or time.
SpeedyWeather.Grid4D Type
Dimension for 4D grid variables with customizable extra dimension (neutral tag). Prefer GridXYZT when the trailing dimensions are specifically vertical + time.
SpeedyWeather.GridVariable Type
GridVariable{D, U}(;
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U}
GridVariable(; name, dims, units, desc, namespace, fuse)
GridVariable{D, U}(
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U} -> GridVariable
GridVariable(
name::Symbol,
dims::D,
units::U,
desc::String,
namespace::Symbol,
fuse::Symbol
) where {D, U} -> GridVariableA variable defined through its name, dimensions dims and optionally its units, description desc and the namespace it's sorted under within a variable group. Variables sharing the same non-empty fuse symbol (within the same namespace) are allocated as views of a single shared parent buffer, which is exposed in the resulting NamedTuple under the fuse symbol. This definition is only used to return an object to define that a given model component wants to define a variable – allocation and being sorted into the Variables tree happens elsewhere.
SpeedyWeather.GridXYT Type
Dimension for 3D grid variables on the horizontal grid with n time steps.
SpeedyWeather.GridXYZ Type
Dimension for 3D grid variables on the horizontal grid with vertical levels (nlayers).
sourceSpeedyWeather.GridXYZT Type
Dimension for 4D grid variables, horizontal + vertical (nlayers) + n time steps.
SpeedyWeather.HEALPixOutput Type
Output writer that writes a SpeedyWeather simulation to a Zarr store on an equal-area grid of the HEALPix family — a HEALPixGrid or an OctaHEALPixGrid — keeping the horizontal dimension flat (unravelled into a single cell dimension) exactly as a Field's data is. Data on any other grid is interpolated onto the output grid; a simulation that already runs on it is written without interpolation.
Alongside the variables the store holds one flat vector per cell with its latitude (lat, ˚N from the equator), its longitude (lon, ˚E in [0, 360)) and its ring index (ring), so consumers need no knowledge of SpeedyWeather's grid machinery to place the data on the sphere. Cells run ring by ring from north to south.
Both grids use this same store convention, but they are not equally portable:
on a
HEALPixGridthe cell order is the standard HEALPix RING order, i.e. the flat indexijis RING pixelij - 1(0-based), and the store carrieshealpix_nside,healpix_npixandhealpix_orderso healpy and cuHPX can read it directly. The coordinates match healpy'spix2ang(..., lonlat=true); healpy's default is colatitude in radians, i.e.θ = deg2rad(90 - lat).an
OctaHEALPixGridis a SpeedyWeather-specific member of the HEALPix family (4 faces,4nlat_half²points, no equatorial belt). It is equal-area and ring-ordered, but it is not standard HEALPix and healpy/cuHPX cannot read it, so those stores deliberately carry nohealpix_*attributes.
The actual implementation lives in the SpeedyWeatherZarrExt extension and is only available once Zarr.jl is loaded:
using Zarr
using SpeedyWeather
spectral_grid = SpectralGrid(truncation = 31, nlayers = 8)
output = HEALPixOutput(spectral_grid, PrimitiveWet, nside = 16)
# or on an OctaHEALPixGrid, which also takes odd nlat_half
output = HEALPixOutput(spectral_grid, PrimitiveWet, output_grid = OctaHEALPixGrid(24))Type parameters: Field2D, Field3D are the scratch field types on the output grid (on the model's architecture), HostField2D, HostField3D their host (CPU) equivalents to write from, Interpolator is the interpolator type (or Nothing when the model grid already is the output grid and interpolation is skipped), DT and S are the start-date and output-step types, C is the Zarr compressor type (or Nothing for the Zarr default), Z is the Zarr group type once initialize! has been called (Nothing before) and Layers the type of the vertical output layers. Fields are
active::Bool = falsepath::String = pwd(): [OPTION] path to output parent folder, run folders will be created withinrun_prefix::String = "run": [OPTION] Prefix for run folder where data is stored, e.g. 'run_'id::String = "": [OPTION] run identification, added between run_prefix and run_numberrun_number::Int64 = 1: [OPTION] run identification number, automatically determined if overwrite=falserun_digits::Int64 = 4: [OPTION] run numbers digitscore::OutputWriterCore = OutputWriterCore(): [DERIVED] shared output writer state (run folder, counters, output frequency)overwrite::Bool = false: [OPTION] Overwrite an existing run folder?filename::String = "output_healpix.zarr": [OPTION] name of the output zarr store (a directory)write_restart::Bool = true: [OPTION] also write restart file if output=true?write_parameters_txt::Bool = true: [OPTION] also write parameters txt file if output=true?write_progress_txt::Bool = true: [OPTION] also write progress txt file if output=true?startdate::Any = DateTime(2000, 1, 1): [DERIVED] start date of the simulation, used for time dimension in zarr storeinterval::Any = Second(DEFAULT_OUTPUT_INTERVAL): [OPTION] output frequency, time stepvariables::Dict{Symbol, SpeedyWeather.AbstractOutputVariable} = OutputVariablesDict(): [OPTION] dictionary of variables to output, e.g. u, v, vor, div, pres, temp, humidlayers::Any = ModelLayers(): [OPTION] vertical layers to write 3D atmospheric variables on,ModelLayers()(default) orPressureLayers(spectral_grid), seeAbstractOutputLayerstime_chunk::Int64 = 1: [OPTION] number of time steps per chunk along the time dimensioncell_chunk::Int64 = 0: [OPTION] chunk size along the flat cell dimension. 0 (default) means one chunk = all cells.vertical_chunk::Int64 = 0: [OPTION] chunk size along the vertical (layer / soil_layer). 0 (default) means full extent.compressor::Union{Nothing, C} where C = nothing: [OPTION] Zarr compressor (extension-typed).nothingkeeps the Zarr default.zarr_group::Union{Nothing, Z} where Z = nothing: [DERIVED] the Zarr group to be written into, created on initialize!time_buffers::Dict{String, Any} = Dict{String, Any}(): [DERIVED] per-variable time-chunk write buffers keyed by variable name, seeZarrOutputinterpolator::Anyland_fraction::Anyfield2D::Anyfield3D::Anyfield3Dland::Anyhost2D::Anyhost3D::Anyhost3Dland::Any
SpeedyWeather.HEALPixOutput Method
HEALPixOutput(SG::SpectralGrid, args...; kwargs...)Stub constructor for HEALPixOutput. Errors with a helpful message until the Zarr.jl extension is loaded, at which point the extension installs the real constructor.
SpeedyWeather.HeldSuarez Type
Temperature relaxation from Held and Suarez, 1996 BAMS
σb::Any = 0.7: [OPTION] sigma coordinate below which faster surface relaxation is appliedrelax_time_slow::Second = Day(40): [OPTION] time scale for slow global relaxationrelax_time_fast::Second = Day(4): [OPTION] time scale for faster tropical surface relaxationTmin::Any = 200: [OPTION] minimum equilibrium temperature [K]Tmax::Any = 315: [OPTION] maximum equilibrium temperature [K]ΔTy::Any = 60: [OPTION] meridional temperature gradient [K]Δθz::Any = 10: [OPTION] vertical temperature gradient [K]log_σ::Any: [DERIVED] log of sigma level per layertemp_relax_freq::Any: [DERIVED] relaxation time scale per layer and latitude (inverse, 1/s)temp_equil_a::Any: [DERIVED] Term a to calculate equilibrium temperature function of latitudetemp_equil_b::Any: [DERIVED] Term b to calculate equilibrium temperature function of latitude
SpeedyWeather.HeldSuarez Method
HeldSuarez(
SG::SpectralGrid;
kwargs...
) -> HeldSuarez{<:AbstractFloat, <:AbstractVector, <:AbstractMatrix}create a HeldSuarez temperature relaxation with arrays allocated given spectral_grid
SpeedyWeather.HyperDiffusion Type
Horizontal hyper diffusion of vorticity, div, temp, humid; implicitly in spectral space with a power of the Laplacian (default = 4) and the strength controlled by time_scale (default = 4 hours, time_scale_div = 1 hour for divergence). For all diffused variables the time_scale (=1/strength of diffusion) is reduced with increasing resolution through resolution_scaling.
Two sets of arrays are precomputed: expl/impl from time_scale at the constant power, applied to vorticity, temperature, humidity and tracers; and expl_div/impl_div from time_scale_div at a power that is linearly decreased in the vertical above the tapering_σ sigma level to power_stratosphere (default 2), applied to divergence only. The lower power aloft makes the diffusion less scale-selective there, acting as a sponge layer on the gravity waves that divergence carries.
For the BarotropicModel and ShallowWaterModel no tapering is applied as they are single-layer. Fields and options are
truncation::Any: spectral resolution (1-based)nlayers::Any: number of vertical levelspower::Any = 4: [OPTION] power of Laplaciantime_scale::Any = Hour(4): [OPTION] diffusion time scaletime_scale_div::Any = Hour(1): [OPTION] diffusion time scale for divergenceresolution_scaling::Any = 1: [OPTION] stronger diffusion with resolution? 0: constant with truncation, 1: (inverse) linear with truncation, etcpower_stratosphere::Any = 2: [OPTION] different power for tropopause/stratospheretapering_σ::Any = 0.2: [OPTION] linearly scale towards power_stratosphere above this σexpl::Any = zeros(NF, truncation + 1, nlayers)impl::Any = ones(NF, truncation + 1, nlayers)expl_div::Any = zeros(NF, truncation + 1, nlayers)impl_div::Any = ones(NF, truncation + 1, nlayers)
SpeedyWeather.HyperDiffusion Method
HyperDiffusion(
spectral_grid::SpectralGrid;
kwargs...
) -> HyperDiffusion{<:AbstractFloat, <:AbstractMatrix, <:Any, Second}Generator function based on the resolution in spectral_grid. Passes on keyword arguments.
SpeedyWeather.ImplicitCondensation Type
Large-scale condensation with implicit latent heat release.
relative_humidity_threshold::Any: [OPTION] Relative humidity threshold [1 = 100%] to trigger condensationreevaporation::Any: [OPTION] Reevaporation efficiency [1/(kg/kg)], 0 for no reevaporationsnow::Bool = true: [OPTION] Convert rain below freezing to snow?freezing_threshold::Any: [OPTION] Freezing temperature for snow fall [K]melting_threshold::Any: [OPTION] Melting temperature for snow fall [K]time_scale::Any: [OPTION] Time scale in multiples of time step Δt, the larger the less immediate
SpeedyWeather.ImplicitFluxes Type
Implicit (backward Euler) time integration of surface fluxes, damping the explicit flux by 1/(1 + Δt/τ). Unconditionally stable.
SpeedyWeather.ImplicitPrimitiveEquation Type
Struct that holds various precomputed arrays for the semi-implicit correction to prevent gravity waves from amplifying in the primitive equation model.
truncation::Any: [DERIVED] Spectral resolutionnlayers::Any: [DERIVED] Number of vertical layersnlayers_val::Val = Val(nlayers): [DERIVED]nlayersas aValso that the vertical loops are more type stablecentering::Any = 0.5: [OPTION] Time-step coefficient: 0.5 = Crank-Nicolson, 1=backward Eulerreference_temperature::Any = IsothermalReferenceTemperature{NF}(): [OPTION] Reference temperature profile to linearise about, isothermal or the global mean (plus offset)schedule::Any = PeriodicSchedule(every = Day(1)): [OPTION] Schedule to recompute the reference temperature profile (and the implicit operators) from the current global-mean temperatureΔt::Any = Ref(zero(NF)): [DERIVED] Time step [s] used to initialize. Used to check whether time step has changed and reinitialization is needed.temp_profile::Any = zeros(NF, nlayers): [DERIVED] Reference temperature profile, the global-mean temperature when last (re)initializedR::Any = zeros(NF, nlayers, nlayers): [DERIVED] divergence: operator for the geopotential calculationU::Any = zeros(NF, nlayers): [DERIVED] divergence: the -RdTₖ∇² term excl the eigenvalues from ∇² for divergenceL::Any = zeros(NF, nlayers, nlayers): [DERIVED] temperature: operator for the TₖD + κTₖD(ln pₛ)/Dt termW::Any = zeros(NF, nlayers): [DERIVED] pressure: vertical averaging of the -D̄ term in the log surface pressure equationL0::Any = zeros(NF, nlayers): [DERIVED] components to construct L, 1/ 2ΔσL1::Any = zeros(NF, nlayers, nlayers): [DERIVED] vert advection term in the temperature equation (below+above)L2::Any = zeros(NF, nlayers): [DERIVED] factor in front of thediv_sum_abovetermL3::Any = zeros(NF, nlayers, nlayers): [DERIVED]_sum_aboveoperator itselfL4::Any = zeros(NF, nlayers): [DERIVED] factor in front of div term in Dlnpₛ/DtS::Any = zeros(NF, nlayers, nlayers): [DERIVED] for every l the matrix to be invertedS⁻¹::Any = zeros(NF, truncation + 1, nlayers, nlayers): [DERIVED] combined inverted operator: S = 1 - ξ²(RL + UW)
SpeedyWeather.ImplicitPrimitiveEquation Method
ImplicitPrimitiveEquation(
spectral_grid::SpectralGrid;
schedule::SpeedyWeather.AbstractSchedule,
reference_temperature::SpeedyWeather.AbstractReferenceTemperature,
kwargs...
) -> ImplicitPrimitiveEquation{<:AbstractFloat, <:AbstractVector, <:AbstractMatrix, <:AbstractArray, <:Any, <:Any, PeriodicSchedule, ReferenceTemperatureType, RefNF} where {ReferenceTemperatureType<:(IsothermalReferenceTemperature{<:AbstractFloat}), RefNF<:(Base.RefValue{T} where T<:AbstractFloat)}Generator using the resolution from SpectralGrid.
sourceSpeedyWeather.ImplicitShallowWater Type
Struct that holds various precomputed arrays for the semi-implicit correction to prevent gravity waves from amplifying in the shallow water model. The implicit time step between i-1 and i+1 is controlled by the centering parameter α in the range [0, 1]
α = 0 means the gravity wave terms are evaluated at i-1 (forward)
α = 0.5 evaluates at i+1 and i-1 (centered implicit)
α = 1 evaluates at i+1 (backward implicit)
α ∈ [0.5, 1] are also possible which controls the strength of the gravity wave dampening.
α = 0.5 slows gravity waves and prevents them from amplifying
α > 0.5 will dampen the gravity waves within days to a few timesteps (α=1)Fields are
centering::Any = 0.5: [OPTION] Centering coefficient for semi-implicit, 0.5 = Crank-Nicolson, 1 = Backwards Euler
SpeedyWeather.ImplicitShallowWater Method
ImplicitShallowWater(
SG::SpectralGrid;
kwargs...
) -> ImplicitShallowWater{<:AbstractFloat}Generator using the resolution from spectral_grid.
SpeedyWeather.IsothermalReferenceTemperature Type
IsothermalReferenceTemperature{NF}(;
temperature
) where NF -> IsothermalReferenceTemperature
IsothermalReferenceTemperature(;
temperature
) -> IsothermalReferenceTemperature{Int64}
IsothermalReferenceTemperature{NF}(
temperature
) where NF -> IsothermalReferenceTemperature
IsothermalReferenceTemperature(
temperature::NF
) where NF -> IsothermalReferenceTemperatureIsothermal reference temperature profile for the semi-implicit time stepping, the implicit operators are therefore only reinitialized when the time step changes.
temperature::Any = 300: [OPTION] Temperature of the isothermal reference profile [K]
SpeedyWeather.JLD2Output Type
Output writer for a JLD2 file that saves the Variables struct directly to a JLD2 file. All internal scalings and units are still applied to these outputs. Fields are
active::Bool = falsepath::String = pwd(): [OPTION] path to output folder, run_???? will be created withinrun_prefix::String = "run": [OPTION] Prefix for run folder where data is stored, e.g. 'run_'id::String = "": [OPTION] run identification, added between run_prefix and run_numberrun_number::Int64 = 1: [OPTION] run identification number, automatically determined if overwrite=falserun_digits::Int64 = 4: [OPTION] run numbers digitsoverwrite::Bool = false: [OPTION] Overwrite an existing run folder?filename::String = "output.jld2": [OPTION] name of the output jld2 filewrite_restart::Bool = true: [OPTION] also write restart file if output=true?write_parameters_txt::Bool = true: [OPTION] also write parameters txt file if output=true?write_progress_txt::Bool = true: [OPTION] also write progress txt file if output=true?interval::Second = Second(DEFAULT_OUTPUT_INTERVAL): [OPTION] output frequency, time stepmerge_output::Bool = true: [OPTION] will reopen and resave the file to merge everything in one big vector. Turn off if the file is too large for memory.groups::Tuple{Vararg{Symbol}} = (:all,): [OPTION] which variable groups to save, e.g. (:prognostic,) or (:prognostic, :grid). Use (:all,) for all groups.core::OutputWriterCore = OutputWriterCore(): [DERIVED] shared output writer state (run folder, counters, output frequency)jld2_file::Union{Nothing, JLD2.JLDFile} = nothing
SpeedyWeather.JablonowskiTemperature Type
JablonowskiTemperature{NF}(;
η₀,
σ_tropopause,
u₀,
lapse_rate,
ΔT,
Tmin
) where NF -> JablonowskiTemperature
JablonowskiTemperature(;
η₀,
σ_tropopause,
u₀,
lapse_rate,
ΔT,
Tmin
)
JablonowskiTemperature{NF}(
η₀,
σ_tropopause,
u₀,
lapse_rate,
ΔT,
Tmin
) where NF -> JablonowskiTemperature
JablonowskiTemperature(
η₀::NF,
σ_tropopause::NF,
u₀::NF,
lapse_rate::NF,
ΔT::NF,
Tmin::NF
) where NF -> JablonowskiTemperatureCreate a struct that contains all parameters for the Jablonowski and Williamson, 2006 intitial conditions for the primitive equation model. Default values as in Jablonowski.
η₀::Any = 0.252: conversion from σ to Jablonowski's ηᵥ-coordinatesσ_tropopause::Any = 0.2: Sigma coordinates of the tropopause [1]u₀::Any = 35: max amplitude of zonal wind [m/s]lapse_rate::Any = 0.005: temperature lapse rate [K/m] of the tropospheric profile, Jablonowski uses Γ = 0.005 [K/m]ΔT::Any = 0: temperature difference used for stratospheric lapse rate [K], Jablonowski uses ΔT = 4.8e5 [K]Tmin::Any = 200: minimum temperature [K] of profile
SpeedyWeather.JeevanjeeRadiation Type
Temperature flux longwave radiation from Jeevanjee and Romps, 2018, following Seeley and Wordsworth, 2023, eq (1)
dF/dT = α*(T_t - T)with F the upward temperature flux between two layers with temperature difference dT, α = 0.025 W/m²/K² and T_t = 200K a prescribed tropopause temperature. Flux into the lowermost layer is 0. Flux out of uppermost layer also 0, but dT/dt = (T_t - T)/τ is added to relax the uppermost layer towards the tropopause temperature T_t with time scale τ = 24h (Seeley and Wordsworth, 2023 use 6h, which is unstable a low resolutions here). Fields are
α::Any: [OPTION] Radiative forcing constant (W/m²/K²)emissivity_atmosphere::Any: [OPTION] Emissivity of the atmosphere [1]emissivity_ocean::Any: [OPTION] Emissivity for surface flux over ocean [1]emissivity_land::Any: [OPTION] Emissivity for surface flux over land [1]temp_tropopause::Any: [OPTION] Tropopause temperature [K]time_scale::Second = Hour(24): [OPTION] Tropopause relaxation time scale to temp_tropopause
SpeedyWeather.JetStreamForcing Type
Forcing term for the Barotropic or ShallowWaterModel with an idealised jet stream similar to the initial conditions from Galewsky, 2004, but mirrored for both hemispheres.
latitude::Any: [OPTION] jet latitude [˚N]width::Any: [OPTION] jet width [˚], default ≈ 19.29˚sigma::Any: [OPTION] sigma level [1], vertical location of jetspeed::Any: [OPTION] jet speed scale [m/s]time_scale::Second = Day(30): [OPTION] time scale [days]amplitude::Any: [DERIVED] precomputed amplitude vector [m/s²]tapering::Any: [DERIVED] precomputed vertical tapering
SpeedyWeather.KolmogorovFlow Type
Kolmogorov flow forcing. Fields are
strength::Any: [OPTION] Strength of forcing [1/s²]wavenumber::Any: [OPTION] Wavenumber of forcing in meridional direction (pole to pole)
SpeedyWeather.Land4D Type
Dimension for 4D land surface variables, horizontal + vertical (nlayers) + n time steps.
SpeedyWeather.LandBucketMoisture Type
LandBucketMoisture model with two soil layers exchanging moisture via vertical diffusion. Forced by precipitation, evaporation, surface condensation, snow melt and river runoff drainage.
time_scale::Second = Day(2): [OPTION] Time scale of vertical diffusion [s]infiltration_fraction::Any: [OPTION] Infiltration fraction, that is, fraction of top layer runoff that is put into layer below [1]mask::Bool = true: [OPTION] Apply land-sea mask to set ocean-only points?ocean_moisture::Any: [OPTION] Initial soil moisture over ocean, fraction of field capacity [1]
SpeedyWeather.LandBucketTemperature Type
MITgcm's two-layer soil model (https://mitgcm.readthedocs.io/en/latest/phys_pkgs/land.html). Fields are
mask::Bool = true: [OPTION] Apply land-sea mask to set ocean-only points?ocean_temperature::Any = 285: [OPTION] Initial soil temperature over ocean [K]
SpeedyWeather.LandModel Type
Full land model with all components: geometry, thermodynamics, soil temperature (bucket scheme), soil moisture, snow, vegetation, and optional rivers. Intended for use with PrimitiveWet. Fields are
spectral_grid::SpectralGridgeometry::Anythermodynamics::Anytemperature::Anysoil_moisture::Anysnow::Anyvegetation::Anyrivers::Any
SpeedyWeather.LandSnowAlbedo Type
Albedo over land based on bare soil, vegetation (high and low cover) and snow cover. Fields are
albedo_land::Any: Albedo of bare land (excluding vegetation) [1]albedo_high_vegetation::Any: Albedo of high vegetation [1]albedo_low_vegetation::Any: Albedo of low vegetation [1]albedo_snow::Any: Albedo of snow [1], additive to landsnow_depth_scale::Any: Conversion from snow depth to snow cover [m]snow_cover::SpeedyWeather.AbstractSnowCover: Snow cover-albedo scheme
SpeedyWeather.LandXYZ Type
Dimension for 3D land surface variables, horizontal + vertical (nlayers).
sourceSpeedyWeather.Leapfrog Type
Leapfrog time stepping defined by the following fields
Δt_at_T32::Any: [OPTION] Time step for T32, scale linearly to spectral resolutiontruncationadjust_with_output::Any: [OPTION] AdjustΔt_at_T32with the outputintervalto output exactly after integer time stepsrobert_filter::Any: [OPTION] Robert (1966) time filter coefficient to suppress the computational modewilliams_filter::Any: [OPTION] Williams time filter (Amezcua 2011) coefficient for 3rd order accΔt_millisec::Any: [DERIVED] Time step Δt in milliseconds at specified resolutionΔt::Any: [DERIVED] Time step Δt [s] at specified resolutionocean::Any: [OPTION] Time stepper for the ocean (incl sea ice) variables,nothingfor leapfrog as the atmosphereland::Any: [OPTION] Time stepper for the land variables,nothingfor leapfrog as the atmosphere
SpeedyWeather.Leapfrog Method
Leapfrog(
spectral_grid::SpectralGrid;
Δt_at_T32=Minute(40),
adjust_with_output=true,
robert_filter=0.1,
williams_filter=0.53,
ocean=EulerForward(spectral_grid; Δt_at_T32, adjust_with_output),
land=EulerForward(spectral_grid; Δt_at_T32, adjust_with_output)
) -> Leapfrog{NF, Second, Bool, Millisecond, O, L} where {NF<:AbstractFloat, O<:(EulerForward{NF, Second, Bool, Millisecond} where NF<:AbstractFloat), L<:(EulerForward{NF, Second, Bool, Millisecond} where NF<:AbstractFloat)}Generator function for a Leapfrog struct using spectral_grid for the resolution information.
SpeedyWeather.LeapfrogCore Type
LeapfrogCore{NF, MS}(
Δt_millisec,
Δt
) where {NF, MS} -> SpeedyWeather.LeapfrogCore
LeapfrogCore(
Δt_millisec::MS,
Δt::NF
) where {NF, MS} -> SpeedyWeather.LeapfrogCoreImmutable core struct used to adapt only the time step fields for use in kernels
sourceSpeedyWeather.LearnedLandAlbedo Type
Learned albedo over land based on surface properties and some ambient conditions. This breaks the scheme down into visible and near-infrared components and calculates scattering parameters for each wavelength that depend on the properties of the surface. The parameters are combined into representative broadband shortwave parameters, then used to construct the white- and black-sky albedo, which combine depending on the optical properties of the atmosphere - to finally produce the blue-sky albedo. Fields are
vis_weight::Any: Visible wavelength weight to the broadband shortwave albedosnow_depth_scale::Any: Snow depth scaling for calculating snow cover fraction from snow depthsnow_cover::SpeedyWeather.AbstractSnowCover: Snow cover-albedo schemenoise::Any = false: [OPTION] Switch on stochastic output for the learned albedovisible_isotropic::SpeedyWeather.VisibleIsotropicScattering: Learned visible isotropic scattering expressionvisible_volumetric::SpeedyWeather.VisibleVolumetricScattering: Learned visible volumetric scattering expressionvisible_geometric::SpeedyWeather.VisibleGeometricScattering: Learned visible geometric scattering expressionnear_infrared_isotropic::SpeedyWeather.NIRIsotropicScattering: Learned NIR isotropic scattering expressionnear_infrared_volumetric::SpeedyWeather.NIRVolumetricScattering: Learned NIR volumetric scattering expressionnear_infrared_geometric::SpeedyWeather.NIRGeometricScattering: Learned NIR geometric scattering expression
SpeedyWeather.LearnedLandRoughness Type
Learned surface roughness lengths over land for momentum, heat and humidity fluxes, using symbolic regression expressions.
The momentum roughness length is
z₀M = exp(max(m_c1, A + B) / (C + D) + m_c9)where
A = m_c4 * exp(S / (m_c2*C_H - m_c3))
B = exp(C_L * (min(m_c5*L_L, m_c6*T - W) - m_c7^L_L))
C = exp(C_H * max(L_H, m_c8))
D = min(L_H, W)The heat roughness length is
z₀H = exp(min(A, B))where
Γ = max(
(h_c1^h_c2 * min(C_H, L_H)) / (L_L + T)^h_c2 + L_H,
2*C_H + h_c3
)
A = h_c5 * (Γ - h_c4 + C_L*min(C_L, L_L - W)) - h_c6*L_H
B = h_c8 * h_c7^C_HThe humidity roughness length is taken to equal the heat roughness length,
z₀Q = z₀HPredictors:
C_H, C_L: High and low vegetation cover fractions
L_H, L_L: High and low vegetation leaf area indices
S: Snow depth
T: Soil temperature at the bottom soil layer
W: Soil moisture at the bottom soil layer
Fields are
momentum_roughness_max::Any: [OPTION] Maximum land surface momentum roughness length [m]heat_roughness_max::Any: [OPTION] Maximum land surface heat roughness length [m]momentum_roughness_min::Any: [OPTION] Minimum land surface momentum roughness length [m]heat_roughness_min::Any: [OPTION] Minimum land surface heat roughness length [m]m_c1::Any: [OPTION] Coefficients for momentum roughness closure over landm_c2::Anym_c3::Anym_c4::Anym_c5::Anym_c6::Anym_c7::Anym_c8::Anym_c9::Anyh_c1::Any: [OPTION] Coefficients for heat roughness closure over landh_c2::Anyh_c3::Anyh_c4::Anyh_c5::Anyh_c6::Anyh_c7::Anyh_c8::Any
SpeedyWeather.LearnedOceanRoughness Type
LearnedOceanRoughnessLearned surface roughness lengths over ocean for momentum, heat and humidity fluxes, using symbolic regression expressions and sea-ice corrections.
The open-ocean momentum roughness length is
z₀M_base = exp(A - B + C)where
A = uₙ^m_c1
B = (m_c3*uₙ + α + exp(m_c2)) / (exp(m_c4*uₙ - m_c5) + m_c6)
C = m_c7*α - m_c8Here α = log(α_charnock), obtained from the Charnock parameterization using neutral wind speed uₙ.
The open-ocean momentum roughness is upper bounded,
z₀M_open = min(z₀M_base, z₀M_max)where z₀M_max is determined by the wind-dependent momentum roughness cap.
The final momentum roughness includes sea-ice blending,
z₀M = s*z₀M_ice + (1 - s)*z₀M_openwhere
z₀M_ice = max(
0.93e-3*(1 - s) + 6.05e-3*exp(-17*(s - 0.5)^2),
1.0e-3
)The heat roughness length is
z₀H = s*z₀H_ice + (1 - s)*exp(A - B)where
A = h_c1*(uₙ + h_c2)^h_c3
B = exp(h_c4/uₙ)and z₀H_ice is the prescribed sea-ice heat roughness length, defaulting to 1.0e-3 m.
The humidity roughness length is proportional to the heat roughness length,
z₀Q = z₀H * (a_q / a_h)Predictors and parameters:
uₙ: Neutral wind speed [m/s]
s: Sea-ice concentration
α: Logarithm of the Charnock parameter, evaluated using neutral wind speed
a_h, a_q: Heat and humidity scaling coefficients
z₀M_min: Minimum open-ocean momentum roughness length [m]
z₀M_max: Wind-dependent maximum open-ocean momentum roughness length [m]
z₀H_ice: Sea-ice heat roughness length [m]
Fields are
a_h::Any: [OPTION] Heat-related constant (from IFS documentation)a_q::Any: [OPTION] Moisture-related constant (from IFS documentation)charnock::Any: [OPTION] Charnock parameter estimationsea_ice_momentum_roughness::Any: [OPTION] Sea-ice momentum_roughnesssea_ice_heat_roughness::Any: [OPTION] sea-ice heat roughness lengthmax_ocean_momentum_roughness::Any: [OPTION] Momentum roughness upper limitmin_ocean_momentum_roughness::Any: [OPTION] Momentum roughness lower limitm_c1::Any: [OPTION] coefficient for momentum roughness closure over oceanm_c2::Anym_c3::Anym_c4::Anym_c5::Anym_c6::Anym_c7::Anym_c8::Anyh_c1::Any: [OPTION] coefficient for heat roughness closure over oceanh_c2::Anyh_c3::Anyh_c4::Any
SpeedyWeather.LearnedSurfaceRoughness Type
Combined learned surface roughness parameterization for momentum, heat and humidity fluxes over land and ocean.
Land and ocean roughness lengths are calculated independently using LearnedLandRoughness and LearnedOceanRoughness, respectively.
The grid-cell mean roughness length for each quantity X ∈ {M, H, Q} is obtained through area-weighted blending,
z₀X = f_land*z₀X_land + (1 - f_land)*z₀X_oceanwhere
f_land: Land fraction of the grid cell
z₀X_land: Learned land roughness length
z₀X_ocean: Learned ocean roughness length
Fields are
land_surface_roughness::Any: [OPTION] learned land surface roughness schemeocean_surface_roughness::Any: [OPTION] learned ocean surface roughness scheme
SpeedyWeather.LearnedWindSlowdown Type
Learned near-surface wind slowdown parameterization using a symbolic regression expression.
The slowdown factor is calculated as
f = max(1 - s, 0)where
s = c1*U - c2*U/z + c3*Δθᵥ +
c4*log(z₀) + c5*log(z) + c6Here U is the lowest-level wind speed, z is its height above the surface, z₀ is the momentum roughness length, and Δθᵥ is the virtual potential temperature difference between the lowest model level and the surface.
By default we set use_computed_roughness = true which uses the roughness from the previous timestep, and we fall back to the fixed roughness length on the first time step. With use_computed_roughness = false the roughness length z₀ is a fixed land-sea mask-weighted value (land_roughness, ocean_roughness).
While called the wind slowdown, this is a multiplicative factor that can actually take values > 1 rather than strictly [0, 1) (i.e., winds can speed up near the surface under certain conditions). However, on average, the effect is that the surface winds are slowed down relative to the bottom model level.
Fields are
use_computed_roughness::Bool = true: [OPTION] Use the computed roughness from the previous time step (true) or fixed roughness lengths (false)?land_roughness::Any: [OPTION] Fixed momentum roughness length over land [m]ocean_roughness::Any: [OPTION] Fixed momentum roughness length over ocean [m]c1::Anyc2::Anyc3::Anyc4::Anyc5::Anyc6::Any
SpeedyWeather.LinearDrag Type
Linear boundary layer drag following Held and Suarez, 1996 BAMS
σb::Any: [OPTION] Sigma coordinate below which linear drag is appliedtime_scale::Second = Day(1): [OPTION] Time scale for linear drag coefficient at σ=1 (=1/kf in HS96)drag_coefs::Any: [DERIVED] Precomputed drag coefficients for each layer
SpeedyWeather.LinearDrag Method
LinearDrag(
SG::SpectralGrid;
kwargs...
) -> LinearDrag{<:AbstractFloat, <:AbstractVector}Generator function using nlayers from SG::SpectralGrid
SpeedyWeather.LinearEntrainment Type
Linear entrainment profile: entrainment rate decreases linearly from surface_entrainment at the surface (σ=1) to zero at σ_entrainment. Above (σ < σ_entrainment), entrainment is zero. Fields are
σ_entrainment::Any: [OPTION] Sigma level at which entrainment becomes zero [1]surface_entrainment::Any: [OPTION] Entrainment rate at the surface [1]
SpeedyWeather.LinearEntrainment Method
(E::LinearEntrainment)(σ)Entrainment rate at sigma level σ for the linear profile.
sourceSpeedyWeather.LinearInLogPressure Type
Interpolate linearly in the logarithm of pressure between two model layers. Default, as most variables vary more linearly with log(p) than with p.
sourceSpeedyWeather.LinearSnowCover Type
Linear ramp: snow cover grows with snow depth from 0 to 1 at snow_depth_scale.
SpeedyWeather.LinearSnowCover Method
(::LinearSnowCover)(snow_depth, scale)Snow cover fraction for the linear scheme, clamped to 1.
sourceSpeedyWeather.Locator2DDim Type
Dimension for 2D locator, locating n positions, e.g. particles.
SpeedyWeather.Locator3DDim Type
Dimension for 3D locator, locating n positions on model's nlayers, e.g. particles.
SpeedyWeather.ManualAlbedo Type
Manual albedo field, to be used with set! and is copied into the diagnostic variables on every time step. Defined so that parameterizations can change the albedo at every time step (e.g. snow cover) without losing the information of the original surface albedo. Fields are
albedo::Any: Albedo field [1]
SpeedyWeather.ManualOrography Type
Orography with (initially) zero height in orography and zero surface geopotential surface_geopotential. Will not be changed at initialize! so can be changed at any time with set!
orography::Any: [OPTION] height [m] on grid-point space.surface_geopotential::Any: [OPTION] surface geopotential, height*gravity [m²/s²]
SpeedyWeather.MaxOceanMomentumRoughness Type
Momentum roughness cap following Willett et al. (2026). Fields are
z₀_cap::Any: [OPTION] Roughness length cap (global maximum) [m]z₀_high::Any: [OPTION] Roughness length high (lower roughness for even higher winds) [m]uₙ_cap::Any: [OPTION] Wind speed for maximum roughness length z₀_cap [m/s]uₙ_high::Any: [OPTION] Wind speed for high roughness length z₀_high [m/s]
SpeedyWeather.MaxOceanMomentumRoughness Method
(max_ocean_momentum_roughness::MaxOceanMomentumRoughness)(
uₙ
)Momentum roughness cap following Willett et al. (2026) given surface wind speed uₙ.
sourceSpeedyWeather.MaximumReferenceTemperature Type
MaximumReferenceTemperature{NF}(;
margin
) where NF -> MaximumReferenceTemperature
MaximumReferenceTemperature(;
margin
) -> MaximumReferenceTemperature{Int64}
MaximumReferenceTemperature{NF}(
margin
) where NF -> MaximumReferenceTemperature
MaximumReferenceTemperature(
margin::NF
) where NF -> MaximumReferenceTemperatureIsothermal reference temperature for the semi-implicit time stepping from the current maximum temperature of the model plus margin, recomputed on the schedule of the implicit solver. The semi-implicit scheme is stable for a warm isothermal reference temperature, warmer than the atmosphere (Simmons, Hoskins and Burridge, 1978), but the warmer the reference the more the gravity waves treated implicitly are slowed down. In contrast to IsothermalReferenceTemperature this follows the model's climate, e.g. for a snowball Earth or a hot climate.
margin::Any = 30: [OPTION] Margin [K] added to the maximum temperature
SpeedyWeather.Millenium Type
Millenium{IntType} <: PeriodConvenience time type representing a 1000-year period. Parametric on IntType for Reactant compatibility.
SpeedyWeather.ModelLayers Type
Write 3D variables on the model's vertical layers, sigma or hybrid sigma-pressure depending on model.geometry.vertical_coordinates. Default for all output writers.
SpeedyWeather.NCycleLorenz Type
NCycleLorenz{NF, V, ...} <: AbstractTimeStepperA semi-implicit Lorenz N-cycle time integration scheme following Hotta et al. (2016).
Algorithm (per substep of a cycle)
G = w_F_E(x) + (1-w)_G (weighted tendency accumulation)
dx = (I - α_Δt_L_I)^(-1) * (G + L_I*x) (implicit solve)
x = x + Δt*dx (state update)
steps::Any: [OPTION] Number of steps N in a cycle (3 or 4 recommended, 4 is more stable)variant::Any: [OPTION] Variant: NCycleLorenzA() (default), B, AB, or ABBAΔt_at_T32::Any: [OPTION] Time step for T32 resolution, scale linearly with resolutionadjust_with_output::Any: [OPTION] AdjustΔt_at_T32with theintervalto reachintervalexactlyΔt_millisec::Any: [DERIVED] Time step Δt in milliseconds at specified resolutionΔt::Any: [DERIVED] Time step Δt [s] at specified resolutionocean::Any: [OPTION] Time stepper for the ocean (incl sea ice) variables,nothingfor the same N-cycle as the atmosphereland::Any: [OPTION] Time stepper for the land variables,nothingfor the same N-cycle as the atmosphere
SpeedyWeather.NCycleLorenz Method
NCycleLorenz(
spectral_grid::SpectralGrid;
steps=3,
variant=NCycleLorenzA(),
Δt_at_T32=Minute(30),
adjust_with_output=true,
ocean=nothing,
land=nothing
) -> NCycleLorenz{NF, NCycleLorenzA, Int64, Second, Millisecond, Bool, Nothing, Nothing} where NF<:AbstractFloatGenerator function for NCycleLorenz struct using spectral_grid for resolution.
SpeedyWeather.NCycleLorenzABBA Type
Version ABBA: uses A-B-B-A sequence (only for N=4, provides 4th order accuracy)
sourceSpeedyWeather.NCycleLorenzVariant Type
Abstract type for Lorenz N-cycle variants following Hotta et al. (2016).
sourceSpeedyWeather.NIRGeometricScattering Type
Near-infrared radiation geometric-optical scattering parameter calculation. This expression was derived by distilling a trained neural network using symbolic regression. Geometric scattering represents the reflection due to shadowcasting of 3D objects at the surface, like tree crowns or big rocks, and obscuration of shadows due to viewing angle. Fields are
c1::Any: Coefficient fit via symbolic regressionc2::Any: Coefficient fit via symbolic regressionc3::Any: Coefficient fit via symbolic regressionc4::Any: Coefficient fit via symbolic regressionc5::Any: Coefficient fit via symbolic regressionc6::Any: Coefficient fit via symbolic regressionc7::Any: Coefficient fit via symbolic regressionc8::Any: Coefficient fit via symbolic regressionc9::Any: Coefficient fit via symbolic regressionc10::Any: Coefficient fit via symbolic regressionc11::Any: Coefficient fit via symbolic regressionc12::Any: Coefficient fit via symbolic regressionc13::Any: Coefficient fit via symbolic regression
SpeedyWeather.NIRIsotropicScattering Type
Near-infrared radiation isotropic scattering parameter calculation. This expression was derived by distilling a trained neural network using symbolic regression. Isotropic scattering means that light at the surface is reflected equally in all directions, regardless of where the sun is. Fields are
c1::Any: Coefficient fit via symbolic regressionc2::Any: Coefficient fit via symbolic regressionc3::Any: Coefficient fit via symbolic regressionc4::Any: Coefficient fit via symbolic regressionc5::Any: Coefficient fit via symbolic regressionc6::Any: Coefficient fit via symbolic regressionc7::Any: Coefficient fit via symbolic regressionc8::Any: Coefficient fit via symbolic regressionc9::Any: Coefficient fit via symbolic regressionc10::Any: Coefficient fit via symbolic regressionc11::Any: Coefficient fit via symbolic regressionc12::Any: Coefficient fit via symbolic regressionc13::Any: Coefficient fit via symbolic regressionc14::Any: Coefficient fit via symbolic regressionc15::Any: Coefficient fit via symbolic regressionc16::Any: Coefficient fit via symbolic regression
SpeedyWeather.NIRVolumetricScattering Type
Near-infrared radiation volumetric scattering parameter calculation. This expression was derived by distilling a trained neural network using symbolic regression. Volumetric scattering represents the reflection mechanism of light interacting with horizontally homogenous vegetation canopy at the surface - light meets the canopy, bounces around a bit beneath the canopy and exits back towards the sky. This does depend on where the sun is and the viewing angle. Fields are
c1::Any: Coefficient fit via symbolic regressionc2::Any: Coefficient fit via symbolic regressionc3::Any: Coefficient fit via symbolic regressionc4::Any: Coefficient fit via symbolic regressionc5::Any: Coefficient fit via symbolic regressionc6::Any: Coefficient fit via symbolic regressionc7::Any: Coefficient fit via symbolic regressionc8::Any: Coefficient fit via symbolic regressionc9::Any: Coefficient fit via symbolic regression
SpeedyWeather.NetCDFOutput Type
NetCDFOutput(
SG::SpectralGrid,
Model::Type{<:AbstractModel}=Barotropic;
nlayers_soil=DEFAULT_NLAYERS_SOIL,
output_grid::AbstractFullGrid=(RingGrids.full_grid_type(SG.grid))(SG.grid.nlat_half, output_architecture(SG.architecture)),
output_NF::DataType=DEFAULT_OUTPUT_NF,
interval::Dates.Period=Second(DEFAULT_OUTPUT_INTERVAL),
layers::SpeedyWeather.AbstractOutputLayers=ModelLayers(),
kwargs...
) -> NetCDFOutputConstructor for NetCDFOutput based on S::SpectralGrid and optionally the Model type (e.g. ShallowWater, PrimitiveWet) as second positional argument. In case a non-default number of soil layers is used, it also needs the respective nlayers_soil to allocate those outputs. The output grid is optionally determined by keyword arguments output_Grid (its type, full grid required), nlat_half (resolution) and output_NF (number format, only used for variables not coordinates). By default, uses the full grid equivalent of the grid and resolution used in SpectralGrid S. Interpolation and post-processing run on the architecture of S, e.g. on the GPU, the output grid is moved there accordingly, and only the interpolated fields are copied to the CPU for writing.
SpeedyWeather.NetCDFOutput Type
Output writer for a netCDF file with (re-)gridded variables. Interpolates non-rectangular grids. Fields are
active::Bool = falsepath::String = pwd(): [OPTION] path to output parent folder, run folders will be created withinrun_prefix::String = "run": [OPTION] Prefix for run folder where data is stored, e.g. 'run_'id::String = "": [OPTION] run identification, added between run_prefix and run_numberrun_number::Int64 = 1: [OPTION] run identification number, automatically determined if overwrite=falserun_digits::Int64 = 4: [OPTION] run numbers digitscore::OutputWriterCore = OutputWriterCore(): [DERIVED] shared output writer state (run folder, counters, output frequency)overwrite::Bool = false: [OPTION] Overwrite an existing run folder?filename::String = "output.nc": [OPTION] name of the output netcdf filewrite_restart::Bool = true: [OPTION] also write restart file if output=true?write_parameters_txt::Bool = true: [OPTION] also write parameters txt file if output=true?write_progress_txt::Bool = true: [OPTION] also write progress txt file if output=true?startdate::Any = DateTime(2000, 1, 1): [DERIVD] start date of the simulation, used for time dimension in netcdf fileinterval::Any = Second(DEFAULT_OUTPUT_INTERVAL): [OPTION] output frequency, time stepvariables::Dict{Symbol, SpeedyWeather.AbstractOutputVariable} = OutputVariablesDict(): [OPTION] dictionary of variables to output, e.g. u, v, vor, div, pres, temp, humidlayers::Any = ModelLayers(): [OPTION] vertical layers to write 3D atmospheric variables on,ModelLayers()(default) orPressureLayers(spectral_grid), seeAbstractOutputLayersnetcdf_file::Union{Nothing, NCDatasets.NCDataset} = nothinginterpolator::Anyland_fraction::Anyfield2D::Anyfield3D::Anyfield3Dland::Anyhost2D::Anyhost3D::Anyhost3Dland::Any
SpeedyWeather.NeutralWindSpeed Type
Ocean-based neutral wind speed calculation from actual wind speed, derived from ERA5 data via symbolic regression. Fields are
c1::Any: [OPTION] symbolic regression parameter 1 [1]c2::Any: [OPTION] symbolic regression parameter 2 [1]c3::Any: [OPTION] symbolic regression parameter 3 [1]c4::Any: [OPTION] symbolic regression parameter 4 [1]c5::Any: [OPTION] symbolic regression parameter 5 [1]c6::Any: [OPTION] symbolic regression parameter 6 [1]c7::Any: [OPTION] symbolic regression parameter 7 [1]c8::Any: [OPTION] symbolic regression parameter 8 [1]c9::Any: [OPTION] symbolic regression parameter 9 [1]minimum_wind::Any: [OPTION] Minimum wind speed to avoid zero surface fluxes [m/s]log_safety::Any: [OPTION] Minimum argument for logarithm to avoid log(0) [1]
SpeedyWeather.NoEntrainment Type
No entrainment: the rising parcel in the Betts-Miller convection scheme does not mix with its environment, reproducing the scheme without entrainment. The default for BettsMillerDryConvection; BettsMillerConvection defaults to LinearEntrainment instead.
SpeedyWeather.NoOrography Type
Orography with zero height in orography and zero surface geopotential surface_geopotential. Will be initialized (back) to zero at initialize!.
orography::Any: [OPTION] height [m] on grid-point space.surface_geopotential::Any: [OPTION] surface geopotential, height*gravity [m²/s²]
SpeedyWeather.Ocean3D Type
Dimension for 3D ocean variables with an unspecified 3rd dimension of length n (default 1, a trailing singleton dimension). Carries a neutral tag; prefer OceanXYZ or OceanXYT when the 3rd dimension is specifically vertical or time.
SpeedyWeather.Ocean4D Type
Dimension for 4D ocean variables, horizontal + vertical (ocean layers) + n time steps.
SpeedyWeather.OceanLandAlbedo Type
Composite type: Two albedo parameterizations, one for ocean and one for land surfaces. Fields are
ocean::Any: [OPTION] Albedo parameterization for ocean surfacesland::Any: [OPTION] Albedo parameterization for land surfaces
SpeedyWeather.OceanSeaIceAlbedo Type
Albedo that scales linearly between ocean and ice albedo depending on sea ice concentration. Fields are
albedo_ocean::Any: [OPTION] Albedo over open ocean [1]albedo_ice::Any: [OPTION] Albedo over sea ice at concentration=1 [1]
SpeedyWeather.OceanXYZ Type
Dimension for 3D ocean variables, horizontal + vertical (ocean layers).
sourceSpeedyWeather.OneBandLongwave Type
One-band longwave radiation scheme with transmissivity and radiative transfer components. Following Frierson, 2006, JAS, https://doi.org/10.1175/JAS3753.1. Fields are
transmissivity::Anyradiative_transfer::Any
SpeedyWeather.OneBandLongwaveRadiativeTransfer Type
Radiative transfer solver for OneBandLongwave radiation scheme. Computes longwave radiative transfer with upward and downward beams including surface fluxes. Fields are
emissivity_ocean::Any: [OPTION] Emissivity for surface flux over ocean [1]emissivity_land::Any: [OPTION] Emissivity for surface flux over land [1]
SpeedyWeather.OneBandShortwave Type
OneBandShortwave <: AbstractShortwaveA one-band shortwave radiation scheme with diagnostic clouds following Fortran SPEEDY documentation, section B4. Implements cloud top detection and cloud fraction calculation based on relative humidity and precipitation, with radiative transfer through clear sky and cloudy layers.
Cloud cover is calculated as a combination of relative humidity and precipitation contributions, and a cloud albedo is applied to the downward beam. Fields and options are
clouds::Anytransmissivity::Anyradiative_transfer::Any
SpeedyWeather.OneBandShortwaveRadiativeTransfer Type
OneBandShortwaveRadiativeTransfer <: AbstractShortwaveRadiativeTransferozone_absorption::Any: [OPTION] Total ozone absorption as fraction of incoming solar radiation (1)ozone_distribution::Any: [OPTION] Ozone distribution above σ₀, has to be explicitly normalized to ∫dσ = 1 (1)
.
sourceSpeedyWeather.OutputWriterCore Type
Shared runtime state for output writers: derived file paths, output frequency, and step/output counters. Embed as core::OutputWriterCore in every output writer. Option fields (path, id, overwrite, interval, …) stay as flat fields on the writer itself.
Call initialize!(core, output, model) inside the writer's initialize! method to populate all derived fields from the writer's option fields and the model time step. Call output!(core, output) each time step to check if output should be written. Fields are
run_folder::String = "": [DERIVED] folder name where data is stored, determined at initialize!run_path::String = "": [DERIVED] full path to folder where data is stored, determined at initialize!output_every_n_steps::Int64 = 0: [DERIVED] output frequency in time steps, computed at initialize!output_counter::Int64 = 0: [DERIVED] output step counter, incremented every time output is written
SpeedyWeather.ParameterizationVariable Type
ParameterizationVariable{D, U}(;
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U}
ParameterizationVariable(;
name,
dims,
units,
desc,
namespace,
fuse
)
ParameterizationVariable{D, U}(
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U} -> ParameterizationVariable
ParameterizationVariable(
name::Symbol,
dims::D,
units::U,
desc::String,
namespace::Symbol,
fuse::Symbol
) where {D, U} -> ParameterizationVariableA variable defined through its name, dimensions dims and optionally its units, description desc and the namespace it's sorted under within a variable group. Variables sharing the same non-empty fuse symbol (within the same namespace) are allocated as views of a single shared parent buffer, which is exposed in the resulting NamedTuple under the fuse symbol. This definition is only used to return an object to define that a given model component wants to define a variable – allocation and being sorted into the Variables tree happens elsewhere.
SpeedyWeather.ParametersTxt Type
ParametersTxt callback. Writes a parameters.txt file with all model parameters. Options are
path::String = "": [OPTION] Path for parameters.txt file, uses model.output.run_path if not specifiedfilename::String = "parameters.txt": [OPTION] File name for parameters.txt filewrite_only_with_output::Bool = true: [OPTION] Only write with model.output.active = true?
SpeedyWeather.Particle Type
Particle with location lon (longitude), lat (latitude) and σ (vertical coordinate). Longitude is assumed to be in [0,360˚E), latitude in [-90˚,90˚N] and σ in [0,1] but not strictly enforced at creation, see mod(::Particle) and ismod(::Particle). A particle is either active or inactive, determined by the active field. By default, a particle is active, of number format DEFAULT_NF and at 0˚N, 0˚E, σ=0.
active::Bool: activitylon::AbstractFloat: longitude in [0,360˚]lat::AbstractFloat: latitude [-90˚,90˚]σ::AbstractFloat: vertical sigma coordinate [0 (top) to 1 (surface)]
SpeedyWeather.ParticleAdvection2D Type
nparticles::Any = 10: [OPTION] Number of particlesevery_n_time_steps::Any = 6: [OPTION] Execute particle advection every n timestepslayer::Any = 1: [OPTION] Advect with velocities from this vertical layer indexbackwards::Bool = false: [OPTION] Advect backwards in time if true (for backtracking trajectories)geometry::Any: [DERIVED] Interpolation geometry used during advection
Particle advection on a fixed model layer: particles are advected horizontally with the velocity of a single, user-specified vertical layer, their σ coordinate stays constant.
sourceSpeedyWeather.ParticleAdvection3D Type
nparticles::Any = 10: [OPTION] Number of particlesevery_n_time_steps::Any = 6: [OPTION] Execute particle advection every n timestepsbackwards::Bool = false: [OPTION] Advect backwards in time if true (for backtracking trajectories)geometry::Any: [DERIVED] Interpolation geometry used during advection
Continuous 3D particle advection: particles are tracked at their own σ coordinate, which evolves in time driven by the model's diagnosed vertical velocity, in addition to being advected horizontally.
sourceSpeedyWeather.ParticleTracker Type
A ParticleTracker is implemented as a callback to output the trajectories of particles from particle advection. To be added like
add!(model.callbacks, ParticleTracker(spectral_grid; kwargs...))Output done via netCDF. Fields and options are
schedule::Schedule = Schedule(every = Hour(4)): [OPTION] when to schedule particle trackingfilename::String = "particles.nc": [OPTION] File name for netCDF filepath::String = "": [OPTION] Path for netCDF file, uses model.output.run_path if not specifiedcompression_level::Int64 = 1: [OPTION] lossless compression level; 1=low but fast, 9=high but slowshuffle::Bool = false: [OPTION] shuffle/bittranspose filter for compressionkeepbits::Int64 = 15: [OPTION] mantissa bits to keep, (14, 15, 16) means at least (2km, 1km, 500m) accurate locationsnparticles::Int64 = 0: Number of particles to tracknetcdf_file::Union{Nothing, NCDatasets.NCDataset} = nothing: The netcdf file to be written into, will be created at initializationlon::Anylat::Anyσ::Any
SpeedyWeather.ParticleVariable Type
ParticleVariable{D, U}(;
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U}
ParticleVariable(; name, dims, units, desc, namespace, fuse)
ParticleVariable{D, U}(
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U} -> ParticleVariable
ParticleVariable(
name::Symbol,
dims::D,
units::U,
desc::String,
namespace::Symbol,
fuse::Symbol
) where {D, U} -> ParticleVariableA variable defined through its name, dimensions dims and optionally its units, description desc and the namespace it's sorted under within a variable group. Variables sharing the same non-empty fuse symbol (within the same namespace) are allocated as views of a single shared parent buffer, which is exposed in the resulting NamedTuple under the fuse symbol. This definition is only used to return an object to define that a given model component wants to define a variable – allocation and being sorted into the Variables tree happens elsewhere.
SpeedyWeather.PeriodicSchedule Type
A periodic schedule, to execute something every period every (first time step excluded), rounded to a multiple of the time step. Unlike Schedule it does not need the clock (start time or length of the simulation) and can therefore be initialized with the time stepper only, e.g. in initialize!(model), converting every into every_n_steps. Use as
@kwdef struct MyComponent
schedule::PeriodicSchedule = PeriodicSchedule(every = Day(1))
endwith isscheduled(component.schedule, clock) || return nothing. Fields
every::Second = Day(1): [OPTION] Execute every time period, rounded to a multiple of the time step,Second(0)= neverevery_n_steps::Int64 = 0: [DERIVED]everyin time steps (at least 1), 0 = nevercounter::Int64 = 0: [DERIVED] Count up the number of executions
SpeedyWeather.PeriodicSchedule Method
PeriodicSchedule(every::Dates.Period) -> PeriodicScheduleA PeriodicSchedule executing every period.
SpeedyWeather.PrescribedAlbedo Type
Prescribed albedo field, to be used with set!. In contrast to ManualAlbedo the albedo is not hold in the struct and not copied into the diagnostic variables automatically. It's expected that the albedo variable (e.g vars.land.albedo) is set externally at every time step. Defined so that the albedo can be prescribed externally e.g. when coupling the model.
SpeedyWeather.PrescribedLandHeatFlux Type
Prescribed surface sensible heat flux over land. Reads heat flux values from external data sources instead of calculating them dynamically. Useful for coupled model runs where land heat fluxes are provided by a land model or for sensitivity experiments with fixed flux patterns.
sourceSpeedyWeather.PrescribedLandHumidityFlux Type
Prescribed humidity flux over land surfaces. Applies surface humidity flux from progn.land.surface_humidity_flux.
SpeedyWeather.PrescribedOcean Type
Prescribed ocean that declares the necessary allocations for the sea surface temperature, but all dynamics are expected to be externally set. Used for coupling to external ocean models.
sourceSpeedyWeather.PrescribedOceanHeatFlux Type
Prescribed surface sensible heat flux over ocean. Reads heat flux values from external data sources instead of calculating them dynamically. Useful for coupled model runs where ocean heat fluxes are provided by an ocean model or for sensitivity experiments with fixed flux patterns.
sourceSpeedyWeather.PrescribedOceanHumidityFlux Type
Prescribed humidity flux over ocean surfaces. Applies surface humidity flux from progn.ocean.surface_humidity_flux.
SpeedyWeather.PrescribedSeaIce Type
Prescribed sea ice that declares the necessary allocations for the sea ice concentration, but all dynamics are expected to be externally set. Used for coupling to external sea ice models.
sourceSpeedyWeather.PressureLayers Type
Write 3D atmospheric variables interpolated onto pressure layers [Pa] instead of the model's vertical layers, see Vertical interpolation onto pressure layers. Construct with a SpectralGrid and pass to an output writer as NetCDFOutput(spectral_grid, layers = PressureLayers(spectral_grid)). Land (soil) variables and 2D variables are unaffected. Fields are
pressure::Any: [OPTION] pressure layers [Pa] to interpolate onto, monotonic, e.g. ascending from the top of the atmosphere to the surface. In the model's number format and on its architecture so that the interpolation kernel can run on the GPUinterpolation::Any: [OPTION] interpolate linearly in pressure or in its logarithm?scratch::Any: [DERIVED] scratch field (npoints, npressure) on the model grid to interpolate into before the horizontal interpolation onto the output grid
SpeedyWeather.PressureLayers Method
PressureLayers(
SG::SpectralGrid;
pressure::AbstractVector=DEFAULT_PRESSURE_LAYERS,
interpolation::SpeedyWeather.AbstractVerticalInterpolation=LinearInLogPressure()
)Vertical output layers at the given pressure [Pa], Float32[100.0, 200.0, 500.0, 850.0, 1000.0] hPa by default. Allocates the pressure vector and one scratch field (shared by all output variables) on SG's architecture and in its number format, so that the vertical interpolation runs where the model runs.
SpeedyWeather.PrimitiveDryModel Type
The PrimitiveDryModel contains all model components (themselves structs) needed for the simulation of the primitive equations without humidity. To be constructed like
model = PrimitiveDryModel(spectral_grid; kwargs...)with spectral_grid::SpectralGrid used to initalize all non-default components passed on as keyword arguments, e.g. planet=Earth(spectral_grid). Fields, representing model components, are
spectral_grid::Anyarchitecture::Any = spectral_grid.architecturedynamics::Bool = truegeometry::Anyplanet::Anyatmosphere::Anycoriolis::Anygeopotential::Anyadiabatic_conversion::Anyparticle_advection::Anyinitial_conditions::Anyforcing::Anydrag::Anyrandom_process::Any = nothingtracers::Dict{Symbol, Tracer} = TRACER_DICT()dynamics_only::Bool = falseorography::Anyland_sea_mask::Anyocean::Anysea_ice::Anyland::Anysolar_zenith::Anyalbedo::Anyboundary_layer::Anyvertical_diffusion::Anysurface_momentum_flux::Anysurface_heat_flux::Anyconvection::Anyradiation::Anygreenhouse_gases::Anystochastic_physics::Anycustom_parameterization::Anytime_stepping::Any = Leapfrog(spectral_grid)spectral_transform::Any = WhichTransform(spectral_grid)implicit::Any = ImplicitPrimitiveEquation(spectral_grid)horizontal_diffusion::Any = HyperDiffusion(spectral_grid)vertical_advection::Any = CenteredVerticalAdvection(spectral_grid)output::Any = NetCDFOutput(spectral_grid, PrimitiveDry)callbacks::Dict{Symbol, SpeedyWeather.AbstractCallback} = Dict{Symbol, AbstractCallback}()feedback::Any = Feedback()core_components::Any = (:architecture, :time_stepping, :orography, :geopotential, :atmosphere, :planet, :geometry, :land_sea_mask)parameterizations::Any = (:solar_zenith, :vertical_diffusion, :boundary_layer, :surface_momentum_flux, :surface_heat_flux, :convection, :albedo, :radiation, :stochastic_physics)params::Any = Val(parameterizations)
SpeedyWeather.PrimitiveWetModel Type
The PrimitiveWetModel contains all model components (themselves structs) needed for the simulation of the primitive equations with humidity. To be constructed like
model = PrimitiveWetModel(spectral_grid; kwargs...)with spectral_grid::SpectralGrid used to initalize all non-default components passed on as keyword arguments, e.g. planet=Earth(spectral_grid). Fields, representing model components, are
spectral_grid::Anyarchitecture::Any = spectral_grid.architecturedynamics::Bool = truegeometry::Anyplanet::Anyatmosphere::Anycoriolis::Anygeopotential::Anyadiabatic_conversion::Anyparticle_advection::Anyinitial_conditions::Anyforcing::Anydrag::Anyrandom_process::Any = nothingtracers::Dict{Symbol, Tracer} = TRACER_DICT()dynamics_only::Bool = falseorography::Anyland_sea_mask::Anyocean::Anysea_ice::Anyland::Anysolar_zenith::Anyalbedo::Anyboundary_layer::Anyvertical_diffusion::Anysurface_momentum_flux::Anysurface_heat_flux::Anysurface_humidity_flux::Anylarge_scale_condensation::Anyconvection::Anyradiation::Anygreenhouse_gases::Anystochastic_physics::Anycustom_parameterization::Anytime_stepping::Any = Leapfrog(spectral_grid)spectral_transform::Any = WhichTransform(spectral_grid)implicit::Any = ImplicitPrimitiveEquation(spectral_grid)horizontal_diffusion::Any = HyperDiffusion(spectral_grid)vertical_advection::Any = CenteredVerticalAdvection(spectral_grid)hole_filling::Any = ClipNegatives(spectral_grid)output::Any = NetCDFOutput(spectral_grid, PrimitiveWet)callbacks::Dict{Symbol, SpeedyWeather.AbstractCallback} = Dict{Symbol, AbstractCallback}()feedback::Any = Feedback()core_components::Any = (:architecture, :time_stepping, :orography, :geopotential, :atmosphere, :planet, :geometry, :land_sea_mask)parameterizations::Any = (:solar_zenith, :vertical_diffusion, :boundary_layer, :surface_momentum_flux, :surface_heat_flux, :surface_humidity_flux, :large_scale_condensation, :convection, :albedo, :radiation, :stochastic_physics)params::Any = Val(parameterizations)
SpeedyWeather.PrognosticVariable Type
PrognosticVariable{D, U}(;
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U}
PrognosticVariable(;
name,
dims,
units,
desc,
namespace,
fuse
)
PrognosticVariable{D, U}(
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U} -> PrognosticVariable
PrognosticVariable(
name::Symbol,
dims::D,
units::U,
desc::String,
namespace::Symbol,
fuse::Symbol
) where {D, U} -> PrognosticVariableA variable defined through its name, dimensions dims and optionally its units, description desc and the namespace it's sorted under within a variable group. Variables sharing the same non-empty fuse symbol (within the same namespace) are allocated as views of a single shared parent buffer, which is exposed in the resulting NamedTuple under the fuse symbol. This definition is only used to return an object to define that a given model component wants to define a variable – allocation and being sorted into the Variables tree happens elsewhere.
SpeedyWeather.ProgressTxt Type
ProgressTxt callback. Writes a progress.txt file with time stepping progress. Options are
path::String = "": [OPTION] Path for progress.txt file, uses model.output.run_path if not specifiedfilename::String = "progress.txt": [OPTION] File name for progress.txt filewrite_only_with_output::Bool = true: [OPTION] Only write with model.output.active = true?every_n_percent::Int64 = 5: [OPTION] Every n% of time steps write to progress.txt, default is 5%file::IOStream = IOStream(""): [DERIVED] IOStream for progress.txt file
SpeedyWeather.Radiation Type
Radiation scheme bundling a shortwave and a longwave scheme into one model component Radiaton. Inside the fused column kernel the shortwave scheme is called first, then the longwave scheme. Either can be nothing to disable that stream. A radiation scheme that computes both streams at once (e.g. a correlated-k scheme sharing gas optics) subtypes AbstractRadiation directly instead, declares its variables and parameterization! as any other parameterization. Fields are
shortwave::Any: [OPTION] Shortwave radiation scheme,<: AbstractShortwaveornothinglongwave::Any: [OPTION] Longwave radiation scheme,<: AbstractLongwaveornothing
SpeedyWeather.Radiation Method
Radiation(
SG::SpectralGrid;
shortwave=OneBandShortwave(SG),
longwave=OneBandLongwave(SG)
) -> Radiation{SW, LW} where {SW<:(OneBandShortwave{C, T, R} where {C<:(DiagnosticClouds{<:AbstractFloat}), T<:(BackgroundShortwaveTransmissivity{<:AbstractFloat}), R<:(OneBandShortwaveRadiativeTransfer{<:AbstractFloat, SpeedyWeather.var"#OneBandShortwaveRadiativeTransfer##0#OneBandShortwaveRadiativeTransfer##1"})}), LW<:(OneBandLongwave{T, R} where {T<:(FriersonLongwaveTransmissivity{<:AbstractFloat}), R<:(OneBandLongwaveRadiativeTransfer{<:AbstractFloat})})}Bundle shortwave and longwave into one Radiation component, defaulting to OneBandShortwave and OneBandLongwave (the PrimitiveWetModel defaults). For a dry model use shortwave = OneBandGreyShortwave(spectral_grid) and longwave = OneBandGreyLongwave(spectral_grid).
SpeedyWeather.RandomVelocity Type
Start with random velocity as initial conditions
max_speed::Any = 60: [OPTION] maximum speed [ms⁻¹]truncation::Int64 = 14: [OPTION] Maximum wavenumber after truncation (1-based)seed::Any = 0: [OPTION] Random number generator seed, 0=randomly seed from Julia's GLOBAL_RNGrandom_number_generator::Any = Random.Xoshiro(seed): Independent random number generator for this random process
SpeedyWeather.RandomVorticity Type
Start with random vorticity as initial conditions
power::Any = -3: [OPTION] Power of the spectral distribution k^poweramplitude::Any = 0.0001: [OPTION] the (approximate) amplitude in [1/s], used as standard deviation of spherical harmonic coefficientsmax_wavenumber::Int64 = 20: [OPTION] Maximum wavenumberseed::Any = 123: [OPTION] Random number generator seed, 0=randomly seed from Julia's GLOBAL_RNGrandom_number_generator::Any = Random.Xoshiro(seed): Independent random number generator for this random process
SpeedyWeather.RandomWaves Type
Parameters for random initial conditions for the interface displacement η in the shallow water equations.
amplitude::Any = 2000: [OPTION] amplitude [m]lmin::Int64 = 10: [OPTION] minimum wavenumberlmax::Int64 = 30: [OPTION] maximum wavenumber
SpeedyWeather.RationalFluxes Type
Rational approximation of ExponentialFluxes, damping the explicit flux by (6 + z)/(6 + 4z + z²) with z = Δt/τ. Matches (1 - exp(-z))/z to second order in z and as 1/z for large z, at the cost of ImplicitFluxes. Unconditionally stable but overshoots the surface value slightly (≤ 10%) for z > 3.
SpeedyWeather.RockyPlanetMask Type
Land-sea mask with one = land everywhere.
land_fraction::Any: Land-sea mask [1] on grid-point space. Land=1, sea=0, land-area fraction in between.
SpeedyWeather.RossbyHaurwitzWave Type
Rossby-Haurwitz wave initial conditions as in Williamson et al. 1992, J Computational Physics with an additional cut-off amplitude c to filter out tiny harmonics in the vorticity field. Parameters are
m::Int64 = 4ω::Any = 7.848e-6K::Any = 7.848e-6c::Any = 1.0e-10
SpeedyWeather.SaturatingSnowCover Type
Saturating ramp: snow cover grows with snow depth S as S/(S+scale).
SpeedyWeather.SaturatingSnowCover Method
(::SaturatingSnowCover)(snow_depth, scale)Snow cover fraction for the saturating scheme.
sourceSpeedyWeather.ScalarDim Type
Dimension for scalar variables holding single numerical values as RefValue. Default value is 0, but can be set via ScalarDim, e.g. ScalarDim(1) for a default value of 1.
sourceSpeedyWeather.Schedule Type
A schedule for callbacks, to execute them periodically after a given period has passed (first timestep excluded) or on/after specific times (initial time excluded). For two consecutive time steps i, i+1, an event is scheduled at i+1 when it occurs in (i,i+1]. Similarly, a periodic schedule of period p will be executed at start+p, but p is rounded to match the multiple of the model timestep. Periodic schedules and event schedules can be combined, executing at both. A Schedule is supposed to be added into callbacks as fields
@kwdef struct MyCallback
schedule::Schedule = Schedule(every=Day(1))
other_fields
endsee also initialize!(::Schedule, ::Clock) and isscheduled(::Schedule, ::Clock).
Fields
every::Second = Second(typemax(Int)): [OPTION] Execute every time period, first timestep excluded. Default=never.times::Vector{DateTime} = zeros(DateTime, 0): [OPTION] Events scheduled at timesschedule::BitVector = BitVector(undef, 0): Actual schedule, true=execute this timestep, false=don'tsteps::Int64 = length(schedule): Number of scheduled executionscounter::Int64 = 0: Count up the number of executions
SpeedyWeather.Schedule Method
Schedule(times::DateTime...) -> ScheduleA Schedule based on DateTime arguments, For two consecutive time steps i, i+1, an event is scheduled at i+1 when it occurs in (i,i+1].
sourceSpeedyWeather.ScratchVariable Type
ScratchVariable{D, U}(;
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U}
ScratchVariable(; name, dims, units, desc, namespace, fuse)
ScratchVariable{D, U}(
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U} -> ScratchVariable
ScratchVariable(
name::Symbol,
dims::D,
units::U,
desc::String,
namespace::Symbol,
fuse::Symbol
) where {D, U} -> ScratchVariableA variable defined through its name, dimensions dims and optionally its units, description desc and the namespace it's sorted under within a variable group. Variables sharing the same non-empty fuse symbol (within the same namespace) are allocated as views of a single shared parent buffer, which is exposed in the resulting NamedTuple under the fuse symbol. This definition is only used to return an object to define that a given model component wants to define a variable – allocation and being sorted into the Variables tree happens elsewhere.
SpeedyWeather.SeaIceMomentumRoughness Type
Sea ice momentum roughness as defined for ECMWF's IFS model. Fields are
roughness_min::Anyc1::Anyc2::Anyc3::Anyc4::Any
SpeedyWeather.SeaIceMomentumRoughness Method
(R::SeaIceMomentumRoughness)(ℵ)Functor returning surface roughness over sea ice given sea ice concentration ℵ.
sourceSpeedyWeather.SeasonalLandTemperature Type
SeasonalLandTemperature model that prescribes land surface temperature from a monthly climatology file. The temperature is linearly interpolated between months based on the model time.
file::String = "land_surface_temperature.nc": [OPTION] filename of land surface temperaturespath::String = joinpath("data", "boundary_conditions", file): [OPTION] path to the folder containing the lstfrom_assets::Bool = true: [OPTION] flag to check for lst in SpeedyWeatherAssets or locallyversion::VersionNumber = DEFAULT_ASSETS_VERSION: [OPTION] SpeedyWeatherAssets version numbervarname::String = "lst": [OPTION] variable name in netcdf fileFieldType::Type{<:AbstractField} = FullGaussianField: [OPTION] Grid the land surface temperature file comes onmask::Bool = true: [OPTION] Apply land-sea mask to use fallback ocean temperature for ocean-only points?ocean_temperature::Any = 285: [OPTION] Fallback ocean temperature when mask=true [K]monthly_temperature::Any: Monthly land surface temperatures [K], interpolated onto Grid
SpeedyWeather.SeasonalOceanClimatology Type
Seasonal ocean climatology that reads monthly sea surface temperature fields from file, and interpolates them in time on every time step and writes them to the prognostic variables. Fields and options are
grid::Any: Grid used for the modelfile::String = "sea_surface_temperature.nc": [OPTION] Filename of sea surface temperaturespath::String = joinpath("data", "boundary_conditions", file): [OPTION] path to the folder containing the sstfrom_assets::Bool = true: [OPTION] flag to check for sst in SpeedyWeatherAssets or locallyversion::VersionNumber = DEFAULT_ASSETS_VERSION: [OPTION] SpeedyWeatherAssets version numbervarname::String = "sst": [OPTION] Variable name in netcdf fileFieldType::Type{<:AbstractField} = FullGaussianField: [OPTION] Grid the sea surface temperature file comes onmask::Bool = true: [OPTION] Mask initial sea surface temperature with land-sea mask?land_temperature::Any = 285: [OPTION] SST over land [K]monthly_temperature::Any = zeros(GridVariable3D, grid, 12): [DERIVED] Monthly sea surface temperatures [K], interpolated onto Grid
SpeedyWeather.SeasonalSoilMoisture Type
SeasonalSoilMoisture model that prescribes soil moisture from a monthly climatology file. The soil moisture is linearly interpolated between months based on the model time.
file::String = "soil_moisture.nc": [OPTION] filename of soil moisturepath::String = joinpath("data", "boundary_conditions", file): [OPTION] path to the folder containing the soil moisturefrom_assets::Bool = true: [OPTION] flag to check for soil moisture in SpeedyWeatherAssets or locallyversion::VersionNumber = DEFAULT_ASSETS_VERSION: [OPTION] SpeedyWeatherAssets version numbervarname_layer1::String = "swl1": [OPTION] variable name in netcdf file for layer 1varname_layer2::String = "swl2": [OPTION] variable name in netcdf file for layer 2FieldType::Type{<:AbstractField} = FullGaussianField: [OPTION] Grid the soil moisture file comes onmissing_value::Any = NF(NaN): [OPTION] The missing value in the data respresenting oceanmask::Bool = true: [OPTION] Apply land-sea mask to set ocean-only points and missing values?ocean_moisture::Any = 0: [OPTION] Soil moisture for ocean points/missing values, fraction of field capacity [1]monthly_soil_moisture::Any: Monthly soil moisture fraction of field capacity [1], interpolated onto Grid
SpeedyWeather.ShallowWaterModel Type
The ShallowWaterModel contains all model components needed for the simulation of the shallow water equations. To be constructed like
model = ShallowWaterModel(spectral_grid; kwargs...)with spectral_grid::SpectralGrid used to initalize all non-default components passed on as keyword arguments, e.g. planet = Earth(spectral_grid). Fields, representing model components, are
spectral_grid::Anyarchitecture::Any = spectral_grid.architecturegeometry::Anyplanet::Anyatmosphere::Anycoriolis::Anyorography::Anyforcing::Anydrag::Anyparticle_advection::Anyinitial_conditions::Anyrandom_process::Any = nothingtracers::Dict{Symbol, Tracer} = TRACER_DICT()time_stepping::Any = Leapfrog(spectral_grid)spectral_transform::Any = WhichTransform(spectral_grid)implicit::Any = ImplicitShallowWater(spectral_grid)horizontal_diffusion::Any = HyperDiffusion(spectral_grid)output::Any = NetCDFOutput(spectral_grid, ShallowWater)callbacks::Dict{Symbol, SpeedyWeather.AbstractCallback} = Dict{Symbol, AbstractCallback}()feedback::Any = Feedback()
SpeedyWeather.SigmaCoordinates Type
Terrain-following sigma vertical coordinates. Pressure at full level k is p_k = σ_k * surface_pressure, where σ ∈ (0, 1] is the fraction of surface pressure. Levels are defined by σ_half (half levels at layer interfaces, including σ = 0 at the top and σ = 1 at the surface); full levels sit at the midpoints.
nlayers::Any: [DERIVED] Number of vertical layersσ_half::Any: [DERIVED] σ at half levels (interfaces); k = 1 is top of atmosphere (σ = 0), k = nlayers+1 is surface (σ = 1)σ_full::Any: [DERIVED] σ at full levels (layer midpoints); σ_full[k] = (σ_half[k] + σ_half[k+1]) / 2σ_thickness::Any: [DERIVED] Layer thickness in sigma; σ_thickness[k] = σ_half[k+1] - σ_half[k], sums to 1
SpeedyWeather.SigmaPressureCoordinates Type
Hybrid sigma-pressure vertical coordinates. Pressure at full level k is p_k = A_k * reference_pressure + B_k * surface_pressure, where A_k + B_k = σ_k (the nominal sigma level). The A/B split is controlled by a transition function: transition(σ) = 0 gives pure pressure levels (terrain-independent, fixed in space), transition(σ) = 1 gives pure sigma levels (terrain-following). See CubicSigmaPressureCoordinates for a ready-to-use constructor with a smooth transition.
reference_pressure::Any: [DERIVED] Reference pressure for the pressure component [Pa]A_half::Any: [DERIVED] Pressure component coefficient at half levels (k = 1 top, nlayers+1 surface)B_half::Any: [DERIVED] Sigma component coefficient at half levelsA_full::Any: [DERIVED] Pressure component coefficient at full levelsB_full::Any: [DERIVED] Sigma component coefficient at full levelsA_thickness::Any: [DERIVED] Pressure component of layer thickness (ΔA = A_half[k+1] - A_half[k])B_thickness::Any: [DERIVED] Sigma component of layer thickness (ΔB = B_half[k+1] - B_half[k])
SpeedyWeather.Simulation Type
Simulation{V, M}(
variables,
model
) where {V, M<:AbstractModel} -> Simulation
Simulation(
variables::V,
model::M
) where {V, M<:AbstractModel} -> SimulationSimulation is a container struct simply wrapping the variables (prognostic and diagnostic) and the model. It contains
variables::Any: All variablesmodel::AbstractModel: All model components, containing parameters, constant at runtime
SpeedyWeather.Simulation Method
Simulation(model::AbstractModel; kwargs...)Same as initialize!(model) which returns a Simulation.
SpeedyWeather.SinSolarDeclination Type
Coefficients to calculate the solar declination angle δ [radians] based on a simple sine function, with Earth's axial tilt as amplitude, equinox as phase shift.
axial_tilt::Any = AXIAL_TILTequinox::Any = EARTH_EQUINOX
SpeedyWeather.SinSolarDeclination Method
(S::SpeedyWeather.SinSolarDeclination)(g::NF) where NFSinSolarDeclination functor, computing the solar declination angle of angular fraction of year g [radians] using the coefficients of the SinSolarDeclination struct. Uses LENGTH_OF_DAY and LENGTH_OF_YEAR as Earth's constants and not from planet as Dates functionality here is relative to the Earth calendar. The year angle g should reflect slower/faster seasons.
SpeedyWeather.SlabOcean Type
Interactive slab ocean model that evolves sea surface temperature with the central time stepper. Tendencies are from net surface radiation and surface latent and sensible heat fluxes. The effective mixed-layer heat capacity is specific_heat_capacity * mixed_layer_depth * density. Initialised from seasonal SST climatology, with land points set to land_temperature. Fields are
specific_heat_capacity::Any = 4184: [OPTION] Specific heat capacity of water [J/kg/K]mixed_layer_depth::Any: [OPTION] Average mixed-layer depth [m]density::Any = 1000: [OPTION] Density of water [kg/m³]mask::Bool = true: [OPTION] Mask initial sea surface temperature with land-sea mask?land_temperature::Any = 285: [OPTION] SST over land [K]heat_capacity_mixed_layer::Any = specific_heat_capacity * mixed_layer_depth * density: [DERIVED] Effective mixed-layer heat capacity [J/K/m²]
SpeedyWeather.SnowModel Type
SnowModel{NF}(;
melting_threshold,
snow_depth_cap,
initial_snow_depth_rate,
initial_snow_depth_max
) where NF -> SnowModel
SnowModel(;
melting_threshold,
snow_depth_cap,
initial_snow_depth_rate,
initial_snow_depth_max
)
SnowModel{NF}(
melting_threshold,
snow_depth_cap,
initial_snow_depth_rate,
initial_snow_depth_max
) where NF -> SnowModel
SnowModel(
melting_threshold::NF,
snow_depth_cap::NF,
initial_snow_depth_rate::NF,
initial_snow_depth_max::NF
) where NF -> SnowModelSingle-column snow bucket model in equivalent liquid water depth. Snow accumulates from the diagnosed precipitation, melts once the top soil layer exceeds melting_threshold, and is capped at snow_depth_cap to limit infinite snow/ice accumulation over perennial ice caps and glaciers. The snow depth is time stepped by the land time stepper (time_stepper(model.time_stepping, :land)), the cap (and non-negativity) is applied in filter!.
melting_threshold::Any: [OPTION] Temperature threshold for snow melting [K]snow_depth_cap::Any = 10: [OPTION] Permanent snow/ice depth cap in equivalent liquid water depth [m]initial_snow_depth_rate::Any: [OPTION] Initial snow depth per Kelvin the top soil layer is belowmelting_threshold[m/K]initial_snow_depth_max::Any: [OPTION] Maximum initial snow depth [m]
SpeedyWeather.SolarDeclination Type
Coefficients to calculate the solar declination angle δ from
δ = 0.006918 - 0.399912*cos(g) + 0.070257*sin(g)
- 0.006758*cos(2g) + 0.000907*sin(2g)
- 0.002697*cos(3g) + 0.001480*sin(3g)with g the angular fraction of the year in radians. Following Spencer 1971, Fourier series representation of the position of the sun. Search 2(5):172.
Note that this Declination type does not support an axial tilt different from Earth's 23.4 degree. Use SinSolarDeclination instead.
a::Any = 0.006918s1::Any = 0.070257c1::Any = -0.399912s2::Any = 0.000907c2::Any = -0.006758s3::Any = 0.00148c3::Any = -0.002697
SpeedyWeather.SolarDeclination Method
(SD::SpeedyWeather.SolarDeclination)(g)SolarDeclination functor, computing the solar declination angle of angular fraction of year g [radians] using the coefficients of the SolarDeclination struct.
sourceSpeedyWeather.SolarDeclination Method
Generator function pulling the number format NF from a SpectralGrid.
sourceSpeedyWeather.SolarTimeCorrection Type
Coefficients for the solar time correction (also called Equation of time) which adjusts the solar hour to an oscillation of sunrise/set by about +-16min throughout the year.
sourceSpeedyWeather.SolarTimeCorrection Method
(STC::SpeedyWeather.SolarTimeCorrection)(g)Functor that returns the time correction for a angular fraction of the year g [radians], so that g=0 for Jan-01 and g=2π for Dec-31.
sourceSpeedyWeather.SolarZenith Type
Solar zenith angle varying with daily and seasonal cycle.
seasonal_cycle::Bool = true: [OPTION] Seasonal cycle? Otherwise daily cycle only.solar_declination::Any: [OPTION] Calculate seasonal cycle from this solar declination function.initial_time::Any = Ref(DEFAULT_DATE): [DERIVED] Use this time, set via `initialize!(model, time=...), to hold seasonal cycle fixed.time_correction::Any: [OPTION] Time correction for seasonal wobble of sunset/sunrise times
SpeedyWeather.SolarZenithSeason Type
Solar zenith angle varying with seasonal cycle only.
seasonal_cycle::Bool = true: [OPTION] Seasonal cycle? Otherwise daily cycle only.solar_declination::Any: [OPTION] Calculate seasonal cycle from this solar declination function.initial_time::Any = Ref(DEFAULT_DATE): [DERIVED] Use this time, set via `initialize!(model, time=...), to hold seasonal cycle fixed.
SpeedyWeather.Spectral3D Type
Dimension for 3D spectral variables with an unspecified 3rd dimension of length n (default 1, a trailing singleton dimension). Carries a neutral tag; prefer SpectralXYZ or SpectralXYT when the 3rd dimension is specifically vertical or time.
SpeedyWeather.Spectral4D Type
Dimension for 4D spectral variables with customizable extra dimension (neutral tag). Prefer SpectralXYZT when the trailing dimensions are specifically vertical + time.
SpeedyWeather.SpectralAR1Process Type
First-order auto-regressive random process (AR1) in spectral space, evolving wavenumbers with respectice time_scales and standard_deviations independently. Transformed after every time step to grid space with a clamp applied to limit extrema. For reproducability seed can be provided and an independent random_number_generator is used that is reseeded on every initialize!. Fields are:
truncation::Anytime_scale::Second = Hour(6): [OPTION] Time scale of the AR1 processwavenumber::Any = 12: [OPTION] Wavenumber (0-based) of the AR1 processstandard_deviation::Any = 1 / 3: [OPTION] Standard deviation of the AR1 processclamp::Tuple{NF, NF} where NF = (-1, 1): [OPTION] Range to clamp values into after every transform into grid spaceseed::Any = 0: [OPTION] Random number generator seed, 0=randomly seed from Julia's GLOBAL_RNGrandom_number_generator::Any = Random.Xoshiro(seed): Independent random number generator for this random processautoregressive_factor::Base.RefValue = Ref(zero(NF)): Precomputed auto-regressive factor [1], function of time scale and model time stepnoise_factors::Any = zeros(NF, truncation + 1): Precomputed noise factors [1] for every total wavenumber l
SpeedyWeather.SpectralFilter Type
Spectral filter for horizontal diffusion. Fields are:
truncation::Any: spectral resolution (1-based)nlayers::Any: number of vertical levelsshift::Any = 0: [OPTION] shift diffusion to higher (positive shift) or lower (neg) wavenumbers, relative to truncationscale::Any = 0.05: [OPTION] Scale-selectiveness, steepness of the sigmoid, higher is more selectivetime_scale::Second = Hour(4): [OPTION] diffusion time scaletime_scale_div::Second = Minute(30): [OPTION] stronger diffusion time scale for divergenceresolution_scaling::Any = 1: [OPTION] resolution scaling to shorten time_scale with truncationpower::Any = 4: [OPTION] power of the tanh functionpower_div::Any = 4: [OPTION] power of the tanh function for divergenceexpl::Any = zeros(NF, truncation + 1, nlayers)impl::Any = ones(NF, truncation + 1, nlayers)expl_div::Any = zeros(NF, truncation + 1, nlayers)impl_div::Any = ones(NF, truncation + 1, nlayers)
SpeedyWeather.SpectralFilter Method
SpectralFilter(
spectral_grid::SpectralGrid;
kwargs...
) -> SpectralFilter{<:AbstractFloat}Generator function based on the resolutin in spectral_grid. Passes on keyword arguments.
SpeedyWeather.SpectralGrid Type
Defines the horizontal spectral resolution and corresponding grid and the vertical coordinate for SpeedyWeather.jl. Options are
NF::Type{<:AbstractFloat}: [OPTION] number format used throughout the modelarchitecture::Any: [OPTION] device architecture to run onArrayType::Type{<:AbstractArray}: [DERIVED] array type to use for all variables, customize by define a new architectureVectorType::Type{<:AbstractVector}: [DERIVED] Type of vectorMatrixType::Type{<:AbstractMatrix}: [DERIVED] Type of matrixTensorType::Type{<:AbstractArray}: [DERIVED] Type of 3D arrayVectorIntType::Type{<:AbstractVector}: [DERIVED] Type of vector of integersMatrixIntType::Type{<:AbstractMatrix}: [DERIVED] Type of matrix of integersTensorIntType::Type{<:AbstractArray}: [DERIVED] Type of 3D array of integerstruncation::Any: [OPTION] horizontal resolution as the maximum degree of spherical harmonics (1-based)trunc::Any: [OPTION] horizontal resolution as the maximum degree of spherical harmonics (0-based)spectrum::Any: [DERIVED] spectral spaceSpectralVariable2D::Type{<:AbstractArray}: [DERIVED] Type of spectral variable in 2D (horizontal only, flattened into 1D vector)SpectralVariable3D::Type{<:AbstractArray}: [DERIVED] Type of spectral variable in 3D (horizontal + unspecified, flattened into 2D matrix)SpectralVariableXYZ::Type{<:AbstractArray}: [DERIVED] Type of spectral variable in 3D (horizontal + vertical, flattened into 2D matrix)SpectralVariableXYT::Type{<:AbstractArray}: [DERIVED] Type of spectral variable in 3D (horizontal + time, flattened into 2D matrix)SpectralVariable4D::Type{<:AbstractArray}: [DERIVED] Type of spectral variable in 4D (horizontal + 2 unspecified, flattened into 3D array)SpectralVariableXYZT::Type{<:AbstractArray}: [DERIVED] Type of spectral variable in 4D (horizontal + vertical + time, flattened into 3D array)dealiasing::Any: [OPTION] how to match spectral with grid resolution: dealiasing factor, 1=linear, 2=quadratic, 3=cubic gridnlat_half::Any: [DERIVED] number of latitude rings on one hemisphere (Equator incl)nlat::Any: [DERIVED] number of latitude rings on both hemispheresnpoints::Any: [DERIVED] total number of grid points in the horizontalgrid::Any: [DERIVED] instance of horizontal grid used for calculations in grid-point spaceGrid::Type{<:AbstractGrid}: [OPTION] type of horizontal grid used for calculations in grid-point spaceGridVariable2D::Type{<:AbstractArray}: [DERIVED] Type of grid variable in 2D (horizontal only, flattened into 1D vector)GridVariable3D::Type{<:AbstractArray}: [DERIVED] Type of grid variable in 3D (horizontal + unspecified, flattened into 2D matrix)GridVariableXYZ::Type{<:AbstractArray}: [DERIVED] Type of grid variable in 3D (horizontal + vertical, flattened into 2D matrix)GridVariableXYT::Type{<:AbstractArray}: [DERIVED] Type of grid variable in 3D (horizontal + time, flattened into 2D matrix)GridVariable4D::Type{<:AbstractArray}: [DERIVED] Type of grid variable in 4D (horizontal + 2 unspecified, flattened into 3D array)GridVariableXYZT::Type{<:AbstractArray}: [DERIVED] Type of grid variable in 4D (horizontal + vertical + time, flattened into 3D array)ParticleVectorType::Type: [DERIVED] ArrayType of particle vectornlayers::Any: [OPTION] number of vertical layers in the atmospheretransform_batch::Vector{Int64}: [OPTION] list of batch sizes K to pre-plan FFTs for. Each distinct K requires its own FFTW/cuFFT plan (plans bake the batch dim at construction). The K=1 entry (always added) is the per-layer fallback. The Legendre / column scratch is sized tomaximum(transform_batch). Architecture-dependent defaultdefault_transform_batch.
nlat_half and npoints should not be chosen but are derived from truncation, Grid and dealiasing.
SpeedyWeather.SpectralGrid Method
SpectralGrid(
grid::AbstractGrid;
NF::Type{<:AbstractFloat}=DEFAULT_NF,
dealiasing::Real=SpeedyTransforms.default_dealiasing(grid),
nlayers::Int64=DEFAULT_NLAYERS,
transform_batch::AbstractVector{<:Integer}=default_transform_batch(grid.architecture, nlayers)
) -> SpectralGrid{<:Any, Spectrum{A, O, L, IntType}, <:AbstractGrid{Architecture}, <:Any, Float32} where {A, O, L, IntType}Initialize a SpectralGrid from a given grid.
sourceSpeedyWeather.SpectralGrid Method
SpectralGrid(;
NF::Type{<:AbstractFloat}=DEFAULT_NF,
architecture::Union{SpeedyWeatherInternals.Architectures.AbstractArchitecture, Type{<:SpeedyWeatherInternals.Architectures.AbstractArchitecture}}=DEFAULT_ARCHITECTURE,
truncation::Int64=DEFAULT_TRUNCATION,
trunc::Union{Nothing, Int64}=nothing,
Grid::Type{<:AbstractGrid}=DEFAULT_GRID,
dealiasing::Real=SpeedyTransforms.default_dealiasing(Grid),
nlayers::Int64=DEFAULT_NLAYERS,
transform_batch::AbstractVector{<:Integer}=default_transform_batch(architecture, nlayers)
) -> SpectralGrid{CPU{KernelAbstractions.CPU}, Spectrum{CPU{KernelAbstractions.CPU}, Vector{UnitRange{Int64}}, Vector{Int64}, Int64}, OctahedralGaussianGrid{CPU{KernelAbstractions.CPU}, Vector{UnitRange{Int64}}, Vector{Int64}, Int64}, Int64, Float32}Initialize a SpectralGrid from a given truncation and all [OPTION] parameters of SpectralGrid.
sourceSpeedyWeather.SpectralXYZ Type
Dimension for 3D spectral variables, horizontal + vertical (nlayers).
sourceSpeedyWeather.SpectralXYZT Type
Dimension for 4D spectral variables, horizontal + vertical (nlayers) + n time steps.
SpeedyWeather.StartFromFile Type
Restart from a previous SpeedyWeather.jl simulation via the restart file restart.jld2 Applies interpolation in the horizontal but not in the vertical. restart.jld2 is identified by
path::String = pwd(): path for restart filerun_prefix::String = "run": run prefix, e.g. 'run' inrun_0001/restart.jld2id::String = "": identification of run folder, e.g. 'set1' inrun_set1_0001/restart.jld2run_number::Int64 = 1: run number, e.g. 1 inrun_set1_0001/restart.jld2run_digits::Int64 = 4: run digits, e.g. 4 inrun_set1_0001/restart.jld2for run_number=1run_folder::String = "": directly specify the run folder, e.q.run_0001filename::String = "restart.jld2": File name of restart file, defaultrestart.jld2
SpeedyWeather.StepSchedule Type
An immutable schedule executing every every_n_steps time steps (first time step and spin-up steps excluded), 0 = never, 1 = every time step. Needs no initialization. Use as isscheduled(component.schedule, clock) || return nothing. Fields
every_n_steps::Int64 = 1: [OPTION] Execute every n time steps, 0 = never
SpeedyWeather.StepSchedule Method
StepSchedule(every_n_steps::Integer) -> StepScheduleA StepSchedule executing every every_n_steps time steps.
SpeedyWeather.StochasticallyPerturbedParameterizationTendencies Type
Defines the stochastically perturbed parameterization tendencies (SPPT) including an optional tapering as a function of the vertical sigma level
tapering::Any: [OPTION] Vertical tapering function, reduce strength towards surface (σ=1)taper::Any: [DERIVED] Precalculate vertical tapering during initialization
SpeedyWeather.SubsurfaceMask Type
Mask everything below the surface (p > pₛ) with missing_value, and use above_surface between the lowest model layer and the surface, where a pressure layer is below the lowest model layer but still above ground. Fields are
above_surface::Any = ConstantExtrapolation(): [OPTION] extrapolation between the lowest model layer and the surfacemissing_value::Any = NaN: [OPTION] value to mask subsurface points with, ideallyvariable.missing_value
SpeedyWeather.SurfaceCondition Type
Surface condition parameterization that calculates near-surface atmospheric variables needed for surface flux calculations. Computes surface wind speed including sub-grid scale gusts, surface air density, and surface air temperature by extrapolating from the lowest model level to the surface using standard atmospheric relationships. Fields are
wind_slowdown::Any: [OPTION] Ratio of near-surface wind to lowest-level wind [1]wind_gust::Any: [OPTION] Wind speed of sub-grid scale gusts [m/s]
SpeedyWeather.SurfaceHeatFlux Type
Composite surface (sensible) heat flux type that holds flux for ocean and land (each of any type) separately. Fields are
ocean::Anyland::Any
SpeedyWeather.SurfaceHumidityFlux Type
Composite surface humidity flux type that holds flux for ocean and land (each of any type) separately. Fields are
ocean::Any: [OPTION] Surface humidity flux parameterization for ocean surfacesland::Any: [OPTION] Surface humidity flux parameterization for land surfaces
SpeedyWeather.SurfaceLandHeatFlux Type
Surface sensible heat flux parameterization over land. Calculates the turbulent exchange of sensible heat between the land surface and the atmosphere based on soil temperature differences and wind speed. Uses bulk aerodynamic formulas with drag coefficients that can account for surface roughness. Fields are
use_boundary_layer_drag::Bool = true: [OPTION] Use drag coefficient from calculated following model.boundary_layer.dragdrag::Any: [OPTION] Or fixed drag coefficient for heat fluxes over landsnow_insulation_depth::Any: [OPTION] Snow insulation depth [m], e-folding depth reducing surface heat fluxestime_integration::SpeedyWeather.AbstractFluxIntegration = DEFAULT_FLUX_INTEGRATION(): [OPTION] Time integration of the flux into the lowermost layer
SpeedyWeather.SurfaceLandHumidityFlux Type
Humidity flux parameterization over land surfaces. Fields are
use_boundary_layer_drag::Bool = true: [OPTION] Use drag coefficient from calculated following model.boundary_layer.dragdrag::Any: [OPTION] Or fixed drag coefficient for humidity flux over landsnow_insulation_depth::Any: [OPTION] Snow insulation depth [m], e-folding depth controlling how snow insulates surface humidity fluxestime_integration::SpeedyWeather.AbstractFluxIntegration = DEFAULT_FLUX_INTEGRATION(): [OPTION] Time integration of the flux into the lowermost layer
SpeedyWeather.SurfaceMomentumFlux Type
Surface momentum flux parameterization for wind stress. Calculates the turbulent exchange of momentum between the surface and atmosphere, representing surface drag that slows down near-surface winds. Uses bulk aerodynamic formulas with separate drag coefficients for ocean and land surfaces to account for different surface roughness characteristics. Fields are
use_boundary_layer_drag::Bool = true: [OPTION] Use drag coefficient from calculated following model.boundary_layer.dragdrag_ocean::Any: [OPTION] Or fixed drag coefficient for momentum fluxes over oceandrag_land::Any: [OPTION] Or fixed drag coefficient for momentum fluxes over landtime_integration::SpeedyWeather.AbstractFluxIntegration = DEFAULT_FLUX_INTEGRATION(): [OPTION] Time integration of the flux into the lowermost layer
SpeedyWeather.SurfaceOceanHeatFlux Type
Surface sensible heat flux parameterization over ocean. Calculates the turbulent exchange of sensible heat between the ocean surface and the atmosphere based on temperature differences and wind speed. Uses bulk aerodynamic formulas with drag coefficients. Fields are
use_boundary_layer_drag::Bool = true: [OPTION] Use drag coefficient from calculated following model.boundary_layer.dragdrag::Any: [OPTION] Or fixed drag coefficient for heat fluxes over oceansea_ice_insulation::Any: [OPTION] Sea ice insulating surface heat fluxes [1]time_integration::SpeedyWeather.AbstractFluxIntegration = DEFAULT_FLUX_INTEGRATION(): [OPTION] Time integration of the flux into the lowermost layer
SpeedyWeather.SurfaceOceanHumidityFlux Type
Humidity flux parameterization over ocean surfaces. Fields are
use_boundary_layer_drag::Bool = true: [OPTION] Use drag coefficient from calculated following model.boundary_layer.dragdrag::Any: [OPTION] Or fixed drag coefficient for humidity flux over oceansea_ice_insulation::Any: [OPTION] Sea ice insulating surface humidity fluxes [1]time_integration::SpeedyWeather.AbstractFluxIntegration = DEFAULT_FLUX_INTEGRATION(): [OPTION] Time integration of the flux into the lowermost layer
SpeedyWeather.TendencyVariable Type
TendencyVariable{D, U}(;
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U}
TendencyVariable(; name, dims, units, desc, namespace, fuse)
TendencyVariable{D, U}(
name,
dims,
units,
desc,
namespace,
fuse
) where {D, U} -> TendencyVariable
TendencyVariable(
name::Symbol,
dims::D,
units::U,
desc::String,
namespace::Symbol,
fuse::Symbol
) where {D, U} -> TendencyVariableA variable defined through its name, dimensions dims and optionally its units, description desc and the namespace it's sorted under within a variable group. Variables sharing the same non-empty fuse symbol (within the same namespace) are allocated as views of a single shared parent buffer, which is exposed in the resulting NamedTuple under the fuse symbol. This definition is only used to return an object to define that a given model component wants to define a variable – allocation and being sorted into the Variables tree happens elsewhere.
SpeedyWeather.TetensEquation Type
Parameters for computing saturation vapor pressure of water using the Tetens' equation,
eᵢ(T) = e₀ * exp(Cᵢ * (T - T₀) / (T + Tᵢ)),where T is in Kelvin and i = 1, 2 for saturation above and below freezing, respectively. From Tetens (1930), and Murray (1967) for below freezing.
e₀::AbstractFloat = 610.78: Saturation water vapor pressure at 0°C [Pa]T₀::AbstractFloat = 273.15: 0°C in KelvinT₁::AbstractFloat = 237.3: Tetens denominator (water) [˚C]T₂::AbstractFloat = 265.5: Tetens denominator following Murray (1967, below freezing) [˚C]C₁::AbstractFloat = 17.27: Tetens numerator scaling [1], above freezingC₂::AbstractFloat = 21.875: Tetens numerator scaling [1], below freezing
SpeedyWeather.ThermodynamicSeaIce Type
Thermodynamic sea ice model using sea ice concentration as prognostic variable, also modifies sea surface temperature as cooling below freezing grows sea ice. Fields are
freezing_temperature::Any: [OPTION] Freezing temperature of sea water [K]melt_rate::Any: [OPTION] Melting rate of sea ice [m²/m²/s/K]freeze_rate::Any: [OPTION] Freezing rate of sea ice [m²/m²/K]
SpeedyWeather.Tracer Type
Define tracer through a name::Symbol (used as key in the tracer dictionaries) and define it as active (=true default). active=false will (temporarily) disable the time evolution of the tracer. Fields are
name::Symbolactive::Any = true
SpeedyWeather.UniformCooling Type
Uniform cooling following Paulius and Garner, 2006. JAS. https://doi.org/10.1175/JAS3705.1 imposing a default temperature tendency of -1.5K/day (=1K/16hours for a time_scale of 16 hours) on every level except for the stratosphere (diagnosed as temp < temp_min) where a relaxation term with time_scale_stratosphere towards temp_stratosphere is applied.
dT/dt = -1.5K/day for T > 207.5K else (200K-T) / 5 daysFields are
time_scale::Second = Hour(16): [OPTION] time scale of cooling, default = -1.5K/day = -1K/16hrstemp_min::Any: [OPTION] temperature [K] below which stratospheric relaxation is appliedtemp_stratosphere::Any: [OPTION] target temperature [K] of stratospheric relaxationtime_scale_stratosphere::Second = Day(5): [OPTION] time scale of stratospheric relaxation
SpeedyWeather.Variables Type
Struct that holds all variables of a simulation. Variables are split into groups corresponding to the fields here
prognostic::Any = NamedTuple(): Prognostic variables subject to time stepping.grid::Any = NamedTuple(): Variables defined on the grid, mostly copies of spectral prognostic variables.tendencies::Any = NamedTuple(): Tendencies of the prognostic variablesdynamics::Any = NamedTuple(): Variables used in the dynamical coreparameterizations::Any = NamedTuple(): Variables used in the parameterizationsparticles::Any = NamedTuple(): Variables used for particle advectionscratch::Any = NamedTuple(): Scratch variables for temporary storage during calculations with undetermined state (write before read).fused::Any = NamedTuple(): Fused variables, contiguous allocations of e.g. spectral prognostic variables for batching transforms and other optimizations.
Each group can have their own namespaces to distinguish between e.g. ocean, land, or tracer variables. All non-prognostic groups are considered to be diagnostic with no memory between time steps.
sourceSpeedyWeather.Variables Method
Variables(
model::AbstractModel
) -> Variables{Po, G, T, D, Pm, Pt, S, F} where {Po<:NamedTuple, G<:NamedTuple, T<:NamedTuple, D<:NamedTuple, Pm<:NamedTuple, Pt<:NamedTuple, S<:NamedTuple, F<:NamedTuple}Allocate all variables for a model as defined by its components. Filters out duplicates and sorts the variables into groups and namespaces. Variables sharing a non-empty fuse symbol (within the same namespace) share a single parent buffer; their per-variable entries are views of that parent. Fused parents themselves live under vars.fused.<fuse_symbol>.
SpeedyWeather.VisibleGeometricScattering Type
Visible radiation geometric-optical scattering parameter calculation. This expression was derived by distilling a trained neural network using symbolic regression. Geometric scattering represents the reflection due to shadowcasting of 3D objects at the surface, like tree crowns or big rocks, and obscuration of shadows due to viewing angle. Fields are
c1::Any: Coefficient fit via symbolic regressionc2::Any: Coefficient fit via symbolic regressionc3::Any: Coefficient fit via symbolic regressionc4::Any: Coefficient fit via symbolic regressionc5::Any: Coefficient fit via symbolic regressionc6::Any: Coefficient fit via symbolic regressionc7::Any: Coefficient fit via symbolic regressionc8::Any: Coefficient fit via symbolic regressionc9::Any: Coefficient fit via symbolic regressionc10::Any: Coefficient fit via symbolic regressionc11::Any: Coefficient fit via symbolic regressionc12::Any: Coefficient fit via symbolic regressionc13::Any: Coefficient fit via symbolic regression
SpeedyWeather.VisibleIsotropicScattering Type
Visible radiation isotropic scattering parameter calculation. This expression was derived by distilling a trained neural network using symbolic regression. Isotropic scattering means that light at the surface is reflected equally in all directions, regardless of where the sun is. Fields are
c1::Any: Coefficient fit via symbolic regressionc2::Any: Coefficient fit via symbolic regressionc3::Any: Coefficient fit via symbolic regressionc4::Any: Coefficient fit via symbolic regressionc5::Any: Coefficient fit via symbolic regressionc6::Any: Coefficient fit via symbolic regressionc7::Any: Coefficient fit via symbolic regressionc8::Any: Coefficient fit via symbolic regressionc9::Any: Coefficient fit via symbolic regressionc10::Any: Coefficient fit via symbolic regressionc11::Any: Coefficient fit via symbolic regression
SpeedyWeather.VisibleVolumetricScattering Type
Visible radiation volumetric scattering parameter calculation. This expression was derived by distilling a trained neural network using symbolic regression. Volumetric scattering represents the reflection mechanism of light interacting with horizontally homogenous vegetation canopy at the surface - light meets the canopy, bounces around a bit beneath the canopy and exits back towards the sky. This does depend on where the sun is and the viewing angle. Fields are
c1::Any: Coefficient fit via symbolic regressionc2::Any: Coefficient fit via symbolic regressionc3::Any: Coefficient fit via symbolic regressionc4::Any: Coefficient fit via symbolic regressionc5::Any: Coefficient fit via symbolic regressionc6::Any: Coefficient fit via symbolic regressionc7::Any: Coefficient fit via symbolic regressionc8::Any: Coefficient fit via symbolic regressionc9::Any: Coefficient fit via symbolic regressionc10::Any: Coefficient fit via symbolic regressionc11::Any: Coefficient fit via symbolic regressionc12::Any: Coefficient fit via symbolic regressionc13::Any: Coefficient fit via symbolic regression
SpeedyWeather.WriteModelComponentFile Type
WriteModelComponentFile callback. Writes a file containing a model component as .jld2. This is written at the end of the simulation, reflecting therefore the state that model component at the end of the simulation. Options are
filename::String = "model_component.jld2": [OPTION] File name for model component restart file, should end with .jld2path::String = "": [OPTION] Path for restart file, uses model.output.run_path if not specifiedcompress::Bool = true: [OPTION] Apply lossless compression in JLD2?write_only_with_output::Bool = true: [OPTION] Only write with model.output.active = true?component::Any: [OPTION] Model component to write, to be passed on as keyword argument to the callbackpkg_version::VersionNumber = if isnothing(pkgversion(SpeedyWeather)) …: [DERIVED] package version to track possible incompatibilities
SpeedyWeather.WriteVariablesRestartFile Type
WriteVariablesRestartFile callback. Writes a restart file for the prognostic variables on the last time step as jld2 file. Options are
filename::String = "restart.jld2": [OPTION] File name for restart file, should end with .jld2path::String = "": [OPTION] Path for restart file, uses model.output.run_path if not specifiedcompress::Bool = true: [OPTION] Apply lossless compression in JLD2?write_only_with_output::Bool = true: [OPTION] Only write with model.output.active = true?pkg_version::VersionNumber = if isnothing(pkgversion(SpeedyWeather)) …: [DERIVED] package version to track possible incompatibilities
SpeedyWeather.ZarrOutput Type
Output writer that writes a SpeedyWeather simulation to a Zarr store. Mirrors the behaviour of NetCDFOutput but writes a chunked, optionally compressed Zarr hierarchy on disk. The actual implementation lives in the SpeedyWeatherZarrExt extension and is only available once Zarr.jl is loaded:
using Zarr
using SpeedyWeather
output = ZarrOutput(spectral_grid)Type parameters: Field2D, Field3D are the scratch field types (on the model's architecture), HostField2D, HostField3D their host (CPU) equivalents to write from, Interpolator is the interpolator type, DT and S are the start-date and output-step types, C is the Zarr compressor type (or Nothing for the Zarr default), Z is the Zarr group type once initialize! has been called (Nothing before) and Layers the type of the vertical output layers.
SpeedyWeather.ZarrOutput Method
ZarrOutput(SG::SpectralGrid, args...; kwargs...)Stub constructor for ZarrOutput. Errors with a helpful message until the Zarr.jl extension is loaded, at which point the extension installs the real constructor.
SpeedyWeather.ZonalJet Type
A struct that contains all parameters for the Galewsky et al, 2004 zonal jet intitial conditions for the ShallowWaterModel. Default values as in Galewsky.
latitude::Any = 45: jet latitude [˚N]width::Any = (1 / 4 - 1 / 7) * 180: jet width [˚], default ≈ 19.29˚umax::Any = 80: jet maximum velocity [m/s]perturb_lat::Any = latitude: perturbation latitude [˚N], position in jet by defaultperturb_lon::Any = 270: perturbation longitude [˚E]perturb_xwidth::Any = ((1 / 3) * 360) / (2π): perturbation zonal extent [˚], default ≈ 19.1˚perturb_ywidth::Any = ((1 / 15) * 360) / (2π): perturbation meridinoal extent [˚], default ≈ 3.8˚perturb_height::Any = 120: perturbation amplitude [m]
SpeedyWeather.ZonalRidge Type
Zonal ridge orography after Jablonowski and Williamson, 2006.
η₀::Any = 0.252: [OPTION] conversion from σ to Jablonowski's ηᵥ-coordinatesu₀::Any = 35: [OPTION] max amplitude of zonal wind [m/s] that scales orography heightorography::Any: height [m] on grid-point space.surface_geopotential::Any: surface geopotential, height*gravity [m²/s²]
SpeedyWeather.ZonalWind Type
ZonalWind{NF}(;
η₀,
u₀,
perturb_lat,
perturb_lon,
perturb_uₚ,
perturb_radius
) where NF -> ZonalWind
ZonalWind(;
η₀,
u₀,
perturb_lat,
perturb_lon,
perturb_uₚ,
perturb_radius
)
ZonalWind{NF}(
η₀,
u₀,
perturb_lat,
perturb_lon,
perturb_uₚ,
perturb_radius
) where NF -> ZonalWind
ZonalWind(
η₀::NF,
u₀::NF,
perturb_lat::NF,
perturb_lon::NF,
perturb_uₚ::NF,
perturb_radius::NF
) where NF -> ZonalWindCreate a struct that contains all parameters for the Jablonowski and Williamson, 2006 intitial conditions for the primitive equation model. Default values as in Jablonowski.
η₀::Any = 0.252: conversion from σ to Jablonowski's ηᵥ-coordinatesu₀::Any = 35: [OPTION] max amplitude of zonal wind [m/s]perturb_lat::Any = 40: [OPTION] perturbation centred at [˚N]perturb_lon::Any = 20: [OPTION] perturbation centred at [˚E]perturb_uₚ::Any = 1: [OPTION] perturbation strength [m/s]perturb_radius::Any = 1 / 10: [OPTION] radius of Gaussian perturbation in units of Earth's radius [1]
Adapt.adapt_structure Method
adapt_structure(to, model::PrimitiveDryModel) -> NamedTupleA model is adapted to the GPU or CPU by wrapping some (but not all!) of its fields (determined by model.core_components) into a NamedTuple. Importantly, while accessing fields model.field still works as usual, one cannot use multiple dispatch on the model as a whole, e.g. ::PrimitiveDry will not work on GPU-adapted models.
Adapt.adapt_structure Method
adapt_structure(to, model::PrimitiveWetModel) -> NamedTupleA model is adapted to the GPU or CPU by wrapping some (but not all!) of its fields (determined by model.core_components) into a NamedTuple. Importantly, while accessing fields model.field still works as usual, one cannot use multiple dispatch on the model as a whole, e.g. ::PrimitiveDry will not work on GPU-adapted models.
Base.copy! Method
copy!(dest::Variables, src::Variables) -> VariablesCopy all entries from src to dest by recursing over the variable groups and namespaces. Uses copyto! for arrays, copy! for Clock, and direct assignment for Ref values.
Fused variables of dest (see is_fused_view) are skipped: they are views of a fused parent dest.fused.<fuse symbol>, which is copied directly, after which every view of it holds the new data. Copying through both view and parent is unnecessary work, and on cross-architecture copies it fails: copyto! between a SubArray on one side and a GPU array on the other falls back to scalar indexing (CPU ↔ CUDA, a contiguous view of a CuArray is not a SubArray), and the broadcast-aliasing check inside copyto! fails (CPU ↔ Reactant).
Base.deepcopy_internal Method
deepcopy_internal(
vars::Variables,
stackdict::IdDict
) -> Variablesdeepcopy of vars in which every fused variable is again a view of its (copied) fused parent vars.fused.<fuse symbol>, on every architecture. The default deepcopy keeps a fused variable attached to its parent only if the variable is a SubArray and the parent's array type registers its copy in deepcopy's IdDict. On CUDA a contiguous view of a fused parent is not a SubArray but another CuArray sharing the parent's memory, which the default deepcopy copies into independent memory (and GPUArrays' generic deepcopy of a GPU array, e.g. for JLArrays, does not use the IdDict at all). The batched transforms would then read the copied parent while the time stepping writes into the detached copy of the variable. Here every fused variable is created anew as the same view of its copied parent, see map_variables.
Base.delete! Method
delete!(
output::SpeedyWeather.AbstractOutput,
keys::Union{String, Symbol}...
) -> SpeedyWeather.AbstractOutputDelete output variables from output by their (short name) (Symbol or String), corresponding to the keys in the dictionary.
Base.filter! Method
filter!(
vars::Variables,
soil::LandBucketMoisture,
model::PrimitiveEquation
)Applied after the time step: Excess water above field capacity in the top layer is split into infiltration (fraction p) into the lower layer and river runoff (fraction 1-p, accumulated in river_runoff [m]). Excess water in the lower layer is removed (this disappears), and soil moisture is capped at 0 from below. This needs to be done after the time step as the excess water is only known for the new soil moisture.
Base.filter! Method
filter!(
vars::Variables,
snow::SnowModel,
model::PrimitiveEquation
)Keep snow depth within [0, snow_depth_cap] after the time step. Conservation of mass is violated here by removing excess snow above the depth cap, done after the time step so that this excess does not add to the melt rate.
Base.getproperty Method
getproperty(output::SpeedyWeather.AbstractOutput, s::Symbol)Forward OutputWriterCore field reads transparently from any AbstractOutput that embeds a core::OutputWriterCore field, so callers can write output.run_path etc.
Base.mod Method
mod(p::P) where P<:Particle -> ParticleModulo operator for particle locations to map them back into [0,360˚E) and [-90˚,90˚N], in the horizontal and to clamp vertical σ coordinates into [0,1].
sourceBase.setproperty! Method
setproperty!(
output::SpeedyWeather.AbstractOutput,
s::Symbol,
v
)Forward OutputWriterCore field writes transparently from any AbstractOutput that embeds a core::OutputWriterCore field, so callers can write output.run_path = ... etc.
SpeedyTransforms.transform! Method
transform!(
::Variables,
::Nothing,
::SpeedyTransforms.AbstractSpectralTransform
)random_process=nothing does not need to transform any random pattern from spectral to grid space.
SpeedyTransforms.transform! Method
transform!(
vars::Variables,
random_process::SpeedyWeather.AbstractRandomProcess,
spectral_transform::SpeedyTransforms.AbstractSpectralTransform
)General transform for random processes <: AbstractRandomProcess. Takes the spectral random_pattern in the prognostic variables and transforms it to spectral space in diagn.grid.random_pattern.
SpeedyTransforms.transform! Method
transform!(
vars::Variables,
time_stepping::SpeedyWeather.AbstractTimeStepper,
model::Barotropic;
initialize::Bool=false
)Propagate the spectral state of the prognostic variables of vars to the grid variables vars for the barotropic vorticity model. Updates grid vorticity, spectral stream function and spectral and grid velocities u, v.
SpeedyTransforms.transform! Method
transform!(
vars::Variables,
time_stepping::SpeedyWeather.AbstractTimeStepper,
model::PrimitiveEquation;
initialize::Bool=false
)Propagate the spectral state of the prognostic variables of vars to the grid variables in vars for primitive equation models. Updates grid vorticity, grid divergence, grid temperature, pressure (pres_grid) and the velocities u, v.
SpeedyTransforms.transform! Method
transform!(
vars::Variables,
time_stepping::SpeedyWeather.AbstractTimeStepper,
model::ShallowWater;
initialize::Bool=false
)Propagate the spectral state of the prognostic variables of vars to the grid variables in vars for the shallow water model. Updates grid vorticity, grid divergence, grid interface displacement (pres_grid) and the velocities u, v.
SpeedyWeather.BoundaryLayerDragOutput Method
Deprecated, use OutputVariables.BoundaryLayerDrag instead.
SpeedyWeather.BoundaryLayerOutput Method
Deprecated, use OutputVariables.BoundaryLayer instead.
SpeedyWeather.CallbackDict Method
CallbackDict(
pairs::Pair{Symbol, <:SpeedyWeather.AbstractCallback}...
) -> Dict{Symbol, SpeedyWeather.AbstractCallback}Create Callback dictionary like normal dictionaries.
sourceSpeedyWeather.CallbackDict Method
CallbackDict() -> Dict{Symbol, SpeedyWeather.AbstractCallback}Empty Callback dictionary generator.
sourceSpeedyWeather.ConvectiveRainOutput Method
Deprecated, use OutputVariables.ConvectiveRain instead.
SpeedyWeather.ConvectiveRainRateOutput Method
Deprecated, use OutputVariables.ConvectiveRainRate instead.
SpeedyWeather.ConvectiveSnowOutput Method
Deprecated, use OutputVariables.ConvectiveSnow instead.
SpeedyWeather.ConvectiveSnowRateOutput Method
Deprecated, use OutputVariables.ConvectiveSnowRate instead.
SpeedyWeather.CubicSigmaPressureCoordinates Method
CubicSigmaPressureCoordinates(
SG::SpectralGrid,
args...;
pressure_only_above=0.2,
σ_only_below=0.8,
kwargs...
) -> SigmaPressureCoordinates{NF} where NF<:AbstractFloatSigma-pressure coordinate with a cubic smoothstep transition: pure pressure levels near the top of the atmosphere (σ ≤ pressure_only_above), pure sigma levels near the surface (σ ≥ σ_only_below), and a cubic smoothstep transition in between. The thresholds and transition shape are a pragmatic choice and do not follow any specific operational model's formulation.
SpeedyWeather.DryRadiation Method
DryRadiation(
SG::SpectralGrid;
shortwave=OneBandGreyShortwave(SG),
longwave=OneBandGreyLongwave(SG)
) -> Radiation{SW, LW} where {SW<:(OneBandShortwave{NoClouds, T, R} where {T<:(ConstantShortwaveTransmissivity{<:AbstractFloat}), R<:(OneBandShortwaveRadiativeTransfer{<:AbstractFloat, SpeedyWeather.var"#OneBandShortwaveRadiativeTransfer##0#OneBandShortwaveRadiativeTransfer##1"})}), LW<:(OneBandLongwave{T, R} where {T<:(ConstantLongwaveTransmissivity{<:AbstractFloat}), R<:(OneBandLongwaveRadiativeTransfer{<:AbstractFloat})})}Radiation but with longwave/shortwave defaults for the PrimitiveDryModel.
SpeedyWeather.FourTimesCO2 Function
FourTimesCO2(
t0=DateTime(2000)
) -> CO2{F} where F<:SpeedyWeather.var"#FourTimesCO2##0#FourTimesCO2##1"4xCO2 scenario: Quadruples preindustrial DEFAULT_CO2 in the year 2000.
SpeedyWeather.FriersonSigmaCoordinates Method
FriersonSigmaCoordinates(
SG::SpectralGrid
) -> SigmaCoordinatesFrierson 2006 spacing, higher resolution in surface boundary layer and in stratosphere. Following exp(-5 * (0.05 * (1 - σ) + 0.95 * (1 - σ)^3)), σ being equi-spaced. Originally without the 1 - σ, but then vertical ordering is reversed.
sourceSpeedyWeather.HeatBoundaryLayerDragOutput Method
Deprecated, use OutputVariables.HeatBoundaryLayerDrag instead.
SpeedyWeather.HeatSurfaceRoughnessOutput Method
Deprecated, use OutputVariables.HeatSurfaceRoughness instead.
SpeedyWeather.HumidityBoundaryLayerDragOutput Method
Deprecated, use OutputVariables.HumidityBoundaryLayerDrag instead.
SpeedyWeather.InitialConditions Method
InitialConditions(
spectral_grid,
::Type{<:Barotropic}
) -> NamedTuple{(:vordiv,), <:Tuple{RandomVelocity{<:AbstractFloat, Int64, Random.Xoshiro}}}Default initial conditions for the BarotropicModel.
sourceSpeedyWeather.InitialConditions Method
InitialConditions(
spectral_grid,
::Type{<:PrimitiveDry}
) -> NamedTuple{(:vordiv, :pres, :temp), <:Tuple{ZonalWind{<:AbstractFloat}, PressureOnOrography, JablonowskiTemperature{<:AbstractFloat}}}Default initial conditions for the PrimitiveDryModel.
sourceSpeedyWeather.InitialConditions Method
InitialConditions(
spectral_grid,
::Type{<:PrimitiveWet}
) -> NamedTuple{(:zonal, :humid), <:Tuple{BalancedZonalState{<:AbstractFloat}, ConstantRelativeHumidity{<:AbstractFloat}}}Default initial conditions for the PrimitiveWetModel.
sourceSpeedyWeather.InitialConditions Method
InitialConditions(
spectral_grid,
::Type{<:ShallowWater}
) -> NamedTuple{(:vordiv,), <:Tuple{ZonalJet{<:AbstractFloat}}}Default initial conditions for the ShallowWaterModel.
sourceSpeedyWeather.InterfaceDisplacementOutput Method
Deprecated, use OutputVariables.InterfaceDisplacement instead.
SpeedyWeather.LargeScaleRainOutput Method
Deprecated, use OutputVariables.LargeScaleRain instead.
SpeedyWeather.LargeScaleRainRateOutput Method
Deprecated, use OutputVariables.LargeScaleRainRate instead.
SpeedyWeather.LargeScaleSnowOutput Method
Deprecated, use OutputVariables.LargeScaleSnow instead.
SpeedyWeather.LargeScaleSnowRateOutput Method
Deprecated, use OutputVariables.LargeScaleSnowRate instead.
SpeedyWeather.MeanSeaLevelPressureOutput Method
Deprecated, use OutputVariables.MeanSeaLevelPressure instead.
SpeedyWeather.MeridionalVelocity10mOutput Method
Deprecated, use OutputVariables.MeridionalVelocity10m instead.
SpeedyWeather.MeridionalVelocityOutput Method
Deprecated, use OutputVariables.MeridionalVelocity instead.
SpeedyWeather.MomentumBoundaryLayerDragOutput Method
Deprecated, use OutputVariables.MomentumBoundaryLayerDrag instead.
SpeedyWeather.MomentumSurfaceRoughnessOutput Method
Deprecated, use OutputVariables.MomentumSurfaceRoughness instead.
SpeedyWeather.OutgoingLongwaveRadiationOutput Method
Deprecated, use OutputVariables.OutgoingLongwaveRadiation instead.
SpeedyWeather.OutgoingShortwaveRadiationOutput Method
Deprecated, use OutputVariables.OutgoingShortwaveRadiation instead.
SpeedyWeather.Parameterization Function
Parameterization(spectral_grid::SpectralGrid, scheme; kwargs...)Create a SpeedyWeather parameterization from scheme, a parameterization defined in another package. That package does not have to depend on SpeedyWeather, instead it adds a method to Parameterization in its SpeedyWeather extension, e.g.
# in the main code of ExternalPackage, no SpeedyWeather dependency
struct ExternalLongwave
...
end
# in ExternalPackageSpeedyWeatherExt
struct SpeedyExternalLongwave{NF} <: SpeedyWeather.AbstractLongwave
...
end
SpeedyWeather.Parameterization(spectral_grid::SpectralGrid, scheme::ExternalLongwave; kwargs...) =
SpeedyExternalLongwave(spectral_grid, scheme; kwargs...)which is then used as
using SpeedyWeather, ExternalPackage
spectral_grid = SpectralGrid()
longwave = Parameterization(spectral_grid, ExternalLongwave())
radiation = Radiation(spectral_grid; longwave)
model = PrimitiveWetModel(spectral_grid; radiation)Types defined in extensions cannot be exported, so this avoids having to access them via Base.get_extension. Parameterizations that are already an AbstractParameterization are returned unchanged.
SpeedyWeather.PrecipitationOutput Method
Deprecated, use OutputVariables.Precipitation instead.
SpeedyWeather.RandomPatternOutput Method
Deprecated, use OutputVariables.RandomPattern instead.
SpeedyWeather.SeaIceConcentrationOutput Method
Deprecated, use OutputVariables.SeaIceConcentration instead.
SpeedyWeather.SeaSurfaceTemperatureOutput Method
Deprecated, use OutputVariables.SeaSurfaceTemperature instead.
SpeedyWeather.SoilMoistureAvailabilityOutput Method
Deprecated, use OutputVariables.SoilMoistureAvailability instead.
SpeedyWeather.SoilTemperatureOutput Method
Deprecated, use OutputVariables.SoilTemperature instead.
SpeedyWeather.SurfaceFluxesOutput Method
Deprecated, use OutputVariables.SurfaceFluxes instead.
SpeedyWeather.SurfaceHumidityFluxOutput Method
Deprecated, use OutputVariables.SurfaceHumidityFlux instead.
SpeedyWeather.SurfaceLatentHeatFluxOutput Method
Deprecated, use OutputVariables.SurfaceLatentHeatFlux instead.
SpeedyWeather.SurfaceLongwaveDownOutput Method
Deprecated, use OutputVariables.SurfaceLongwaveDown instead.
SpeedyWeather.SurfaceLongwaveUpOutput Method
Deprecated, use OutputVariables.SurfaceLongwaveUp instead.
SpeedyWeather.SurfacePressureOutput Method
Deprecated, use OutputVariables.SurfacePressure instead.
SpeedyWeather.SurfaceRoughnessOutput Method
Deprecated, use OutputVariables.SurfaceRoughness instead.
SpeedyWeather.SurfaceSensibleHeatFluxOutput Method
Deprecated, use OutputVariables.SurfaceSensibleHeatFlux instead.
SpeedyWeather.SurfaceShortwaveDownOutput Method
Deprecated, use OutputVariables.SurfaceShortwaveDown instead.
SpeedyWeather.SurfaceShortwaveUpOutput Method
Deprecated, use OutputVariables.SurfaceShortwaveUp instead.
SpeedyWeather.SurfaceTemperatureOutput Method
Deprecated, use OutputVariables.SurfaceTemperature instead.
SpeedyWeather.TwoTimesCO2 Function
TwoTimesCO2(
t0=DateTime(2000)
) -> CO2{F} where F<:SpeedyWeather.var"#TwoTimesCO2##0#TwoTimesCO2##1"2xCO2 scenario: Doubles preindustrial DEFAULT_CO2 in the year 2000.
SpeedyWeather.WhichTransform Method
WhichTransform(spectral_grid::SpectralGrid; kwargs...)Chooses the transform based on resolution and architecture. For low-resolution GPU a MatrixSpectralTransform is returned, otherwise the SpectralTransform. On Reactant always the SpectralTransform: it computes the Fourier transform as a truncated DFT up to DFT_MAX_TRUNCATION (matrix multiplies that XLA can accelerate more efficently).
SpeedyWeather.WhichZenith Method
WhichZenith(
SG::SpectralGrid,
planet::SpeedyWeather.AbstractPlanet;
solar_declination=SinSolarDeclination(planet),
time_correction=SolarTimeCorrection(SG)
) -> Union{SolarZenith, SolarZenithSeason}Chooses from SolarZenith (daily and seasonal cycle) or SolarZenithSeason given the parameters in model.planet. In both cases the seasonal cycle can be disabled, calculating the solar declination from the initial time instead of current (orbit) time.
sourceSpeedyWeather.ZonalVelocity10mOutput Method
Deprecated, use OutputVariables.ZonalVelocity10m instead.
SpeedyWeather.ZonalVelocityOutput Method
Deprecated, use OutputVariables.ZonalVelocity instead.
SpeedyWeather._assert_fuse_alignment Method
_assert_fuse_alignment(
a::SpeedyWeather.FusedParent,
b::SpeedyWeather.FusedParent;
name_a=:a,
name_b=:b
)Assert that two fuse parents a and b declare members in matching order — i.e. they agree both on which member names exist and on each member's layer-axis slot range. This is what lets a mega-batched transform! map slot k of one parent to slot k of the other (e.g. :prognostic ↔ :prog_grid).
name_a / name_b are used purely for the error message.
SpeedyWeather.activate! Method
activate!(
simulation::SpeedyWeather.AbstractSimulation,
tracers::Tracer...
)Activate a deactivated (=frozen) tracers in a simulation, which is a setting in simulation.model only.
SpeedyWeather.activate Method
activate(p::Particle{NF}) where NF -> ParticleActivate particle. Active particles can move.
sourceSpeedyWeather.add! Method
add!(
model::AbstractModel,
key_callbacks::Pair{Symbol, <:SpeedyWeather.AbstractCallback}...
)Add a or several callbacks to a model::AbstractModel. To be used like
add!(model, :my_callback => callback)
add!(model, :my_callback1 => callback, :my_callback2 => other_callback)SpeedyWeather.add! Method
add!(
model::AbstractModel,
callbacks::SpeedyWeather.AbstractCallback...
) -> Dict{Symbol, SpeedyWeather.AbstractCallback}Add a or several callbacks to a mdoel without specifying the key which is randomly created like callback_????. To be used like
add!(model.callbacks, callback)
add!(model.callbacks, callback1, callback2).SpeedyWeather.add! Method
add!(
model::AbstractModel,
outputvariables::SpeedyWeather.AbstractOutputVariable...
)Add outputvariables to the dictionary in output::NetCDFOutput of model, i.e. at model.output.variables.
SpeedyWeather.add! Method
add!(
D::Dict{Symbol, SpeedyWeather.AbstractCallback},
key_callbacks::Pair{Symbol, <:SpeedyWeather.AbstractCallback}...
) -> Dict{Symbol, SpeedyWeather.AbstractCallback}Add a or several callbacks to a Dict{String, AbstractCallback} dictionary. To be used like
add!(model.callbacks, :my_callback => callback)
add!(model.callbacks, :my_callback1 => callback, :my_callback2 => other_callback)SpeedyWeather.add! Method
add!(
D::Dict{Symbol, SpeedyWeather.AbstractCallback},
callbacks::SpeedyWeather.AbstractCallback...;
verbose=true
) -> Dict{Symbol, SpeedyWeather.AbstractCallback}Add a or several callbacks to a Dict{Symbol, AbstractCallback} dictionary without specifying the key which is randomly created like callback_????. To be used like
add!(model.callbacks, callback)
add!(model.callbacks, callback1, callback2).SpeedyWeather.add! Method
add!(
D::Dict{Symbol, SpeedyWeather.AbstractOutputVariable},
outputvariables::SpeedyWeather.AbstractOutputVariable...
) -> Dict{Symbol, SpeedyWeather.AbstractOutputVariable}Add outputvariables to a dictionary defining the variables subject to NetCDF output.
SpeedyWeather.add! Method
add!(
output::SpeedyWeather.AbstractOutput,
outputvariables::SpeedyWeather.AbstractOutputVariable...
) -> SpeedyWeather.AbstractOutputAdd outputvariables to the dictionary in output::NetCDFOutput, i.e. at output.variables.
SpeedyWeather.add_default! Method
add_default!(
output_variables::Dict{Symbol, SpeedyWeather.AbstractOutputVariable},
Model::Type{<:Barotropic}
) -> Dict{Symbol, SpeedyWeather.AbstractOutputVariable}Add default variables to output for a Barotropic model: Vorticity, zonal and meridional velocity.
SpeedyWeather.add_default! Method
add_default!(
variables::Dict{Symbol, SpeedyWeather.AbstractOutputVariable},
Model::Type{<:PrimitiveDry}
) -> Dict{Symbol, SpeedyWeather.AbstractOutputVariable}Add default variables to output for a PrimitiveDry model, same as for a Barotropic model but also the surface pressure and temperature.
SpeedyWeather.add_default! Method
add_default!(
variables::Dict{Symbol, SpeedyWeather.AbstractOutputVariable},
Model::Type{<:PrimitiveWet}
) -> Dict{Symbol, SpeedyWeather.AbstractOutputVariable}Add default variables to output for a PrimitiveWet model, same as for a PrimitiveDry model but also the specific humidity.
SpeedyWeather.add_default! Method
add_default!(
variables::Dict{Symbol, SpeedyWeather.AbstractOutputVariable},
Model::Type{<:ShallowWater}
) -> Dict{Symbol, SpeedyWeather.AbstractOutputVariable}Add default variables to output for a ShallowWater model, same as for a Barotropic model but also the interface displacement.
SpeedyWeather.all_variables Method
all_variables(model::AbstractModel)Extracts all variables from the model by iterating over all components and collecting their variables. Return a tuple of all variables.
sourceSpeedyWeather.allocate Function
allocate(
group,
model,
fuse_parents=Dict{Tuple{Symbol, Symbol}, NamedTuple}()
) -> NamedTupleAllocates all variables within a group given a tuple of variables expected to be <: AbstractVariable definitions. Determines the namespaces, allocates the arrays with zeros and collects them into NamedTuples. Members of a fuse group are returned as views of a shared parent (allocated via build_fuse_parents), and the parent itself is exposed under the fuse symbol in the same NamedTuple.
SpeedyWeather.balanced_zonal_wind Method
balanced_zonal_wind(z, u₀, H, z_jet, D) -> Tuple{Any, Any}Zonal wind amplitude U = u₀ tanh(z/H) f(z) of BalancedZonalState and its derivative dU/dz in z = -ln(σ), with f(z) = exp(-((z - z_jet)/D)²) above z_jet and 1 below.
SpeedyWeather.bernoulli_grid_potential! Method
bernoulli_grid_potential!(
vars::Variables,
model::ShallowWater,
time_stepping::SpeedyWeather.AbstractTimeStepper
)Gridded contribution of bernoulli_potential! for ShallowWater: writes kinetic_energy_grid = ½(u²+v²)+Φ (geopotential Φ is included because in ShallowWater geopotential lives only on the grid).
SpeedyWeather.bernoulli_grid_potential! Method
bernoulli_grid_potential!(
vars::Variables,
::Union{PrimitiveEquation, SpeedyTransforms.AbstractSpectralTransform},
time_stepping::SpeedyWeather.AbstractTimeStepper
)Gridded contribution of bernoulli_potential! for PrimitiveEquation: writes kinetic_energy_grid = ½(u²+v²)+Φ with the grid-point geopotential Φ calculated in transform!, shared with the parameterizations.
SpeedyWeather.bernoulli_potential! Method
bernoulli_potential!(
vars::Variables,
S::SpeedyTransforms.AbstractSpectralTransform,
TS::SpeedyWeather.AbstractTimeStepper
)Computes the Laplace operator ∇² of the Bernoulli potential B in spectral space.
computes the kinetic energy KE = ½(u²+v²) on the grid
transforms KE to spectral space
adds geopotential for the Bernoulli potential in spectral space
takes the Laplace operator.
This version is used for both ShallowWater and PrimitiveEquation, only the geopotential calculation in geopotential! differs.
sourceSpeedyWeather.bernoulli_spectral_potential! Method
bernoulli_spectral_potential!(
vars::Variables,
model::ShallowWater
)Spectral half of bernoulli_potential!. kinetic_energy is assumed to already hold the spec transform of kinetic_energy_grid (from the mega-batched transform). Adds -∇²(KE) into div_tend. The geopotential is already absorbed into kinetic_energy_grid on the grid side.
SpeedyWeather.build_fuse_parents Method
build_fuse_parents(
all_vars,
model
) -> Dict{Tuple{Symbol, Symbol}, NamedTuple}For every non-empty fuse symbol used across all_vars, allocate one parent buffer covering all members in that (namespace, fuse) group across all variable types. Returns a Dict{Tuple{Symbol,Symbol}, NamedTuple} keyed by (namespace, fuse). Each entry holds the parent and a Dict{Symbol, AbstractArray} mapping each member's identifier(v) to its view.
Validates at build time that every constructed view actually aliases the parent at its declared slot range, that slot ranges are pairwise non-overlapping, and that together they tile the parent's fused axis exactly with no gaps. This catches offset/order bugs in _split_views_* and ensures the right variable is wired to the right slot.
SpeedyWeather.build_fused_namespace Method
build_fused_namespace(fuse_parents) -> NamedTupleBuild the vars.fused NamedTuple from the fuse_parents Dict. Keyed flat by fuse symbol; errors if the same fuse symbol is reused across namespaces.
SpeedyWeather.bulk_richardson! Method
bulk_richardson!(
ij,
vars,
diffusion::BulkRichardsonDiffusion,
time_stepping::SpeedyWeather.AbstractTimeStepper,
atmosphere::SpeedyWeather.AbstractAtmosphere
)Calculate the bulk Richardson number following Frierson, 2007. For vertical stability in the boundary layer.
sourceSpeedyWeather.bulk_richardson_surface Method
bulk_richardson_surface(
ij,
ΔΦ₀,
vars,
atmosphere,
drag,
time_stepping
) -> Tuple{Any, Any}Bulk Richardson number between the lowermost layer and the land and ocean surface following Frierson, 2006, eq. (15), Ri = ΔΦ₀ (Θ₁ - Θ₀) / (Θ₀ Vₛ²), with the virtual dry static energy Θ₁ = cₚTᵥ + ΔΦ₀ of the lowermost layer and Θ₀ = cₚTᵥ₀ of the surface. Over land Tᵥ₀ uses the uppermost soil layer temperature and humidity α q⋆ (as in SurfaceLandHumidityFlux), over ocean the sea surface temperature and q⋆ (as in SurfaceOceanHumidityFlux). Returns (Ri_land, Ri_ocean).
SpeedyWeather.callback! Method
callback!(
callback::GlobalSurfaceTemperatureCallback,
vars::Variables,
model::PrimitiveEquation
)Pulls the average temperature from the lowermost layer and stores it in the next element of the callback.temperature vector.
sourceSpeedyWeather.callback! Method
callback!(progress_txt::ProgressTxt, vars, model)Writes the time stepping progress to the progress.txt file every every_n_percent % of time steps.
SpeedyWeather.column_parameterization_cpu! Method
column_parameterization_cpu!(vars, parameterization, model)Loop over all horizontal grid points ij for a single column parameterization on CPU. Parameterizations that bundle several schemes (e.g. Radiation) extend this method to loop over the grid points for every scheme separately, keeping the memory access contiguous per scheme and the loop bodies small.
SpeedyWeather.combine_albedos! Method
combine_albedos!(ij, vars, fraction_direct)Blend black/white-sky albedos over ocean and land wherever defined.
sourceSpeedyWeather.combine_surface_albedo! Method
combine_surface_albedo!(
ij,
surface::NamedTuple,
fraction_direct
)Blend direct (black-sky) and diffuse (white-sky) albedo into the broadband albedo of surface (a namespace of vars.parameterizations, e.g. .land) given the fraction of direct shortwave radiation fraction_direct. Does nothing if surface does not define both, decided at compile time.
SpeedyWeather.convection! Method
convection!(
ij,
vars,
convection::BettsMillerConvection,
model
)calculates temperature and humidity tendencies for the convection scheme following the simplified Betts-Miller convection. Starts with a first-guess relaxation to determine the convective criteria (none, dry/shallow or deep), then adjusts reference profiles for thermodynamic consistency (e.g. in dry convection the humidity profile is non-precipitating), and relaxes current vertical profiles to the adjusted references.
sourceSpeedyWeather.convection! Method
convection!(ij, vars, DBM::BettsMillerDryConvection, model)calculates temperature tendency for the dry convection scheme following the simplified Betts-Miller convection from Frierson 2007 but with zero humidity. Starts with a first-guess relaxation to determine the convective criterion, then adjusts the reference profiles for thermodynamic consistency (e.g. in dry convection the humidity profile is non-precipitating), and relaxes current vertical profiles to the adjusted references.
sourceSpeedyWeather.copy_variables! Method
copy_variables!(dest::NamedTuple, src::NamedTuple)Copy variables in NamedTuples from src into dest, only copying keys present in both. Recurses into nested NamedTuples (namespaces like ocean, land, tracers). With the fused parents fused of dest (as for copy!(::Variables, ::Variables)), the fused variables of dest are skipped, as their parents are copied directly; without (nothing), variables that are views on both sides are skipped. Uses @generated to unroll the key iteration at compile time so that Enzyme can differentiate through this function without runtime reflection more easily.
SpeedyWeather.coriolis! Method
coriolis!(
f::AbstractField;
rotation=DEFAULT_ROTATION
) -> AbstractFieldReturn the Coriolis parameter f on the grid Grid of resolution nlat_half on a planet of rotation [1/s]. Default rotation of Earth.
SpeedyWeather.coriolis Method
coriolis(field::AbstractField; kwargs...) -> AbstractFieldReturn the Coriolis parameter f on the same grid as field on a planet of kwarg rotation [1/s]. Default rotation of Earth.
SpeedyWeather.cos_zenith! Method
cos_zenith!(
cos_zenith::AbstractField{NF},
S::SolarZenith,
rotation_time::Dates.AbstractDateTime,
orbit_time::Dates.AbstractDateTime,
geometry::SpeedyWeather.AbstractGeometry
) where NFCalculate cos of solar zenith angle with a daily cycle at rotation_time rotation_timeand orbit_timeorbit_time. Seasonal cycle or time correction may be disabled, depending on parameters in SolarZenith.
SpeedyWeather.cos_zenith! Method
cos_zenith!(
cos_zenith::AbstractField{NF},
S::SolarZenithSeason,
rotation_time::Dates.AbstractDateTime,
orbit_time::Dates.AbstractDateTime,
geometry::SpeedyWeather.AbstractGeometry
) where NFCalculate cos of solar zenith angle as daily average at rotation_time rotation_timeand orbit_timeorbit_time. Seasonal cycle or time correction may be disabled, depending on parameters in SolarZenithSeason.
SpeedyWeather.create_run_folder! Method
create_run_folder!(output::SpeedyWeather.AbstractOutput)Creates a new folder prefix_id_number with the identification id. Also returns the full path run_path of that folder.
SpeedyWeather.cubic_transition Method
cubic_transition(
σ;
pressure_only_above=0.2,
σ_only_below=0.8
)Transition function for CubicSigmaPressureCoordinates. Returns 0 (pure pressure) for σ ≤ pressure_only_above, 1 (pure sigma) for σ ≥ σ_only_below, and a cubic smoothstep in between, giving C¹ continuity at both thresholds. The smoothstep coefficients 3 and 2 are fixed by the C¹ boundary conditions on the normalised variable t ∈ [0, 1] and do not depend on the thresholds.
SpeedyWeather.current_substep Method
current_substep(L::NCycleLorenz, clock)Get current substep within N-cycle (0 to N-1) from the clock.
sourceSpeedyWeather.deactivate! Method
deactivate!(
simulation::SpeedyWeather.AbstractSimulation,
tracers::Tracer...
)Deactivate a tracer in a simulation, which is a setting in simulation.model only.
SpeedyWeather.deactivate Method
deactivate(p::Particle{NF}) where NF -> ParticleDeactivate particle. Inactive particles cannot move.
sourceSpeedyWeather.default_transform_batch Method
default_transform_batch(
arch::SpeedyWeatherInternals.Architectures.AbstractArchitecture,
nlayers::Integer
) -> Vector{Int64}Default transform_batch for a SpectralGrid. Architecture-dependent because:
On CPU, batched FFT plans give negligible speedup, default:
[1, nlayers]— matches the pre-multiplexing system.On GPU, batched plans are essential, the default corresponds to the transforms needed for the models:
[1, nlayers, 2*nlayers, 2*nlayers + 2, 4*nlayers + 1, 6*nlayers + 1, 9*nlayers + 1]— covers single-layer (1), one variable (L), the u, v tendencies of the barotropic model (2L), U/V together with the surface-pressure gradient pair in primitive equation models (2L + 2), the prognostic batch (4L + 1) and the tendency batches of the dry and wet primitive equation models (6L + 1,9L + 1)
On GPU, if a transform is hit with a K not in transform_batch, the transform plans are re-allocated to avoid slow transform performance during model runs.
SpeedyWeather.define_coordinate! Method
define_coordinate!(
dataset::NCDatasets.NCDataset,
name::String,
values::AbstractVector;
attribs=Dict{String, String}()
)Define a coordinate in dataset: a dimension name of length(values) with values as its coordinate variable and attribs as its attributes. Used by custom output variables to define their own dimension in define_dimension!.
SpeedyWeather.define_dimension! Method
define_dimension!(
dest,
variable::SpeedyWeather.AbstractOutputVariable
)Function called by define_variable! before variable is defined in the output file or store dest; no-op by default as the default dimensions (see vertical_dimension_name) are defined upfront by initialize!. Custom output variables written on their own vertical dimension extend this to define that dimension, typically via get_dimension_length and define_coordinate! so that one method covers all output backends.
SpeedyWeather.define_vertical_coordinate! Method
define_vertical_coordinate!(
dest,
layers::ModelLayers,
model::AbstractModel
)Define the vertical coordinate of 3D atmospheric variables in the output file or store dest: sigma for ModelLayers, pressure in hPa for PressureLayers. Backend-agnostic via define_coordinate!.
SpeedyWeather.determine_run_folder! Method
determine_run_folder!(
output::SpeedyWeather.AbstractOutput
) -> StringChecks existing folders in path and determine run_numberby counting up. E.g. if folder run_0001 exists then run_number is 2. Does not create a folder for the returned run id.
SpeedyWeather.diagnose_cloud_properties Method
diagnose_cloud_properties(
ij,
vars,
clouds::DiagnosticClouds,
model
) -> NamedTuple{(:cloud_cover, :cloud_top, :stratocumulus_cover), <:Tuple{Any, Any, Any}}Core cloud diagnosis algorithm shared by DiagnosticClouds and SpectralDiagnosticClouds. Returns (cloud_cover, cloud_top, stratocumulus_cover) tuple.
sourceSpeedyWeather.dilate Method
dilate(Δt::Millisecond, dilation)Time step Δt dilated by dilation, rounded to whole milliseconds. Used to advance (or, on the leapfrog spin-up step, rewind) the rotation and orbit times.
SpeedyWeather.do_output! Method
do_output!(
core::OutputWriterCore,
clock::Clock,
output::SpeedyWeather.AbstractOutput
)Increment the timestep counter and return true if output should be written on this step (i.e. active is true and the counter is a multiple of output_every_n_steps).
SpeedyWeather.drag! Method
drag!(
vars::Variables,
drag::LinearDrag,
model::AbstractModel
)Compute tendency for boundary layer drag of a column and add to its tendencies fields
SpeedyWeather.drag! Method
drag!(
vars::Variables,
drag::LinearVorticityDrag,
model::AbstractModel
)Linear drag for the vorticity equations of the form F = -cξ with c drag coefficient [1/s].
sourceSpeedyWeather.drag! Method
drag!(
vars::Variables,
scheme::QuadraticDrag,
model::AbstractModel
)Quadratic drag for the momentum equations.
F = -c_D/H*|(u, v)|*(u, v)with c_D the non-dimensional drag coefficient as defined in drag::QuadraticDrag. c_D and layer thickness H are precomputed in initialize!(::QuadraticDrag, ::AbstractModel) and scaled by the radius as are the momentum equations.
SpeedyWeather.drag! Method
drag!(
vars::Variables,
scheme::SpeedLimitDrag,
model::AbstractModel
)Speed limit drag for the momentum equations.
(Fu, Fv) = -c*max(0, |(u, v)| - speed_limit)^2 * (u, v)/|(u, v)|with c the drag coefficient [1/m] as defined in drag::SpeedLimitDrag and kicking in only above a certain speed limit. The drag is quadratic in the excess speed above the limit and antiparallel to the flow, so it only decelerates and never rotates it.
SpeedyWeather.dry_adiabat! Method
dry_adiabat!(
ij,
temp_ref_profile,
temp_environment,
temp_parcel,
σ,
atmosphere,
entrainment
) -> Int64Calculates the dry adiabat given the temperature of the surface parcel. Follows the dry adiabat to the level of zero buoyancy (LZB). Levels above the LZB are set to the environmental temperature (rather than left undefined), so that
SpeedyWeather.dynamics_tendencies! Method
dynamics_tendencies!(vars::Variables, model::Barotropic)Calculate all tendencies for the BarotropicModel.
sourceSpeedyWeather.dynamics_tendencies! Method
dynamics_tendencies!(
vars::Variables,
model::PrimitiveEquation
)Calculate all tendencies for the PrimitiveEquation model (wet or dry).
sourceSpeedyWeather.dynamics_tendencies! Method
dynamics_tendencies!(vars::Variables, model::ShallowWater)Calculate all tendencies for the ShallowWaterModel.
sourceSpeedyWeather.entraining Method
Whether an entrainment profile actually mixes environmental air into the rising parcel. false for NoEntrainment so that the mixing step in the ascent can be skipped (compiled away) entirely for the default case; true for all other entrainment profiles.
SpeedyWeather.extrapolate_above Method
extrapolate_above(
ξ_top,
p,
p_top,
::SpeedyWeather.AbstractVerticalExtrapolation
)Value at pressure p above the top-most full model layer at p_top with value ξ_top.
TODO: currently the top-most layer is held constant for every extrapolation method. To change this, e.g. to mask with a missing value or to continue isothermally, extend this method for a new <: AbstractVerticalExtrapolation.
SpeedyWeather.extrapolate_below Method
extrapolate_below(
ξ_bottom,
p,
p_bottom,
pₛ,
::SpeedyWeather.ConstantExtrapolation
)Value at pressure p below the bottom-most full model layer at p_bottom with value ξ_bottom, given the surface pressure pₛ. Note that p_bottom < pₛ, so p may well be above ground; pₛ is passed on to distinguish the two.
SpeedyWeather.filter_groups Method
filter_groups(
vars::Variables,
output::SpeedyWeather.AbstractVariablesOutput
) -> Union{NamedTuple, Variables}Filter vars::Variables to only include the groups specified in output.groups. Returns the Variables struct directly when groups contains :all, otherwise a NamedTuple with the selected groups.
SpeedyWeather.filter_variables Method
filter_variables(vars, VariableType) -> Dict{Symbol, Tuple}Filters a tuple of variables vars by VariableTyple, removes duplicates such that the variable path remains unique. Returns a dictionary of the variable definitions (but the arrays aren't allocated here but in allocate)
SpeedyWeather.finalize! Method
finalize!(F::Feedback)Finalises the progress meter and the progress txt file.
sourceSpeedyWeather.finalize! Method
finalize!(progress_txt::ProgressTxt, vars, model)Finalizes the ProgressTxt callback by writing the total time taken to the progress.txt file and closing it.
sourceSpeedyWeather.finalize! Method
finalize!(
simulation::SpeedyWeather.AbstractSimulation
) -> SpeedyWeather.AbstractSimulationFinalize a simulation. Finishes the progress meter, unscales variables, finalizes the output, writes a restart file and finalizes callbacks.
SpeedyWeather.finalize! Method
finalize!(
restart::WriteModelComponentFile,
::Variables,
model::AbstractModel
)A restart file for the specified model component is written to the output folder (or current path) that can be used to restart the model. With the component field in WriteModelComponentFile as at the end of the simulation.
SpeedyWeather.finalize! Method
finalize!(
restart::WriteVariablesRestartFile,
vars::Variables,
model::AbstractModel
)A restart file restart.jld2 with the prognostic variables is written to the output folder (or current path) that can be used to restart the model. restart.jld2 will then be used as initial conditions. Variables in restart file are not scaled.
SpeedyWeather.flux_damping Method
flux_damping(::ExplicitFluxes, z)Factor φ(z) multiplying an explicit relaxation flux for z = Δt/τ given time integration scheme.
SpeedyWeather.flux_divergence! Method
flux_divergence!(
A_tend::LowerTriangularArray,
A_grid::AbstractField,
vars::Variables,
model::AbstractModel;
add::Bool=true,
flipsign::Bool=true,
uA=vars.scratch.a,
vA=vars.scratch.b,
uA_grid=vars.scratch.grid.a,
vA_grid=vars.scratch.grid.b
)Computes ∇⋅((u, v)*A) with the option to add/overwrite A_tend and to flip_sign of the flux divergence by doing so.
A_tend = ∇⋅((u, v)*A)foradd=false,flip_sign=falseA_tend = -∇⋅((u, v)*A)foradd=false,flip_sign=trueA_tend += ∇⋅((u, v)*A)foradd=true,flip_sign=falseA_tend -= ∇⋅((u, v)*A)foradd=true,flip_sign=true
SpeedyWeather.flux_grid_divergence! Method
flux_grid_divergence!(
uA_grid::AbstractField,
vA_grid::AbstractField,
A_grid::AbstractField,
vars::Variables,
model::AbstractModel
)Gridded half of flux_divergence!: writes u*A and v*A to (uA_grid, vA_grid) on the grid, with the standard coslat⁻¹ scaling.
SpeedyWeather.flux_spectral_divergence! Method
flux_spectral_divergence!(
A_tend::LowerTriangularArray,
uA::LowerTriangularArray,
vA::LowerTriangularArray,
S::SpeedyTransforms.AbstractSpectralTransform;
add::Bool=true,
flipsign::Bool=true
)Purely spectral half of flux_divergence!: Just computes the actual divergence
SpeedyWeather.flux_to_tendency Method
flux_to_tendency(flux::Real, pₛ::Real, g::Real, Δσ_k::Real)Flux flux into layer k of thickness Δσ converted to tendency [?/s]. Using surface pressure pₛ [Pa] and gravity g [m/s^2].
SpeedyWeather.forcing! Method
forcing!(
vars::Variables,
forcing::HeldSuarez,
model::AbstractModel
)Apply temperature relaxation following Held and Suarez 1996, BAMS.
sourceSpeedyWeather.forcing! Method
forcing!(
vars::Variables,
forcing::JetStreamForcing,
time_stepping::SpeedyWeather.AbstractTimeStepper
)Set for every latitude ring the tendency to the precomputed forcing in the momentum equations following the JetStreamForcing. The forcing is precomputed in initialize!(::JetStreamForcing, ::AbstractModel).
SpeedyWeather.fused_view_location Method
fused_view_location(name, variable, fused)Where the variable name sits in the fused parents fused: (fuse_name, indices) such that variable.data is view(parent(fused[fuse_name]).data, indices...), or nothing if it is not a fused variable (also for a variable of the same name in another group). Works for SubArrays and for GPU arrays sharing the parent's memory.
SpeedyWeather.geopotential! Method
geopotential!(vars::Variables, model::PrimitiveEquation)Calculate the geopotential in grid-point space, used by both the dynamical core (in the Bernoulli potential) and the parameterizations. The time step is chosen by which_prognostic_step(var, time_stepping, ::AbstractGeopotential) which for Leapfrog is the previous step, as the linear (gravity wave) terms of the dynamical core are evaluated there before the semi-implicit correction.
SpeedyWeather.geopotential! Method
geopotential!(vars::Variables, model::ShallowWater)calculates the geopotential in the ShallowWaterModel as g*η, i.e. gravity times the interface displacement (field pres)
SpeedyWeather.get_dimension_length Method
get_dimension_length(
dataset::NCDatasets.NCDataset,
name::String
) -> Union{Nothing, Int64}Length of dimension name in dataset or nothing if not defined. Used by custom output variables to define their own dimension in define_dimension!.
SpeedyWeather.get_flat_indices Method
get_flat_indices(
i,
variable::SpeedyWeather.AbstractOutputVariable
)Indices to write the output slice of variable at output step i into a store that keeps the horizontal dimension unravelled into a single flat dimension, as a Field's data already is. The x and y flags of variable.dims_xyzt collapse into that one flat dimension, so a 3D+time variable is written as (:, :, i) where the equivalent get_indices for a rectangular lon/lat store gives (:, :, :, i). Used by the flat HEALPixOutput backend.
SpeedyWeather.get_full_output_file_path Method
get_full_output_file_path(
output::SpeedyWeather.AbstractOutput
)Returns the full path of the output file after it was created.
sourceSpeedyWeather.get_indices Method
get_indices(
i,
variable::SpeedyWeather.AbstractOutputVariable,
ensemble_index::Integer
)Ensemble-aware variant: appends the ensemble_index as the outermost (last, Julia column-major) index when ensemble output is on (ensemble_index > 0), otherwise falls back to the regular indices. Works for both time-varying and static variables (static variables ignore i). Used by the ensemble-capable ZarrOutput backend.
SpeedyWeather.get_interval Method
get_interval(output::SpeedyWeather.AbstractOutput)Returns the output time step of the model M.
SpeedyWeather.get_neutral_wind_speed Method
get_neutral_wind_speed(
ij,
vars,
::SpeedyWeather.AbstractNeutralWindSpeed
)Neutral wind speed at grid point ij as computed by the neutral wind speed scheme. With neutral_wind_speed = nothing the neutral wind speed is approximated by the (non-neutral) surface wind speed, i.e. without stability correction.
SpeedyWeather.get_nlayers Method
get_nlayers(::ModelLayers, SG::SpectralGrid)Number of vertical layers that 3D atmospheric variables are written on, used by the output writers to allocate their 3D scratch field on the output grid.
sourceSpeedyWeather.get_nlayers Method
get_nlayers(
output::SpeedyWeather.AbstractOutput,
variable::SpeedyWeather.AbstractOutputVariable
)Number of vertical layers variable is written on, as allocated in the scratch fields of output. Extend for custom output variables written on their own vertical dimension, see vertical_dimension_name.
SpeedyWeather.get_nsteps Method
get_nsteps(
time_stepping::SpeedyWeather.AbstractTimeStepper,
component::Symbol
) -> @NamedTuple{prognostic::Int64, tendency::Int64}Number of steps of the prognostic variables and tendencies of component (:ocean or :land), decided by its time stepper within the time_stepping setup, see time_stepper. These variables are stepped forward directly (not transformed), so the time stepper's prognostic_steps and tendency_steps apply without a distinction between grid and spectral space.
SpeedyWeather.get_output_path Method
get_output_path(
simulation::SpeedyWeather.AbstractSimulation
)Returns the full path of the output file for a simulation. Throws an error if output is not active.
SpeedyWeather.get_parameterizations Method
get_parameterizations(
model::ModelType
) where ModelType<:PrimitiveEquationExtract the parameterizations from the model as NamedTuple. These are the GPU-compatible components of the model.
sourceSpeedyWeather.get_soil_layers Method
get_soil_layers(model::AbstractModel)Extract the number of soil layers from the model. The fallback is 0 soil layers, i.e. no land model.
sourceSpeedyWeather.get_step Method
get_step(var)Select the step dimension from a variable, when no step is provided as 2nd argument select the last step as this typically represents the "current" step (and not any previous ones). But this depends on the time stepping a variable with step dimension was created for. Variables without a step dimension have a single step, so get_step(var) returns the full variable as a view.
SpeedyWeather.get_step Method
get_step(
var::AbstractField2D{T, A, G, SpeedyWeatherInternals.ArrayDimensions.XY},
step::Integer
) where {T, A, G}Get the i-th step of a field as a view (wrapped into the same type as the input variable). "step" refers to the time dimension T in the variable's ArrayDimensions, for prognostic variables e.g. used for the leapfrog time step. These methods are for fields WITHOUT a time dimension (XY, XYZ), which have no step dimension to select from: the full array is returned as a view and step is ignored (it should be 1).
SpeedyWeather.get_step Method
get_step(
var::AbstractField{T, 1, A, G, SpeedyWeatherInternals.ArrayDimensions.XYT},
step::Integer
) where {T, A, G}Get the i-th step of a field as a view (wrapped into the same type as the input variable). "step" refers to the time dimension T in the variable's ArrayDimensions, for prognostic variables e.g. used for the leapfrog time step. These methods are for fields WITH a time dimension (XYT horizontal + time, XYZT horizontal + vertical + time), whose last dimension is the step dimension.
SpeedyWeather.get_step Method
get_step(
var::LowerTriangularArray{T, 1, A, S, SpeedyWeatherInternals.ArrayDimensions.LM},
step::Integer
) where {T, A, S}Get the i-th step of a LowerTriangularArray as a view (wrapped into a LowerTriangularArray). "step" refers to the time dimension T in the variable's ArrayDimensions, for prognostic variables e.g. used for the leapfrog time step. These methods are for spectral variables WITHOUT a time dimension (LM, LMZ), which have no step dimension to select from: the full array is returned as a view and step is ignored (it should be 1).
SpeedyWeather.get_step Method
get_step(
var::LowerTriangularArray{T, 2, A, S, SpeedyWeatherInternals.ArrayDimensions.LMT},
step::Integer
) where {T, A, S}Get the i-th step of a LowerTriangularArray as a view (wrapped into a LowerTriangularArray). "step" refers to the time dimension T in the variable's ArrayDimensions, for prognostic variables e.g. used for the leapfrog time step. These methods are for spectral variables WITH a time dimension (LMT horizontal + time, LMZT horizontal + vertical + time), whose last dimension is the step dimension.
SpeedyWeather.get_steps Function
Get all steps of a variable as a tuple of views (wrapped into the same type as the input variable) as defined by get_step. "Steps" refer to the step dimension, i.e. the time dimension T in the variable's ArrayDimensions (e.g. XYT, LMZT), for prognostic variables e.g. used for the leapfrog time step. Variables without a time dimension have no steps to splat, so a 1-tuple holding the full variable (as a view, consistent with get_step) is returned.
SpeedyWeather.get_steps Method
get_steps(var::AbstractArray, ::Val{N}) where N -> TupleGet the first N steps of a variable as a tuple of views with a COMPILE-TIME length, fully unrolled via Val(N) (branchless, in contrast to the runtime-length methods above whose ntuple(f, ::Int) returns a small union of tuple types; that union breaks Enzyme's type analysis on Julia ≥ 1.11, see https://github.com/EnzymeAD/Enzyme.jl/issues/3275). NOTE: in Enzyme-differentiated code that launches kernels on the views, even a compile-time tuple of large step views (e.g. of a LowerTriangularArray) can exceed Enzyme's type analysis — there, avoid the tuple altogether and bind steps individually via get_step.
SpeedyWeather.get_Δt_millisec Function
get_Δt_millisec(
Δt_at_T32::Dates.TimePeriod,
truncation,
radius,
adjust_with_output::Bool,
interval::Dates.TimePeriod=DEFAULT_OUTPUT_INTERVAL
)Computes the time step in [ms]. Δt_at_T32 is always scaled with the resolution truncation of the model. In case adjust_Δt_with_output is true, the Δt_at_T32 is additionally adjusted to the closest divisor of interval so that the output time axis is keeping interval exactly.
SpeedyWeather.grad Method
grad(
TetensCoefficients::TetensEquation{NF},
temp_kelvin::NF
) where NFGradient of the Tetens equation wrt to temperature, evaluated at temp_kelvin.
SpeedyWeather.greenhouse_gases_time_step! Method
greenhouse_gases_time_step!(
vars::Variables,
model::PrimitiveEquation
)Time step greenhouse gas concentration as function of time only.
sourceSpeedyWeather.grid_tendencies! Method
grid_tendencies!(vars::Variables, model::Barotropic)Calculate tendencies in grid space for the Barotropic model.
sourceSpeedyWeather.grid_tendencies! Method
grid_tendencies!(vars::Variables, model::PrimitiveEquation)Calculate tendencies in grid space for the PrimitiveEquation model.
sourceSpeedyWeather.grid_tendencies! Method
grid_tendencies!(vars::Variables, model::ShallowWater)Calculate tendencies in grid space for the ShallowWater model.
sourceSpeedyWeather.horizontal_advection! Method
horizontal_advection!(
A_tend::LowerTriangularArray,
A_tend_grid::AbstractField,
A_grid::AbstractField,
vars::Variables,
model::AbstractModel;
add::Bool=true,
uA=vars.scratch.a,
vA=vars.scratch.b,
uA_grid=vars.scratch.grid.a,
vA_grid=vars.scratch.grid.b
)#TODO: OLD VERSION / SEQUENTIAL VERSION: MIGHT BE DELETED
Compute the horizontal advection (combined grid + transform + spec reduction).
sourceSpeedyWeather.horizontal_diffusion! Method
horizontal_diffusion!(
tendency::LowerTriangularArray,
var::LowerTriangularArray,
expl::AbstractMatrix,
impl::AbstractMatrix
)Apply horizontal diffusion to a 2D field var in spectral space by updating its tendency tendency with an implicitly calculated diffusion term. The implicit diffusion of the next time step is split into an explicit part expl and an implicit part impl, such that both can be calculated in a single forward step by using var as well as its tendency tendency.
SpeedyWeather.horizontal_diffusion! Method
horizontal_diffusion!(
vars::Variables,
diffusion::SpeedyWeather.AbstractHorizontalDiffusion,
model::Barotropic
)Apply horizontal diffusion to vorticity in the BarotropicModel.
sourceSpeedyWeather.horizontal_diffusion! Method
horizontal_diffusion!(
vars::Variables,
diffusion::SpeedyWeather.AbstractHorizontalDiffusion,
model::PrimitiveEquation
)Apply horizontal diffusion applied to vorticity, divergence, temperature, and humidity (PrimitiveWet only) in the PrimitiveEquation models.
sourceSpeedyWeather.horizontal_diffusion! Method
horizontal_diffusion!(
vars::Variables,
diffusion::SpeedyWeather.AbstractHorizontalDiffusion,
model::ShallowWater
)Apply horizontal diffusion to vorticity and divergence in the ShallowWaterModel.
sourceSpeedyWeather.horizontal_grid_advection! Method
horizontal_grid_advection!(
A_tend_grid::AbstractField,
A_grid::AbstractField,
vars::Variables,
model::AbstractModel;
add::Bool=true,
uA_grid=get_step(vars.dynamics.grid.uT_anomaly),
vA_grid=get_step(vars.dynamics.grid.vT_anomaly)
)Compute the gridded contribution to the horizontal advection.
Writes +A*div to A_tend_grid and (u*A, v*A) to (uA_grid, vA_grid)
SpeedyWeather.horizontal_spectral_advection! Method
horizontal_spectral_advection!(
A_tend::LowerTriangularArray,
uA::LowerTriangularArray,
vA::LowerTriangularArray,
S::SpeedyTransforms.AbstractSpectralTransform
)Compute the spectral tendencies due to horizontal advection.
Computes A_tend += -∇⋅(uA, vA). A_tend is assumed to already hold the spectral form of A_tend_grid (= forcing + parameterizations
- the
+A*divterm written byhorizontal_grid_advection!).
SpeedyWeather.host_field Method
host_field(field::AbstractField)Host (CPU) equivalent of field to write from: field itself if it already is on the CPU, otherwise a newly allocated copy on the CPU.
SpeedyWeather.humidity_grid_tendency! Method
humidity_grid_tendency!(
vars::Variables,
model::PrimitiveWet
)Computes the gridded contributation to the humidity tendency humid_tend_grid via the horizontal_grid_advection! Grid half of humidity_tendency!. Adds the +q·div advection term to humid_tend_grid and writes the (uq, vq) flux intermediates to the grid-side named slots — no transform.
SpeedyWeather.humidity_spectral_tendency! Method
humidity_spectral_tendency!(
vars::Variables,
model::PrimitiveWet
)Computes the spectral humidity tendency via the horizontal_spectral_advection! Adds -∇⋅(uq, vq) to the previously computed gridded and transformed tendency.
SpeedyWeather.identifier Method
identifier(v::SpeedyWeather.AbstractVariable) -> SymbolSymbol representing a unique identifier for a variable, combining its type, namespace and name and namespace. Used to remove duplicates when extracting variables from the model. E.g. :Variable_ocean_sea_surface_temperature.
SpeedyWeather.implicit_correction! Method
implicit_correction!(
vars::Variables,
implicit::ImplicitPrimitiveEquation,
time_stepping::SpeedyWeather.AbstractLeapfrog,
model::PrimitiveEquation
)Apply the implicit corrections to dampen gravity waves in the primitive equation models.
sourceSpeedyWeather.implicit_correction! Method
implicit_correction!(
vars::Variables,
implicit::ImplicitShallowWater,
time_stepping::SpeedyWeather.AbstractLeapfrog,
model::ShallowWater
)Apply correction to the tendencies in diagn to prevent the gravity waves from amplifying. The correction is implicitly evaluated using the parameter implicit.α to switch between forward, centered implicit or backward evaluation of the gravity wave terms.
SpeedyWeather.implicit_correction! Method
implicit_correction!(
vars::Variables,
implicit::ImplicitShallowWater,
time_stepping::SpeedyWeather.AbstractNCycleLorenz,
model::ShallowWater
)Apply correction to the tendencies in diagn to prevent the gravity waves from amplifying. The correction is implicitly evaluated using the parameter implicit.α to switch between forward, centered implicit or backward evaluation of the gravity wave terms.
SpeedyWeather.initialize! Method
initialize!(
land_sea_mask::AquaPlanetMask,
model::PrimitiveEquation
)Sets all grid points to 0 = sea.
sourceSpeedyWeather.initialize! Method
initialize!(
output::ArrayOutput,
vars::Variables,
model::AbstractModel
)Initialize ArrayOutput by pre-allocating the full output array and storing the initial condition.
SpeedyWeather.initialize! Method
initialize!(
model::Barotropic;
time::DateTime=DEFAULT_DATE
) -> Simulation{V, M} where {V<:(Variables{Po, G, T, D, Pm, Pt, S, F} where {Po<:NamedTuple, G<:NamedTuple, T<:NamedTuple, D<:NamedTuple, Pm<:NamedTuple, Pt<:NamedTuple, S<:NamedTuple, F<:NamedTuple}), M<:Barotropic}Calls all initialize! functions for most fields, representing components, of model, except for model.output and model.feedback which are always called at in time_stepping!.
SpeedyWeather.initialize! Method
initialize!(
clock::Clock,
time_stepping::SpeedyWeather.AbstractTimeStepper,
period::Dates.Period
) -> ClockInitialize the clock with the time step Δt and period to integrate for. n_time_steps is for the clock only, spin up steps (e.g. Leapfrog with 1 Euler to start) are not counted for the clock.
SpeedyWeather.initialize! Method
initialize!(
clock::Clock,
time_stepping::SpeedyWeather.AbstractTimeStepper,
n_steps::Integer
) -> ClockInitialize the clock with the time step Δt and the number of time stepper steps n_steps.
SpeedyWeather.initialize! Method
initialize!(
clock::Clock,
time_stepping::SpeedyWeather.AbstractTimeStepper,
planet::SpeedyWeather.AbstractPlanet,
args...
) -> ClockInitialize the clock with the time step Δt from time_stepping and computes the time dilation given a planet with length_of_day and length_of_year.
SpeedyWeather.initialize! Method
initialize!(clock::Clock) -> ClockInitialize the clock with setting the start time and resetting the (time) step counters.
sourceSpeedyWeather.initialize! Method
initialize!(
land_sea_mask::EarthLandSeaMask,
model::PrimitiveEquation
)Reads a high-resolution land-sea mask from file and interpolates (grid-cell average) onto the model grid for a fractional sea mask.
sourceSpeedyWeather.initialize! Method
initialize!(
orog::EarthOrography,
P::SpeedyWeather.AbstractPlanet,
S::SpeedyTransforms.AbstractSpectralTransform
)Initialize the arrays orography, surface_geopotential in orog by reading the orography field from file.
SpeedyWeather.initialize! Method
initialize!(E::EulerForward, model::AbstractModel)Initialize E by recalculating the time step for the resolution of model.
SpeedyWeather.initialize! Method
initialize!(
feedback::Feedback,
variables::Variables,
model::AbstractModel
)Initializes the a Feedback struct.
SpeedyWeather.initialize! Method
initialize!(G::Geopotential, model::PrimitiveEquation)Precomputes constants for the vertical integration of the geopotential, defined as
Φ_{k+1/2} = Φ_{k+1} + R*T_{k+1}*(ln(p_{k+1}) - ln(p_{k+1/2})) (half levels) Φ_k = Φ_{k+1/2} + R*T_k*(ln(p_{k+1/2}) - ln(p_k)) (full levels)
Same formula but k → k-1/2.
SpeedyWeather.initialize! Method
initialize!(forcing::HeldSuarez, model::PrimitiveEquation)initialize the HeldSuarez temperature relaxation by precomputing terms for the equilibrium temperature Teq.
sourceSpeedyWeather.initialize! Method
initialize!(diffusion::HyperDiffusion, model::AbstractModel)Precomputes the hyper diffusion terms in diffusion based on the model time step, and possibly with a changing strength/power in the vertical.
SpeedyWeather.initialize! Method
initialize!(
implicit::ImplicitPrimitiveEquation,
Δt::Number,
temp_average::AbstractVector,
geometry::SpeedyWeather.AbstractGeometry,
geopotential::SpeedyWeather.AbstractGeopotential,
atmosphere::SpeedyWeather.AbstractAtmosphere,
adiabatic_conversion::SpeedyWeather.AbstractAdiabaticConversion
)Initialize the implicit terms for the PrimitiveEquation models. The operators are constructed via broadcasting on the device, without transfers to the CPU, scalar indexing, or data-dependent control flow so that Reactant can trace this inside the time step. S⁻¹ is then computed per degree l with invert_S!.
SpeedyWeather.initialize! Method
initialize!(
implicit::ImplicitPrimitiveEquation,
model::PrimitiveEquation
)Initialize the schedule of implicit with the time step of model. The implicit operators themselves are only built in the first time steps by reinitialize!, as they need the temperature profile of the initial conditions and the time step of the leapfrog start.
SpeedyWeather.initialize! Method
initialize!(
output::JLD2Output,
vars::Variables,
model::AbstractModel
)Initialize JLD2 output by creating a JLD2 file. To be called just before the first timesteps.
SpeedyWeather.initialize! Method
initialize!(L::Leapfrog, model::AbstractModel)Initialize leapfrogging L by recalculating the time step given the output time step interval from model.output. Recalculating will slightly adjust the time step to be a divisor such that an integer number of time steps matches exactly with the output time step.
SpeedyWeather.initialize! Method
initialize!(drag::LinearDrag, model::PrimitiveEquation)Precomputes the drag coefficients for the LinearDrag scheme.
SpeedyWeather.initialize! Method
initialize!(L::NCycleLorenz, model::AbstractModel)Initialize NCycleLorenz time stepper.
sourceSpeedyWeather.initialize! Method
initialize!(
output::NetCDFOutput,
vars::Variables,
model::AbstractModel
)Initialize NetCDF output by creating a netCDF file and storing the initial conditions of vars. To be called just before the first timesteps.
SpeedyWeather.initialize! Method
initialize!(
core::OutputWriterCore,
output::SpeedyWeather.AbstractOutput,
model::AbstractModel;
create_folder::Bool=true
) -> BoolInitialize the OutputWriterCore from the option fields of output and model: determine the run folder (skipped for in-memory writers when create_folder=false), compute the output frequency from model.time_stepping, reset the output counter, and add standard callbacks (parameters txt, progress txt, restart file) if enabled. Returns true if output is active, false otherwise.
SpeedyWeather.initialize! Method
initialize!(parameters_txt::ParametersTxt, vars, model)Initialize ParametersTxt by writing the model parameters (via defined show of model components) into a text file.
sourceSpeedyWeather.initialize! Method
initialize!(
schedule::PeriodicSchedule,
time_stepping::SpeedyWeather.AbstractTimeStepper
) -> PeriodicScheduleInitialize a PeriodicSchedule with the time step of time_stepping: precomputes every_n_steps from schedule.every (at least 1, 0 = never for every = Second(0)) and resets the counter.
SpeedyWeather.initialize! Method
initialize!(
model::PrimitiveDry;
time::DateTime=DEFAULT_DATE
) -> Simulation{V, M} where {V<:(Variables{Po, G, T, D, Pm, Pt, S, F} where {Po<:NamedTuple, G<:NamedTuple, T<:NamedTuple, D<:NamedTuple, Pm<:NamedTuple, Pt<:NamedTuple, S<:NamedTuple, F<:NamedTuple}), M<:PrimitiveDry}Calls all initialize! functions for components of model, except for model.output and model.feedback which are always called at in time_stepping! and model.implicit which is done in first_timesteps! (except for its schedule).
SpeedyWeather.initialize! Method
initialize!(
model::PrimitiveWet;
time::DateTime=DEFAULT_DATE
) -> Simulation{V, M} where {V<:(Variables{Po, G, T, D, Pm, Pt, S, F} where {Po<:NamedTuple, G<:NamedTuple, T<:NamedTuple, D<:NamedTuple, Pm<:NamedTuple, Pt<:NamedTuple, S<:NamedTuple, F<:NamedTuple}), M<:PrimitiveWet}Calls all initialize! functions for components of model, except for model.output and model.feedback which are always called at in time_stepping! and model.implicit which is done in first_timesteps! (except for its schedule).
SpeedyWeather.initialize! Method
initialize!(progress_txt::ProgressTxt, vars, model)Initializes the ProgressTxt callback by creating a progress.txt file and writing some initial information to it.
sourceSpeedyWeather.initialize! Method
initialize!(
land_sea_mask::RockyPlanetMask,
model::PrimitiveEquation
)Sets all grid points to 1 = land.
sourceSpeedyWeather.initialize! Method
initialize!(scheduler::Schedule, clock::Clock) -> ScheduleInitialize a Schedule with a Clock (which is assumed to have been initialized). Takes both scheduler.every and scheduler.times into account, such that both periodic and events can be scheduled simultaneously. But execution will happen only once if they coincide on a given time step.
sourceSpeedyWeather.initialize! Method
initialize!(
model::ShallowWater;
time::DateTime=DEFAULT_DATE
) -> Simulation{V, M} where {V<:(Variables{Po, G, T, D, Pm, Pt, S, F} where {Po<:NamedTuple, G<:NamedTuple, T<:NamedTuple, D<:NamedTuple, Pm<:NamedTuple, Pt<:NamedTuple, S<:NamedTuple, F<:NamedTuple}), M<:ShallowWater}Calls all initialize! functions for most components (=fields) of model, except for model.output and model.feedback which are always initialized in time_stepping! and model.implicit which is done in first_timesteps!.
SpeedyWeather.initialize! Method
initialize!(
parameterization::SpeedyWeather.AbstractParameterization,
model::AbstractModel
)Initialize an AbstractParameterization. This is called once at when calling initialize!(model). The default behaviour is to return nothing.
SpeedyWeather.initialize! Method
initialize!(
simulation::SpeedyWeather.AbstractSimulation;
period::Dates.Period=DEFAULT_PERIOD,
steps::Int64=DEFAULT_TIMESTEPS,
output::Bool=false
) -> SpeedyWeather.AbstractSimulationInitializes a simulation. Scales the variables, initializes the output, stores initial conditions, initializes the progress meter feedback, callbacks and performs the first two initial time steps to spin up the leapfrogging scheme.
SpeedyWeather.initialize! Method
initialize!(
schedule::StepSchedule,
::SpeedyWeather.AbstractTimeStepper
) -> StepScheduleNothing to initialize for a StepSchedule.
SpeedyWeather.initialize! Method
initialize!(vars::Variables, model::AbstractModel)Apply initial conditions as defined by model.ocean, .sea_ice, .land, .particle_advection and .initial_conditions in that order.
SpeedyWeather.initialize! Method
initialize!(
vars::Variables,
initial_conditions::JablonowskiTemperature,
model::PrimitiveEquation
)Initial conditions from Jablonowski and Williamson, 2006, QJR Meteorol. Soc
sourceSpeedyWeather.initialize! Method
initialize!(
vars::Variables,
initial_conditions::NamedTuple,
model::AbstractModel
)Apply initial conditions as in the initial_conditions::NamedTuple one after another.
SpeedyWeather.initialize! Method
initialize!(
vars::Variables,
::PressureOnOrography,
model::PrimitiveEquation
)Initialize surface pressure on orography by integrating the hydrostatic equation with the reference temperature lapse rate.
sourceSpeedyWeather.initialize! Method
initialize!(
vars::Variables,
initial_conditions::RandomVelocity,
model::AbstractModel
)Start with random vorticity as initial conditions
sourceSpeedyWeather.initialize! Method
initialize!(
vars::Variables,
initial_conditions::RandomVorticity,
model::AbstractModel
)Kernel version of initialize! for RandomVorticity initial conditions.
sourceSpeedyWeather.initialize! Method
initialize!(
vars::Variables,
initial_conditions::RandomWaves,
model::AbstractModel
)Random initial conditions for the interface displacement η in the shallow water equations. The flow (u, v) is zero initially. This kicks off gravity waves that will interact with orography.
sourceSpeedyWeather.initialize! Method
initialize!(
vars::Variables,
initial_conditions::RossbyHaurwitzWave,
model::AbstractModel
)Rossby-Haurwitz wave initial conditions as in Williamson et al. 1992, J Computational Physics with an additional cut-off amplitude c to filter out tiny harmonics in the vorticity field.
SpeedyWeather.initialize! Method
initialize!(
vars::Variables,
snow::SnowModel,
model::PrimitiveEquation
)Initial snow depth estimated from the top-layer soil temperature (which therefore has to be initialized first), growing linearly by initial_snow_depth_rate per Kelvin below melting_threshold up to initial_snow_depth_max, zero over ocean. Starting from cold but snow-free land puts the model on the wrong side of the snow-albedo feedback as snow accumulates only slowly.
SpeedyWeather.initialize! Method
initialize!(
vars::Variables,
initial_conditions::StartFromFile,
model::AbstractModel
)Restart from a previous SpeedyWeather.jl simulation via the restart file restart.jld2. Applies interpolation in the horizontal but not in the vertical.
SpeedyWeather.initialize! Method
initialize!(
vars::Variables,
initial_conditions::ZonalJet,
model::AbstractModel
)Initial conditions from Galewsky, 2004, Tellus
sourceSpeedyWeather.initialize! Method
initialize!(
vars::Variables,
initial_conditions::ZonalWind,
model::PrimitiveEquation
)Initial conditions from Jablonowski and Williamson, 2006, QJR Meteorol. Soc
sourceSpeedyWeather.initialize! Method
initialize!(
orog::ZonalRidge,
P::SpeedyWeather.AbstractPlanet,
S::SpectralTransform,
G::Geometry
)Initialize the arrays orography, surface_geopotential in orog following Jablonowski and Williamson, 2006.
SpeedyWeather.initialize! Method
initialize!(
callback::GlobalSurfaceTemperatureCallback{NF},
vars::Variables,
model::PrimitiveEquation
) where NFInitializes callback.temperature vector that records the global mean surface temperature on every time step. Allocates vector of correct length (number of elements = total time steps plus one) and stores the global surface temperature of the initial conditions
sourceSpeedyWeather.initialize! Method
initialize!(
vars::Variables,
initial_conditions::BalancedZonalState{NF},
model::PrimitiveEquation
) where NFInitialize vorticity, divergence and temperature with BalancedZonalState.
SpeedyWeather.initialize! Method
initialize!(
particles::AbstractVector{P},
vars::Variables,
particle_advection::SpeedyWeather.AbstractParticleAdvection,
model::AbstractModel
) where P<:Particle -> AbstractVector{P} where P<:ParticleInitialize particle locations uniformly in latitude, longitude and in the vertical σ coordinates. This uses a cosine-distribution in latitude for an equal-area uniformity.
sourceSpeedyWeather.initialize! Method
initialize!(
vars::Variables,
particles::AbstractVector{P},
particle_advection::ParticleAdvection2D,
model::AbstractModel
) where P<:ParticleInitialize particle advection time integration: Store u,v interpolated initial conditions in diagn.particles.u and .v to be used when particle advection actually executed for first time.
SpeedyWeather.initialize! Method
initialize!(
vars::Variables,
particles::AbstractVector{P},
particle_advection::ParticleAdvection3D,
model::AbstractModel
) where P<:ParticleInitialize 3D particle advection work arrays: interpolate u, v, w at each particle's initial 3D position to seed the Heun predictor for the first advection step.
sourceSpeedyWeather.interpolate_layers! Method
interpolate_layers!(
::ModelLayers,
field,
::SpeedyWeather.AbstractOutputVariable,
::SpeedyWeather.AbstractSimulation
)Interpolate field onto the output writer's vertical layers, returning the field to write out. No-op on ModelLayers and for variables that are not 3D atmospheric variables (2D variables, soil variables). For PressureLayers this interpolates into the layers' scratch field, on the model grid and the model's architecture, i.e. before the horizontal interpolation onto the output grid.
SpeedyWeather.interpolate_output! Method
interpolate_output!(
output::SpeedyWeather.AbstractOutput,
dest::AbstractField,
src::AbstractField
)Move src (a field on the model grid and the model's architecture) onto the output grid of output, writing into dest (on the output_architecture, src is moved there first if that differs from the model's). Interpolates with output.interpolator, or copies straight over when output.interpolator === nothing, i.e. when the output grid already is the model grid and output was constructed without an interpolator (see HEALPixOutput for a simulation that already runs on the output's HEALPix grid).
SpeedyWeather.interpolate_pressure_layer Method
interpolate_pressure_layer(
ij,
p,
in_field,
pₛ,
coordinates,
nlayers,
interpolation,
extrapolation
)Value of in_field in column ij interpolated onto pressure p [Pa], given the surface pressure pₛ [Pa] in that column and the vertical coordinates of the model. Column-local, called from interpolate_pressure_layers! for every grid point and pressure layer.
SpeedyWeather.interpolate_pressure_layers! Function
interpolate_pressure_layers!(
out_field::AbstractField,
in_field::AbstractField,
surface_pressure::AbstractField,
p::AbstractVector,
coordinates::SpeedyWeather.AbstractVerticalCoordinates,
interpolation::SpeedyWeather.AbstractVerticalInterpolation=LinearInLogPressure(),
extrapolation::SpeedyWeather.AbstractVerticalExtrapolation=ConstantExtrapolation()
) -> AbstractFieldInterpolate in_field on the model's vertical layers onto the pressure layers p [Pa], writing into the externally allocated out_field. Both are fields on the same horizontal grid, in_field has nlayers vertical layers, out_field has length(p) of them.
The vertical coordinates (SigmaCoordinates or SigmaPressureCoordinates, from model.geometry.vertical_coordinates) together with the surface_pressure [Pa] define the pressure of every model layer in every column, so this works for terrain-following and hybrid sigma-pressure coordinates alike. Interpolation happens in pressure, the interpolation method chooses linear in p or in log(p). Outside the model layers extrapolation decides, see extrapolate_above, extrapolate_below.
Columns are independent, so this launches a kernel over the horizontal grid points and the pressure layers and runs on CPU and GPU. p therefore has to be on the same architecture as the fields. p does not have to be sorted (every layer is searched for independently) but normally would be. If in_field has a time step dimension, pass in the step to interpolate, e.g. via get_prognostic_step.
SpeedyWeather.interpolation_weight Method
interpolation_weight(
p,
p₁,
p₂,
::SpeedyWeather.LinearInPressure
)Weight w of the lower layer (at the higher pressure p₂) when interpolating onto pressure p with p₁ <= p <= p₂, so that the interpolated value is (1 - w)*ξ₁ + w*ξ₂ with ξ₁, ξ₂ the values at p₁, p₂. Returns 0 at p = p₁ and 1 at p = p₂.
SpeedyWeather.invert_S_gauss_jordan! Method
invert_S_gauss_jordan!(
implicit::ImplicitPrimitiveEquation,
ξ
)Compute S⁻¹ as in invert_S_lu! but on the device via Gauss-Jordan elimination (without pivoting) in a kernel, one thread per degree l, so that Reactant can trace it.
SpeedyWeather.invert_S_lu! Method
invert_S_lu!(implicit::ImplicitPrimitiveEquation, ξ)Compute S⁻¹ = (1 - ξ²λₗ(RL + UWᵀ))⁻¹ for every degree l, with λₗ the eigenvalues of ∇², via LU decomposition on the CPU, then transfer S⁻¹ back to the device. These are small (nlayers × nlayers) matrices, so CPU computation is more efficient.
sourceSpeedyWeather.is_fused_view Method
is_fused_view(name, variable, fused)Whether the variable name is a view of one of the fused parents fused. Decided by type for SubArrays (always fused variables, see is_view_entry) and Arrays (never views), so that it is constant-folded on CPU (e.g. for Enzyme), and by fused_view_location for other array types (GPU, Reactant).
SpeedyWeather.is_view_entry Method
is_view_entry(a::AbstractField) -> BoolWhether a variable entry is a view onto another buffer (rather than its own backing storage). View entries are skipped by copy! — see Base.copy!(::Variables, ::Variables). For Field and LowerTriangularArray wrappers we check the underlying .data; a plain SubArray leaf is also a view.
SpeedyWeather.isactive Method
isactive(p::Particle{NF}) where NF -> BoolCheck whether particle is active.
sourceSpeedyWeather.ismod Method
ismod(p::Particle) -> BoolCheck that a particle is in longitude [0,360˚E), latitude [-90˚,90˚N], and σ in [0,1].
sourceSpeedyWeather.isscheduled Method
isscheduled(schedule::PeriodicSchedule, clock::Clock)Whether schedule executes on the time step of clock, i.e. every every_n_steps time steps (spin-up steps excluded). Counts the executions.
SpeedyWeather.isscheduled Method
isscheduled(S::Schedule, clock::Clock)Evaluate whether (e.g. a callback) should be scheduled at the timestep given in clock. Returns true for scheduled executions, false for no execution on this time step.
sourceSpeedyWeather.isscheduled Method
isscheduled(schedule::StepSchedule, clock::Clock)Whether schedule executes on the time step of clock, i.e. every every_n_steps time steps (spin-up steps excluded).
SpeedyWeather.jablonowski_vorticity_perturbation Method
jablonowski_vorticity_perturbation(
φ_rad,
λ,
sinφc,
cosφc,
λc,
radius,
perturb_uₚ,
R
)Vorticity of the Gaussian zonal wind perturbation centred at sinφc, cosφc, λc in Jablonowski and Williamson, 2006, eq. (12). φ_rad in radians, λ, λc in degrees.
SpeedyWeather.land_tendency_names Method
land_tendency_names(::Variables{Po, G, T}) where {Po, G, T}Names (Tuple of Symbols) of the land tendencies in ::Variables. Used to define which land variables are time stepped. Ignores any other names spaces.
SpeedyWeather.large_scale_condensation! Method
large_scale_condensation!(
ij,
vars,
condensation::ImplicitCondensation,
geometry::Geometry,
planet::SpeedyWeather.AbstractPlanet,
atmosphere::SpeedyWeather.AbstractAtmosphere,
time_stepping
)Large-scale condensation for a column by relaxation back to 100% relative humidity. Calculates the tendencies for specific humidity and temperature from latent heat release and integrates the large-scale precipitation vertically for output.
SpeedyWeather.linear_pressure_gradient! Method
linear_pressure_gradient!(
vars::Variables,
model::PrimitiveEquation
)Add the linear contribution of the pressure gradient to the (spectral) Bernoulli potential, which already holds the transformed kinetic energy and geopotential. The pressure gradient in the divergence equation takes the form
-∇⋅(Rd * Tᵥ * ∇lnpₛ) = -∇⋅(Rd * Tᵥ' * ∇lnpₛ) - ∇²(Rd * Tₖ * lnpₛ)So that the second term inside the Laplace operator can be added to the Bernoulli potential. Rd is the gas constant, Tᵥ the virtual temperature, Tᵥ' its anomaly wrt to the average or reference temperature Tₖ, and ln(pₛ) is the logarithm of surface pressure.
sourceSpeedyWeather.load_mask! Method
load_mask!(land_sea_mask::EarthLandSeaMask{NF}) where NFLoads the land-sea mask from the path set in land_sea_mask, interpolates (grid-cell average) onto the model grid for a fractional sea mask and saves it to the field land_sea_mask.land_fraction.
SpeedyWeather.load_trajectory Method
load_trajectory(
var_name::Union{String, Symbol},
model::AbstractModel
)Loads a var_name trajectory of the model M that has been saved in a netCDF file during the time stepping.
SpeedyWeather.map_variables Method
map_variables(f, vars::Variables) -> VariablesNew Variables from f applied to the fused parents vars.fused and to all other variables that are not fused variables. Every fused variable (see fused_view_location) is created anew as the same view of its mapped parent instead, so that it remains a view of it. Applying f to each variable on its own would detach it from its parent whenever f copies (e.g. deepcopy, on_architecture to another architecture).
SpeedyWeather.max_transform_batch Method
max_transform_batch(nlayers::Integer)Largest batch dimension K (number of columns) any model emits in a single transform call: the PrimitiveWetModel's grid → spectral tendency batch of 9 layer-variables plus surface pressure.
SpeedyWeather.merge_output Method
merge_output(output::JLD2Output)We can't directly push to arrays in a JLD2 file or have extendable dimensions. This routine rewrites the file to a single vector. Might be turned off if the file doesn't fit into the memory or speed is a concern.
sourceSpeedyWeather.molar_mass_ratio Method
molar_mass_ratio(::SpeedyWeather.AbstractCO2) -> Float32The molar mass ratio CO2 / molar mass of dry air
sourceSpeedyWeather.monthly_interpolation Method
monthly_interpolation(time) -> Tuple{Any, Any, Any}
monthly_interpolation(
time,
::Type{NF}
) where NF -> Tuple{Any, Any, Any}Months and weight to interpolate a monthly climatology linearly in time at time, (1 - weight) * monthly[this_month] + weight * monthly[next_month] with the weight the fraction of the month's days passed (full days only). Returns (this_month, next_month, weight), the weight of type NF, pass the variable's eltype as it's a kernel argument (Metal doesn't support Float64). Branch-free, so that it also works for the traced clock on Reactant (Dates.daysinmonth is overloaded for traced numbers in the Reactant extension).
SpeedyWeather.move Method
move(
p::Particle{NF},
dlon,
dlat,
dσ
) where NF -> Particle{NF} where NFMove a particle with increments (dlon, dlat, dσ) in those respective coordinates.
sourceSpeedyWeather.move Method
move(
p::Particle{NF},
dlon,
dlat
) where NF -> Particle{NF} where NFMove a particle with increments (dlon, dlat) in 2D. No movement in vertical σ.
sourceSpeedyWeather.move_prognostic_grid_variables_back! Method
move_prognostic_grid_variables_back!(
vars::Variables,
time_stepping::Leapfrog,
model::AbstractModel,
clock::Clock
)Retain the previous time step of the grid prognostic variables before the new spectral state is transformed to the grid: copy the 2nd (current) grid step to the 1st (previous) step whenever the leapfrog update has also moved the previous spectral step forward, such that the 1st grid step is always the grid-point equivalent of the 1st spectral step. The previous step is read by the parameterizations, vertical advection and the geopotential (which enters the semi-implicit dynamics). During the leapfrog start (Euler step and first leapfrog step, lf == 1) the previous spectral step is not advanced and so the previous grid step is left unchanged. Branch-free (ifelse) as the clock is traced with Reactant.
SpeedyWeather.move_prognostic_grid_variables_back! Method
move_prognostic_grid_variables_back!(
vars::Variables,
time_stepping::SpeedyWeather.AbstractLeapfrog,
model::AbstractModel;
move
)Copy the grid prognostic variables from the 2nd (current) to the 1st (previous) step to retain them as the previous time step. With move = false the 1st step is left unchanged.
SpeedyWeather.nan_detection! Method
nan_detection!(
feedback::Feedback,
vars::Variables,
model::AbstractModel
) -> Union{Nothing, Bool}Detect NaN (Not-a-Number, or Inf) in the prognostic variables.
sourceSpeedyWeather.neutral_transfer_coefficient Method
neutral_transfer_coefficient(z, z₀M, z₀X, κ)Bulk transfer coefficient in the neutral limit, κ²/(log(z/z₀M) log(z/z₀X)), for the height z [m] of the lowermost layer, the momentum roughness length z₀M [m] and the roughness length z₀X [m] of momentum, heat or humidity. Should be z > z₀ (z = z₀ means infinitely high drag), so capped one order of magnitude above the roughness length. A roughness length of exactly zero marks a surface type that is absent at a grid point (the coefficient is then weighted by a zero land or ocean fraction). 1e-5 m is used instead, as log(z/0) = Inf gives a zero coefficient but a NaN derivative (0 · ∞) in reverse mode, e.g. with Reactant. Its value is irrelevant as long as it's positive, but it is only a replacement for zero, not a lower bound: real roughness lengths below 1e-5 m are kept.
SpeedyWeather.nsteps Method
nsteps(
var::Union{LowerTriangularArrayWithTime{T, N} where {T, N}, AbstractFieldWithTime}
)Number of steps of a variable, i.e. the length of its step dimension (the time dimension T in the variable's ArrayDimensions). Variables without a time dimension have a single step.
SpeedyWeather.ocean_tendency_names Method
ocean_tendency_names(::Variables{Po, G, T}) where {Po, G, T}Names (Tuple of Symbols) of the ocean tendencies in ::Variables. Used to define which ocean variables are time stepped. Ignores any other names spaces.
SpeedyWeather.on_output_architecture Method
on_output_architecture(
output::SpeedyWeather.AbstractOutput,
x
)x (an array or field of the model) on the architecture of output: x itself if that's the model's architecture, otherwise moved there. For Reactant the output is computed on the CPU, as computing with Reactant arrays outside of a compiled program compiles a program for every operation.
SpeedyWeather.output! Method
output!(output::NetCDFOutput, time::DateTime)Write the current time time::DateTime to the netCDF file in output.
SpeedyWeather.output! Method
output!(
output::SpeedyWeather.AbstractOutput,
output_variables::Dict{Symbol, SpeedyWeather.AbstractOutputVariable},
simulation::SpeedyWeather.AbstractSimulation
)Loop over every variable in output.variables to call the respective output! method to write into the output.netcdf_file.
SpeedyWeather.output! Method
output!(
output::SpeedyWeather.AbstractOutput,
variable::SpeedyWeather.AbstractOutputVariable,
simulation::SpeedyWeather.AbstractSimulation
)Output a variable into output. Interpolates onto the output grid and resolution as specified in output. Method used for all output variables <: AbstractOutputVariable with dispatch over the second argument. Interpolates, scales, custom transform, bitrounding and writes via the backend-specific write_array!.
SpeedyWeather.output! Method
output!(
output::SpeedyWeather.AbstractOutput,
simulation::SpeedyWeather.AbstractSimulation
) -> Union{Nothing, SpeedyWeather.AbstractOutput}Writes the variables from vars of time step i at time time into output.netcdf_file. Simply escapes for no netcdf output or if output shouldn't be written on this time step. Interpolates onto output grid and resolution as specified in output, converts to output number format, truncates the mantissa for higher compression and applies lossless compression.
SpeedyWeather.output_architecture Method
output_architecture(
architecture::SpeedyWeatherInternals.Architectures.AbstractArchitecture
) -> SpeedyWeatherInternals.Architectures.AbstractArchitectureArchitecture that gridded output writers interpolate and post-process on for a model that runs on architecture: the model's own, so that e.g. a GPU simulation is interpolated on the GPU, except for Reactant, I/O has be done outside of the compile context anyway, currently we just use CPU for Reactant simulation output. That may change in the future.
SpeedyWeather.output_layers Method
output_layers(output::SpeedyWeather.AbstractOutput)Vertical output layers of output, ModelLayers for output writers that don't define a layers field.
SpeedyWeather.output_scratch_fields Method
output_scratch_fields(
output_NF::Type{<:AbstractFloat},
output_grid::AbstractGrid,
nlayers::Integer,
nlayers_soil::Integer
) -> NamedTuple{(:land_fraction, :field2D, :field3D, :field3Dland, :host2D, :host3D, :host3Dland), <:NTuple{7, Any}}Allocate the scratch fields of a gridded output writer on output_grid, which is on the model's architecture so that interpolation and post-processing run where the model runs: land_fraction, field2D, field3D (nlayers) and field3Dland (nlayers_soil), all in output_NF. Also returns their host (CPU) copies host2D, host3D, host3Dland that the data is copied into for writing. On CPU these are the very same objects, so no copy is made. Returned as a NamedTuple to be splatted into the writer's keyword constructor.
SpeedyWeather.parameterization! Function
Function that defines the actual parameterization of an AbstractParameterization.
Takes in the index of the column ij, the Variables object vars, the parameterization itself and the model. The model includes - among others - land sea mask, orography and physical constants.
This function is used within a KernelAbstractions kernel and is therefore expected to work on GPU as well. Don't use any dynamic dispatches, try to avoid allocations and branches in your code and only use scalar indexing of arrays.
sourceSpeedyWeather.parameterization! Method
parameterization!(
ij,
vars,
radiation::OneBandShortwave,
model
)Calculate shortwave radiation using the one-band scheme with diagnostic clouds. Computes cloud cover fraction from relative humidity and precipitation, then integrates downward and upward radiative fluxes accounting for cloud albedo effects.
sourceSpeedyWeather.parameterization! Method
parameterization!(
ij,
vars::SpeedyWeather.AbstractVariables,
parameterization::Nothing,
model
)Fallback when setting parameterization=nothing in the model constructor.
SpeedyWeather.parameterization! Method
parameterization!(
ij,
vars::Variables,
albedo::OceanLandAlbedo,
model
)Composite OceanLandAlbedo: Call albedo.ocean over ocean and albedo.land over land.
sourceSpeedyWeather.parameterization! Method
parameterization!(
ij,
vars::Variables,
albedo::SpeedyWeather.AbstractAlbedo,
model
)Single Albedo: Call same albedo over ocean and land.
sourceSpeedyWeather.parameterization! Method
parameterization!(
vars::SpeedyWeather.AbstractVariables,
parameterization,
model
)Fallback for parameterizations that don't have a global kernel.
sourceSpeedyWeather.parameterization_tendencies! Method
parameterization_tendencies!(
vars::Variables,
model::PrimitiveEquation
)Compute tendencies for u, v, temp, humid from physical parametrizations.
sourceSpeedyWeather.parameterization_tendencies_only! Method
parameterization_tendencies_only!(
vars::Variables,
model::PrimitiveEquation
)For dynamics=false, after calling parameterization_tendencies! call this function to transform the physics tendencies from grid-point to spectral space including the necessary coslat⁻¹ scaling.
SpeedyWeather.pressure Method
pressure(
k::Integer,
surface_pressure::Number,
coordinate::SigmaCoordinates
)Pressure [Pa] at full level k given surface_pressure [Pa] and sigma coordinate.
SpeedyWeather.pressure Method
pressure(
k::Integer,
surface_pressure::Number,
coordinate::SigmaPressureCoordinates
)Pressure [Pa] at full level k given surface_pressure [Pa] and hybrid sigma-pressure coordinate. Computed as A[k] * p_ref + B[k] * surface_pressure, where A and B are the pressure and sigma coefficients of the hybrid coordinate.
SpeedyWeather.pressure_above Method
pressure_above(
k::Integer,
surface_pressure::Number,
coordinate::SpeedyWeather.AbstractVerticalCoordinates
)Pressure [Pa] at the upper interface of full level k (half level k-½), given surface_pressure [Pa]. Equivalent to pressure_half(k, surface_pressure, coordinate).
SpeedyWeather.pressure_below Method
pressure_below(
k::Integer,
surface_pressure::Number,
coordinate::SpeedyWeather.AbstractVerticalCoordinates
)Pressure [Pa] at the lower interface of full level k (half level k+½), given surface_pressure [Pa]. Equivalent to pressure_half(k+1, surface_pressure, coordinate).
SpeedyWeather.pressure_gradient_flux! Method
pressure_gradient_flux!(
vars::Variables,
time_stepping::SpeedyWeather.AbstractTimeStepper
)Compute the pressure gradient flux, (u,v) * ∇ln(pₛ). The gradient ∇ln(pₛ) of the logarithm of surface pressure is computed and transformed to grid space in transform! together with u, v.
SpeedyWeather.pressure_half Method
pressure_half(
k::Integer,
surface_pressure::Number,
coordinate::SigmaCoordinates
)Pressure [Pa] at half level k given surface_pressure [Pa] and sigma coordinate. Half levels are indexed 1 (top of atmosphere, σ = 0) to nlayers+1 (surface, σ = 1).
SpeedyWeather.pressure_half Method
pressure_half(
k::Integer,
surface_pressure::Number,
coordinate::SigmaPressureCoordinates
)Pressure [Pa] at half level k given surface_pressure [Pa] and hybrid sigma-pressure coordinate. Half levels are indexed 1 (top of atmosphere) to nlayers+1 (surface). Computed as A_half[k] * p_ref + B_half[k] * surface_pressure.
SpeedyWeather.pressure_thickness Method
pressure_thickness(
k::Integer,
surface_pressure::Number,
coordinate::SigmaCoordinates
)Pressure thickness [Pa] of full level k given surface_pressure [Pa] and sigma coordinate.
SpeedyWeather.pressure_thickness Method
pressure_thickness(
k::Integer,
surface_pressure::Number,
coordinate::SigmaPressureCoordinates
)Pressure thickness [Pa] of full level k given surface_pressure [Pa] and hybrid sigma-pressure coordinate. Computed as ΔA[k] * p_ref + ΔB[k] * surface_pressure.
SpeedyWeather.progress! Method
progress!(
feedback::Feedback,
vars::Variables,
model::AbstractModel,
nsteps::Integer
)Feedback after nsteps time steps at once, e.g. after a compiled program of several time steps with Reactant: advance the progress meter by nsteps and check for NaNs (if feedback.debug).
SpeedyWeather.pseudo_adiabat! Method
pseudo_adiabat!(
ij,
temp_ref_profile,
humid_ref_profile,
temp_environment,
humid_environment,
geopotential,
pres,
σ,
atmosphere,
relative_humidity,
entrainment
) -> Int64Calculates the moist pseudo adiabat given temperature and humidity of surface parcel, and the associated reference humidity profile
SpeedyWeather.remaining_time Method
remaining_time(p::ProgressMeter.Progress) -> StringEstimates the remaining time from a ProgresssMeter.Progress. Adapted from ProgressMeter.jl
SpeedyWeather.resolution_factor Method
resolution_factor(model::AbstractModel)Resolution factor of model, from its trunc and planetary radius.
SpeedyWeather.resolution_factor Method
resolution_factor(truncation::Integer, radius::Real)Factor between the time step at T32 and the time step at resolution trunc on a planet of radius, i.e. Δt = Δt_at_T32 * resolution_factor, matching get_Δt_millisec.
SpeedyWeather.resolution_factor Method
resolution_factor(L::SpeedyWeather.AbstractTimeStepper)Resolution factor inferred from a time stepper's own state, Δt/Δt_at_T32. Approximate: if the current Δt was adjusted to the output frequency (adjust_with_output) then that adjustment is folded into the ratio. Pass the model to set! to use the exact factor instead.
SpeedyWeather.run! Method
run!(
simulation::SpeedyWeather.AbstractSimulation;
period::Dates.Period=DEFAULT_PERIOD,
steps::Int64=DEFAULT_TIMESTEPS,
output::Bool=false
)Run a SpeedyWeather.jl simulation. The simulation.model is assumed to be initialized.
SpeedyWeather.run_folder_name Method
run_folder_name(
prefix::String,
id::String,
number::Int64;
fmt=Printf.Format("%04d")
) -> StringConcatenate the run folder name from prefix, id and number to e.g. "run_0001" or "run_shallow_convection_0001".
SpeedyWeather.saturation_humidity Method
saturation_humidity(
T,
p,
A::SpeedyWeather.AbstractWetAtmosphere
)Saturation specific humidity as a function of temperature [K] and pressure [Pa], defined as qₛ = ε * eₛ(T) / p, with saturation vapor pressure eₛ(T), pressure p [Pa] and ratio of gas constants ε = R_dry/R_vapor.
SpeedyWeather.saturation_vapor_pressure Method
saturation_vapor_pressure(
T,
A::SpeedyWeather.AbstractWetAtmosphere
)Saturation water vapor pressure as a function of temperature using the Clausius-Clapeyron equation,
e(T) = e₀ * exp( -Lᵥ/Rᵥ * (1/T - 1/T₀)),where T is in Kelvin, Lᵥ the the latent heat of condensation and Rᵥ the gas constant of water vapor
sourceSpeedyWeather.saturation_vapor_pressure Method
saturation_vapor_pressure(
TetensCoefficients::TetensEquation{NF},
temp_kelvin::NF
) where NFSaturation water vapor pressure as a function of temperature using the Tetens equation,
eᵢ(T) = e₀ * exp(Cᵢ * (T - T₀) / (T - Tᵢ)),where T is in Kelvin and i = 1, 2 for saturation above and below freezing, respectively.
sourceSpeedyWeather.scalar_ref Method
scalar_ref(
::SpeedyWeatherInternals.Architectures.AbstractArchitecture,
x::Number
) -> Base.RefValue{T} where T<:NumberReference to a scalar x that can change during the simulation, e.g. the time step the implicit solver was initialized with. Extended by ReactantExt to hold a traceable number.
SpeedyWeather.scale! Method
scale!(
variable::Union{LowerTriangularArray, AbstractField},
scale::Real
) -> Union{LowerTriangularArray, AbstractField}Scale the variable var with scalar scale.
SpeedyWeather.scale_prognostic! Method
scale_prognostic!(vars::Variables, scale::Real) -> VariablesScales the prognostic variables vorticity and divergence with the Earth's radius which is used in the dynamical core.
sourceSpeedyWeather.scratch_fields Method
scratch_fields(
output::SpeedyWeather.AbstractOutput,
variable::SpeedyWeather.AbstractOutputVariable
) -> Tuple{Any, Any}Scratch field on the output grid (on the model's architecture) to interpolate variable into, and its host (CPU) equivalent to write from, see output_scratch_fields.
SpeedyWeather.set! Function
set!(
L::SpeedyWeather.AbstractTimeStepper,
Δt::Dates.Period,
factor::Real=resolution_factor(L)
) -> SpeedyWeather.AbstractTimeStepperChange the time step of timestepper L to Δt (unscaled) and disable adjustment to the output frequency. set! can be used before or after initialize!(model): Δt_at_T32 is the quantity calculate_Δt! derives the time step from, so it is back-computed here with resolution_factor to keep a later re-initialization at the requested Δt.
Without a model the resolution factor is inferred from L itself and is only approximate when the current time step had been adjusted to the output frequency; pass model (or use set!(model, Δt=...)) for an exact round trip.
SpeedyWeather.set! Method
set!(
model::AbstractModel;
orography=nothing,
land_sea_mask=nothing,
Δt=nothing,
kwargs...
)Sets a boundary condition fields for model. The input can be a function, RingGrid, LowerTriangularMatrix, or scalar as for other set! functions. If the keyword add==true the input is added to the exisiting field instead.
SpeedyWeather.set! Method
set!(
vars::NamedTuple,
geometry::Geometry;
step=1,
add::Bool=false,
spectral_transform::Union{Nothing, SpeedyTransforms.AbstractSpectralTransform}=nothing,
coslat_scaling_included::Bool=false,
static_func::Bool=true,
namespace::Union{Nothing, Symbol}=nothing,
scratch_field::Union{Nothing, AbstractField}=nothing,
kwargs...
)Sets new values for variables defined through keyword matching the keys in a NamedTuple. Spectral variables can be set at timestep index step. If add==true they are added to the current value instead. If a AbstractSpectralTransform S is provided, it is used when needed to set the variable, otherwise it is recomputed. In case u and v are provied, actually the divergence and vorticity are set and coslat_scaling_included specficies whether or not the 1/cos(lat) scaling is already included in the arrays or not (default: false). If a function or callable object is provided, static_func specficies whether or not the function is static (i.e. does not contain any dynamic code) or not (default: true). On GPU, only static functions are executed efficiently.
The input may be:
A function or callable object
f(lond, latd, σ) -> value(multilevel variables)A function or callable object
f(lond, latd) -> value(surface level variables)An instance of
AbstractFieldAn instance of
LowerTriangularArrayA scalar
<: Number(interpreted as a constant field in grid space)
Specify the namespace as a symbol in case the vars::NamedTuple contains them, e.g.
set!(vars, sea_surface_temperature = 1, namespace=:ocean)The keyword argument step specifies the step index to set, default is 1. For variables without a step dimension use step = nothing to skip the get_step.
SpeedyWeather.set! Method
set!(
output::SpeedyWeather.AbstractOutput,
model::AbstractModel;
interval::Dates.Period
)Reset the output interval of output and re-initialize its OutputWriterCore so that the output interval is recomputed from the model time step. If the requested interval is not an integer multiple of the model time step, it is rounded to the nearest multiple.
SpeedyWeather.set! Method
set!(S::SpeedyWeather.AbstractSimulation; kwargs...)Sets properties of the simuluation S. Convenience wrapper to call the other concrete set! methods. All kwargs are forwarded to these methods, which are documented seperately. See their documentation for possible kwargs.
SpeedyWeather.set! Method
set!(
L::SpeedyWeather.AbstractTimeStepper,
Δt::Dates.Period,
model::AbstractModel
) -> SpeedyWeather.AbstractTimeStepperSet the time step of L using the exact resolution factor of model.
SpeedyWeather.set! Method
set!(
variables::Variables,
args...;
group::Symbol=:prognostic,
kwargs...
)set the variables, default is in the group prognostic.
SpeedyWeather.set_namespace_time_steps! Method
set_namespace_time_steps!(
time_stepping::SpeedyWeather.AbstractTimeStepper,
factor::Real
)Set the time step of the ocean and land time steppers of time_stepping (if not itself) to the time step of time_stepping, so that they stay in sync with the atmosphere.
SpeedyWeather.shortwave_radiative_transfer! Method
shortwave_radiative_transfer!(
ij,
vars,
t,
clouds,
radiation::OneBandShortwaveRadiativeTransfer,
model
)One-band shortwave radiative transfer with cloud reflection and ozone absorption.
sourceSpeedyWeather.sigma Method
sigma(k::Integer, coordinate::SigmaCoordinates)Sigma coordinate (fraction of surface pressure) at full level k for sigma coordinate.
SpeedyWeather.sigma Method
sigma(k::Integer, coordinate::SigmaPressureCoordinates)Sigma coordinate (fraction of surface pressure) at full level k for hybrid sigma-pressure coordinate. Returns A[k] + B[k], which equals the nominal sigma level regardless of the pressure-sigma transition, and is independent of surface pressure.
SpeedyWeather.sigma_half_spacing Function
sigma_half_spacing(
nlayers::Integer,
profile=(z->begin
z
end)
)Vertical sigma coordinates defined by their half levels. Sigma coordinates are fraction of surface pressure (p/p0) and are sorted from top (stratosphere) to bottom (surface). The first half level is at 0 the last at 1. Default profile is equally spaced from 0 to 1 (including).
SpeedyWeather.sigma_okay Method
sigma_okay(nlayers::Integer, σ_half::AbstractVector) -> BoolCheck that nlayers and σ_half match.
sourceSpeedyWeather.skips_interpolation Method
skips_interpolation(output::HEALPixOutput) -> Booltrue if output writes its data without interpolating, i.e. the simulation already runs on the output's grid.
SpeedyWeather.solar_hour_angle Method
solar_hour_angle(
::Type{T},
time::Dates.AbstractDateTime,
λ=0
) where TFraction of day in time as angle in radians [-π...π], noon to noon, at longitude λ. Always calculated relative to the Earth calendar, so LENGTH_OF_DAY is used as constant. This is because Dates functions assume an Earth date. Length of the daily cycle is instead controlled via a faster rotation time, see Earth.
SpeedyWeather.spectral_tendencies! Method
spectral_tendencies!(vars::Variables, model::Barotropic)Reads transformed spectral tendencies and accumulates the final spectral tendencies for the BarotropicModel.
sourceSpeedyWeather.spectral_tendencies! Method
spectral_tendencies!(
vars::Variables,
model::PrimitiveEquation
)Reads transformed spectral tendencies and accumulates the final spectral tendencies for the PrimitiveEquationModel.
sourceSpeedyWeather.spectral_tendencies! Method
spectral_tendencies!(vars::Variables, model::ShallowWater)Reads transformed spectral tendencies and accumulates the final spectral tendencies for the ShallowWaterModel.
sourceSpeedyWeather.speedstring Method
speedstring(sec_per_iter, dt_in_sec) -> StringDefine a ProgressMeter.speedstring method that also takes a time step dt_in_sec to translate sec/iteration to days/days-like speeds.
SpeedyWeather.spin_up_steps Method
spin_up_steps(::SpeedyWeather.AbstractLeapfrog) -> Int64Leapfrog is spun up with 1 Euler forward step that doesn't count for clock + output
sourceSpeedyWeather.spin_up_steps Method
spin_up_steps(::SpeedyWeather.AbstractTimeStepper) -> Int64Extend in case a time stepper requires spin up steps, e.g. Leapfrog starts with 1 Euler step that isn't counted for the clock but requires one more step in the main time loop.
sourceSpeedyWeather.sppt! Method
sppt!(ij, vars, sppt, time_stepping)Apply stochastically perturbed parameterization tendencies (SPPT) to u, v, temperature and humidity in column ij.
sourceSpeedyWeather.surface_flux_damping Method
surface_flux_damping(
scheme::SpeedyWeather.AbstractFluxIntegration,
conductance::Real,
pₛ::Real,
model
)Damping factor for a surface flux into the lowermost layer with mass conductance [kg/m²/s], i.e. -∂flux/∂x with respect to the lowermost-layer variable x for the flux in units of x⋅kg/m²/s (so without cₚ for heat fluxes), surface pressure pₛ [Pa] and time integration scheme. Uses the time step of the time stepper, e.g. 2Δt for Leapfrog.
SpeedyWeather.surface_flux_to_tendency Method
surface_flux_to_tendency(flux::Real, pₛ::Real, model)Flux flux into surface layer with surface pressure pₛ [Pa] and gravity g [m/s^2] converted to tendency [?/s].
SpeedyWeather.surface_flux_to_tendency Method
surface_flux_to_tendency(
scheme::SpeedyWeather.AbstractFluxIntegration,
flux::Real,
conductance::Real,
pₛ::Real,
model
)Flux flux (upward positive) into the lowermost layer with mass conductance [kg/m²/s] converted to tendency [?/s], time-integrated following scheme, see surface_flux_damping.
SpeedyWeather.surface_pressure_grid_tendency! Method
surface_pressure_grid_tendency!(
vars::Variables,
time_stepping::SpeedyWeather.AbstractTimeStepper
)The tendency of the logarithm of surface pressure is computed as
-(ū*px + v̄*py) - D̄with ū, v̄ being the vertically averaged velocities; px, py the gradients of the logarithm of surface pressure ln(pₛ) and D̄ the vertically averaged divergence.
Here, computes the grid tendency contribuation of the logarithm of surface pressure by:
∇ln(pₛ)/px,py is previously computed in grid space in
transform!,Multiply ū, v̄ with ∇ln(pₛ) in grid-point space.
SpeedyWeather.surface_pressure_spectral_tendency! Method
surface_pressure_spectral_tendency!(vars::Variables)The tendency of the logarithm of surface pressure is computed as
-(ū*px + v̄*py) - D̄with ū, v̄ being the vertically averaged velocities; px, py the gradients of the logarithm of surface pressure ln(pₛ) and D̄ the vertically averaged divergence.
Here, we accumlates the spectral tendency of the logarithm of surface pressure:
D̄ is subtracted in spectral space.
Set tendency of the l=m=0 mode to 0 for better mass conservation.
SpeedyWeather.surface_pressure_tendency! Method
surface_pressure_tendency!(
vars::Variables,
S::SpeedyTransforms.AbstractSpectralTransform,
time_stepping::SpeedyWeather.AbstractTimeStepper
)SEQUENTIAL VERSION
Computes the tendency of the logarithm of surface pressure as
-(ū*px + v̄*py) - D̄with ū, v̄ being the vertically averaged velocities; px, py the gradients of the logarithm of surface pressure ln(pₛ) and D̄ the vertically averaged divergence.
Calculate ∇ln(pₛ) in spectral space, convert to grid.
Multiply ū, v̄ with ∇ln(pₛ) in grid-point space, convert to spectral.
D̄ is subtracted in spectral space.
Set tendency of the l=m=0 mode to 0 for better mass conservation.
SpeedyWeather.sync_extrapolations! Method
sync_extrapolations!(
output::SpeedyWeather.AbstractOutput,
model::AbstractModel
)Set κ of any DryAdiabaticExtrapolation in output.variables from the model's atmosphere, so that the adiabatic descent below the lowest model layer uses the same κ = R_dry/cₚ as the model itself, and convert all extrapolation parameters to the model's number format NF. The defaults (κ = 2/7, missing_value = NaN) are Float64 which e.g. Metal does not support inside the interpolation kernel, not even to convert it. Called at initialize!, no-op for a model without an atmosphere (Barotropic) or an output writer that has no output variables (JLD2Output). Theextrapolationfield of an output variable therefore has to accept anyAbstractVerticalExtrapolation.
SpeedyWeather.temperature_average! Method
temperature_average!(
vars::Variables,
temp::LowerTriangularArray,
S::SpeedyTransforms.AbstractSpectralTransform
)Calculates the average temperature of a layer from the l=m=0 harmonic and stores the result in diagn.temp_average
SpeedyWeather.temperature_grid_tendency! Method
temperature_grid_tendency!(
vars::Variables,
model::PrimitiveEquation
)Compute the gridded contribution to the temperature tendency:
adds the adiabatic + T'D terms to
temp_tend_gridvia_temperature_tendency_kernel!writes
(uT_anomaly_grid, vT_anomaly_grid) = (u·T', v·T')for the flux divergence.
SpeedyWeather.temperature_spectral_tendency! Method
temperature_spectral_tendency!(
vars::Variables,
S::SpeedyTransforms.AbstractSpectralTransform,
time_stepping::SpeedyWeather.AbstractTimeStepper
)Compute the temperature tendency.
∂T/∂t += -∇⋅((u, v)*T') + T'D + κTᵥ*Dlnp/Dt+= because the tendencies already contain parameterizations and vertical advection. T' is the anomaly with respect to the reference/average temperature. Tᵥ is the virtual temperature used in the adiabatic term κTᵥ*Dlnp/Dt.
Here, the previosuly computed gridded tendency contribution are accumulated and the spectral tendency computed with divergence is computed via the flux_spectral_divergence! function.
SpeedyWeather.temperature_tendency! Method
temperature_tendency!(
vars::Variables,
model::PrimitiveEquation
)SEQUENTIAL VERSION
Compute the temperature tendency.
∂T/∂t += -∇⋅((u, v)*T') + T'D + κTᵥ*Dlnp/Dt+= because the tendencies already contain parameterizations and vertical advection. T' is the anomaly with respect to the reference/average temperature. Tᵥ is the virtual temperature used in the adiabatic term κTᵥ*Dlnp/Dt.
SpeedyWeather.tendency_and_uv_names Method
tendency_and_uv_names(
::Variables{Po, G, T}
) where {Po, G, T}Like tendency_names, but adds :u and :v if :vorticity is present.
SpeedyWeather.tendency_names Method
tendency_names(::Variables{Po, G, T}) where {Po, G, T}Names (Tuple of Symbols) of the tendencies in ::Variables. Used to define which (atmopsheric) variables are time stepped. Ignores any other names spaces.
SpeedyWeather.time_step! Method
time_step!(
simulation::SpeedyWeather.AbstractSimulation,
time_stepping::SpeedyWeather.AbstractTimeStepper
)Perform one time step of simulation.
SpeedyWeather.time_step! Method
time_step!(
vars::Variables,
time_stepping::SpeedyWeather.AbstractTimeStepper,
model::PrimitiveEquation
)Calculate a single time step for the primitive equation model.
sourceSpeedyWeather.time_step! Method
time_step!(
vars::Variables,
time_stepping::SpeedyWeather.AbstractTimeStepper,
model::Union{Barotropic, ShallowWater}
)Calculate a single time step for the barotropic model.
sourceSpeedyWeather.time_step Method
time_step(
time_stepping::SpeedyWeather.AbstractTimeStepper,
clock
)Time step [s] of time_stepping at the current clock, extend for time steppers with changing time steps, e.g. Leapfrog on its first steps.
SpeedyWeather.time_step Method
time_step(
time_stepping::SpeedyWeather.AbstractTimeStepper,
component::Symbol,
clock
)Time step [s] with which the variables of component (:ocean or :land) are stepped forward within the time_stepping setup at the current clock.
SpeedyWeather.time_step_scale Method
time_step_scale(
parent::SpeedyWeather.AbstractTimeStepper,
child::SpeedyWeather.AbstractTimeStepper,
clock
) -> Int64Factor by which the time step of the child time stepper (for a namespace) is divided when parent is the time stepper of the model, e.g. Leapfrog advances the clock by Δt/2 on its first two steps, so non-leapfrog children use scale = 2 there. Defaults to 1.
SpeedyWeather.time_stepper Method
time_stepper(
time_stepping::SpeedyWeather.AbstractTimeStepper,
component::Symbol
)Time stepper for :atmosphere, :ocean (incl sea ice) or :land within the time_stepping setup of a model (model.time_stepping). Defaults to time_stepping itself, time steppers can extend this to step ocean or land differently, e.g. Leapfrog uses its ocean and land fields (default EulerForward).
SpeedyWeather.time_stepping! Method
time_stepping!(
simulation::SpeedyWeather.AbstractSimulation
) -> SpeedyWeather.AbstractSimulationMain time loop that loops over all time steps.
sourceSpeedyWeather.time_steps! Method
time_steps!(
simulation::SpeedyWeather.AbstractSimulation,
n::Integer;
kwargs...
)Perform n time steps of simulation. Extended in the Reactant extension to implement a time stepping loop that can be differentiated with checkpointing schemes used.
SpeedyWeather.tracer_tendency_names Method
tracer_tendency_names(
::Variables{Po, G, T}
) where {Po, G, T}Names (Tuple of Symbols) of the tracer tendencies in ::Variables. Used to define which tracer variables are time stepped. Ignores any other names spaces.
SpeedyWeather.unit Method
unit(::SpeedyWeather.AbstractCO2) -> Float32CO2 uses unit of ppm, so *1e-6 to convert to kg/kg.
sourceSpeedyWeather.unscale! Method
unscale!(
variable::Union{LowerTriangularArray, AbstractField},
scale::Real
) -> Union{LowerTriangularArray, AbstractField}Undo the scaling of the variable var with scalar scale.
SpeedyWeather.unscale! Method
unscale!(vars::Variables) -> VariablesUndo the radius-scaling of vorticity and divergence from scale_prognostic!(vars, scale::Real).
SpeedyWeather.update_prognostic! Function
update_prognostic!(
var::AbstractArray,
tendency::AbstractArray,
clock::Clock,
time_stepping::EulerForward,
implicit,
::AbstractModel,
scale::Number=1
)Euler forward step var += Δt/scale * tendency.
SpeedyWeather.update_prognostic! Method
update_prognostic!(
vars::Variables,
time_stepping::SpeedyWeather.AbstractTimeStepper,
model::AbstractModel
)Time stepping for all prognostic variables in vars using their tendencies. Decides on which variables to time step based on the presence of their tendencies in vars.tendencies.
SpeedyWeather.variables Function
variables(
::Type{<:PrimitiveWet},
nsteps=DEFAULT_NSTEPS
) -> Tuple{PrognosticVariable{SpeedyWeather.ClockDim, String}, PrognosticVariable{SpeedyWeather.ScalarDim{Int64}, String}, PrognosticVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, ScratchVariable{SpeedyWeather.SpectralXYZ, String}, ScratchVariable{SpeedyWeather.SpectralXYZ, String}, PrognosticVariable{SpeedyWeather.SpectralXYZT, String}, PrognosticVariable{SpeedyWeather.SpectralXYZT, String}, PrognosticVariable{SpeedyWeather.SpectralXYT, String}, TendencyVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.SpectralXYT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.GridXYT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYT, String}, ParameterizationVariable{SpeedyWeather.Grid2D, String}, DynamicsVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, DynamicsVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, DynamicsVariable{SpeedyWeather.GridXYT, String}, DynamicsVariable{SpeedyWeather.GridXYT, String}, DynamicsVariable{SpeedyWeather.Spectral2D, String}, DynamicsVariable{SpeedyWeather.Spectral2D, String}, DynamicsVariable{SpeedyWeather.GridXYZ, String}, DynamicsVariable{SpeedyWeather.Grid2D, String}, DynamicsVariable{SpeedyWeather.Grid2D, String}, DynamicsVariable{SpeedyWeather.Grid2D, String}, DynamicsVariable{SpeedyWeather.Spectral2D, String}, DynamicsVariable{SpeedyWeather.GridXYZ, String}, DynamicsVariable{SpeedyWeather.GridXYZ, String}, DynamicsVariable{SpeedyWeather.GridXYZ, String}, ScratchVariable{SpeedyWeather.GridXYZ, String}, ScratchVariable{SpeedyWeather.GridXYZ, String}, ScratchVariable{SpeedyWeather.Spectral2D, String}, ScratchVariable{SpeedyWeather.Spectral2D, String}, ScratchVariable{SpeedyWeather.Grid2D, String}, ScratchVariable{SpeedyWeather.Grid2D, String}, PrognosticVariable{SpeedyWeather.SpectralXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}}All variables needed for the primitive wet model itself (components excluded).
sourceSpeedyWeather.variables Function
variables(
::Type{<:PrimitiveDry},
nsteps=DEFAULT_NSTEPS
) -> Tuple{PrognosticVariable{SpeedyWeather.ClockDim, String}, PrognosticVariable{SpeedyWeather.ScalarDim{Int64}, String}, PrognosticVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, ScratchVariable{SpeedyWeather.SpectralXYZ, String}, ScratchVariable{SpeedyWeather.SpectralXYZ, String}, PrognosticVariable{SpeedyWeather.SpectralXYZT, String}, PrognosticVariable{SpeedyWeather.SpectralXYZT, String}, PrognosticVariable{SpeedyWeather.SpectralXYT, String}, TendencyVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.SpectralXYT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.GridXYT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYT, String}, ParameterizationVariable{SpeedyWeather.Grid2D, String}, DynamicsVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, DynamicsVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, DynamicsVariable{SpeedyWeather.GridXYT, String}, DynamicsVariable{SpeedyWeather.GridXYT, String}, DynamicsVariable{SpeedyWeather.Spectral2D, String}, DynamicsVariable{SpeedyWeather.Spectral2D, String}, DynamicsVariable{SpeedyWeather.GridXYZ, String}, DynamicsVariable{SpeedyWeather.Grid2D, String}, DynamicsVariable{SpeedyWeather.Grid2D, String}, DynamicsVariable{SpeedyWeather.Grid2D, String}, DynamicsVariable{SpeedyWeather.Spectral2D, String}, DynamicsVariable{SpeedyWeather.GridXYZ, String}, DynamicsVariable{SpeedyWeather.GridXYZ, String}, DynamicsVariable{SpeedyWeather.GridXYZ, String}, ScratchVariable{SpeedyWeather.GridXYZ, String}, ScratchVariable{SpeedyWeather.GridXYZ, String}, ScratchVariable{SpeedyWeather.Spectral2D, String}, ScratchVariable{SpeedyWeather.Spectral2D, String}, ScratchVariable{SpeedyWeather.Grid2D, String}, ScratchVariable{SpeedyWeather.Grid2D, String}}All variables needed for the primitive dry model itself (components excluded).
sourceSpeedyWeather.variables Function
variables(
::Type{<:Barotropic},
nsteps=DEFAULT_NSTEPS
) -> Tuple{PrognosticVariable{SpeedyWeather.ClockDim, String}, PrognosticVariable{SpeedyWeather.ScalarDim{Int64}, String}, PrognosticVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, ScratchVariable{SpeedyWeather.SpectralXYZ, String}, ScratchVariable{SpeedyWeather.SpectralXYZ, String}}All variables needed for the barotropic model itself (components excluded).
sourceSpeedyWeather.variables Function
Define variables needed by a model component. This is used to identify all required variables by a model and initialize them. The default is to return an empty tuple, but components can define their variables by extending this function for their type.
sourceSpeedyWeather.variables Method
variables(component, model::AbstractModel)Fallback: component can define variables(::Component, ::Model) or simply variables(::Component). In the former, model is available to define required variables based on other model components, in the latter only the component itself determines which variables are needed.
SpeedyWeather.variables Method
variables(nt::NamedTuple, model::AbstractModel) -> TupleWhen model components are named tuples themselves then check for variables required by the elements of the named tuple and pass those one as key-value pairs.
sourceSpeedyWeather.variables Method
variables(name_component::Pair, model::AbstractModel)Components can define variables(pair::Pair{<:Symbol, <:AbstractComponent}, ::Model) when they are part of a NamedTuple of components, e.g. greenhouse gases. The key of the pair can then be used to define variables based on the name of the component. The fallback defined here just drops the key so that it is optional.
SpeedyWeather.variables Method
variables(
model::ShallowWater
) -> Tuple{PrognosticVariable{SpeedyWeather.ClockDim, String}, PrognosticVariable{SpeedyWeather.ScalarDim{Int64}, String}, PrognosticVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, ScratchVariable{SpeedyWeather.SpectralXYZ, String}, ScratchVariable{SpeedyWeather.SpectralXYZ, String}, PrognosticVariable{SpeedyWeather.SpectralXYZT, String}, PrognosticVariable{SpeedyWeather.SpectralXYT, String}, TendencyVariable{SpeedyWeather.SpectralXYZT, String}, TendencyVariable{SpeedyWeather.GridXYZT, String}, TendencyVariable{SpeedyWeather.SpectralXYT, String}, TendencyVariable{SpeedyWeather.GridXYT, String}, GridVariable{SpeedyWeather.GridXYZT, String}, GridVariable{SpeedyWeather.GridXYT, String}, DynamicsVariable{SpeedyWeather.GridXYZ, String}, DynamicsVariable{SpeedyWeather.GridXYZT, String}, DynamicsVariable{SpeedyWeather.SpectralXYZT, String}, DynamicsVariable{SpeedyWeather.GridXYT, String}, DynamicsVariable{SpeedyWeather.GridXYT, String}, DynamicsVariable{SpeedyWeather.SpectralXYT, String}, DynamicsVariable{SpeedyWeather.SpectralXYT, String}, ScratchVariable{SpeedyWeather.GridXYZ, String}, ScratchVariable{SpeedyWeather.GridXYZ, String}}All variables needed for the shallow water model itself (components excluded).
sourceSpeedyWeather.vertical_dimension_name Method
vertical_dimension_name(::ModelLayers) -> StringName of the vertical dimension in the output file or store for 3D atmospheric variables.
sourceSpeedyWeather.vertical_dimension_name Method
vertical_dimension_name(
output::SpeedyWeather.AbstractOutput,
variable::SpeedyWeather.AbstractOutputVariable
) -> StringVertical dimension of variable in output. Variables on the model's atmospheric layers follow the output writer's layers, e.g. "layer" or "pressure". Variables with their own vertical dimension (soil variables, custom output variables that extend the 1-argument vertical_dimension_name) keep theirs.
SpeedyWeather.vertical_dimension_name Method
vertical_dimension_name(
variable::SpeedyWeather.AbstractOutputVariable
) -> StringName of the vertical dimension of variable in the output file or store: the atmospheric "layer" dimension, or "soil_layer" for land variables. Extend for custom output variables written on their own vertical dimension, together with get_nlayers and define_dimension!.
SpeedyWeather.vertical_integration! Method
vertical_integration!(
vars::Variables,
geometry::Geometry,
time_stepping::SpeedyWeather.AbstractTimeStepper
)Calculates the vertically averaged (weighted by the thickness of the σ level) velocities (*coslat) and divergence. E.g.
u_mean = ∑_k=1^nlayers Δσ_k * u_ku, v are averaged in grid-point space, divergence in spectral space.
sourceSpeedyWeather.vertical_velocity! Method
vertical_velocity!(
vars::Variables,
geometry::Geometry,
time_stepping::SpeedyWeather.AbstractTimeStepper
)Compute vertical velocity.
sourceSpeedyWeather.volume_flux_divergence! Method
volume_flux_divergence!(
vars::Variables,
model::ShallowWater
)SEQUENTIAL VERSION
Computes the (negative) divergence of the volume fluxes uh, vh for the continuity equation, η_tend -= ∇⋅(uh, vh), with its own grid→spectral transforms of the fluxes.
SpeedyWeather.volume_flux_divergence_grid! Method
volume_flux_divergence_grid!(
vars::Variables,
model::ShallowWater
)Gridded half of volume_flux_divergence!: computes the dynamic layer thickness h = η + H - Hb on the grid and writes the volume fluxes (uh, vh) to the fused uh/vh slots for the batched grid→spectral transform.
SpeedyWeather.volume_flux_divergence_spectral! Method
volume_flux_divergence_spectral!(
vars::Variables,
model::ShallowWater
)Spectral half of volume_flux_divergence!: uh, vh are assumed to already hold the spectral transforms of the volume fluxes (from the batched transform). Accumulates the (negative) divergence of the volume fluxes for the continuity equation, η_tend -= ∇⋅(uh, vh).
SpeedyWeather.vordiv_grid_tendencies! Method
vordiv_grid_tendencies!(
vars::Variables,
coriolis::SpeedyWeather.AbstractCoriolis,
atmosphere::SpeedyWeather.AbstractAtmosphere,
geometry::SpeedyWeather.AbstractGeometry,
implicit::SpeedyWeather.AbstractImplicit,
time_stepping::SpeedyWeather.AbstractTimeStepper
)Tendencies for vorticity and divergence, here just the gridded u and v tendencies are computed.
Launches _vordiv_tendencies_kernel! to add the vorticity flux and pressure gradient terms to u_tend_grid, v_tend_grid (which already contain forcing, drag, and vertical advection contributions); Excludes Bernoulli potential with geopotential and linear pressure gradient inside the Laplace operator, which are added later in spectral space:
u_tend_grid += v·(f + ζ) - R·Tᵥ'·∂lnpₛ/∂x
v_tend_grid += -u·(f + ζ) - R·Tᵥ'·∂lnpₛ/∂y+= because the tendencies already contain the parameterizations and vertical advection. f is coriolis, ζ relative vorticity, R the gas constant, Tᵥ' the virtual temperature anomaly, ∇lnpₛ the gradient of surface pressure and _x, _y its zonal/meridional components.
SpeedyWeather.vordiv_spectral_tendencies! Method
vordiv_spectral_tendencies!(
vars::Variables,
time_stepping::SpeedyWeather.AbstractTimeStepper,
S::SpeedyTransforms.AbstractSpectralTransform
)Tendencies for vorticity and divergence. Given the gridded u and v tendencies, the tendencies are curled/dived to get the tendencies for vorticity/divergence in spectral space
∂ζ/∂t = ∇×(u_tend, v_tend)
∂D/∂t = ∇⋅(u_tend, v_tend) + ...+ ... because there's more terms added later for divergence.
SpeedyWeather.vordiv_tendencies! Method
vordiv_tendencies!(
vars::Variables,
model::PrimitiveEquation
)Function barrier to unpack model.
SpeedyWeather.vordiv_tendencies! Method
vordiv_tendencies!(
vars::Variables,
coriolis::SpeedyWeather.AbstractCoriolis,
atmosphere::SpeedyWeather.AbstractAtmosphere,
geometry::SpeedyWeather.AbstractGeometry,
implicit::SpeedyWeather.AbstractImplicit,
S::SpeedyTransforms.AbstractSpectralTransform,
time_stepping::SpeedyWeather.AbstractTimeStepper
)SEQUENTIAL VERSION
Tendencies for vorticity and divergence. Excluding Bernoulli potential with geopotential and linear pressure gradient inside the Laplace operator, which are added later in spectral space.
u_tend += v*(f+ζ) - RTᵥ'*∇lnpₛ_x
v_tend += -u*(f+ζ) - RTᵥ'*∇lnpₛ_y+= because the tendencies already contain the parameterizations and vertical advection. f is coriolis, ζ relative vorticity, R the gas constant Tᵥ' the virtual temperature anomaly, ∇lnpₛ the gradient of surface pressure and _x and _y its zonal/meridional components. The tendencies are then curled/dived to get the tendencies for vorticity/divergence in spectral space
∂ζ/∂t = ∇×(u_tend, v_tend)
∂D/∂t = ∇⋅(u_tend, v_tend) + ...+ ... because there's more terms added later for divergence.
SpeedyWeather.vorticity_flux! Method
vorticity_flux!(vars::Variables, model::Barotropic)Vorticity flux tendency in the barotropic vorticity equation
∂ζ/∂t = ∇×(u_tend, v_tend)with
u_tend = Fᵤ + v*(ζ+f)
v_tend = Fᵥ - u*(ζ+f)with Fᵤ, Fᵥ the forcing from forcing! already in u_tend_grid/v_tend_grid and vorticity ζ, coriolis f.
SpeedyWeather.vorticity_flux! Method
vorticity_flux!(vars::Variables, model::ShallowWater)Vorticity flux tendency in the shallow water equations
∂ζ/∂t = ∇×(u_tend, v_tend)
∂D/∂t = ∇⋅(u_tend, v_tend)with
u_tend = Fᵤ + v*(ζ+f)
v_tend = Fᵥ - u*(ζ+f)with Fᵤ, Fᵥ the forcing from forcing! already in u_tend_grid/v_tend_grid and vorticity ζ, coriolis f.
SpeedyWeather.vorticity_flux_curldiv! Method
vorticity_flux_curldiv!(
vars::Variables,
model::AbstractModel;
div::Bool=true,
add::Bool=false
)SEQUENTIAL VERSION
Compute the vorticity advection as the curl/div of the vorticity fluxes
∂ζ/∂t = ∇×(u_tend, v_tend)
∂D/∂t = ∇⋅(u_tend, v_tend)with
u_tend = Fᵤ + v*(ζ+f)
v_tend = Fᵥ - u*(ζ+f)with Fᵤ, Fᵥ from u_tend_grid/v_tend_grid that are assumed to be alread set in forcing!. Set div=false for the BarotropicModel which doesn't require the divergence tendency.
SpeedyWeather.vorticity_flux_grid_tendencies! Method
vorticity_flux_grid_tendencies!(
vars::Variables,
model::AbstractModel
)Compute the vorticity advection as the curl/div of the vorticity fluxes
∂ζ/∂t = ∇×(u_tend, v_tend)
∂D/∂t = ∇⋅(u_tend, v_tend)with
u_tend = Fᵤ + v*(ζ+f)
v_tend = Fᵥ - u*(ζ+f)with Fᵤ, Fᵥ from u_tend_grid/v_tend_grid that are assumed to be alread set in forcing!. Set div=false for the BarotropicModel which doesn't require the divergence tendency.
Here, we only compute the gridded contriubation u_tend_grid``,v_tend_grid`` on top of the forcing already accumulated therein.
SpeedyWeather.vorticity_flux_spectral_tendencies! Method
vorticity_flux_spectral_tendencies!(
vars::Variables,
S::SpeedyTransforms.AbstractSpectralTransform,
time_stepper::SpeedyWeather.AbstractTimeStepper;
div::Bool=true,
add::Bool=false
)Compute the vorticity advection as the curl/div of the vorticity fluxes
∂ζ/∂t = ∇×(u_tend, v_tend)
∂D/∂t = ∇⋅(u_tend, v_tend)with
u_tend = Fᵤ + v*(ζ+f)
v_tend = Fᵥ - u*(ζ+f)with Fᵤ, Fᵥ from u_tend_grid/v_tend_grid that are assumed to be alread set in forcing!. Set div=false for the BarotropicModel which doesn't require the divergence tendency.
Here, only final spectral contributions ∂ζ/∂t, ∂D/∂tare computed given previouslyu_tend,v_tend`.
SpeedyWeather.warn_nonexisting_variables Method
warn_nonexisting_variables(
output::SpeedyWeather.AbstractOutput,
simulation
)Warn once about the output variables of output that don't exist in simulation and will therefore be skipped, both in the file/store schema and on every output step.
SpeedyWeather.warn_undefvar Function
warn_undefvar(
vars::Variables,
key::Symbol,
group::Symbol=:prognostic,
namespace::Symbol=Symbol()
) -> BoolHelper function to warn when a variable is not defined in the Variables. Reports on group (prognostic etc.) and namespace therein (e.g. ocean, land, etc.) and lists the defined variables in that group and namespace. Returns true to allow for short-circuiting with && return nothing to exit a function early.
SpeedyWeather.weight_coefficient Method
weight_coefficient(
L::NCycleLorenz{NF},
clock::Clock
) where NFCompute weight coefficient w for current substep in the NCycleLorenz time stepping scheme.
sourceSpeedyWeather.weight_coefficient Method
weight_coefficient(
::Type{NF},
V::NCycleLorenzA,
i,
N::Integer
) where NFWeight coefficient of the A-variant of the N-Cycle Lorenz time stepping scheme.
sourceSpeedyWeather.weight_coefficient Method
weight_coefficient(
::Type{NF},
V::NCycleLorenzAB,
i::Integer,
N::Integer
) where NFWeight coefficient of the AB-variant of the N-Cycle Lorenz time stepping scheme.
sourceSpeedyWeather.weight_coefficient Method
weight_coefficient(
::Type{NF},
V::NCycleLorenzABBA,
i::Integer,
N::Integer
) where NFWeight coefficient of the ABBA-variant of the N-Cycle Lorenz time stepping scheme.
sourceSpeedyWeather.weight_coefficient Method
weight_coefficient(
::Type{NF},
V::NCycleLorenzB,
i,
N::Integer
) where NFWeight coefficient of the B-variant of the N-Cycle Lorenz time stepping scheme.
sourceSpeedyWeather.which_step Function
Time steppers control on which step (index of the step dimension, typically used to store two time steps, e.g. t-dt, t) a variable is evaluated for a given term or in a given computation of the dynamical core. Two types of variables have step dimensions: Prognostic variables and tendencies. Leapfrog uses 2 steps for the prognostic variables but one tendency; Adams-Bashforth is a multi-step method storing one step for the prognostic variables and multiple steps for the tendencies.
This is implemented in the dynamical core via calling get_step, and particularly get_prognostic_step, get_tendency_step which dispatch on the time stepper and the component for which the step is needed. Dispatch in these functions has to be
var::Any, ::AbstractTimeStepper, ::STEP_COMPONENT, ::AbstractModelwhereby the model can be left out. Default is to return step index 1. This means that every time stepper can define which step to call in the get_..._step methods by implementing which_step, which_prognostic_step, or which_tendency_step. With that function signature. So dispatch allows to distinguish the step between model components, between models but also whether a variable is spectral or a grid variable.
SpeedyWeather.write_array! Method
write_array!(
output::NetCDFOutput,
variable::SpeedyWeather.AbstractOutputVariable,
field
)Backend-specific write of an interpolated, post-processed field field for variable into output. Implementations exist for NetCDFOutput and ZarrOutput.
SpeedyWeather.write_output! Method
write_output!(
output::SpeedyWeather.AbstractOutput,
variable::SpeedyWeather.AbstractOutputVariable,
field::AbstractField,
host::AbstractField
)Write field (on the output grid and the model's architecture) of variable into output: copy it into its host equivalent (no-op on CPU where host === field), round its mantissa bits for compression if variable has keepbits (on the host, as rounding is cheap there) and write via the backend-specific write_array!.
SpeedyWeather.year_angle Method
year_angle(::Type{T}, time::Dates.AbstractDateTime) where TFraction of year as angle in radians, sawtooth from 0 at Jan-01T00:00 to 2π at the end of Dec-31, continuous across the New Year. The length of the year is the actual length of time's year (365 or 366 days) so that no discontinuity arises for leap years. Always calculated relative to the Earth calendar, so LENGTH_OF_DAY is used as a constant. This is because Dates functions assume an Earth calendar. Length of the seasonal cycle is instead controlled via a faster orbit time, see Earth.
SpeedyWeatherInternals.Architectures.on_architecture Method
on_architecture(
arch::SpeedyWeatherInternals.Architectures.AbstractArchitecture,
vars::Variables
) -> VariablesTransfer all arrays in vars to arch using on_architecture. Every fused variable is created anew as the same view of its transferred fused parent, see map_variables.
SpeedyWeatherInternals.Architectures.AbstractArchitecture Type
AbstractArchitectureAbstract supertype for architectures supported by SpeedyWeather.
sourceSpeedyWeatherInternals.Architectures.AbstractCPU Type
AbstractCPU <: AbstractArchitectureAbstract supertype for CPU architectures supported by SpeedyWeather.
sourceSpeedyWeatherInternals.Architectures.CPU Type
CPU <: AbstractCPURun SpeedyWeather on one CPU node.
sourceSpeedyWeatherInternals.Architectures.GPU Type
GPU(device)Return a GPU architecture using device. device defauls to CUDA.CUDABackend(always_inline=true). CUDA has to be loaded for this to work.
SpeedyWeatherInternals.Architectures.ReactantDevice Type
ReactantDevice(device)Return a Reactant architecture to run SpeedyWeather using Reactant. The actual device it's running on depends on the Reactant settings.
sourceSpeedyWeatherInternals.Architectures.architecture Method
architecture(a::AbstractArchitecture)Return the architecture of a.
SpeedyWeatherInternals.Architectures.architecture Method
architecture(x)Return the default architecture that's associated with the input x.
SpeedyWeatherInternals.Architectures.array_type Method
array_type(::AbstractArchitecture, NF::Type, N::Int)Return the concrete array type that's used with the architecture for a number type NF and dimension N.
SpeedyWeatherInternals.Architectures.array_type Method
array_type(arch::AbstractArchitecture)Return the array type that's used with the architecture arch.
SpeedyWeatherInternals.Architectures.compatible_array_types Method
compatible_array_types(arch::AbstractArchitecture)Return the array types that are compatible with the architecture arch. This includes the regular array_type(arch) as well as any other array types that are compatible with the architecture, e.g. device arrays on GPU.
SpeedyWeatherInternals.Architectures.device_bytes Method
device_bytes(x) -> IntBytes of x held in device (e.g. GPU) memory if x is a device array, 0 otherwise. Extended for CuArray, ROCArray, MtlArray and Reactant's concrete arrays in the respective extensions.
SpeedyWeatherInternals.Architectures.memorysize Method
memorysize(x) -> IntLike Base.summarysize(x) (memory reachable from x in bytes) but also counting the memory of device arrays (e.g. CuArray), of which Base.summarysize only counts the host-side wrapper. Every mutable object (incl. arrays) is counted only once.
SpeedyWeatherInternals.Architectures.nonparametric_type Method
nonparametric_type(array_T::Type{<:AbstractArray})Strip away all the parameters of array_T and return the nonparametric type.
SpeedyWeatherInternals.Architectures.on_architecture Method
on_architecture(arch::AbstractArchitecture, a)Return a, but on the architecture arch.
SpeedyWeatherInternals.KernelLaunching.AbstractWorkOrder Type
Abstract type for different work order patterns in kernel launching.
sourceSpeedyWeatherInternals.KernelLaunching.ArrayWorkOrder Type
Work order for kernels over a regular N-D array.
sourceSpeedyWeatherInternals.KernelLaunching.DiagonalWorkOrder Type
Work order for kernels over the diagonal of a (m+1)×m or m×m LowerTriangularArray.
sourceSpeedyWeatherInternals.KernelLaunching.LinearWorkOrder Type
Work order for kernels over linear/eachindex iteration.
sourceSpeedyWeatherInternals.KernelLaunching.RingGridWorkOrder Type
Work order for kernels over RingGrids 'ij' indices and layers.
sourceSpeedyWeatherInternals.KernelLaunching.SpectralInnerWorkOrder Type
Work order for kernels over spectral number 'lm' and layers, excluding the lm=1 element.
sourceSpeedyWeatherInternals.KernelLaunching.SpectralWorkOrder Type
Work order for kernels over spectral number 'lm' and layers.
sourceSpeedyWeatherInternals.KernelLaunching.configure_kernel Method
configure_kernel(
arch,
work_order::Type{<:SpeedyWeatherInternals.KernelLaunching.AbstractWorkOrder},
worksize,
kernel!
) -> Tuple{Any, Any, Any}Configure kernel! to launch over the dims of grid on the architecture arch.
Arguments
============
arch: The architecture on which the kernel will be launched.dims_type: The dimensions on which the kernel will be executed, a subtype ofAbstractWorkOrder.worksize: The size that defines the work distribution.kernel!: The kernel function to be executed.
SpeedyWeatherInternals.KernelLaunching.launch! Method
launch!(arch, dims_type, worksize, kernel!, kernel_args...)
Launches kernel! with arguments kernel_args over the dims_type with worksize on the architecture arch. Kernels run on the default stream.
See configure_kernel for more information.
SpeedyWeatherInternals.KernelLaunching.work_layout Method
work_layout(
::Type{SpeedyWeatherInternals.KernelLaunching.ArrayWorkOrder},
worksize::NTuple{N, Int64}
) where N -> Tuple{Any, NTuple{N, Int64} where N}Returns the workgroup and worksize for launching a kernel over a regular N-D array.
SpeedyWeatherInternals.KernelLaunching.work_layout Method
work_layout(
::Type{SpeedyWeatherInternals.KernelLaunching.DiagonalWorkOrder},
worksize::NTuple{N, Int64}
) where N -> Tuple{Any, Tuple{Int64, Vararg{Any}}}Returns the workgroup and worksize for launching a kernel over the diagonal of a LowerTriangularArray.
SpeedyWeatherInternals.KernelLaunching.work_layout Method
work_layout(
::Type{SpeedyWeatherInternals.KernelLaunching.LinearWorkOrder},
worksize::NTuple{N, Int64}
) where N -> Tuple{Int64, Tuple{Int64}}Returns the workgroup and worksize for launching a kernel with linear iteration.
SpeedyWeatherInternals.KernelLaunching.work_layout Method
work_layout(
::Type{SpeedyWeatherInternals.KernelLaunching.RingGridWorkOrder},
worksize::NTuple{N, Int64}
) where N -> Tuple{Any, NTuple{N, Int64} where N}Returns the workgroup and worksize for launching a kernel with ring grid work order.
SpeedyWeatherInternals.KernelLaunching.work_layout Method
work_layout(
::Type{SpeedyWeatherInternals.KernelLaunching.SpectralInnerWorkOrder},
worksize::NTuple{N, Int64}
) where N -> Tuple{Any, Tuple{Int64, Vararg{Any}}}Returns the workgroup and worksize for launching a kernel with spectral inner work order, excluding the lm=1 element.
SpeedyWeatherInternals.KernelLaunching.work_layout Method
work_layout(
::Type{SpeedyWeatherInternals.KernelLaunching.SpectralWorkOrder},
worksize::NTuple{N, Int64}
) where N -> Tuple{Any, NTuple{N, Int64} where N}Returns the workgroup and worksize for launching a kernel with spectral work order.
SpeedyWeatherInternals.Utils.REACTANT_EXCLUDED_PASSES Constant
Optimization patterns of Reactant excluded from every compilation (@maybe_jit, the compiled time loop, see reactant_compile_options), to work around Reactant limitations and bugs: add a pattern's name here, remove it once fixed upstream. None currently (cse_slice was excluded for Reactant v0.2.293 to v0.2.296, see docs/dev/2026-10/reactant-issue-draft-gather-index-cycle.md).
SpeedyWeatherInternals.Utils._jit Method
_jit(
::SpeedyWeatherInternals.Architectures.AbstractArchitecture,
f,
args...;
kwargs...
)Fallback for @maybe_jit when Reactant is not available. Just calls f(args...; kwargs...).
SpeedyWeatherInternals.Utils.isdecreasing Method
isdecreasing(v::AbstractVector)Check whether elements of a vector v are strictly decreasing.
SpeedyWeatherInternals.Utils.isincreasing Method
isincreasing(v::AbstractVector)Check whether elements of a vector v are strictly increasing.
SpeedyWeatherInternals.Utils.print_fields Method
print_fields(
io::IO,
A,
keys;
arrays::Bool=false,
values::Bool=true
)Prints to io all fields of a struct A identified by their keys.
SpeedyWeatherInternals.Utils.reactant_compile_options Function
reactant_compile_options(; kwargs...)Compile options (a Reactant.CompileOptions) for all compilations with Reactant: the KernelAbstractions kernels are raised to StableHLO (raise = true) and the patterns in REACTANT_EXCLUDED_PASSES are excluded; kwargs are passed on to Reactant.CompileOptions and can override both. Defined in the Reactant extension.
SpeedyWeatherInternals.Utils.readable_secs Method
readable_secs(secs::Real) -> Dates.CompoundPeriodReturns a human-readable string for a duration given in seconds, rounding to (days, hours), (hours, minutes), (minutes, seconds), or seconds with 1-2 decimal places for short durations. E.g.
julia> using SpeedyWeather: readable_secs
julia> readable_secs(12345)SpeedyWeatherInternals.Utils.set_scalar! Method
set_scalar!(x::AbstractArray, i, v)Sets the value of x[i] to v in a GPU compatible way. This uses @allowscalar with Reactant and x[i:i] .= v as a workaround for Enzyme compatibility otherwise.
SpeedyWeatherInternals.Utils.@maybe_jit Macro
@maybe_jit arch exprMacro that conditionally applies Reactant.@jit based on the architecture. For ReactantDevice, the extension overloads _jit to use @jit. For other architectures, just executes the expression directly.
Usage: @maybe_jit model.architecture initialize!(model.geometry, model)
SpeedyWeatherInternals.ParameterEditing.NumberParam Type
NumberParam{NF <: Number} <: AbstractParamSpecialized implementation of AbstractParam for Speedy models that defines a fixed set of fields with concrete types.
SpeedyWeatherInternals.ParameterEditing.ParameterTable Type
ParameterTable{NT<:NamedTuple} <: ModelParameters.AbstractModelLightweight wrapper around a NamedTuple of parameters following the ModelParameters AbstractModel interface. This provides a table-like interface for interacting with model parameters.
SpeedyWeatherInternals.ParameterEditing._attrs Method
Internal helper function for filtering out built-in parameter fields.
sourceSpeedyWeatherInternals.ParameterEditing._selectrecursive Method
_selectrecursive(selector, nt::NamedTuple)Recursively filters out all values from a (possibly nested) named tuple nt for which selector returns true.
SpeedyWeatherInternals.ParameterEditing.attributes Method
Returns a NamedTuple of any additional attributes defined for param.
SpeedyWeatherInternals.ParameterEditing.bounds Method
Returns the numerical bounds of the parameter param.
SpeedyWeatherInternals.ParameterEditing.description Method
Returns a human-readable description of the parameter param.
SpeedyWeatherInternals.ParameterEditing.parameterof Method
parameterof(obj, ::Val{propname}; kwargs...)Convenience method that creates a model parameter from its property with the given name and optional extra attributes in kwargs. A parameter attribute copmonenttype is automatically added with value T.
SpeedyWeatherInternals.ParameterEditing.parameters Method
parameters(obj; kwargs...)Extract parameters from the given obj as (possibly nested) named-tuple of NumberParams or some other AbstractParam type. If obj
SpeedyWeatherInternals.ParameterEditing.reconstruct Method
reconstruct(obj, value)Reconstructs the given (possibly nested) data structure with the given values. If values is a NamedTuple, the nested structure must match that of obj. This function is used to reconstruct model types from ParameterTable.
SpeedyWeatherInternals.ParameterEditing.stripparams Method
stripparams(param)Unpacks and strips all AbstractParam types from the given params object, replacing them with their numeric val. This is a type-stable alternative to the (currently unstable) stripparams in ModelParameters.
SpeedyWeatherInternals.ParameterEditing.unpack_params Method
unpack_params(x)Simple recursive dispatch algorithm for unpacking nested named tuples of ParameterTable
SpeedyWeatherInternals.ParameterEditing.@parameterized Macro
@parameterized exprConvenience macro for creating "parameterized" structs. Fields can be marked as parameters with @param, e.g:
@parameterized Base.@kwdef struct Foo{T}
@param x::T = 1.0
y::T = NaN
endwhere here x will be treated as a parameter field and y will not. Parameters will be then automatically generated in a corresponding parameters(::Foo) method definition with descriptions set to the corresponding struct field docstring, if present. Additional parameter attributes can be supplied as keywords after the parameter, e.g. @param p::T = 0.5 bounds=UnitInterval or @param p::T = 0.5 (bounds=UnitInterval, constant=false).
Known limitations
This macro will fail to behave correctly in the following known corner cases:
Untyped struct fields without default values. The macro will not work if the struct has untyped fields without default values specified using the
@kwdefsyntax. This is because untyped fields are not distinguishable in the expression tree from symbols in other expressions (such as typed field definitions). This problem can be avoided by always specifying types on struct fields (which should always be done anyway!).@kwdefstruct with a single parameter field and no default value.@parameterizedhas a buggy interaction with@kwdefin this corner case:julia@parameterized @kwdef struct Foo{T} @param x::T endwhere the auto-generated constructors erroneously duplicate
Tas a function and type parameter. This is, however, a fairly meaningless corner-case since there is no purpose in marking this struct as@kwdefif no default assignments are made!
If you encounter any other weird interactions or behaviors, please raise an issue.
SpeedyWeather.OutputVariables Module
Output variables to be added to an output writer like NetCDFOutput or ZarrOutput, e.g. add!(model, OutputVariables.Temperature(), OutputVariables.Humidity()). Every output variable is a subtype of SpeedyWeather.AbstractOutputVariable and the module is exported but none of its names are, so always access them qualified, e.g. OutputVariables.Vorticity(keepbits = 7). Collections of output variables are returned as tuples, e.g. OutputVariables.Dynamics(), OutputVariables.Land() or all of them with OutputVariables.All().
SpeedyWeather.OutputVariables.Albedo Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "albedo"unit::String = "1"long_name::String = "albedo"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = DEFAULT_COMPRESSION_LEVELshuffle::Bool = DEFAULT_SHUFFLEkeepbits::Int64 = DEFAULT_KEEPBITS
SpeedyWeather.OutputVariables.CloudCover Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "cloud_cover"unit::String = "1"long_name::String = "cloud cover"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.CloudTop Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "cloud_top"unit::String = "m"long_name::String = "cloud top height"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.ConvectiveRain Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "rain_conv"unit::String = "mm"long_name::String = "accumulated convective rain"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 20transform::Any = (x->begin …rate::Any = ConvectiveRainRate()
SpeedyWeather.OutputVariables.ConvectiveRainRate Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "rain_conv_rate"unit::String = "mm/hr"long_name::String = "convective rain rate"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7transform::Any = (x->begin …
SpeedyWeather.OutputVariables.ConvectiveSnow Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "snow_conv"unit::String = "mm"long_name::String = "accumulated convective snow"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 20transform::Any = (x->begin …rate::Any = ConvectiveSnowRate()
SpeedyWeather.OutputVariables.ConvectiveSnowRate Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "snow_conv_rate"unit::String = "mm/hr"long_name::String = "convective snow rate"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7transform::Any = (x->begin …
SpeedyWeather.OutputVariables.Divergence Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "div"unit::String = "s^-1"long_name::String = "divergence"dims_xyzt::NTuple{4, Bool} = (true, true, true, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 5unscale::Bool = true
SpeedyWeather.OutputVariables.HeatBoundaryLayerDrag Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "bld_h"unit::String = "1"long_name::String = "Heat flux related boundary layer drag coefficient"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.Humidity Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "humid"unit::String = "kg/kg"long_name::String = "specific humidity"dims_xyzt::NTuple{4, Bool} = (true, true, true, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.HumidityBoundaryLayerDrag Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "bld_q"unit::String = "1"long_name::String = "Moisture flux related boundary layer drag coefficient"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.InterfaceDisplacement Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "eta"unit::String = "m"long_name::String = "interface displacement"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.LandSeaMask Type
Defines netCDF output for a specific variable, see Vorticity for details. Fields are:
name::String = "lsm"unit::String = "1"long_name::String = "land-sea mask (1=land, 0=sea)"dims_xyzt::NTuple{4, Bool} = (true, true, false, false)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 10
SpeedyWeather.OutputVariables.LargeScaleRain Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "rain_cond"unit::String = "mm"long_name::String = "accumulated large-scale rain"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 20transform::Any = (x->begin …rate::Any = LargeScaleRainRate()
SpeedyWeather.OutputVariables.LargeScaleRainRate Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "rain_cond_rate"unit::String = "mm/hr"long_name::String = "large-scale rain rate"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7transform::Any = (x->begin …
SpeedyWeather.OutputVariables.LargeScaleSnow Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "snow_cond"unit::String = "mm"long_name::String = "accumulated large-scale snow"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 20transform::Any = (x->begin …rate::Any = LargeScaleSnowRate()
SpeedyWeather.OutputVariables.LargeScaleSnowRate Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "snow_cond_rate"unit::String = "mm/hr"long_name::String = "large-scale snow rate"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7transform::Any = (x->begin …
SpeedyWeather.OutputVariables.MeanSeaLevelPressure Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "mslp"unit::String = "hPa"long_name::String = "mean sea-level pressure"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 12transform::Any = (x->begin …
SpeedyWeather.OutputVariables.MeridionalVelocity Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "v"unit::String = "m/s"long_name::String = "meridional wind"dims_xyzt::NTuple{4, Bool} = (true, true, true, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.MeridionalVelocity10m Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "v10"unit::String = "m/s"long_name::String = "10m meridional wind speed"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 12
SpeedyWeather.OutputVariables.MomentumBoundaryLayerDrag Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "bld_m"unit::String = "1"long_name::String = "Momentum flux related boundary layer drag coefficient"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.MomentumSurfaceRoughness Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "sr_m"unit::String = "m"long_name::String = "Momentum surface roughness length"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.Orography Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "orography"unit::String = "m"long_name::String = "orography"dims_xyzt::NTuple{4, Bool} = (true, true, false, false)missing_value::Float64 = NaNcompression_level::Int64 = DEFAULT_COMPRESSION_LEVELshuffle::Bool = DEFAULT_SHUFFLEkeepbits::Int64 = 15
SpeedyWeather.OutputVariables.RandomPattern Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "random_pattern"unit::String = "1"long_name::String = "random pattern"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.RiverRunoff Type
Defines netCDF output for a specific variable, see Vorticity for details. Fields are:
name::String = "roff"unit::String = "m"long_name::String = "river runoff"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 15
SpeedyWeather.OutputVariables.SeaIceConcentration Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "sic"unit::String = "m^2/m^2"long_name::String = "sea ice concentration"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 10ocean_fraction::Bool = true
SpeedyWeather.OutputVariables.SeaSurfaceTemperature Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "sst"unit::String = "degC"long_name::String = "sea surface temperature"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 10transform::Any = (x->begin …
SpeedyWeather.OutputVariables.SnowDepth Type
Defines netCDF output for a specific variable, see Vorticity for details. Fields are:
name::String = "sd"unit::String = "m"long_name::String = "snow depth (equivalent liquid water height)"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 10
SpeedyWeather.OutputVariables.SnowMelt Type
Defines netCDF output for a specific variable, see Vorticity for details. Fields are:
name::String = "smelt"unit::String = "kg/m^2/s"long_name::String = "snow melt+runoff rate"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 12
SpeedyWeather.OutputVariables.SoilMoisture Type
Defines netCDF output for a specific variable, see Vorticity for details. Fields are:
name::String = "sm"unit::String = "1"long_name::String = "soil moisture"dims_xyzt::NTuple{4, Bool} = (true, true, true, true)is_land::Bool = truemissing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 10
SpeedyWeather.OutputVariables.SoilMoistureAvailability Type
Defines netCDF output for a specific variable, see Vorticity for details. Fields are:
name::String = "sma"unit::String = "1"long_name::String = "soil moisture availability"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 10
SpeedyWeather.OutputVariables.SoilTemperature Type
Defines netCDF output for a specific variable, see Vorticity for details. Fields are:
name::String = "st"unit::String = "degC"long_name::String = "soil temperature"dims_xyzt::NTuple{4, Bool} = (true, true, true, true)is_land::Bool = truemissing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 10transform::Any = (x->begin …
SpeedyWeather.OutputVariables.SurfaceHumidityFlux Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "shuf"unit::String = "kg/s/m^2"long_name::String = "Surface humidity flux (positive up)"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.SurfaceLatentHeatFlux Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "slf"unit::String = "W/m^2"long_name::String = "Surface latent heat flux (positive up)"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.SurfacePressure Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "pres"unit::String = "hPa"long_name::String = "surface pressure"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 12transform::Any = (x->begin …
SpeedyWeather.OutputVariables.SurfaceSensibleHeatFlux Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "shf"unit::String = "W/m^2"long_name::String = "Surface sensible heat flux (positive up)"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.SurfaceTemperature Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "tsurf"unit::String = "degC"long_name::String = "Surface air temperature"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 12transform::Any = (x->begin …
SpeedyWeather.OutputVariables.Temperature Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "temp"unit::String = "degC"long_name::String = "temperature"dims_xyzt::NTuple{4, Bool} = (true, true, true, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 10transform::Any = (x->begin …extrapolation::SpeedyWeather.AbstractVerticalExtrapolation = DryAdiabaticExtrapolation(): [OPTION] how to extrapolate below the lowest model layer when written on pressure layers, dry-adiabatic descent so that e.g. 1000 hPa below the lowest model layer is sensible. Only used withPressureLayers, seeAbstractVerticalExtrapolation. Not a type parameter so that it can be converted to the model's number format at initialize!
SpeedyWeather.OutputVariables.Vorticity Type
Defines netCDF output of vorticity. Fields are
name::String = "vor": [Required] short name of variable (unique) used in netCDF file and key for dictionaryunit::String = "s^-1": [Required] unit of variablelong_name::String = "relative vorticity": [Required] long name of variable used in netCDF filedims_xyzt::NTuple{4, Bool} = (true, true, true, true): [Required] NetCDF dimensions the variable uses, lon, lat, layer, timemissing_value::Float64 = NaN: [Optional] missing value for the variable, if not specified uses NaNcompression_level::Int64 = 3: [Optional] compression level of the lossless compressor, 1=lowest/fastest, 9=highest/slowest, 3=defaultshuffle::Bool = true: [Optional] bitshuffle the data for compression, false = defaultkeepbits::Int64 = 5: [Optional] number of mantissa bits to keep for compression (default: 15)unscale::Bool = true: [Optional] Unscale the variable for output? (default: true)
Custom variable output defined similarly with required fields marked, optional fields otherwise use variable-independent defaults. Initialize with Vorticity() and non-default fields can always be passed on as keyword arguments, e.g. Vorticity(long_name="relative vorticity", compression_level=0). Custom variable output also requires the path(::MyOutputVariable, simulation) to be extended to return the AbstractField subject to output. Custom element-wise variable transforms, e.g. scale and/or offset to change units, or even exp(x)/100 to change from log surface pressure to hPa are passed on as transform::Function = x -> exp(x)/100.
SpeedyWeather.OutputVariables.ZonalVelocity Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "u"unit::String = "m/s"long_name::String = "zonal wind"dims_xyzt::NTuple{4, Bool} = (true, true, true, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 7
SpeedyWeather.OutputVariables.ZonalVelocity10m Type
Defines netCDF output for a specific variables, see Vorticity for details. Fields are:
name::String = "u10"unit::String = "m/s"long_name::String = "10m zonal wind speed"dims_xyzt::NTuple{4, Bool} = (true, true, false, true)missing_value::Float64 = NaNcompression_level::Int64 = 3shuffle::Bool = truekeepbits::Int64 = 12
SpeedyWeather.OutputVariables.All Method
All() -> Tuple{SpeedyWeather.OutputVariables.Vorticity, SpeedyWeather.OutputVariables.ZonalVelocity, SpeedyWeather.OutputVariables.MeridionalVelocity, SpeedyWeather.OutputVariables.Divergence, SpeedyWeather.OutputVariables.InterfaceDisplacement, SpeedyWeather.OutputVariables.SurfacePressure{SpeedyWeather.OutputVariables.var"#SurfacePressure##0#SurfacePressure##1"}, SpeedyWeather.OutputVariables.MeanSeaLevelPressure{SpeedyWeather.OutputVariables.var"#MeanSeaLevelPressure##0#MeanSeaLevelPressure##1"}, SpeedyWeather.OutputVariables.Temperature{SpeedyWeather.OutputVariables.var"#Temperature##0#Temperature##1"}, SpeedyWeather.OutputVariables.Humidity, SpeedyWeather.OutputVariables.ConvectiveRain{SpeedyWeather.OutputVariables.var"#ConvectiveRain##0#ConvectiveRain##1", SpeedyWeather.OutputVariables.ConvectiveRainRate{SpeedyWeather.OutputVariables.var"#ConvectiveRainRate##0#ConvectiveRainRate##1"}}, SpeedyWeather.OutputVariables.ConvectiveSnow{SpeedyWeather.OutputVariables.var"#ConvectiveSnow##0#ConvectiveSnow##1", SpeedyWeather.OutputVariables.ConvectiveSnowRate{SpeedyWeather.OutputVariables.var"#ConvectiveSnowRate##0#ConvectiveSnowRate##1"}}, SpeedyWeather.OutputVariables.LargeScaleRain{SpeedyWeather.OutputVariables.var"#LargeScaleRain##0#LargeScaleRain##1", SpeedyWeather.OutputVariables.LargeScaleRainRate{SpeedyWeather.OutputVariables.var"#LargeScaleRainRate##0#LargeScaleRainRate##1"}}, SpeedyWeather.OutputVariables.LargeScaleSnow{SpeedyWeather.OutputVariables.var"#LargeScaleSnow##0#LargeScaleSnow##1", SpeedyWeather.OutputVariables.LargeScaleSnowRate{SpeedyWeather.OutputVariables.var"#LargeScaleSnowRate##0#LargeScaleSnowRate##1"}}, SpeedyWeather.OutputVariables.CloudTop, SpeedyWeather.OutputVariables.CloudCover, SpeedyWeather.OutputVariables.Orography, SpeedyWeather.OutputVariables.OutgoingLongwaveRadiation, SpeedyWeather.OutputVariables.OutgoingShortwaveRadiation, SpeedyWeather.OutputVariables.SurfaceShortwaveUp, SpeedyWeather.OutputVariables.SurfaceShortwaveDown, SpeedyWeather.OutputVariables.SurfaceLongwaveUp, SpeedyWeather.OutputVariables.SurfaceLongwaveDown, SpeedyWeather.OutputVariables.Albedo, SpeedyWeather.OutputVariables.RandomPattern, SpeedyWeather.OutputVariables.SurfaceSensibleHeatFlux, SpeedyWeather.OutputVariables.SurfaceHumidityFlux, SpeedyWeather.OutputVariables.SoilTemperature{SpeedyWeather.OutputVariables.var"#SoilTemperature##0#SoilTemperature##1"}, SpeedyWeather.OutputVariables.SoilMoisture, SpeedyWeather.OutputVariables.SoilMoistureAvailability, SpeedyWeather.OutputVariables.RiverRunoff, SpeedyWeather.OutputVariables.SnowMelt, SpeedyWeather.OutputVariables.SnowDepth, SpeedyWeather.OutputVariables.LandSeaMask, SpeedyWeather.OutputVariables.SeaSurfaceTemperature{SpeedyWeather.OutputVariables.var"#SeaSurfaceTemperature##0#SeaSurfaceTemperature##1"}, SpeedyWeather.OutputVariables.SeaIceConcentration, SpeedyWeather.OutputVariables.ZonalVelocity10m, SpeedyWeather.OutputVariables.MeridionalVelocity10m, SpeedyWeather.OutputVariables.SurfaceTemperature{SpeedyWeather.OutputVariables.var"#SurfaceTemperature##0#SurfaceTemperature##1"}, SpeedyWeather.OutputVariables.MomentumBoundaryLayerDrag, SpeedyWeather.OutputVariables.HeatBoundaryLayerDrag, SpeedyWeather.OutputVariables.HumidityBoundaryLayerDrag, SpeedyWeather.OutputVariables.MomentumSurfaceRoughness, SpeedyWeather.OutputVariables.HeatSurfaceRoughness}All output variables (except tracers and Terrarium) as a tuple, e.g. add!(model, OutputVariables.All()...).
SpeedyWeather.OutputVariables.Terrarium Function
Output variables for the state of a Terrarium land model in coupled Terrarium-SpeedyWeather simulations. Call as OutputVariables.Terrarium(terrarium_model) to create output variables for all prognostic and auxiliary variables of the Terrarium model, or as OutputVariables.Terrarium(terrarium_model, :variable_name) for a single one. Output variables are added to a model's output via add!(model, OutputVariables.Terrarium(terrarium_model)...). Supported by NetCDFOutput, and by ZarrOutput once Zarr.jl is loaded.
SpeedyWeather.OutputVariables.exists_in_simulation Method
exists_in_simulation(
variable::SpeedyWeather.AbstractOutputVariable,
simulation
) -> Booltrue if variable exists in simulation and can therefore be written out. This is the same path_or_nothing check the generic output! applies at write time, exposed so that output writers can apply it at schema-definition time too: a variable that is skipped by output! but still defined in the file/store would otherwise be left behind as an all-missing_value phantom array. Variables can be absent when the Model type an output writer was constructed with declares defaults the actual model doesn't have, e.g. a PrimitiveWet output attached to a BarotropicModel has no temp/humid/mslp.
SpeedyWeather.OutputVariables.output_extrapolation Method
output_extrapolation(
variable::SpeedyWeather.AbstractOutputVariable
)Extrapolation of variable beyond the model's vertical layers: its extrapolation field if it has one (e.g. OutputVariables.Temperature descends dry-adiabatically below the lowest model layer), otherwise constant. Same hasproperty pattern as transform and unscale in the generic output!.
SpeedyWeather.OutputVariables.path Function
To be extended for every output variable to define the path where in simulation to find that output variable ::AbstractField, e.g. OutputVariables.path(::MyOutputVariable, simulation) = simulation.variables.grid.vorticity.
SpeedyWeather.OutputVariables.path_or_nothing Method
path_or_nothing(
variable::SpeedyWeather.AbstractOutputVariable,
simulation
)Like path but returns nothing instead of throwing an error if the variable is not defined in the simulation.
SpeedyWeather.output! Method
output!(
output::NetCDFOutput,
variable::SpeedyWeather.OutputVariables.AbstractRateOutputVariable,
acc_variable::SpeedyWeather.AbstractOutputVariable
)Post-process the netCDF output file to convert accumulated precipitation rain/snow to rates.
SpeedyWeather.output! Method
output!(
output::SpeedyWeather.AbstractOutput,
variable::Union{SpeedyWeather.OutputVariables.MeridionalVelocity10m, SpeedyWeather.OutputVariables.ZonalVelocity10m},
simulation::SpeedyWeather.AbstractSimulation
)10m wind is defined using a logarithmic profile from the lowermost model layer.
u_10 = u_bottom * ln(10 / z₀) / ln(z_bottom / z₀)(with z in m), with
z_bottom = z_surf + T_bottom * Δp_geopot_bottom / g