stilt.model#

Stochastic Time-Inverted Lagrangian Transport (STILT) Model.

A python implementation of the [R-STILT](jmineau/stilt) model framework.

> Inspired by uataq/air-tracker-stiltctl

Functions

stilt_init(project[, branch, repo])

Initialize STILT project

Classes

Model(project, **kwargs)

SimulationCollection([sims])

stilt.model.stilt_init(project, branch=None, repo=None)[source]#

Initialize STILT project

Python implementation of Rscript -e “uataq::stilt_init(‘project’)”

Parameters:
  • project (str) – Name/path of STILT project. If path is not provided, project will be created in current working directory.

  • branch (str, optional) – Branch of STILT project repo. The default is jmineau.

  • repo (str, optional) – URL of STILT project repo. The default is jmineau/stilt.

class stilt.model.SimulationCollection(sims=None)[source]#
COLUMNS = ['id', 'location_id', 'status', 'r_time', 'r_long', 'r_lati', 'r_zagl', 't_start', 't_end', 'path', 'simulation']#
__init__(sims=None)[source]#

Initialize SimulationCollection.

Parameters:

sims (list[Simulation]) – List of Simulation objects to add to the collection. If None, an empty collection is created.

classmethod from_paths(paths)[source]#

Create SimulationCollection from a list of simulation paths.

Parameters:

paths (list[Path | str]) – List of paths to STILT simulation directories or files.

Returns:

Collection of Simulations.

Return type:

SimulationCollection

property df: DataFrame#

Get the underlying DataFrame.

Returns:

DataFrame containing simulation metadata.

Return type:

pd.DataFrame

__getitem__(key)[source]#

Get a Simulation object by its ID.

Parameters:

key (str) – Simulation ID.

Returns:

Simulation object corresponding to the given ID.

Return type:

Simulation

__setitem__(key, value)[source]#

Set a Simulation object by its ID.

Parameters:
  • key (str) – Simulation ID.

  • value (Simulation) – Simulation object to set.

Return type:

None

__contains__(key)[source]#

Check if a Simulation ID exists in the collection.

Parameters:

key (str) – Simulation ID.

Returns:

True if the Simulation ID exists, False otherwise.

Return type:

bool

__iter__()[source]#

Iterate over Simulations in the collection.

Returns:

Iterator over Simulation objects.

Return type:

Iterator[Simulation]

__len__()[source]#

Get the number of Simulations in the collection.

Returns:

Number of Simulations in the collection.

Return type:

int

load_trajectories()[source]#

Load trajectories for all simulations in the collection.

Returns:

The trajectories are loaded into the ‘simulation’ column of the DataFrame.

Return type:

None

load_footprints(resolutions=None)[source]#

Load footprints for simulations in the collection.

Parameters:

resolutions (list[str], optional) – Resolutions to filter footprints. If None, all footprints are loaded.

Returns:

The footprints are loaded into the ‘footprints’ column of the DataFrame.

Return type:

None

classmethod merge(collections)[source]#

Merge multiple SimulationCollections into one.

Parameters:

collections (list[SimulationCollection]) – List of SimulationCollections to merge.

Returns:

Merged SimulationCollection.

Return type:

SimulationCollection

get_missing(in_receptors, include_failed=False)[source]#

Find simulations in csv that are missing from simulation collection.

Parameters:
  • in_receptors (str | Path | pd.DataFrame) – Path to csv file containing receptor configuration or a DataFrame directly.

  • include_failed (bool, optional) – Include failed simulations in output. The default is False.

Returns:

DataFrame of missing simulations.

Return type:

pd.DataFrame

plot_availability(ax=None, **kwargs)[source]#

Plot availability of simulations over time.

Parameters:
  • ax (plt.Axes, optional) – Matplotlib Axes to plot on. If None, a new figure and axes are created.

  • **kwargs (dict) – Additional keyword arguments for the scatter plot.

Returns:

Matplotlib Axes with the plot.

Return type:

plt.Axes

class stilt.model.Model(project, **kwargs)[source]#
__init__(project, **kwargs)[source]#
static initialize(project, **kwargs)[source]#
Return type:

ModelConfig

property simulations: SimulationCollection | None#

Load all simulations from the output working directory.

run()[source]#