floatcsep.experiment.Experiment

class floatcsep.experiment.Experiment(name=None, time_config=None, region_config=None, catalog=None, models=None, tests=None, postproc_config=None, default_test_kwargs=None, rundir='results', report_hook=None, **kwargs)[source]

Main class that handles an Experiment’s context. Contains all the specifications, instructions and methods to carry out an experiment.

Parameters:
  • name (str) – Experiment name

  • time_config (dict) –

    Contains all the temporal specifications. It can contain the following keys:

    • start_date (datetime.datetime): Experiment start date

    • end_date (datetime.datetime): Experiment end date

    • exp_class (str): ti (Time-Independent) or td (Time-Dependent)

    • intervals (int): Number of testing intervals/windows

    • horizon (str, float): Time length of the forecasts (e.g. 1, 10, 1 year, 2 days). ti defaults to years, td to days.

    • growth (str): incremental or cumulative

    • offset (float): recurrence of forecast creation.

    For further details, see timewindows_ti() and timewindows_td()

  • region_config (dict) –

    Contains all the spatial and magnitude specifications. It must contain the following keys:

    • region (str, csep.core.regions.CartesianGrid2D): The geographical region, which can be specified as: (i) the name of a csep/floatcsep default region function (e.g. california_relm_region()) (ii) the name of a user function or (iii) the path to a lat/lon file

    • mag_min (float): Minimum magnitude of the experiment

    • mag_max (float): Maximum magnitude of the experiment

    • mag_bin (float): Magnitud bin size

    • magnitudes (list, numpy.ndarray): Explicit magnitude bins

    • depth_min (float): Minimum depth. Defaults to -2

    • depth_max (float): Maximum depth. Defaults to 6000

  • model_config (str) – Path to the models’ configuration file

  • test_config (str) – Path to the evaluations’ configuration file

  • default_test_kwargs (dict) – Default values for the testing (seed, number of simulations, etc.)

  • postproc_config (dict) – Contains the instruction for postprocessing (e.g. plot forecasts, catalogs)

  • **kwargs – see Note

Note

Instead of using time_config and region_config, an Experiment can be instantiated using these dicts as keywords. (e.g. Experiment( **time_config, **region_config), Experiment(start_date=start_date, intervals=1, region='csep-italy', ...)

__init__(name=None, time_config=None, region_config=None, catalog=None, models=None, tests=None, postproc_config=None, default_test_kwargs=None, rundir='results', report_hook=None, **kwargs)[source]

Methods

__init__([name, time_config, region_config, ...])

as_dict([exclude, extended])

Converts an Experiment instance into a dictionary.

from_yml(config_yml[, reprdir])

Initializes an experiment from a .yml file.

generate_report()

Creates a report summarizing the Experiment's results

get_model(name)

Returns a Model by its name string

get_test_cat([tstring])

Filters the complete experiment catalog to a test sub-catalog bounded by the test time-window.

make_repr()

plot_catalog([dpi, show])

Plots the evaluation catalogs

plot_forecasts()

Plots and saves all the generated forecasts

plot_results()

Plots all evaluation results

read_results(test, window)

Reads an Evaluation result for a given time window and returns a list of the results for all tested models.

run()

Run the task tree

set_input_cat(tstring, model)

Filters the complete experiment catalog to a input sub-catalog filtered to the beginning of thetest time-window.

set_models(model_config[, order])

Parse the models' configuration file/dict.

set_tasks()

Lazy definition of the experiment core tasks by wrapping instances, methods and arguments.

set_test_cat(tstring)

Filters the complete experiment catalog to a test sub-catalog bounded by the test time-window.

set_tests(test_config)

Parse the tests' configuration file/dict.

stage_models()

Stages all the experiment's models.

to_yml(filename, **kwargs)

Serializes the Experiment instance into a .yml file.

Attributes

catalog

Returns a CSEP catalog loaded from the given query function or a stored file if it exists.