calliope.Model(model_definition, scenario=None, override_dict=None, data_table_dfs=None, **kwargs)
¶
A Calliope Model.
Returns a new Model from YAML model configuration files or a fully specified dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_definition
|
str | Path | dict | Dataset
|
If str or Path, must be the path to a model configuration file. If dict or AttrDict, must fully specify the model. If an xarray dataset, must be a valid calliope model. |
required |
scenario
|
str | None
|
Comma delimited string of pre-defined |
None
|
override_dict
|
dict | None
|
Additional overrides to apply to |
None
|
data_table_dfs
|
dict[str, DataFrame] | None
|
Model definition |
None
|
**kwargs
|
initialisation overrides. |
{}
|
Source code in src/calliope/model.py
ATTRS_SAVED = ('_def_path', 'applied_math')
class-attribute
instance-attribute
¶
applied_math: preprocess.CalliopeMath
instance-attribute
¶
backend: BackendModel
instance-attribute
¶
config: AttrDict
instance-attribute
¶
defaults: AttrDict
instance-attribute
¶
inputs
property
¶
Get model input data.
is_built
property
¶
Get built status.
is_solved
property
¶
Get solved status.
name
property
¶
Get the model name.
results
property
¶
Get model result data.
build(force=False, add_math_dict=None, **kwargs)
¶
Build description of the optimisation problem in the chosen backend interface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force
|
bool
|
If |
False
|
add_math_dict
|
dict | None
|
Additional math to apply on top of the YAML base / additional math files. Content of this dictionary will override any matching key:value pairs in the loaded math files. |
None
|
**kwargs
|
build configuration overrides. |
{}
|
Source code in src/calliope/model.py
info()
¶
Generate basic description of the model, combining its name and a rough indication of the model size.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Basic description of the model. |
Source code in src/calliope/model.py
run(force_rerun=False, **kwargs)
¶
Run the model.
If force_rerun
is True, any existing results will be overwritten.
Additional kwargs are passed to the backend.
Source code in src/calliope/model.py
solve(force=False, warmstart=False, **kwargs)
¶
Solve the built optimisation problem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force
|
bool
|
If |
False
|
warmstart
|
bool
|
If True and the optimisation problem has already been run in this session
(i.e., |
False
|
**kwargs
|
solve configuration overrides. |
{}
|
Raises:
Type | Description |
---|---|
ModelError
|
Optimisation problem must already be built. |
ModelError
|
Cannot run the model if there are already results loaded, unless |
ModelError
|
Some preprocessing steps will stop a run mode of "operate" from being possible. |
Source code in src/calliope/model.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
|
to_csv(path, dropna=True, allow_overwrite=False)
¶
Save complete model data (inputs and, if available, results) as a set of CSV files to the given path
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str | Path
|
file path to save at. |
required |
dropna
|
bool
|
If True, NaN values are dropped when saving, resulting in significantly smaller CSV files. Defaults to True |
True
|
allow_overwrite
|
bool
|
If True, allow the option to overwrite the directory contents if it already exists. This will overwrite CSV files one at a time, so if the dataset has different arrays to the previous saved models, you will get a mix of old and new files. Defaults to False. |
False
|
Source code in src/calliope/model.py
to_netcdf(path)
¶
Save complete model data (inputs and, if available, results) to a NetCDF file at the given path
.