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 = ('applied_math', 'config', 'def_path')
class-attribute
instance-attribute
¶
applied_math
instance-attribute
¶
backend
instance-attribute
¶
config
instance-attribute
¶
def_path = None
instance-attribute
¶
defaults
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)
¶
Run the model.
If force_rerun
is True, any existing results will be overwritten.
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
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 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 |
|
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
.