amwrap

Wrapper for Scott Paine’s AM atmospheric radiative transfer code.

The Model class provides an interface for configuring and running AM for specified model atmospheric conditions. A model can be initialized from arrays assigned units from astropy.units or constructed from a standard climatology.

Typical usage example:
m = Model.from_climatology("midlatitude_winter")
m.troposphere_h2o_scaling = 0.8
df = m.run()
print(df.attrs["warnings?"])
class AmExecutable(name)

Bases: object

bin_dir = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/amwrap/envs/latest/lib/python3.10/site-packages/amwrap/bin')
mixing_ratio_from_relative_humidity(pressure: Quantity, PhysicalType({'energy density', 'pressure', 'stress'})], temperature: Annotated[Quantity, Unit('deg_C')] | Annotated[Quantity, PhysicalType('temperature')], relative_humidity: Annotated[Quantity, PhysicalType('dimensionless')])
precipitable_water(pressure: Quantity, PhysicalType({'energy density', 'pressure', 'stress'})], temperature: Annotated[Quantity, Unit('deg_C')] | Annotated[Quantity, PhysicalType('temperature')], relative_humidity: Annotated[Quantity, PhysicalType('dimensionless')])
altitude_from_pressure(pressure: Quantity, PhysicalType({'energy density', 'pressure', 'stress'})])

Convert pressure to height using the U.S. Standard Atmosphere (NOAA 1976). Implementation taken from metpy.calc.pressure_height_std itself from the formula outlined in Hobbs & Wallace (1977) pg. 60-61.

interp_by_pressure(values, pressure: Quantity, PhysicalType({'energy density', 'pressure', 'stress'})] | None = None, pressure_base: Quantity, PhysicalType({'energy density', 'pressure', 'stress'})] | None = None)
class Climatology(name: str = 'midlatitude_winter', pressure_base: Quantity, PhysicalType({'energy density', 'pressure', 'stress'})] | None = None)

Bases: object

Standard atmospheric vertical profiles for the US and North America as reported in Anderson et al. (1986) “AFGL Atmospheric Constituent Profiles (0-120km)”, AFGL-TR-86-0110.

Args:
name: str

Name of the climatology, e.g., “midlatitude_winter”.

pressure_base:

Mask the profiles for pressure values less than the given value. Profiles range from 1018 to 3.6e-5 hPa.

names = ('midlatitude_summer', 'midlatitude_winter', 'subarctic_summer', 'subarctic_winter', 'tropical', 'us_standard')
classmethod midlat_from_datetime(dt)
property pwv
column_density(specie)

Use the Ideal Gas Law to calculate air volume density and then use a trapezoidal sum to integrate the volume density as a function of altitude.

dobson_unit(specie)

The Dobson unit (DU) is defined as the thickness (in units of 10 μm) of that layer of pure gas which would be formed by the total column amount at standard conditions for temperature and pressure (STP).

class Model(pressure: ~astropy.units.quantity.Annotated[~astropy.units.quantity.Quantity, PhysicalType({'energy density', 'pressure', 'stress'})], temperature: ~astropy.units.quantity.Annotated[~astropy.units.quantity.Quantity, Unit("deg_C")] | ~astropy.units.quantity.Annotated[~astropy.units.quantity.Quantity, PhysicalType('temperature')], mixing_ratio: ~typing.Dict[str, ~astropy.units.quantity.Annotated[~astropy.units.quantity.Quantity, PhysicalType('dimensionless')] | None] | None = None, water_cloud: ~astropy.units.quantity.Annotated[~astropy.units.quantity.Quantity, PhysicalType('surface mass density')] | None = None, ice_cloud: ~astropy.units.quantity.Annotated[~astropy.units.quantity.Quantity, PhysicalType('surface mass density')] | None = None, zenith_angle: ~astropy.units.quantity.Annotated[~astropy.units.quantity.Quantity, PhysicalType('angle')] = <Quantity 0. deg>, freq_min: ~astropy.units.quantity.Annotated[~astropy.units.quantity.Quantity, PhysicalType('frequency')] = <Quantity 18. GHz>, freq_max: ~astropy.units.quantity.Annotated[~astropy.units.quantity.Quantity, PhysicalType('frequency')] = <Quantity 26.5 GHz>, freq_step: ~astropy.units.quantity.Annotated[~astropy.units.quantity.Quantity, PhysicalType('frequency')] = <Quantity 10. MHz>, troposphere_h2o_scaling=1.0, output_columns=('frequency', 'brightness temperature', 'opacity', 'delay'), tolerance=0.0001, self_broadening_tolerance=0.003)

Bases: object

AM model configuration.

Attributes:
background_temperature:

Background brightness temperature. By default set to the temperature of the Cosmic Microwave Background.

valid_output_descriptors:

Map of valid AM output columns and default units.

Initialize directly from array data of atmospheric properties. Mixing ratios are scaled to unity (not parts per million), and should range between 0 and 1.

Args:
pressure:

Atmospheric pressure at the base of the layer.

temperature:

Atmospheric temperature at the base of the layer.

mixing_ratio:

Dictionary of volumetric mixing ratios indexed by a string for a specie name recognized by AM. If a specie is set to None, then values are interpolated from the US Standard climatology.

water_cloud:

Liquid water cloud mass surface density at the base of the layer.

ice_cloud:

Ice water cloud mass surface density at the base of the layer.

zenith_angle:

Zenith angle of ray; 0 deg is towards zenith and 90 deg is towards the horizon.

freq_min:

Minimum frequency to compute output values over.

freq_max:

Maximum frequency to compute output values over.

freq_step:

Frequency step or “channel” size to compute output values over.

troposphere_h2o_scaling:

Scale the tropospheric water mixing ratio by this factor.

output_columns:

Values to calculate as part of the returned output. See available output columns in the valid_output_descriptors class attribute.

tolerance:

Numerical tolerance of line-by-line absorption coefficient computations. If set to zero, each line is computed over the entire frequency range.

self_broadening_tolerance:

Numerical tolerance for the self-broadening approximation described in S2.3.1 of the AM manual.

background_temperature = <Quantity 2.725 K>
valid_output_descriptors = {'Rayleigh-Jeans brightness temperature': 'Trj K', 'absorption coefficient': 'k auto', 'brightness temperature': 'Tb K', 'delay': 'L mm', 'frequency': 'f GHz', 'opacity': 'tau neper', 'radiance': 'I watt*cm-2*GHz-1*sr-1', 'radiance difference': 'I_diff watt*cm-2*GHz-1*sr-1', 'transmittance': 'tx none'}
valid_species = ['ch4', '12ch4', '13ch4', '12ch3d', 'ch3cn', '12ch3_12c14n', 'ch3oh', '12ch3_16oh', 'co', '12c_16o', '13c_16o', '12c_18o', '12c_17o', '13c_18o', '13c_17o', 'co2', '12c_16o2', '13c_16o2', '16o_12c_18o', '16o_12c_17o', '16o_13c_18o', '16o_13c_17o', '12c_18o2', 'clo', '35cl_16o', '37cl_16o', 'hbr', 'h_79br', 'h_81br', 'hcn', 'h_12c_14n', 'h_13c_14n', 'h_12c_15n', 'h2co', 'h2_12c_16o', 'h2_13c_16o', 'h2_12c_18o', 'hcl', 'h_35cl', 'h_37cl', 'hf', 'h_19f', 'hno3', 'h_14n_16o3', 'h2o', 'h2o_lines', 'h2_16o', 'h2_18o', 'h2_17o', 'hd_16o', 'hd_18o', 'hd_17o', 'h2o2', 'h2_16o2', 'ho2', 'h_16o2', 'hocl', 'h_16o_35cl', 'h_16o_37cl', 'h2s', 'h2_32s', 'h2_34s', 'h2_33s', 'nh3', '14nh3', '15nh3', 'n2o', '14n2_16o', '14n_15n_16o', '15n_14n_16o', '14n2_18o', '14n2_17o', 'no', '14n_16o', 'no2', '14n_16o2', 'o', '16o', 'o2', 'o2_coupled', '16o2_coupled', '16o2', '16o_18o', '16o_17o', 'o2_uncoupled', '16o2_uncoupled', '16o_18o_uncoupled', '16o_17o_uncoupled', 'o3', '16o3', '16o2_18o', '16o_18o_16o', '16o2_17o', '16o_17o_16o', 'ocs', '16o_12c_32s', '16o_12c_34s', '16o_13c_32s', '16o_12c_33s', '18o_12c_32s', 'oh', '16oh', '18oh', '16od', 'so2', '32s_16o2', '34s_16o2', 'h2o_continuum', 'h2o_air_continuum', 'h2o_self_continuum', 'n2n2', 'n2air', 'o2o2', 'o2air', 'lwp_abs_Rayleigh', 'iwp_abs_Rayleigh']
water_cloud_type = 'lwp_abs_Rayleigh'
ice_cloud_type = 'iwp_abs_Rayleigh'
classmethod from_climatology(clim: str | Climatology, **kwargs)
property output_units
property altitude
property output_descriptor
property increasing_pressure_order
property config_text

AM configuration text. The Voigt-Kielkopf lineshape is used for pressures less than 1 mbar.

Layers are labeled by pressure for: - thermosphere less than 0.01 mbar - mesosphere from 0.01 to 0.1 mbar - stratosphere from 1 to 100 mbar - troposphere greater than 100 mbar

write_config(outname='output', ext='amc')
run(parallel=False, cache_dir=None)

Execute AM for the given configuration.

Args:
parallel:

Whether to call an AM executable that has been compiled for serial computations or multi-threaded parallel computation using OpenMP.

cache_dir:

Override the AM disk cache directory for this run, setting AM_CACHE_PATH to the given path in the subprocess environment. Useful for isolating cache directories across parallel worker processes to avoid file-locking contention.

Returns:

pandas.DataFrame of the output with other metadata set in the attrs attribute. Metadata includes output from STDERR, whether warnings were raised, and the units for each output column.