arts.workspace

The workspace subpackage provides an interactive interface to ARTS and can be used to directly call workspace methods and agendas as well as access and manipulate workspace variables.

Setup

The python interface needs access to the arts_api.so shared library, which is located in the src subfolder of the ARTS build tree. The interface expects the location of the ARTS build tree to be provided in the ARTS_BUILD_PATH environment variable.

The Workspace Class

The main functionality of the interface is implemented by the Workspace class. A Workspace object represents an ongoing ARTS simulation and is used to execute controlfiles and workspace methods and access workspace variables

>>> from typhon.arts.workspace import Workspace
>>> ws = Workspace()

Executing Controlfiles

Controlfiles can be execute on a workspace using the execute_controlfile class method.

>>> ws.execute_controlfile("general.arts")

This will search recursively through the working directory and the path provided in the environment variable ARTS_INCLUDE_PATH and parse and execute the found controlfile on the workspace object.

Parsing and execution of controlfiles is handled completely by ARTS, so in order to resolve INCLUDE statements and loading of data the include path and the data path must be set correctly. By default, the ARTS interface will set them to be the controlfiles subfolder of the path contained in ARTS_INCLUDE_PATH and the controlfiles/testdata folder, respectively. Both can be set manually using the include_path_add and data_path_add methods.

Calling Workspace Methods

ARTS workspace methods are available as member functions of each Workspace object:

>>> ws.AtmosphereSet1D()
>>> ws.IndexSet(ws.stokes_dim, 1)

Arguments can be passed to a workspace function in three ways:

  1. As workspace variables using the attributes of the workspace object (ws.stokes_dim)
  2. Using one of the symbolic variables in typhon.arts.workspace.variables
  3. Passing python objects directly

Arguments to a WSM can be passed using either positional or named arguments or both. If positional arguments are provided at least all generic output and generic input arguments must be given in order.

>>> ws.VectorNLogSpace(ws.p_grid, 361, 500e2, 0.1 )

Keyword arguments to define generic input and output arguments. Available keywords are the names of the generic outputs and inputs defined in methods.cc.

>>> ws.abs_speciesSet(species=[ "O3" ])

Calls to supergeneric functions are resolved by the interface.

Workspace Variables

Symbolic representation of all workspace variables are available in the typhon.arts.workspace.variables module as module attributes. The purpose of these is to be passed to workspace functions as placeholders for variables in the workspace.

Variable objects can be associated to a workspace, which is the case for variables accessed as attributes of a workspace, i.e. using for example:

>>> ws.y

If that is the case their value can be accessed using the value() member function. In order to print out a textual representation of the value, the print() member function can be used, which will call the corresponding Print() ARTS WSV.

Workspace variables of the groups Vector, Matrix and Tensor with an associated workspace implement the numpy array interface and can therefore be used just as any other numpy array. In some cases, however, it may be necessary to explicitly create a view on the array using numpy.asarray.

arts.workspace.agendas

The agendas submodule.

This module provides the Agenda class, which is used to represent parsed controlfiles and can be executed on a given Workspace object.

Agenda(ptr)

arts.workspace.api

ARTS C API Interface

This module provides a foreign function interface for the ARTS C API. It defines the C structs used by the interface as ctypes.Structure child classes as well as the return argument and return types of the function provided by the C API.

Requirements

The ARTS C API is provided by the arts_api.so library and is required by the module. The module will check if the ARTS_BUILD_PATH variable is set and assume the library can be found in the src subdirectory. If opening the library fails loading the module will fail with an EnvironmentError.

typhon.arts.workspace.api.arts_api

CDLL – The ctypes library handle holding the ARTS C API.

arts.workspace.methods

The methods submodule.

This module exposes all ARTS workspace methods represented by WorkspaceMethod object.

The methods are loaded dynamically when the module is imported, which ensures that they up to date with the current ARTS build.

typhon.arts.workspace.methods.workspace_methods

dict – Dictionary containing all ARTS workspace methods.

WorkspaceMethod(m_id, name, description, …) The WorkspaceMethod class represents ARTS workspace methods.
iter() Iterator returning a WorkspaceMethod object for each available ARTS WSM.

arts.workspace.variables

The variables submodule.

This module contains symbolic representations of all ARTS workspace variables.

The variables are loaded dynamically when the module is imported, which ensures that they up to date with the current ARTS build.

typhon.arts.workspace.variables.group_names

[str] – List of strings holding the groups of ARTS WSV variables.

typhon.arts.workspace.variables.group_ids

dict – Dictionary mapping group names to the group IDs which identify groups in the ARTS C API.

WorkspaceVariable(ws_id, name, group, …[, ws]) The WorkspaceVariable represents ARTS workspace variables in a symbolic way.

arts.workspace.workspace

The workspace submodule.

Contains the Workspace which implements the main functionality of the ARTS interface. Users should only have to use this class to interact with ARTS.

typhon.arts.workspace.workspace.imports

dict – Dictionary of parsed controlfiles. This is kept to ensure to avoid crashing of the ARTS runtime, when a file is parsed for the second time.

arts_agenda(func) Parse python method as ARTS agenda
Workspace() The Workspace class represents an ongoing ARTS simulation.