Module trase.tools.sei_pcs

The Trase SEI-PCS tool is a set of Python classes and functions designed to aid the development of Standardised Spatially Explicit Information on Production to Consumption (sSEI-PCS) models. From the perspective of the person developing the model, the tool:

  1. Helps you load data into the model; even if the data recently changed at its source
  2. Runs quality assurance on the input data: in particular ensuring that datasets can be fully-joined on common columns
  3. Provides useful wrapping functions around Pandas that provides a higher-level abstraction to things we often need to do in SEI-PCS models, such as "consolidation" or "splitting"
  4. Writes out model results in a way that can be directly ingested into Trase's main database

For the whole Trase project, the tool:

  1. Sets some standards about how data is loaded and written so that we can all work more efficiently
  2. Ensures that similar models have very similar-looking code, to reduce the cognitive load on the team
  3. Provides a standard interface to run models so that anybody on the team can run them, even if they didn't originally work on the model

Guiding Principles

The tool is written with a few guiding principles in mind:

  1. Be lightweight (in the sense of a small amount of code) and modular
  2. Set standards by default but don't enforce them, in order to remain flexible to needs
  3. Leverage Pandas 🐼 where possible: do not reinvent existing standards in the data science community

Sub-modules

trase.tools.sei_pcs.constants
trase.tools.sei_pcs.dataframe_container

How we store and update Pandas dataframes once they have been loaded from disk into memory.

trase.tools.sei_pcs.definition

The "definition" of an SEI-PCS model. It provides a quick overview of the datasets the model requires, the "topology" of the model (the auxiliary …

trase.tools.sei_pcs.exceptions
trase.tools.sei_pcs.flows_container
trase.tools.sei_pcs.formatting

Utility functions for formatting Python numbers as strings

trase.tools.sei_pcs.pandas_lp

Pandas-friendly wrapper functions for common linear programming problems that we encounter in SEI-PCS.

trase.tools.sei_pcs.pandas_utilities

Useful functions that utilise Pandas with the goal of (a) reducing code repetition and (b) minimising common errors.

trase.tools.sei_pcs.plotting
trase.tools.sei_pcs.recursive_join

In order to reduce the amount of joins that a user has to do in their model code we allow them to specify a recipe of joins that can be handled for …

trase.tools.sei_pcs.reload

Auto-reloading of Python code. Hopefully one day we can delete this in favour of IPython's autoreload.

trase.tools.sei_pcs.reporting

Some useful functions to summarise Pandas dataframes

trase.tools.sei_pcs.supply_chain

The "central" interface which enables a user use to easily run an SEI-PCS model

trase.tools.sei_pcs.utilities
trase.tools.sei_pcs.validation
trase.tools.sei_pcs.validation_base