API Documentation
Commands
The main entrypoint functions from the Command Line Interface are:
Entry point for the floatCSEP command-line interface (CLI). |
|
Core routine of the floatCSEP workflow. |
|
This function is a preliminary step that stages the models before the experiment is run. |
|
Generates plots for an already executed experiment. |
|
Reproduces the results of a previously run experiment. |
Experiment
The Experiment class is the main handler of floatCSEP, which
orchestrates the Model and Evaluation
instances onto an experimental workflow. The class and its main methods are:
Main class that handles an Experiment's context. |
|
Parse the models' configuration file/dict. |
|
Parse the tests' configuration file/dict. |
|
Stages all the experiment's models. |
|
Lazy definition of the experiment core tasks by wrapping instances, methods and arguments. |
|
Run the task tree. |
|
Reads an Evaluation result for a given time window and returns a list of the results for all tested models. |
|
Creates a reproducibility configuration file, re-directing the forecasts/catalog paths, in order to reproduce the existing results and compare them with previous runs. |
Model
The Model class is the handler of forecasts creation, storage and
reading. The abstract and concrete classes, and their main methods are:
The Model class represents a forecast generating system. |
|
Retrieves the model from a web repository |
|
Factory method. |
|
A Model whose forecast is invariant in time. |
|
Wrapper that just returns a forecast when requested. |
|
Retrieve model artifacts and Set up its interface with the experiment. |
|
When the model is a source code, the args file is a plain text file with the required input arguments. |
|
Creates a forecast from the model source and a given time window. |
|
Wrapper that returns a forecast, by accessing the model's forecast repository. |
Evaluations
The Evaluation class is a wrapper for pycsep functions,
encapsulating the multiple function, arguments, forecast and catalogs of the entire experiment.
The class and main methods are:
Class representing a Scoring Test, which wraps the evaluation function, its arguments, parameters and hyperparameters. |
|
Prepares the positional argument for the Evaluation function. |
|
Runs the test, structuring the arguments according to the test-typology/function-signature |
Accessors
These are functions that access a model source from a web repository.
Helper Functions
These are the helper functions of floatCSEP
Search in pyCSEP and floatCSEP a function or method whose name matches the provided string. |
|
Converts a time window (list/tuple of datetimes) to a string that represents it. |
|
Converts a string representation of a time window into a list of datetimes representing the time window edges. |
|
Parses a float or string representing the testing time window length. |
|
Builds the temporal configuration of an experiment. |
|
Builds the region configuration of an experiment. |
|
Creates the testing intervals for a time-independent experiment. |
|
Creates the testing intervals for a time-dependent experiment. |
Some additional plotting functions to pyCSEP are:
Plot of likelihood against time. |
|
Scatter plot of the catalog magnitudes and origin times. |
|
Performs the likelihood test on Gridded Forecast using an Observed Catalog. |
|
Evaluates the Information Gain for multiple time-windows. |
|
Computes Student's t-test for the information gain per earthquake over. |
Readers
A small wrapper for pyCSEP readers
Parsers for |
|
Load a pyCSEP catalog in the ASCII catalog format. |
|
Load a pyCSEP catalog from JSON. |
|
Serializers for |
|
Serialize a catalog to the pyCSEP ASCII format. |
|
Serialize a catalog to JSON using the pyCSEP encoder. |
|
Parsers for grid-based earthquake forecasts. |
|
Load a CSEP-style ASCII .dat gridded forecast. |
|
Load a CSEP XML gridded forecast. |
|
Load a quadtree forecast from CSV. |
|
Load a gridded forecast from CSV. |
|
Load a gridded forecast from an HDF5 container. |
|
Parsers for catalog-based forecasts stored on disk. |
|
Load a catalog-based forecast from a CSV file. |
|
Loads hermes synthetic catalogs in csep-ascii format. |
|
Store a cartesian gridded forecast into an HDF5 file. |
|
Basic format checks for supported forecast files. |
|
Small CLI for testing gridded forecast parsers. |
Environments
The computational environment managers for floatcsep.
Manages a conda (or mamba) environment, providing methods to create, check and manipulate conda environments specifically. |
|
Creates a conda environment using either an environment.yml file or the specified Python version in setup.py/setup.cfg or project/toml. |
|
Checks if the conda environment exists by querying the list of existing conda environments. |
|
Installs the necessary dependencies for the environment based on the specified configuration or requirements. |
|
Runs a specified command within the conda environment. |
|
Manages a virtual environment created using Python's venv module. |
|
Creates a conda environment using either an environment.yml file or the specified Python version in setup.py/setup.cfg or project/toml. |
|
Checks if the conda environment exists by querying the list of existing conda environments. |
|
Installs the necessary dependencies for the environment based on the specified configuration or requirements. |
|
Runs a specified command within the conda environment. |
Registries
The registries hold references to the access points (e.g., filepaths) of the experiment components (e.g., forecasts, catalogs, results, etc.), and allows to be aware of their status.
The class is responsible to handle the keys (in this case filepaths) to access model objects such as forecasts, input catalogs or argument/parameter files. |
|
Returns: The extension or format of the forecast |
|
Gets the filepath of the input catalog for a given sequence of keys (usually a timewindow string). |
|
Gets the filepath of a forecast for a given sequence of keys (usually a timewindow string). |
|
Gets the filepath of an arguments file for a given sequence of keys (usually a timewindow string). |
|
Returns the directory that contains the per-window input files (args/catalog). |
|
Returns the directory that contains the forecasts. |
|
Path to the model’s canonical args template: <model.path>/input/<args_file>. |
|
Checks if forecasts exist for a sequence of time_windows |
|
Creates the run directory, and reads the file structure inside. |
|
The class has the responsibility of managing the keys (based on models, timewindow and evaluation name strings) to the structure of the experiment inputs (catalogs, models etc) and results from the competing evaluations. |
|
Adds a model's ForecastRegistry to the ExperimentFileRegistry. |
|
Retrieves a model's ForecastRegistry from the ExperimentFileRegistry. |
|
Gets the file path of an evaluation result. |
|
Gets the file path of a testing catalog. |
|
Gets the file path of a result figure. |
|
Checks if a given test results exist |
|
Creates the run directory and reads the file structure inside. |
Repositories
The repositories here are designed to store and access the experiment artifacts (results, catalogs, forecasts), abstracting the experiment logic from the pyCSEP io functionality.
The class handles the main and sub-catalogs from the experiment. |
|
Sets the catalog to be used for the experiment. |
|
Returns a CSEP catalog loaded from the given query function or a stored file if it exists. |
|
Filters the complete experiment catalog to a test sub-catalog bounded by the test time-window. |
|
Filters the complete experiment catalog to a test sub-catalog bounded by the test time-window. |
|
Filters the complete experiment catalog to input sub-catalog filtered to the beginning of the test time-window. |
|
Wrapper for pyCSEP catalog filters, to constrain a catalog to a given time and magnitude range, as well to a spatial region. |
|
The class is responsible to access (or store in memory) the gridded-based forecasts of a model. |
|
Returns a forecast object or a sequence of them for a set of time window strings. |
|
The class is responsible to access (or store in memory) the catalog-based forecasts of a model. |
|
Returns a forecast object or a sequence of them for a set of time window strings. |
|
The class is responsible to access, read and write the results of a given evaluation |
|
Reads an Evaluation result for a given time window and returns a list of the results for all tested models. |
|
Writes the evaluation results using their method .to_dict() as json file. |
Engine
The engine routines are designed for the execution of an experiment.
Represents a unit of work to be executed later as part of a task graph. |
|
Executes the task by calling the method on the object instance with the stored arguments. |
|
Checks whether the task matches a given function signature. |
|
Context manager of floatcsep workload distribution. |
|
Returns the number of tasks currently in the graph. |
|
Adds a new task to the task graph. |
|
Adds a dependency to a task already within the graph. |
|
Executes in sequential all tasks in the task graph according to the order set in Experiment.set_tasks(). |