Evaluation Class

class floatcsep.evaluation.Evaluation(name, func, func_kwargs=None, ref_model=None, plot_func=None, plot_args=None, plot_kwargs=None, markdown='')[source]

Bases: object

Class representing a Scoring Test, which wraps the evaluation function, its arguments, parameters and hyperparameters.

Parameters:
  • name (str) – Name of the Test.

  • func (str, Callable) – Test function/callable.

  • func_kwargs (dict) – Keyword arguments of the test function.

  • ref_model (str) – String of the reference model, if any.

  • plot_func (str, Callable) – Test’s plotting function.

  • plot_args (list,dict) – Positional arguments of the plotting function.

  • plot_kwargs (list,dict) – Keyword arguments of the plotting function.

  • markdown (str) – The caption to be placed beneath the result figure.

as_dict()[source]

Represents an Evaluation instance as a dictionary, which can be serialized and then parsed

Return type:

dict

compute(timewindow, model, ref_model=None, region=None)[source]

Runs the test, structuring the arguments according to the test-typology/function-signature

Parameters:
  • timewindow (list[datetime, datetime]) – A pair of datetime objects representing the testing time span

  • catalog (str) – Path to the filtered catalog

  • model (Model, list[Model]) – Model(s) to be evaluated

  • ref_model (Model | Sequence[Model]) – Model to be used as reference

  • region – region to filter a catalog forecast.

Return type:

None

Returns:

classmethod from_dict(record)[source]

Parses a dictionary and re-instantiate an Evaluation object.

get_catalog(timewindow, forecast)[source]

Reads the catalog(s) from the given path(s). References the catalog region to the forecast region.

Parameters:
  • timewindow (str) – Time window of the testing catalog

  • forecast (GriddedForecast) – Forecast object, onto which the catalog will be confronted for testing.

Return type:

CSEPCatalog | List[CSEPCatalog]

Returns:

parse_plots(plot_func, plot_args, plot_kwargs)[source]

It parses the plot function(s) and its(their) arguments from the test configuration file. The plot function can belong to csep.utils.plots or a custom function. Each plotting function is parsed by using the function parse_csep_function(), and assigned to its respective args and kwargs

Parameters:
  • plot_func (Any) – The name of the plotting function

  • plot_args (Any) – The arguments of the plotting function

  • plot_kwargs (Any) – The keyword arguments of the plotting function

Return type:

None

prepare_args(timewindow, model, ref_model=None, region=None)[source]

Prepares the positional argument for the Evaluation function.

Parameters:
  • timewindow (str, list) – Time window string (or list of str) formatted from floatcsep.utils.timewindow2str()

  • model (floatcsep:model.Model) – Model to be evaluated

  • ref_model (floatcsep:model.Model, list) – Reference model (or models) reference for the evaluation.

  • region (csep:core.regions.CartesianGrid2D) – Experiment region

Returns:

A tuple of the positional arguments required by the evaluation function Evaluation.func().

Return type:

tuple

read_results(window, models)[source]

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

Parameters:
Return type:

List

property type

Returns the type of the test, mapped from the class attribute Evaluation._TYPES.