Skip to content

Clima API

AdiabatClimate is the primary interface for one-dimensional radiative-convective climate calculations.

Construction

photochem.clima.AdiabatClimate(
    species_file,
    settings_file,
    flux_file,
    data_dir=None,
    double_radiative_grid=True,
)

The constructor is shown explicitly because Python's runtime inspection does not expose constructor parameters for compiled extension classes. The generated class and member documentation below comes from the installed extension.

AdiabatClimate

AdiabatClimate()

One-dimensional multispecies adiabatic and radiative-convective climate model.

The model constructs a pseudoadiabatic troposphere connected to an isothermal stratosphere and can compute top-of-atmosphere radiative fluxes or solve for radiative-convective equilibrium. Arrays indexed by gas use species_names order; arrays indexed by particle use particle_names. Atmospheric profiles run from the surface upward.

Array-valued properties return copies. The rad property and its nested channel and work objects are non-owning views; keep this model alive while using them.

Initialize an AdiabatClimate model from its input files.

Construction allocates the model and configurable defaults but does not construct a physical atmospheric profile. Profile-building methods update the atmospheric state.

Parameters:

Name Type Description Default
species_file str

Species YAML file.

required
settings_file str

Climate-settings YAML file.

required
flux_file str

Stellar-flux text file.

required
data_dir str

Directory containing radiative-transfer data. By default, use the installed photochem_clima_data package.

required
double_radiative_grid bool

If True (default), radiative transfer uses a refined grid where each physical layer is split into two RT layers, plus two ghost RT layers above the model top to improve TOA numerical stability.

required

Cd property

Cd

float: Writable dimensionless drag coefficient.

L property

L

float: Writable circulation horizontal scale (cm).

N_atmos property

N_atmos

ndarray, shape (ng,): Read-only copy of atmospheric gas reservoirs (mol/cm^2).

N_ocean property

N_ocean

ndarray, shape (ng, ng): Read-only copy of ocean gas reservoirs (mol/cm^2).

N_ocean[:, j] contains gases dissolved in the ocean made from species j. Values are strictly consistent when reference_pressure <= 0.

N_surface property

N_surface

ndarray, shape (ng,): Read-only copy of surface gas reservoirs (mol/cm^2).

Strictly consistent when reference_pressure <= 0, meaning that the configured planet radius is defined at P_surf.

P property

P

ndarray, shape (nz,): Read-only copy of layer-center pressure (dyn/cm^2).

P_surf property

P_surf

float: Surface pressure (dyn/cm^2).

P_top property

P_top

float: Writable target pressure at the model top (dyn/cm^2).

P_trop property

P_trop

float: Tropopause pressure (dyn/cm^2).

RH property

RH

ndarray, shape (ng,): Writable relative humidity of each gas.

Values follow species_names order. Getting this property returns a copy; assign the complete array to update the model.

T property

T

ndarray, shape (nz,): Read-only copy of layer-center temperature (K).

T_surf property

T_surf

float: Surface temperature (K).

T_trop property

T_trop

float: Writable isothermal-stratosphere temperature (K).

albedo_fcn property

albedo_fcn

numba.cfunc or None: Write-only temperature-dependent albedo callback.

The callback can parameterize ice-albedo feedback and must have C signature double(double) with temperature in K and dimensionless albedo returned. Keep the compiled callback alive while the model uses it. Assign None to clear it.

atol property

atol

float: Writable absolute tolerance for adiabatic-profile integrations.

chi property

chi

float: Writable dimensionless heat-engine efficiency.

compute_solar_in_jac property

compute_solar_in_jac

bool: Whether the RCE Jacobian recomputes shortwave radiative transfer.

When false, the Jacobian reuses the base-state shortwave calculation for each temperature perturbation.

convecting_with_below property

convecting_with_below

ndarray, shape (nz,): Read-only copy of convective connectivity.

A true element means that the corresponding layer convects with the layer below. Element 0 refers to the lowest layer and the surface.

convective_hysteresis_frac_off property

convective_hysteresis_frac_off

float: Writable fractional threshold for making RCE layers radiative.

The applied threshold is the maximum of convective_hysteresis_min and this value times the magnitude of lapse_rate_intended.

convective_hysteresis_frac_on property

convective_hysteresis_frac_on

float: Writable fractional threshold for making RCE layers convective.

The applied threshold is the maximum of convective_hysteresis_min and this value times the magnitude of lapse_rate_intended.

convective_hysteresis_min property

convective_hysteresis_min

float: Writable absolute dln(T)/dln(P) hysteresis threshold.

convective_max_boundary_shift property

convective_max_boundary_shift

int: Writable convective-boundary motion limit in layers.

Negative values disable the limiter.

convective_newton_step_size property

convective_newton_step_size

float: Writable fraction of the Newton step used for convective classification.

densities property

densities

ndarray, shape (nz, ng): Read-only copy of gas number densities (molecules/cm^3).

dt_increment property

dt_increment

float: Writable multiplicative growth factor for PTC timestep updates.

dz property

dz

ndarray, shape (nz,): Read-only copy of layer thickness (cm).

epsj property

epsj

float: Writable temperature perturbation for the RCE Jacobian (K).

f_i property

f_i

ndarray, shape (nz, ng): Read-only copy of gas volume mixing ratios.

f_i_surf property

f_i_surf

ndarray, shape (ng,): Read-only copy of surface gas volume mixing ratios.

gravity property

gravity

ndarray, shape (nz,): Read-only copy of layer-center gravity (cm/s^2).

gravity_surf property

gravity_surf

float: Surface gravitational acceleration (cm/s^2).

lapse_rate property

lapse_rate

ndarray, shape (nz,): Read-only copy of actual dln(T)/dln(P).

lapse_rate_intended property

lapse_rate_intended

ndarray, shape (nz,): Read-only copy of adiabatic target dln(T)/dln(P).

make_column_P_guess property

make_column_P_guess

ndarray, shape (ng,): Writable surface-partial-pressure guess.

Values are in dyn/cm^2 and follow species_names order. Getting this property returns a copy; assign the complete array to update the model.

max_rc_iters property

max_rc_iters

int: Writable maximum number of outer RCE iterations.

max_rc_iters_convection property

max_rc_iters_convection

int: Writable RCE iterations allowed to convert convective layers to radiative.

n_LW property

n_LW

float: Writable dimensionless longwave-opacity exponent, normally 1 or 2.

ocean_args_p property

ocean_args_p

int or None: Write-only address passed to ocean-solubility callbacks.

The pointed-to data and its lifetime are managed by the caller. Assign None to pass a null pointer.

particle_names property

particle_names

list[str]: Particle names in the ordering used by particle-indexed arrays.

pdensities property

pdensities

ndarray, shape (nz, np): Read-only copy of particle number densities (particles/cm^3).

pradii property

pradii

ndarray, shape (nz, np): Read-only copy of particle radii (cm).

prevent_overconvection property

prevent_overconvection

bool: Whether strong inversions shrink the tops of convective zones.

rad property

rad

Radtran: Non-owning view of the model's radiative-transfer object.

Keep this AdiabatClimate alive while using the returned object.

rce_solve_strategy property

rce_solve_strategy

int: Writable RCE nonlinear-solver strategy.

Use RCE_SOLVE_HYBRJ_ONLY, RCE_SOLVE_PTC_THEN_HYBRJ, or RCE_SOLVE_HYBRJ_THEN_PTC_THEN_HYBRJ from photochem.clima.

reference_pressure property

reference_pressure

float: Writable pressure at which the configured planet radius is defined.

Units are dyn/cm^2. If nonpositive, the radius is defined at P_surf.

require_mode2 property

require_mode2

bool: Whether RCE must pass through mode 2 before optional mode 3 polishing.

rtol property

rtol

float: Writable relative tolerance for adiabatic-profile integrations.

solve_for_T_trop property

solve_for_T_trop

bool: Whether equilibrium solvers also solve the tropopause temperature.

When enabled, the target is the radiative skin temperature and T_trop supplies the initial guess.

species_names property

species_names

list[str]: Gas names in the ordering used by gas-indexed arrays.

surface_heat_flow property

surface_heat_flow

float: Writable heat flow from the surface into the atmosphere (mW/m^2).

tidally_locked_dayside property

tidally_locked_dayside

bool: Whether equilibrium solvers apply tidally locked dayside redistribution.

tol_make_column property

tol_make_column

float: Writable nonlinear-solver tolerance used by make_column.

use_make_column_P_guess property

use_make_column_P_guess

bool: Whether make_column first uses make_column_P_guess.

verbose property

verbose

bool: Whether RCE writes progress information.

xtol_rc property

xtol_rc

float: Writable nonlinear-solver step tolerance for RCE.

z property

z

ndarray, shape (nz,): Read-only copy of layer-center altitude (cm).

RCE method descriptor

RCE(
    P_i_surf,
    T_surf_guess,
    T_guess,
    convecting_with_below=None,
    custom_dry_mix=None,
)

Solve for full radiative-convective equilibrium.

The solution and convective classification are stored in the atmospheric state properties. The return value reports convergence; invalid inputs and model failures raise ClimaException.

Parameters:

Name Type Description Default
P_i_surf (ndarray, shape(ng))

Surface partial pressures in species_names order (dyn/cm^2).

required
T_surf_guess float

Initial surface-temperature guess (K).

required
T_guess (ndarray, shape(nz))

Initial layer-temperature guess (K).

required
convecting_with_below ndarray of bool, shape (nz,)

Initial convective connectivity. Element 0 indicates whether the lowest atmospheric layer convects with the surface.

None
custom_dry_mix dict[str, ndarray]

Vertically inhomogeneous mixing ratios for dry gases. The dictionary must contain a "pressure" key specifying a strictly decreasing pressure grid in dyn/cm^2. The other keys are mixing ratio profiles for dry species at each pressure point. The total custom surface pressure is determined by:

P_dry_surf = 0.0
for key in custom_dry_mix:
    if key != 'pressure':
        ind = self.species_names.index(key)
        P_dry_surf += P_i_surf[ind]

The underlying code interpolates custom_dry_mix to the appropriate pressure levels. Note, these mixing ratios are not absolute volume mixing ratios. They are instead gas concentrations relative to all gases specified in custom_dry_mix.

None

Returns:

Type Description
bool

True if the RCE solve converged.

TOA_fluxes method descriptor

TOA_fluxes(T_surf, P_i_surf)

Construct a pseudoadiabatic profile and return its top-of-atmosphere fluxes.

Parameters:

Name Type Description Default
T_surf float

The surface temperature (K)

required
P_i_surf (ndarray, shape(ng))

Surface partial pressures in species_names order (dyn/cm^2).

required

Returns:

Type Description
tuple[float, float]

Incoming stellar radiation and outgoing longwave radiation at the top of the atmosphere, respectively (mW/m^2).

TOA_fluxes_bg_gas method descriptor

TOA_fluxes_bg_gas(T_surf, P_i_surf, P_surf, bg_gas)

Construct a fixed-pressure background-gas profile and return TOA fluxes.

Parameters:

Name Type Description Default
T_surf float

The surface temperature (K)

required
P_i_surf (ndarray, shape(ng))

Initial surface partial pressures in species_names order (dyn/cm^2).

required
P_surf float

Target total surface pressure (dyn/cm^2).

required
bg_gas str

The name of the background gas

required

Returns:

Type Description
tuple[float, float]

Incoming stellar radiation and outgoing longwave radiation at the top of the atmosphere, respectively (mW/m^2).

TOA_fluxes_column method descriptor

TOA_fluxes_column(T_surf, N_i_surf)

Construct a column-reservoir profile and return top-of-atmosphere fluxes.

Parameters:

Name Type Description Default
T_surf float

The surface temperature (K)

required
N_i_surf (ndarray, shape(ng))

Total gas reservoirs in species_names order (mol/cm^2).

required

Returns:

Type Description
tuple[float, float]

Incoming stellar radiation and outgoing longwave radiation at the top of the atmosphere, respectively (mW/m^2).

TOA_fluxes_dry method descriptor

TOA_fluxes_dry(P, T, f_i)

Construct a dry prescribed profile and return top-of-atmosphere fluxes.

Parameters:

Name Type Description Default
P (ndarray, shape(n))

Pressure ordered from the surface upward (dyn/cm^2).

required
T (ndarray, shape(n))

Temperature defined on P (K).

required
f_i (ndarray, shape(n, ng))

Gas volume mixing ratios in species_names order.

required

Returns:

Type Description
tuple[float, float]

Incoming stellar radiation and outgoing longwave radiation at the top of the atmosphere, respectively (mW/m^2).

heat_redistribution_parameters method descriptor

heat_redistribution_parameters()

Compute tidally locked heat-redistribution parameters.

This implements Equation 10 of Koll (2022, ApJ). Call a top-of-atmosphere flux method first because this calculation uses the current atmospheric state and radiative-transfer results.

Returns:

Type Description
tuple[float, float, float]

(tau_LW, k_term, f_term): the dimensionless Planck-weighted longwave optical depth, Equation 10's dimensionless k term, and dimensionless heat-redistribution factor f.

make_column method descriptor

make_column(T_surf, N_i_surf)

Construct a profile whose total gas reservoirs match prescribed columns.

This method repeatedly calls make_profile while solving for surface partial pressures. On success, make_column_P_guess is updated to the solved partial pressures.

Parameters:

Name Type Description Default
T_surf float

Surface temperature (K).

required
N_i_surf (ndarray, shape(ng))

Total gas reservoirs in species_names order (mol/cm^2), including atmospheric, surface, and ocean reservoirs.

required

make_profile method descriptor

make_profile(T_surf, P_i_surf)

Construct a multispecies pseudoadiabat connected to an isothermal stratosphere.

The pseudoadiabat follows Equation 1 of Graham et al. (2021, PSJ). Atmospheric state fields, particle profiles, reservoirs, lapse rates, and the convective mask are updated on success.

Parameters:

Name Type Description Default
T_surf float

Surface temperature (K).

required
P_i_surf (ndarray, shape(ng))

Surface partial pressures in species_names order (dyn/cm^2).

required

make_profile_bg_gas method descriptor

make_profile_bg_gas(T_surf, P_i_surf, P_surf, bg_gas)

Construct a profile with a named background gas and fixed surface pressure.

The background gas partial pressure is adjusted until the profile's total surface pressure equals P_surf. Other entries of P_i_surf are retained.

Parameters:

Name Type Description Default
T_surf float

Surface temperature (K).

required
P_i_surf (ndarray, shape(ng))

Initial surface partial pressures in species_names order (dyn/cm^2).

required
P_surf float

Target total surface pressure (dyn/cm^2).

required
bg_gas str

Background-gas name. It must occur in species_names.

required

make_profile_dry method descriptor

make_profile_dry(P, T, f_i)

Construct a dry atmosphere from prescribed pressure, temperature, and composition.

Condensation is not applied, so supersaturated gas is retained. All atmospheric state fields except P_trop and convecting_with_below are updated on success.

Parameters:

Name Type Description Default
P (ndarray, shape(n))

Pressure ordered from the surface upward (dyn/cm^2).

required
T (ndarray, shape(n))

Temperature defined on P (K).

required
f_i (ndarray, shape(n, ng))

Gas volume mixing ratios in species_names order.

required

out2atmosphere_txt method descriptor

out2atmosphere_txt(
    filename,
    eddy,
    number_of_decimals=5,
    overwrite=False,
    clip=True,
)

Write the current atmosphere in Photochem's legacy text format.

This method first calls to_regular_grid and therefore mutates the stored atmosphere, including when a later file validation or write error occurs. Output altitude is in km, pressure in bar, total gas density in molecules/cm^3, temperature in K, and eddy diffusion in cm^2/s.

Parameters:

Name Type Description Default
filename str

Output filename

required
eddy (ndarray, shape(nz))

Eddy diffusion to write (cm^2/s).

required
number_of_decimals int

Number of decimal places, from 2 through 17; by default 5.

5
overwrite bool

Allow replacement of an existing file, by default False.

False
clip bool

Clip output mixing ratios below 1.0e-40, by default True.

True

set_ocean_solubility_fcn method descriptor

set_ocean_solubility_fcn(species, fcn)

Set the solubility callback for an ocean made from a modeled species.

The callback receives surface temperature, the number of gases, gas partial pressures in bar, an output array for solubilities in mol/kg, and ocean_args_p. Keep the compiled callback alive while the model uses it.

Parameters:

Name Type Description Default
species str

Name of the species that makes up the ocean.

required
fcn cfunc or None

Compiled callback with C signature void(double, int32, double*, double*, void*). Pass None to clear the callback for this ocean.

required

set_particle_density_and_radii method descriptor

set_particle_density_and_radii(P, pdensities, pradii)

Set pressure-dependent particle number-density and radius profiles.

Inputs are retained as log-pressure interpolation functions and sampled onto the model grid whenever a profile is constructed. P must be strictly decreasing. Values outside its range are held at the nearest endpoint. Zero values are represented internally by a small positive floor.

Parameters:

Name Type Description Default
P (ndarray, shape(n))

Pressure grid (dyn/cm^2).

required
pdensities (ndarray, shape(n, numpy))

Particle number densities (particles/cm^3).

required
pradii (ndarray, shape(n, numpy))

Particle radii (cm).

required

surface_temperature method descriptor

surface_temperature(P_i_surf, T_guess=280.0)

Solve for radiative-equilibrium surface temperature using make_profile.

If solve_for_T_trop is true, the tropopause temperature is solved simultaneously. If tidally_locked_dayside is true, the dayside redistribution correction is included. The converged atmospheric and radiative state remains stored in the model.

Parameters:

Name Type Description Default
P_i_surf (ndarray, shape(ng))

Surface partial pressures in species_names order (dyn/cm^2).

required
T_guess float

Initial surface-temperature guess (K), by default 280.

280.0

Returns:

Type Description
float

Equilibrium surface temperature (K).

surface_temperature_bg_gas method descriptor

surface_temperature_bg_gas(
    P_i_surf, P_surf, bg_gas, T_guess=280.0
)

Solve for surface temperature with a background gas and fixed pressure.

Profile construction uses make_profile_bg_gas; other solver behavior matches surface_temperature.

Parameters:

Name Type Description Default
P_i_surf (ndarray, shape(ng))

Initial surface partial pressures in species_names order (dyn/cm^2).

required
P_surf float

Target total surface pressure (dyn/cm^2).

required
bg_gas str

The name of the background gas

required
T_guess float

Initial surface-temperature guess (K), by default 280.

280.0

Returns:

Type Description
float

Equilibrium surface temperature (K).

surface_temperature_column method descriptor

surface_temperature_column(N_i_surf, T_guess=280.0)

Solve for radiative-equilibrium surface temperature using make_column.

Other solver behavior matches surface_temperature.

Parameters:

Name Type Description Default
N_i_surf (ndarray, shape(ng))

Total gas reservoirs in species_names order (mol/cm^2).

required
T_guess float

Initial surface-temperature guess (K), by default 280.

280.0

Returns:

Type Description
float

Equilibrium surface temperature (K).

to_regular_grid method descriptor

to_regular_grid()

Regrid the current atmosphere to equal-width altitude layers.

Gas number densities are conservatively rebinned, temperature is interpolated, and pressure and mixing ratios are recomputed. This method mutates the stored grid and atmospheric state.

Radiative-transfer state

The radiative-transfer object is available as clima.rad. It is created and owned by AdiabatClimate; users should not construct it directly.

Radtran

Radtran(*args, **kwargs)

Non-owning view of an AdiabatClimate radiative-transfer model.

Obtain this object from AdiabatClimate.rad; it cannot be initialized independently. Keep the parent climate model alive while using this view. Array-valued properties return copies, while ir, sol, wrk_ir, and wrk_sol return nested non-owning views.

Initialize self. See help(type(self)) for accurate signature.

has_hard_surface property

has_hard_surface

bool: Whether to use the hard-surface lower thermal boundary condition.

False selects the gas-giant no-hard-surface diffusion boundary.

ir property

ir

RTChannel: Non-owning view of longwave spectral-grid metadata.

ir_tau_min property

ir_tau_min

float: Writable dimensionless thin-layer guard for longwave two-stream terms.

photon_scale_factor property

photon_scale_factor

float: Writable dimensionless multiplier applied to the stellar spectrum.

sol property

sol

RTChannel: Non-owning view of shortwave spectral-grid metadata.

surface_albedo property

surface_albedo

ndarray, shape (sol.nw,): Writable surface albedo in each solar bin.

Getting this property returns a copy; assign the complete array to update the model.

surface_emissivity property

surface_emissivity

ndarray, shape (ir.nw,): Writable surface emissivity in each longwave bin.

Getting this property returns a copy; assign the complete array to update the model.

wrk_ir property

wrk_ir

ClimaRadtranWrk: Non-owning view of current longwave results.

wrk_sol property

wrk_sol

ClimaRadtranWrk: Non-owning view of current shortwave results.

zenith_u property

zenith_u

ndarray, shape (n_zenith,): Writable cosines of solar zenith angles.

Getting this property returns a copy; assign the complete array to update the model.

bolometric_flux method descriptor

bolometric_flux()

Return the bolometric stellar flux at the planet.

Returns

float Bolometric flux (W/m^2)

equilibrium_temperature method descriptor

equilibrium_temperature(bond_albedo)

Return the planetary equilibrium temperature for a Bond albedo.

Parameters:

Name Type Description Default
bond_albedo float

Dimensionless Bond albedo.

required
Returns

float Equilibrium temperature (K).

opacities2yaml method descriptor

opacities2yaml()

Return a YAML fragment describing all configured model opacities.

Returns

str YAML opacity configuration.

set_bolometric_flux method descriptor

set_bolometric_flux(flux)

Set bolometric stellar flux by adjusting photon_scale_factor.

Parameters:

Name Type Description Default
flux float

Bolometric stellar flux at the planet (W/m^2).

required

set_custom_optical_properties method descriptor

set_custom_optical_properties(wv, P, dtau_dz, w0, g0)

Set pressure-dependent custom optical properties.

Pressure must be strictly decreasing and wavelength strictly increasing; both grids must be positive. The profiles are copied into interpolation data and included in subsequent opacity calculations.

Parameters:

Name Type Description Default
wv (ndarray, shape(n_wavelength))

Wavelengths (nm).

required
P (ndarray, shape(n_pressure))

Pressure grid (dyn/cm^2).

required
dtau_dz (ndarray, shape(n_pressure, n_wavelength))

Optical depth per altitude (1/cm).

required
w0 (ndarray, shape(n_pressure, n_wavelength))

Dimensionless single-scattering albedo.

required
g0 (ndarray, shape(n_pressure, n_wavelength))

Dimensionless asymmetry parameter.

required

skin_temperature method descriptor

skin_temperature(bond_albedo)

Return the radiative skin temperature for a Bond albedo.

Parameters:

Name Type Description Default
bond_albedo float

Dimensionless Bond albedo.

required
Returns

float Skin temperature (K).

unset_custom_optical_properties method descriptor

unset_custom_optical_properties()

Remove custom optical properties installed by set_custom_optical_properties.

Workspace arrays and longwave and shortwave channel metadata are available through clima.rad.wrk, clima.rad.lw, and clima.rad.sw.

ClimaRadtranWrk

ClimaRadtranWrk(*args, **kwargs)

Non-owning view of radiative-transfer results for one spectral channel.

Vertical index 0 is the lower boundary and index nz is the top-of-atmosphere boundary. Spectral indices follow the corresponding RTChannel bins. Obtain this object from Radtran.wrk_ir or Radtran.wrk_sol and keep the parent climate model alive while using it. Every property returns a copy.

Initialize self. See help(type(self)) for accurate signature.

amean property

amean

ndarray, shape (nz + 1, nw): Mean photon intensity (photons/cm^2/s).

This quantity is populated only for shortwave radiative transfer.

fdn_a property

fdn_a

ndarray, shape (nz + 1, nw): Downward spectral flux at boundaries (mW/m^2/Hz).

fdn_n property

fdn_n

ndarray, shape (nz + 1,): Spectrally integrated downward flux (mW/m^2).

fup_a property

fup_a

ndarray, shape (nz + 1, nw): Upward spectral flux at boundaries (mW/m^2/Hz).

fup_n property

fup_n

ndarray, shape (nz + 1,): Spectrally integrated upward flux (mW/m^2).

tau_band property

tau_band

ndarray, shape (nz, nw): Dimensionless band optical thickness.

RTChannel

RTChannel(*args, **kwargs)

Non-owning view of spectral-grid metadata for one radiative channel.

Obtain this object from Radtran.ir or Radtran.sol and keep the parent climate model alive while using it. Array-valued properties return copies.

Initialize self. See help(type(self)) for accurate signature.

freq property

freq

ndarray, shape (nw + 1,): Read-only copy of spectral-bin edges (Hz).

wavl property

wavl

ndarray, shape (nw + 1,): Read-only copy of spectral-bin edges (nm).

Rebinning utilities

rebin method descriptor

rebin(old_bins, old_vals, new_bins)

Rebin piecewise-constant values by overlap-weighted averaging.

This routine is optimized for down-binning, such as reducing the resolution of a spectrum. Both edge arrays must be strictly increasing. Portions of new bins outside the old-bin extent receive no contribution.

Parameters:

Name Type Description Default
old_bins (ndarray, shape(n_old + 1))

Original bin edges.

required
old_vals (ndarray, shape(n_old))

Piecewise-constant values in the original bins.

required
new_bins (ndarray, shape(n_new + 1))

Target bin edges.

required

Returns:

Type Description
(ndarray, shape(n_new))

Overlap-weighted values in the target bins.

Raises:

Type Description
ClimaException

If array lengths are inconsistent or either edge array is not strictly increasing.

rebin_with_errors method descriptor

rebin_with_errors(old_bins, old_vals, old_errs, new_bins)

Rebin piecewise-constant values and independent standard deviations.

Values use the same overlap-weighted averaging as rebin. Variances are propagated in quadrature. Unlike rebin, the target-bin extent must lie within the original-bin extent.

Parameters:

Name Type Description Default
old_bins (ndarray, shape(n_old + 1))

Original bin edges.

required
old_vals (ndarray, shape(n_old))

Piecewise-constant values in the original bins.

required
old_errs (ndarray, shape(n_old))

Nonnegative standard deviations in the original bins.

required
new_bins (ndarray, shape(n_new + 1))

Target bin edges.

required

Returns:

Type Description
tuple[ndarray, ndarray]

Re-binned values and standard deviations, each with shape (n_new,).

Raises:

Type Description
ClimaException

If shapes or bin extents are inconsistent, edges are not strictly increasing, or an input standard deviation is negative.