arts_agenda

pyarts.workspace.arts_agenda(func=None, *, ws=None, fix=False)[source]

Creates an agenda by parsing the supported expressions into Workspace Method calls.

Examples

These all produce the same Agenda, with minor modifications on how it is stored.

Listing 1 Creating a basic Agenda
from pyarts.workspace import Workspace, arts_agenda, callback_operator

@arts_agenda
def propmat_clearsky_agenda(ws):
    ws.propmat_clearskyInit()
    ws.propmat_clearskyAddLines()
    ws.Ignore(ws.rtp_los)

ws = Workspace()
ws.propmat_clearsky_agenda = propmat_clearsky_agenda
Listing 2 Setting an agenda to a workspace directly
from pyarts.workspace import Workspace, arts_agenda, callback_operator

ws = Workspace()

@arts_agenda(ws=ws)
def propmat_clearsky_agenda(ws):
    ws.propmat_clearskyInit()
    ws.propmat_clearskyAddLines()
    ws.Ignore(ws.rtp_los)
Listing 3 Setting an Agenda while skipping some housekeeping
from pyarts.workspace import Workspace, arts_agenda, callback_operator

ws = Workspace()

@arts_agenda(ws=ws, fix=True)
def propmat_clearsky_agenda(ws):
    ws.propmat_clearskyInit()
    ws.propmat_clearskyAddLines()
Listing 4 Using custom values
from pyarts.workspace import Workspace, arts_agenda, callback_operator

ws = Workspace()

@arts_agenda(ws=ws, fix=True)
def propmat_clearsky_agenda(ws):
    ws.propmat_clearskyInit()
    ws.propmat_clearskyAddLines(ws.propmat_clearsky,  # By pos
                                lines_sparse_df=0)  # By name

Additional options

We support some additional functionality of python beyond just calling workspace methods.

Listing 5 Assigning or copying a variable using python syntax
from pyarts.workspace import Workspace, arts_agenda, callback_operator

ws = Workspace()

@arts_agenda(ws=ws, fix=True)
def propmat_clearsky_agenda(ws):
    ws.propmat_clearsky = []
    ws.x = ws.f_grid
Listing 6 Using callback operators to execute code in python
from pyarts.workspace import Workspace, arts_agenda, callback_operator

def fun(f_grid):
    x = f_grid
    return x

ws = Workspace()

@arts_agenda(ws=ws, fix=True)
def propmat_clearsky_agenda(ws):
    fun()  # This will set x to f_grid
param func:

The function to be turned into an Agenda

type func:

function

param ws:

The workspace to put this onto after finalization, defaults to None

type ws:

~pyarts.workspace.Workspace, optional

param fix:

Whether to fix missing input/output in finalization, defaults to False

type fix:

bool, optional