Helper Functions
The following functions are auxiliary (helper) functions frequently used in radiative transfer problems.
- bbflux_wavenumber(*args, **kwargs)
Overloaded function.
bbflux_wavenumber(wave: torch.Tensor, temp: float, ncol: int = 1) -> torch.Tensor
Calculate blackbody flux using wavenumber
- Parameters:
wave (torch.Tensor) – wavenumber [cm^-1]
temp (float) – temperature [K]
ncol (int, optional) – number of columns, default to 1
- Returns:
blackbody flux [w/(m^2 cm^-1)]
- Return type:
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)
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:
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:
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{RT}{g} \cdot d\ln p\]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:
pres (torch.Tensor) – pressure [pa] at layers
temp (torch.Tensor) – temperature [K] at layers
g_ov_R (torch.Tensor) – gravity over specific gas constant [K/m] at layers
- Returns:
height between pressure levels [m]
- Return type:
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)
- Returns:
Interpolated values
- Return type:
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)