API Reference

Global States

The following functions are used to set and get global states in the Pyharp package.

species_names() list[str]

Retrieves the list of species names

species_weights() list[float]

Retrieves the list of species molecular weights [kg/mol]

shared() Iterator[tuple[str, torch.Tensor]]

Pyharp module deposits data – tensors – to a shared dictionary, which can be accessed by other modules. This function returns an iterator over the shared data.

After running the forward method of the RadiationBand, the shared data with the following keys are available:

Key

Description

“radiation/<band_name>/total_flux”

total flux in a band

Yields:

torch.Tensor – shared data of the pyharp module

Examples

>>> import pyharp
>>> import torch

# ... after calling the forward method

# loop over the shared data
>>> for data in pyharp.shared():
>>>     print(type(data), data.size())  # prints the shared data
set_search_paths(path: str) list[str]

Set the search paths for resource files.

Parameters:

path (str) – The search paths

Returns:

The search paths

Return type:

str

Example

>>> import pyharp

# set the search paths
>>> pyharp.set_search_paths("/path/to/resource/files")
get_search_paths() list[str]

Get the search paths for resource files.

Returns:

The search paths

Return type:

str

Example

>>> import pyharp

# get the search paths
>>> pyharp.get_search_paths()
find_resource(filename: str) str

Find a resource file from the search paths.

Parameters:

filename (str) – The name of the resource file.

Returns:

The full path to the resource file.

Return type:

str

Example

>>> import pyharp

# find a resource file
>>> path = pyharp.find_resource("example.txt")
>>> print(path)  # /path/to/resource/files/example.txt

Radiation Classes

The following classes are used to configure and compute radiative transfer.

class RadiationOptions
bands(*args, **kwargs)

Overloaded function.

  1. bands(self: pyharp.RadiationOptions) -> dict[str, pyharp.RadiationBandOptions]

Set radiation band options

Parameters:

bands (dict[str,RadiationBandOptions]) – radiation band options

Returns:

class object if argument is not empty, otherwise the radiation band options

Return type:

RadiationOptions | dict[str,RadiationBandOptions]

Examples

>>> import torch
>>> from pyharp import RadiationOptions
>>> op = RadiationOptions().bands({'band1': 'outdir1', 'band2': 'outdir2'})
>>> print(op)
  1. bands(self: pyharp.RadiationOptions, arg0: dict[str, pyharp.RadiationBandOptions]) -> pyharp.RadiationOptions

Set radiation band options

Parameters:

bands (dict[str,RadiationBandOptions]) – radiation band options

Returns:

class object if argument is not empty, otherwise the radiation band options

Return type:

RadiationOptions | dict[str,RadiationBandOptions]

Examples

>>> import torch
>>> from pyharp import RadiationOptions
>>> op = RadiationOptions().bands({'band1': 'outdir1', 'band2': 'outdir2'})
>>> print(op)
static from_yaml(filename: str) pyharp.RadiationOptions

Create a pyharp.RadiationOptions object from a YAML file

Parameters:

filename (str) – YAML file name

Returns:

class object

Return type:

RadiationOptions

Examples

>>> import torch
>>> from pyharp import RadiationOptions
>>> op = RadiationOptions.from_yaml('radiation.yaml')
outdirs(*args, **kwargs)

Overloaded function.

  1. outdirs(self: pyharp.RadiationOptions) -> str

Set outgoing ray directions

Parameters:

outdirs (str) – outgoing ray directions

Returns:

class object if argument is not empty, otherwise the outgoing ray directions

Return type:

RadiationOptions | str

Examples

>>> import torch
>>> from pyharp import RadiationOptions
>>> op = RadiationOptions().outdirs('(0, 10), (0, 20)')
>>> print(op)
  1. outdirs(self: pyharp.RadiationOptions, arg0: str) -> pyharp.RadiationOptions

Set outgoing ray directions

Parameters:

outdirs (str) – outgoing ray directions

Returns:

class object if argument is not empty, otherwise the outgoing ray directions

Return type:

RadiationOptions | str

Examples

>>> import torch
>>> from pyharp import RadiationOptions
>>> op = RadiationOptions().outdirs('(0, 10), (0, 20)')
>>> print(op)
class RadiationBandOptions
disort(*args, **kwargs)

Overloaded function.

  1. disort(self: pyharp.RadiationBandOptions) -> disort::DisortOptions

Set or get disort options

Parameters:

disort (pydisort.DisortOptions) – disort options

Returns:

class object if argument is not empty, otherwise the disort options

Return type:

RadiationBandOptions | pydisort.DisortOptions

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> from pydisort import DisortOptions
>>> op = RadiationBandOptions().disort(DisortOptions().nwave(10))
>>> print(op)
  1. disort(self: pyharp.RadiationBandOptions, arg0: disort::DisortOptions) -> pyharp.RadiationBandOptions

Set or get disort options

Parameters:

disort (pydisort.DisortOptions) – disort options

Returns:

class object if argument is not empty, otherwise the disort options

Return type:

RadiationBandOptions | pydisort.DisortOptions

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> from pydisort import DisortOptions
>>> op = RadiationBandOptions().disort(DisortOptions().nwave(10))
>>> print(op)
integration(*args, **kwargs)

Overloaded function.

  1. integration(self: pyharp.RadiationBandOptions) -> str

Set or get integration method

Parameters:

integration (str) – integration method

Returns:

class object if argument is not empty, otherwise the integration method

Return type:

RadiationBandOptions | str

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().integration('simpson')
>>> print(op)
  1. integration(self: pyharp.RadiationBandOptions, arg0: str) -> pyharp.RadiationBandOptions

Set or get integration method

Parameters:

integration (str) – integration method

Returns:

class object if argument is not empty, otherwise the integration method

Return type:

RadiationBandOptions | str

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().integration('simpson')
>>> print(op)
name(*args, **kwargs)

Overloaded function.

  1. name(self: pyharp.RadiationBandOptions) -> str

Set or get radiation band name

Parameters:

name (str) – radiation band name

Returns:

class object if argument is not empty, otherwise the band name

Return type:

RadiationBandOptions | str

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().name('band1')
>>> print(op)
  1. name(self: pyharp.RadiationBandOptions, arg0: str) -> pyharp.RadiationBandOptions

Set or get radiation band name

Parameters:

name (str) – radiation band name

Returns:

class object if argument is not empty, otherwise the band name

Return type:

RadiationBandOptions | str

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().name('band1')
>>> print(op)
opacities(*args, **kwargs)

Overloaded function.

  1. opacities(self: pyharp.RadiationBandOptions) -> dict[str, pyharp.opacity.AttenuatorOptions]

Set or get opacities

Parameters:

opacities (dict[str,AttenuatorOptions]) – opacities

Returns:

class object if argument is not empty, otherwise the attenuator options

Return type:

RadiationBandOptions | dict[str,AttenuatorOptions]

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().opacities({'band1': 'opacity1', 'band2': 'opacity2'})
>>> print(op)
  1. opacities(self: pyharp.RadiationBandOptions, arg0: dict[str, pyharp.opacity.AttenuatorOptions]) -> pyharp.RadiationBandOptions

Set or get opacities

Parameters:

opacities (dict[str,AttenuatorOptions]) – opacities

Returns:

class object if argument is not empty, otherwise the attenuator options

Return type:

RadiationBandOptions | dict[str,AttenuatorOptions]

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().opacities({'band1': 'opacity1', 'band2': 'opacity2'})
>>> print(op)
outdirs(*args, **kwargs)

Overloaded function.

  1. outdirs(self: pyharp.RadiationBandOptions) -> str

Set or get outgoing ray directions

Parameters:

outdirs (str) – outgoing ray directions

Returns:

class object if argument is not empty, otherwise the outgoing ray directions

Return type:

RadiationBandOptions | str

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().outdirs('(0, 10), (0, 20)')
>>> print(op)
  1. outdirs(self: pyharp.RadiationBandOptions, arg0: str) -> pyharp.RadiationBandOptions

Set or get outgoing ray directions

Parameters:

outdirs (str) – outgoing ray directions

Returns:

class object if argument is not empty, otherwise the outgoing ray directions

Return type:

RadiationBandOptions | str

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().outdirs('(0, 10), (0, 20)')
>>> print(op)
query_waves(self: pyharp.RadiationBandOptions, op_name: str = '') list[float]

Query the spectral grids

Parameters:

op_name (str) – opacity name

Returns:

spectral grids

Return type:

list[float]

Examples

>>> import torch
>>> from pyharp import RadiationOptions
>>> op = RadiationOptions().query_waves()
query_weights(self: pyharp.RadiationBandOptions, op_name: str = '') list[float]

Query the weights

Parameters:

op_name (str) – opacity name

Returns:

weights

Return type:

list[float]

Examples

>>> import torch
>>> from pyharp import RadiationOptions
>>> op = RadiationOptions().query_weights()
solver_name(*args, **kwargs)

Overloaded function.

  1. solver_name(self: pyharp.RadiationBandOptions) -> str

Set or get solver name

Parameters:

solver_name (str) – solver name

Returns:

class object if argument is not empty, otherwise the solver name

Return type:

RadiationBandOptions | str

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().solver_name('disort')
>>> print(op)
  1. solver_name(self: pyharp.RadiationBandOptions, arg0: str) -> pyharp.RadiationBandOptions

Set or get solver name

Parameters:

solver_name (str) – solver name

Returns:

class object if argument is not empty, otherwise the solver name

Return type:

RadiationBandOptions | str

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().solver_name('disort')
>>> print(op)
ww(*args, **kwargs)

Overloaded function.

  1. ww(self: pyharp.RadiationBandOptions) -> list[float]

Set or get wavelength, wavenumber or weights for a wave grid

Parameters:

ww (list[float]) – wavenumbers/wavelengths/weights

Returns:

class object if argument is not empty, otherwise the wavenumbers/wavelengths/weights

Return type:

pyharp.RadiationBandOptions | list[float]

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().ww([1.0, 2.0, 3.0])
>>> print(op)
  1. ww(self: pyharp.RadiationBandOptions, arg0: list[float]) -> pyharp.RadiationBandOptions

Set or get wavelength, wavenumber or weights for a wave grid

Parameters:

ww (list[float]) – wavenumbers/wavelengths/weights

Returns:

class object if argument is not empty, otherwise the wavenumbers/wavelengths/weights

Return type:

pyharp.RadiationBandOptions | list[float]

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().ww([1.0, 2.0, 3.0])
>>> print(op)
class RadiationBand
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyharp.cpp.RadiationBand) -> None

Construct a new default module.

  1. __init__(self: pyharp.cpp.RadiationBand, options: pyharp.RadiationBandOptions) -> None

Construct a RadiationBand module

forward(*args, **kwargs)

Overloaded function.

  1. forward(self: pyharp.cpp.RadiationBand, arg0: torch.Tensor, arg1: torch.Tensor, arg2: dict[str, torch.Tensor], arg3: dict[str, torch.Tensor]) -> torch.Tensor

  2. forward(self: pyharp.cpp.RadiationBand, conc: torch.Tensor, dz: torch.Tensor, bc: dict[str, torch.Tensor], kwargs: dict[str, torch.Tensor]) -> torch.Tensor

Calculate the net radiation flux for a band

Parameters:
Returns:

[W/m^2] (ncol, nlyr+1)

Return type:

torch.Tensor

Examples

>>> import torch
>>> from pyharp import RadiationBandOptions
>>> op = RadiationBandOptions().band_options(['band1', 'band2'])
class Radiation
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyharp.cpp.Radiation) -> None

Construct a new default module.

  1. __init__(self: pyharp.cpp.Radiation, options: pyharp.RadiationOptions) -> None

Construct a Radiation module

forward(*args, **kwargs)

Overloaded function.

  1. forward(self: pyharp.cpp.Radiation, arg0: torch.Tensor, arg1: torch.Tensor, arg2: dict[str, torch.Tensor], arg3: dict[str, torch.Tensor]) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]

  2. forward(self: pyharp.cpp.Radiation, conc: torch.Tensor, dz: torch.Tensor, bc: dict[str, torch.Tensor], kwargs: dict[str, torch.Tensor]) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]

Calculate the net radiation flux

Parameters:
Returns:

net flux [w/m^2]

Return type:

torch.Tensor

Examples

>>> import torch
>>> from pyharp import RadiationOptions
>>> op = RadiationOptions().band_options(['band1', 'band2'])

Opacity Classes

class AttenuatorOptions
bname(*args, **kwargs)

Overloaded function.

  1. bname(self: pyharp.opacity.AttenuatorOptions) -> str

Set or get the name of the band that the opacity is associated with

Parameters:

bname (str) – name of the band that the opacity is associated with

Returns:

class object if argument is not empty, otherwise the band name

Return type:

AttenuatorOptions | str

Examples

>>> import torch
>>> from pyharp.opacity import AttenuatorOptions
>>> op = AttenuatorOptions().bname('band1')
  1. bname(self: pyharp.opacity.AttenuatorOptions, arg0: str) -> pyharp.opacity.AttenuatorOptions

Set or get the name of the band that the opacity is associated with

Parameters:

bname (str) – name of the band that the opacity is associated with

Returns:

class object if argument is not empty, otherwise the band name

Return type:

AttenuatorOptions | str

Examples

>>> import torch
>>> from pyharp.opacity import AttenuatorOptions
>>> op = AttenuatorOptions().bname('band1')
fractions(*args, **kwargs)

Overloaded function.

  1. fractions(self: pyharp.opacity.AttenuatorOptions) -> list[float]

Set or get fractions of species in cia calculatioin

Parameters:

fractions (list[float]) – list of species fractions

Returns:

class object if argument is not empty, otherwise the list of species fractions

Return type:

AttenuatorOptions | list[float]

Examples

>>> import torch
>>> from pyharp.opacity import AttenuatorOptions
>>> op = AttenuatorOptions().fractions([0.9, 0.1])
  1. fractions(self: pyharp.opacity.AttenuatorOptions, arg0: list[float]) -> pyharp.opacity.AttenuatorOptions

Set or get fractions of species in cia calculatioin

Parameters:

fractions (list[float]) – list of species fractions

Returns:

class object if argument is not empty, otherwise the list of species fractions

Return type:

AttenuatorOptions | list[float]

Examples

>>> import torch
>>> from pyharp.opacity import AttenuatorOptions
>>> op = AttenuatorOptions().fractions([0.9, 0.1])
opacity_files(*args, **kwargs)

Overloaded function.

  1. opacity_files(self: pyharp.opacity.AttenuatorOptions) -> list[str]

Set or get the list of opacity data files

Parameters:

opacity_files (list) – list of opacity data files

Returns:

class object if argument is not empty, otherwise the list of opacity data files

Return type:

AttenuatorOptions | list[str]

Examples

>>> import torch
>>> from pyharp.opacity import AttenuatorOptions
>>> op = AttenuatorOptions().opacity_files(['file1', 'file2'])
  1. opacity_files(self: pyharp.opacity.AttenuatorOptions, arg0: list[str]) -> pyharp.opacity.AttenuatorOptions

Set or get the list of opacity data files

Parameters:

opacity_files (list) – list of opacity data files

Returns:

class object if argument is not empty, otherwise the list of opacity data files

Return type:

AttenuatorOptions | list[str]

Examples

>>> import torch
>>> from pyharp.opacity import AttenuatorOptions
>>> op = AttenuatorOptions().opacity_files(['file1', 'file2'])
species_ids(*args, **kwargs)

Overloaded function.

  1. species_ids(self: pyharp.opacity.AttenuatorOptions) -> list[int]

Set or get the list of dependent species indices

Parameters:

species_ids (list[int]) – list of dependent species indices

Returns:

class object if argument is not empty, otherwise the list of dependent species indices

Return type:

AttenuatorOptions | list[int]

Examples

>>> import torch
>>> from pyharp.opacity import AttenuatorOptions
>>> op = AttenuatorOptions().species_ids([1, 2])
  1. species_ids(self: pyharp.opacity.AttenuatorOptions, arg0: list[int]) -> pyharp.opacity.AttenuatorOptions

Set or get the list of dependent species indices

Parameters:

species_ids (list[int]) – list of dependent species indices

Returns:

class object if argument is not empty, otherwise the list of dependent species indices

Return type:

AttenuatorOptions | list[int]

Examples

>>> import torch
>>> from pyharp.opacity import AttenuatorOptions
>>> op = AttenuatorOptions().species_ids([1, 2])
type(*args, **kwargs)

Overloaded function.

  1. type(self: pyharp.opacity.AttenuatorOptions) -> str

Set or get the type of the opacity source format

Valid options are:

Key

Description

‘rfm-lbl’

Line-by-line absorption data computed by RFM

‘rfm-ck’

Correlated-k absorption computed from line-by-line data

‘multiband-ck’

Multi-band opacity data from saved torch “.pt” file

‘fourcolumn’

Four-column opacity data (wavelength [um]/wavenumber [cm^{-1}], cross-section [m^2/kg], ssa, g)

Parameters:

type (str) – type of the opacity source

Returns:

class object if argument is not empty, otherwise the type

Return type:

AttenuatorOptions | str

Examples

>>> import torch
>>> from pyharp.opacity import AttenuatorOptions
>>> op = AttenuatorOptions().type('rfm-lbl')
>>> print(op)
  1. type(self: pyharp.opacity.AttenuatorOptions, arg0: str) -> pyharp.opacity.AttenuatorOptions

Set or get the type of the opacity source format

Valid options are:

Key

Description

‘rfm-lbl’

Line-by-line absorption data computed by RFM

‘rfm-ck’

Correlated-k absorption computed from line-by-line data

‘multiband-ck’

Multi-band opacity data from saved torch “.pt” file

‘fourcolumn’

Four-column opacity data (wavelength [um]/wavenumber [cm^{-1}], cross-section [m^2/kg], ssa, g)

Parameters:

type (str) – type of the opacity source

Returns:

class object if argument is not empty, otherwise the type

Return type:

AttenuatorOptions | str

Examples

>>> import torch
>>> from pyharp.opacity import AttenuatorOptions
>>> op = AttenuatorOptions().type('rfm-lbl')
>>> print(op)
class FourColumn
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyharp.opacity.cpp.FourColumn) -> None

Construct a new default module.

  1. __init__(self: pyharp.opacity.cpp.FourColumn, options: pyharp.opacity.AttenuatorOptions) -> None

Construct a FourColumn module

forward(*args, **kwargs)

Overloaded function.

  1. forward(self: pyharp.opacity.cpp.FourColumn, arg0: torch.Tensor, arg1: dict[str, torch.Tensor]) -> torch.Tensor

  2. forward(self: pyharp.opacity.cpp.FourColumn, conc: torch.Tensor, kwargs: dict[str, torch.Tensor]) -> torch.Tensor

Four-column opacity data

Parameters:
  • conc (torch.Tensor) – concentration of the species in mol/cm^3

  • kwargs (dict[str, torch.Tensor]) – keyword arguments. Either ‘wavelength’ or ‘wavenumber’ must be provided if ‘wavelength’ is provided, the unit is um. if ‘wavenumber’ is provided, the unit is cm^-1.

Returns:

attenuation [1/m], single scattering albedo and scattering phase function The shape of the output tensor is (nwave, ncol, nlyr, 2 + nmom) where nwave is the number of wavelengths, ncol is the number of columns, nlyr is the number of layers, 2 is for attenuation and scattering coefficients, and nmom is the number of scattering moments.

Return type:

torch.Tensor

Examples

>>> import torch
>>> from pyharp.opacity import FourColumn, AttenuatorOptions
>>> op = FourColumn(AttenuatorOptions())
class MultiBand
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyharp.opacity.cpp.MultiBand) -> None

Construct a new default module.

  1. __init__(self: pyharp.opacity.cpp.MultiBand, options: pyharp.opacity.AttenuatorOptions) -> None

Construct a MultiBand module

forward(*args, **kwargs)

Overloaded function.

  1. forward(self: pyharp.opacity.cpp.MultiBand, arg0: torch.Tensor, arg1: dict[str, torch.Tensor]) -> torch.Tensor

  2. forward(self: pyharp.opacity.cpp.MultiBand, conc: torch.Tensor, kwargs: dict[str, torch.Tensor]) -> torch.Tensor

Multi-band opacity data

Parameters:
  • conc (torch.Tensor) – concentration of the species in mol/cm^3

  • kwargs (dict[str, torch.Tensor]) – keyword arguments. Both ‘temp’ [k] and ‘pres’ [pa] must be provided

Returns:

attenuation [1/m], single scattering albedo and scattering phase function The shape of the output tensor is (nwave, ncol, nlyr, 1) where nwave is the number of wavelengths, ncol is the number of columns, nlyr is the number of layers, 1 is for attenuation coefficients, and nmom is the number of scattering moments.

Return type:

torch.Tensor

Examples

>>> import torch
>>> from pyharp.opacity import MultiBand, AttenuatorOptions
>>> op = MultiBand(AttenuatorOptions())
class WaveTemp
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyharp.opacity.cpp.WaveTemp) -> None

Construct a new default module.

  1. __init__(self: pyharp.opacity.cpp.WaveTemp, options: pyharp.opacity.AttenuatorOptions) -> None

Construct a WaveTemp module

forward(*args, **kwargs)

Overloaded function.

  1. forward(self: pyharp.opacity.cpp.WaveTemp, arg0: torch.Tensor, arg1: dict[str, torch.Tensor]) -> torch.Tensor

  2. forward(self: pyharp.opacity.cpp.WaveTemp, conc: torch.Tensor, kwargs: dict[str, torch.Tensor]) -> torch.Tensor

Wave-Temp opacity data

Parameters:
  • conc (torch.Tensor) – concentration of the species in mol/cm^3

  • kwargs (dict[str, torch.Tensor]) – keyword arguments. Both ‘temp’ [k] and (‘wavenumber’ [cm^{-1}] or ‘wavelength’ [num]) must be provided

Returns:

attenuation [1/m], single scattering albedo and scattering phase function The shape of the output tensor is (nwave, ncol, nlyr, 1) where nwave is the number of wavelengths, ncol is the number of columns, nlyr is the number of layers, 1 is for attenuation coefficients, and nmom is the number of scattering moments.

Return type:

torch.Tensor

Examples

>>> import torch
>>> from pyharp.opacity import WaveTemp, AttenuatorOptions
>>> op = MultiBand(AttenuatorOptions())
class RFM
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyharp.opacity.cpp.RFM) -> None

Construct a new default module.

  1. __init__(self: pyharp.opacity.cpp.RFM, options: pyharp.opacity.AttenuatorOptions) -> None

Construct a RFM module

forward(*args, **kwargs)

Overloaded function.

  1. forward(self: pyharp.opacity.cpp.RFM, arg0: torch.Tensor, arg1: dict[str, torch.Tensor]) -> torch.Tensor

  2. forward(self: pyharp.opacity.cpp.RFM, conc: torch.Tensor, kwargs: dict[str, torch.Tensor]) -> torch.Tensor

Line-by-line absorption data computed by RFM

Parameters:
  • conc (torch.Tensor) – concentration of the species in mol/cm^3

  • kwargs (dict[str, torch.Tensor]) – keyword arguments Either ‘wavelength’ or ‘wavenumber’ must be provided if ‘wavelength’ is provided, the unit is nm. if ‘wavenumber’ is provided, the unit is cm^-1.

Returns:

attenuation [1/m], single scattering albedo and scattering phase function

The shape of the output tensor is (nwave, ncol, nlyr, 2 + nmom) where nwave is the number of wavelengths, ncol is the number of columns, nlyr is the number of layers, 2 is for attenuation and scattering coefficients, and nmom is the number of moments.

Return type:

torch.Tensor

Examples

>>> import torch
>>> from pyharp.opacity import RFM, AttenuatorOptions
>>> op = RFM(AttenuatorOptions())

Helper Functions

The following functions are auxiliary (helper) functions frequently used in radiative transfer problems.

bbflux_wavenumber(*args, **kwargs)

Overloaded function.

  1. bbflux_wavenumber(wave: torch.Tensor, temp: float, ncol: int = 1) -> torch.Tensor

Calculate blackbody flux using wavenumber

Parameters:
Returns:

blackbody flux [w/(m^2 cm^-1)]

Return type:

torch.Tensor

Examples

>>> import torch
>>> from pyharp import bbflux_wavenumber

>>> wave = torch.tensor([1.0, 2.0, 3.0])
>>> temp = 300.0
>>> flux = bbflux_wavenumber(wave, temp)
  1. bbflux_wavenumber(wn1: float, wn2: float, temp: torch.Tensor = 1) -> torch.Tensor

Calculate blackbody flux using wavenumber

Parameters:
  • wn1 (float) – wavenumber [cm^-1]

  • wn2 (float) – temperature [K]

  • temp (torch.Tensor) – number of columns, default to 1

Returns:

blackbody flux [w/(m^2 cm^-1)]

Return type:

torch.Tensor

Examples

bbflux_wavelength(wave: torch.Tensor, temp: float, ncol: int = 1) torch.Tensor

Calculate blackbody flux using wavelength

Parameters:
  • wave (torch.Tensor) – wavelength [um]

  • temp (float) – temperature [K]

  • ncol (int, optional) – number of columns, default to 1

Returns:

blackbody flux [w/(m^2 um^-1)]

Return type:

torch.Tensor

Examples

>>> from pyharp import bbflux_wavelength
>>> wave = torch.tensor([1.0, 2.0, 3.0])
>>> temp = 300.0
>>> flux = bbflux_wavelength(wave, temp)
calc_dz_hypsometric(pres: torch.Tensor, temp: torch.Tensor, g_ov_R: torch.Tensor) torch.Tensor

Calculate the height between pressure levels using the hypsometric equation

\[dz = \frac{R}{g} \cdot T \cdot \ln\left(\frac{p_1}{p_2}\right)\]

where \(R\) is the specific gas constant, \(g\) is the gravity, \(T\) is the temperature, \(p_1\) and \(p_2\) are the pressure levels.

Parameters:
Returns:

height between pressure levels [m]

Return type:

torch.Tensor

Examples

>>> from pyharp import calc_dz_hypsometric
>>> pres = torch.tensor([1.0, 2.0, 3.0])
>>> temp = torch.tensor([300.0, 310.0, 320.0])
>>> g_ov_R = torch.tensor([1.0, 2.0, 3.0])
>>> dz = calc_dz_hypsometric(pres, temp, g_ov_R)
interpn(query: list[torch.Tensor], coords: list[torch.Tensor], lookup: torch.Tensor, extrapolate: bool = False) torch.Tensor

Multidimensional linear interpolation

Parameters:
  • query_coords (list[torch.Tensor]) – Query coordinates

  • coords (list[torch.Tensor]) – Coordinate arrays, len = ndim, each tensor has shape (nx1,), (nx2,) …

  • lookup (torch.Tensor) – Lookup tensor (nx1, nx2, …, nval)

Examples

>>> import torch
>>> from pyharp import interpn
>>> query = [torch.tensor([0.5]), torch.tensor([0.5])]
>>> coords = [torch.tensor([0.0, 1.0]), torch.tensor([0.0, 1.0])]
>>> lookup = torch.tensor([[1.0, 2.0], [3.0, 4.0]])
>>> interpn(query, coords, lookup)
tensor(2.5000)