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