calliope.Model(inputs, attrs, results=None, **kwargs)
¶
Bases: ModelStructure
A Calliope Model.
Returns a instantiated Calliope Model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
Dataset
|
Input dataset. |
required |
attrs
|
CalliopeAttrs
|
Model attributes & properties. |
required |
results
|
Dataset | None
|
Results dataset from another Calliope Model with compatible math formulation. Defaults to None. |
None
|
**kwargs
|
initialisation keyword arguments |
{}
|
Source code in src/calliope/model.py
all_attrs
property
¶
Get all model attributes as a CalliopeAttrs object.
backend
instance-attribute
¶
config = self.config.update({'init': kwargs})
instance-attribute
¶
definition = attrs.definition
instance-attribute
¶
inputs
instance-attribute
¶
is_built
property
¶
Get built status.
is_solved
property
¶
Get solved status.
math = attrs.math
instance-attribute
¶
name
property
¶
Get the model name.
results = xr.Dataset() if results is None else results
instance-attribute
¶
runtime = model_data_factory.runtime
instance-attribute
¶
build(force=False, **kwargs)
¶
Build description of the optimisation problem in the chosen backend interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
If |
False
|
**kwargs
|
build configuration overrides. |
{}
|
Source code in src/calliope/model.py
dump_all_attrs()
¶
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
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 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
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.