floatcsep.model.Model
- class floatcsep.model.Model(name, model_path, forecast_unit=1, use_db=False, func=None, func_kwargs=None, zenodo_id=None, giturl=None, repo_hash=None, authors=None, doi=None, **kwargs)[source]
Class defining a forecast generating Model. Initializes a model source either from filesystem or web repositories, contains information about the Model’s typology, and maps accordingly to a forecast generating function.
- Parameters:
name (str) – Name of the model
model_path (str) – Relative path of the model (file or runnable code) to the Experiment’s instance path
forecast_unit (float) – Temporal unit of the forecast. Default to years in time-independent models and days in time-dependent
use_db (bool) – Flag the use of a database for speed/memory purposes
func (str, Callable) – Forecast generating function (for code models)
func_kwargs (dict) – Arguments to pass into func
zenodo_id (int) – Zenodo ID or record of the Model
giturl (str) – Link to a git repository
repo_hash (str) – Specific commit/branch/tag hash.
doi – Digital Object Identifier metadata:
- __init__(name, model_path, forecast_unit=1, use_db=False, func=None, func_kwargs=None, zenodo_id=None, giturl=None, repo_hash=None, authors=None, doi=None, **kwargs)[source]
Methods
__init__
(name, model_path[, forecast_unit, ...])as_dict
([excluded])- returns:
Dictionary with relevant attributes. Model can be reinstantiated
build_model
()create_forecast
(tstring, **kwargs)Creates a forecast from the model source and a given time window
forecast_from_file
(start_date, end_date, ...)Generates a forecast from a file, by parsing and scaling it to the desired time window.
forecast_from_func
(start_date, end_date, ...)from_dict
(record, **kwargs)Returns a Model instance from a dictionary containing the required atrributes.
get_forecast
([tstring, region])Wrapper that just returns a forecast, which should hide the access method (db storage, ti_td, etc.) under the hood
get_source
([zenodo_id, giturl, force])Search, download or clone the model source in the filesystem, zenodo and git, respectively.
init_db
([dbpath, force])Initializes the database if use_db is True.
prepare_args
(start, end, **kwargs)rm_db
()Clean up the generated HDF5 File
run_model
()stage
([timewindows])Pre-steps to make the model runnable before integrating
Attributes
dir
Returns: The directory containing the model source.