Code Reference
framcore
check_type(value: object, expected: type | tuple[type], caller: Callable | None = None) -> None
Check a value matches expected type(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
object
|
value being checked. |
required |
expected
|
type | tuple[type]
|
Expected types. |
required |
caller
|
Callable
|
The origin of the check. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
When value does not match expected types. |
Source code in framcore/Base.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
Base
Base
Core base class to share methods.
Source code in framcore/Base.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
__repr__() -> str
Display type and non-None fields.
Source code in framcore/Base.py
121 122 123 124 125 126 127 128 129 130 | |
get_fingerprint_default(refs: dict[str, str] | None = None, excludes: set[str] | None = None) -> Fingerprint
Generate a Fingerprint for the object, optionally including references and excluding specified properties.
Parameters
refs : dict[str, str] | None, optional Dictionary mapping property names to reference keys to include as references in the fingerprint. excludes : set[str] | None, optional Set of property names to exclude from the fingerprint.
Returns
Fingerprint The generated fingerprint for the object.
Source code in framcore/Base.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
send_debug_event(message: str) -> None
Use this to send debug event.
Source code in framcore/Base.py
70 71 72 | |
send_error_event(message: str, exception_type_name: str, traceback: str) -> None
Use this to send error event.
Source code in framcore/Base.py
62 63 64 | |
send_event(event_type: str, **kwargs: dict[str, Any]) -> None
All events in core should use this.
Source code in framcore/Base.py
54 55 56 | |
send_info_event(message: str) -> None
Use this to send info event.
Source code in framcore/Base.py
66 67 68 | |
send_warning_event(message: str) -> None
Use this to send warning event.
Source code in framcore/Base.py
58 59 60 | |
check_type(value: object, expected: type | tuple[type], caller: Callable | None = None) -> None
Check a value matches expected type(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
object
|
value being checked. |
required |
expected
|
type | tuple[type]
|
Expected types. |
required |
caller
|
Callable
|
The origin of the check. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
When value does not match expected types. |
Source code in framcore/Base.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
Model
Model
Bases: Base
Model stores the representation of the energy system with Components, TimeVectors, Expression, and the Aggregators applied to the Model.
- Components describe the main elements in the energy system. Can have additional Attributes.
- TimeVector and Curve hold the time series data.
- Expressions for data manipulation of TimeVectors and Curves. Can be queried.
- Aggregators handle aggregation and disaggregation of Components. Aggregators are added to Model when used (Aggregator.aggregate(model)), and can be undone in LIFO order with disaggregate().
Methods:
| Name | Description |
|---|---|
get_data |
Get dict of Components, Expressions, TimeVectors and Curves stored in the Model. Can be modified. |
disaggregate |
Undo all aggregations applied to Model in LIFO order. |
get_content_counts |
Return number of objects stored in model organized into concepts and types. |
Source code in framcore/Model.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
__init__() -> None
Create a new model instance with empty data and no aggregators.
Source code in framcore/Model.py
45 46 47 48 | |
disaggregate() -> None
Undo all aggregations applied to Model in LIFO order.
Source code in framcore/Model.py
54 55 56 57 58 | |
get_content_counts() -> dict[str, Counter]
Return number of objects stored in model organized into concepts and types.
Source code in framcore/Model.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
get_data() -> ModelDict
Get dict of Components, Expressions, TimeVectors and Curves stored in the Model. Can be modified.
Source code in framcore/Model.py
50 51 52 | |
ModelDict
Bases: dict
Dict storing only values of type Component | Expr | TimeVector | Curve.
Source code in framcore/Model.py
14 15 16 17 18 19 20 21 22 23 24 25 | |
__setitem__(key: str, value: Component | Expr | TimeVector | Curve) -> None
Set item with type checking.
Source code in framcore/Model.py
17 18 19 20 21 22 23 24 25 | |
aggregators
SolarAggregator
Bases: _WindSolarAggregator
Aggregate Solar components into groups based on their power nodes.
Aggregation steps (self._aggregate):
- Group components based on their power nodes (self._group_by_power_node):
- Aggregate grouped components into a single aggregated component for each group (self._aggregate_groups):
- Max_capacity is calculated as the sum of the maximum capacity levels with weighted profiles.
- Variable operation costs (voc) are aggregated using weighted averages based on the weighting method (now ony max_capacity supported).
- TODO: Add support for additional weighting methods (e.g. production instead of capacity).
- Production is aggregated as the sum of production levels with weighted profiles. 2a. Make new hydro module and delete original components from model data.
- Add mapping from detailed to aggregated components to self._aggregation_map.
Disaggregation steps (self._disaggregate):
- Restore original components from self._original_data. NB! Changes to aggregated modules are lost except for results.
- Distribute production from aggregated components back to the original components:
- Results are weighted based on the weighting method (now ony max_capacity supported).
- Delete aggregated components from the model.
See Aggregator for general design notes and rules to follow when using Aggregators.
Attributes:
| Name | Type | Description |
|---|---|---|
_data_dim |
SinglePeriodTimeIndex | None
|
Data dimension for eager evaluation. |
_scen_dim |
FixedFrequencyTimeIndex | None
|
Scenario dimension for eager evaluation. |
_grouped_components |
dict[str, set[str]]
|
Mapping of aggregated components to their detailed components. agg to detailed |
Parent Attributes (see framcore.aggregators.Aggregator):
_is_last_call_aggregate (bool | None): Tracks whether the last operation was an aggregation.
_original_data (dict[str, Component | TimeVector | Curve | Expr] | None): Original detailed data before aggregation.
_aggregation_map (dict[str, set[str]] | None): Maps aggregated components to their detailed components. detailed to agg
Source code in framcore/aggregators/WindSolarAggregator.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 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 | |
WindAggregator
Bases: _WindSolarAggregator
Aggregate Wind components into groups based on their power nodes.
Aggregation steps (self._aggregate):
- Group components based on their power nodes (self._group_by_power_node):
- Aggregate grouped components into a single aggregated component for each group (self._aggregate_groups):
- Max_capacity is calculated as the sum of the maximum capacity levels with weighted profiles.
- Variable operation costs (voc) are aggregated using weighted averages based on the weighting method (now ony max_capacity supported).
- TODO: Add support for additional weighting methods (e.g. production instead of capacity).
- Production is aggregated as the sum of production levels with weighted profiles. 2a. Make new hydro module and delete original components from model data.
- Add mapping from detailed to aggregated components to self._aggregation_map.
Disaggregation steps (self._disaggregate):
- Restore original components from self._original_data. NB! Changes to aggregated modules are lost except for results.
- Distribute production from aggregated components back to the original components:
- Results are weighted based on the weighting method (now ony max_capacity supported).
- Delete aggregated components from the model.
See Aggregator for general design notes and rules to follow when using Aggregators.
Attributes:
| Name | Type | Description |
|---|---|---|
_data_dim |
SinglePeriodTimeIndex | None
|
Data dimension for eager evaluation. |
_scen_dim |
FixedFrequencyTimeIndex | None
|
Scenario dimension for eager evaluation. |
_grouped_components |
dict[str, set[str]]
|
Mapping of aggregated components to their detailed components. agg to detailed |
Parent Attributes (see framcore.aggregators.Aggregator):
_is_last_call_aggregate (bool | None): Tracks whether the last operation was an aggregation.
_original_data (dict[str, Component | TimeVector | Curve | Expr] | None): Original detailed data before aggregation.
_aggregation_map (dict[str, set[str]] | None): Maps aggregated components to their detailed components. detailed to agg
Source code in framcore/aggregators/WindSolarAggregator.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
Aggregator
Aggregator
Bases: Base, ABC
Aggregator interface class.
Aggregators handles aggregation and disaggregation of Components. - The general approach for aggregation is to group Components, aggregate Components in the same group to (a) new Component(s), delete the detailed Components, and add the mapping to self._aggregation_map. - The general approach for disaggregation is to restore the detailed Components, move results from aggregated Components to detailed Components, and delete the aggregated Components.
Concrete Aggregators must implement the abstract methods _aggregate() and _disaggregate().
Some rules for using Aggregators: 1. Disaggragate can only be called after aggregate has been called. 2. Not allowed to call aggregate twice. Must call disaggregate before aggregate can be called again. 3. Aggregators are stored in Model when aggregate is called. Disaggregate by calling Model.disaggregate(), which will disaggregate all Aggregators in LIFO order. 4. At the moment we allow changes to the aggregated Components, which is ignored during disaggregation. TODO: Handle this 5. It is recommended to only use the same Aggregator type once on the same components of a Model. If you want to go from one aggregation level to another, it is better to use Model.disaggregate first and then aggregate again. This is to keep the logic simple and avoid complex expressions.
Some design notes: - Levels and profiles are aggregated separately and then combined into attributes. - We have chosen to eagerly evaluate weights for aggregation (weighted averages) and disaggregation of levels and profiles. This approach supports any form of aggregation by varying the weights, and complex weights can be created by eagerly evaluating expressions and using the result to compute those weights. - This is a balance between eagerly evaluating everything and setting up complex expressions. Eagerly evaluating everything would require setting up new TimeVectors after evaluation, which is not ideal. While setting up complex expressions gives expressions that are harder to work with and slower to query from. - This trade-off simplifies adding logic that recognises if result expressions come from aggregations or disaggregations. When aggregating or disaggregating these, we can go back to the original results rather than setting up complex expressions that for examples aggregates the disaggregated results.
Source code in framcore/aggregators/Aggregator.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
__init__() -> None
Initialize the Aggregator with default state for aggregation tracking and data storage.
Source code in framcore/aggregators/Aggregator.py
53 54 55 56 57 | |
aggregate(model: Model) -> None
Aggregate model. Keep original data in case disaggregate is called.
Source code in framcore/aggregators/Aggregator.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
disaggregate(model: Model) -> None
Disaggregate model back to pre-aggregate form. Move results into the disaggregated objects.
Source code in framcore/aggregators/Aggregator.py
90 91 92 93 94 95 96 97 | |
get_aggregation_map() -> dict[str, set[str]]
Return dictionary mapping from disaggregated to aggregated Component IDs.
The mapping should tell you which of the original Components were aggregated into which new Components. Components which are left as is should not be in the mapping. Components which are deleted without being aggregated are mapped to an empty set.
Source code in framcore/aggregators/Aggregator.py
99 100 101 102 103 104 105 106 107 108 109 110 | |
transfer_unambigous_memberships(group_component: Component, member_components: Iterable[Component]) -> None
Transfer unambiguous membership metadata from member components to a group component.
Parameters
group_component : Component The component to which unambiguous membership metadata will be transferred. member_components : Iterable[Component] The components from which membership metadata is collected.
Notes
Only metadata keys with a single unique Member value among all member components are transferred. Existing metadata on the group component is not overwritten.
Source code in framcore/aggregators/Aggregator.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
HydroAggregator
HydroAggregator
Bases: Aggregator
Aggregate HydroModules into two equivalent modules based on the regulation factor, into one regulated and one unregulated module per area.
Aggregation steps (self._aggregate):
- Group modules based on their power nodes (self._group_modules_by_power_node)
- Modules with generators are grouped based on their power nodes. You can choose to only group modules for certain power nodes by giving self._power_node_members alone or together with self._metakey_power_node. NB! Watershed that crosses power nodes should not be aggregated in two different HydroAggregators as the aggregator will remove all connected modules from the model after the first aggregation.
- Reservoirs are assigned to the power node which has the highest cumulative energy equivalent downstream of the reservoir. This is because JulES currently only support one-to-one mapping of detailed and aggregated reservoirs.
- Reservoirs without generators downstream are ignored in the aggregation.
- Group area modules into regulated and unregulated based on regulation factor (self._group_modules_by_regulation_factor)
- Regulation factor = upstream reservoir capacity / yearly upstream inflow. Modules with generators that have regulation factor <= self._ror_threshold are grouped into unregulated run-of-river modules, the other modules with generators are grouped into regulated reservoir modules.
- All reservoirs are assigned to the regulated group.
- Generators without upstream inflows are ignored in the aggregation.
- Make aggregated hydro module for each group (self._aggregate_groups)
- The resulting HydroModule has a generator with energy equivalent of 1 kWh/m3. The inflow, discharge capacity and reservoir capacity is calculated based on energy and transformed back to water using this energy equivalent.
- Generation capacity (release_cap*energy_equivalent/agg_energy_equivalent, capacity of hydraulic couplings not double counted). The release capacity profile is ignored except if self._release_capacity_profile is given, then this profile is used for all aggregated modules.
- Energy reservoir capacity (res_cap*energy_equivalent_downstream/agg_energy_equivalent)
- Gross energy inflow (inflow_up*energy_equivalent/agg_energy_equivalent) - TODO: Add possibility to adjust inflow to closer represent net inflow
- Inflow profiles weighted based on gross energy inflow (inflow_up_per_profile*energy_equivalent) - calc from core model using self._map_topology()
- TODO: Other details like pumps and environmental constraints are currently ignored in the aggregation. 3a. Aggregate results if all modules in group have results.
- Production is the sum of production levels with weighted profiles
- Reservoir filling is the sum of energy reservoir filling levels (filling*energy_equivalent_downstream/agg_energy_equivalent) with weighted profiles
- TODO: Water values, spill, bypass and pumping results are currently ignored in the aggregation.
- TODO: Add possibility to skip results aggregation. 3b. Make new hydro module and delete original modules from model data.
- Add mapping from detailed to aggregated modules to self._aggregation_map.
Disaggregation steps (self._disaggregate):
- Restore original modules from self._original_data. NB! Changes to aggregated modules are lost except for results (TODO)
- Move production and filling results from aggregated modules to detailed modules, weighted based on production capacity and reservoir capacity.
- TODO: Water values, spill, bypass and pumping results are currently ignored in the disaggregation.
- Delete aggregated modules.
NB! Watershed that crosses power nodes should not be aggregated in two different HydroAggregators as the aggregator will remove all connected modules from the model after the first aggregation. Reservoirs will also be assigned to the power node which has the highest cumulative energy equivalent, so this aggregator does not work well for reservoirs that are upstream of multiple power nodes.
See Aggregator for general design notes and rules to follow when using Aggregators.
Attributes:
| Name | Type | Description |
|---|---|---|
_metakey_energy_eq_downstream |
str
|
Metadata key for energy equivalent downstream. |
_data_dim |
SinglePeriodTimeIndex
|
Data dimension for eager evalutation. |
_scen_dim |
FixedFrequencyTimeIndex
|
Scenario dimension for eager evalutation. |
_grouped_modules |
dict[str, set[str]]
|
Mapping of aggregated modules to detailed modules. agg to detailed |
_grouped_reservoirs |
dict[str, set[str]]
|
Mapping of aggregated reservoirs to detailed reservoirs. agg to detailed |
_ror_threshold |
float
|
Regulation factor (upstream reservoir capacity / yearly upstream inflow) threshold for run-of-river classification. Default is 0.5. |
_metakey_power_node |
str | None
|
If given, check metadata of power nodes to check if they should be grouped. |
_power_node_members |
list[str] | None
|
If given along with metakey_power_node, group modules only for power nodes with these metadata values. If given without metakey_power_node, only group power nodes in this list. |
_release_capacity_profile |
TimeVector | None
|
If given, use this profile for all aggregated modules' release capacities. |
Parent Attributes (see framcore.aggregators.Aggregator):
_is_last_call_aggregate (bool | None): Tracks whether the last operation was an aggregation.
_original_data (dict[str, Component | TimeVector | Curve | Expr] | None): Original detailed data before aggregation.
_aggregation_map (dict[str, set[str]] | None): Maps aggregated components to their detailed components. detailed to agg
Source code in framcore/aggregators/HydroAggregator.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 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 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 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 | |
__init__(metakey_energy_eq_downstream: str, data_dim: SinglePeriodTimeIndex, scen_dim: FixedFrequencyTimeIndex, ror_threshold: float = 0.5, metakey_power_node: str | None = None, power_node_members: list[str] | None = None, release_capacity_profile: TimeVector | None = None) -> None
Initialize HydroAggregator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metakey_energy_eq_downstream
|
str
|
Metadata key for energy equivalent downstream. Can be calculated with framcore.utils.set_global_energy_equivalent |
required |
data_dim
|
SinglePeriodTimeIndex
|
Data dimension for eager evalutation. |
required |
scen_dim
|
FixedFrequencyTimeIndex
|
Scenario dimension for eager evalutation. |
required |
ror_threshold
|
float
|
Regulation factor (upstream reservoir capacity / yearly upstream inflow) threshold for run-of-river classification. Default is 0.5. |
0.5
|
metakey_power_node
|
str | None
|
If given, check metadata of power nodes to check if they should be grouped. |
None
|
power_node_members
|
list[str] | None
|
If given along with metakey_power_node, group modules only for power nodes with these metadata values. If given without metakey_power_node, only group power nodes in this list. |
None
|
release_capacity_profile
|
TimeVector | None
|
If given, use this profile for all aggregated modules' release capacities. |
None
|
Source code in framcore/aggregators/HydroAggregator.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
NodeAggregator
NodeAggregator
Bases: Aggregator
Aggregate groups of Nodes for a commodity. Subclass of Aggregator.
Aggregation steps (self._aggregate):
- Map all Components to their Nodes of the correct commodity if they are referencing any. This is important to redirect all references to the new Nodes after aggregation.
- Create mapping of what members the new Nodes will be aggregated from. This step also does alot of error handling and checks the validity of the
metadata and groupings. Raises error if:
- Nodes do not have any metadata for the meta key.
- Nodes have the wrong metadata object type for the meta key (must be Member).
- Exogenous Nodes are grouped together for aggregation with endogenous Nodes.
- Initialize new Node objects and set prices and exogenous status. Prices are calculated as a weighted average of all the member Node prices.
- Old Nodes are deleted from the Model data, after which the aggregated Node is added, and references in the rest of the system are updated to point to the new Node.
- Handling of transports: All Components which transport the same commodity as the aggregated Nodes are analysed. If the two Nodes they connect is now the same aggregated Node, the transpart is 'internal' meaning it is now operating within a Node. If the transport Component is lossy, it is replaced by a Demand Component representing the commodity consumption caused by the loss. All internal transports are afterwards deleted.
Disaggregation steps (self._aggregate):
- Collect set of Nodes group keys for which have been either removed from the Model data or changed to reference something other than Nodes.
- Validate that IDs of Nodes to be restored have not been used to reference something else in the meantime.
- Delete the aggregated Nodes and restore the old Nodes to the Model. Also copy shadow price results from the aggregated Nodes to the disaggregated. NB! This will overwrite the possible previous shadow prices of the original disaggregated Nodes.
- Restore the references in all objects to the disaggregated Nodes. A mapping created during aggregation is used for this.
- Validate that no restorable internal transports has a name conflict with existing objects in the Model. NB! an internal transport is not restorable if one or both of its referenced Nodes have been removed from the Model or is now referencing another object. See step 1.
- Restore all the restorable internal transports from the original data.
- Delete the aggregation-created Demand objects representing internal transports.
See Aggregator for general design notes and rules to follow when using Aggregators.
Source code in framcore/aggregators/NodeAggregator.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 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 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 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | |
__init__(commodity: str, meta_key: str, data_dim: SinglePeriodTimeIndex, scen_dim: FixedFrequencyTimeIndex, utilization_rate: float = 0.5) -> None
Aggregate groups of nodes (defined by metadata key) for a commodity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commodity
|
str
|
Commodity of the Nodes to be aggregated. |
required |
meta_key
|
str
|
description |
required |
data_dim
|
SinglePeriodTimeIndex
|
Data dimension for eager evalutation of prices. |
required |
scen_dim
|
FixedFrequencyTimeIndex
|
Scenario dimension for eager evalutation of prices. |
required |
utilization_rate
|
float
|
Assumed utilization rate on internal transports. Used to calculate new Demands after aggregation if the transport does not have a volume. Defaults to 0.5 (i.e. 50 percent utilization in each direction). |
0.5
|
Source code in framcore/aggregators/NodeAggregator.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
WindSolarAggregator
SolarAggregator
Bases: _WindSolarAggregator
Aggregate Solar components into groups based on their power nodes.
Aggregation steps (self._aggregate):
- Group components based on their power nodes (self._group_by_power_node):
- Aggregate grouped components into a single aggregated component for each group (self._aggregate_groups):
- Max_capacity is calculated as the sum of the maximum capacity levels with weighted profiles.
- Variable operation costs (voc) are aggregated using weighted averages based on the weighting method (now ony max_capacity supported).
- TODO: Add support for additional weighting methods (e.g. production instead of capacity).
- Production is aggregated as the sum of production levels with weighted profiles. 2a. Make new hydro module and delete original components from model data.
- Add mapping from detailed to aggregated components to self._aggregation_map.
Disaggregation steps (self._disaggregate):
- Restore original components from self._original_data. NB! Changes to aggregated modules are lost except for results.
- Distribute production from aggregated components back to the original components:
- Results are weighted based on the weighting method (now ony max_capacity supported).
- Delete aggregated components from the model.
See Aggregator for general design notes and rules to follow when using Aggregators.
Attributes:
| Name | Type | Description |
|---|---|---|
_data_dim |
SinglePeriodTimeIndex | None
|
Data dimension for eager evaluation. |
_scen_dim |
FixedFrequencyTimeIndex | None
|
Scenario dimension for eager evaluation. |
_grouped_components |
dict[str, set[str]]
|
Mapping of aggregated components to their detailed components. agg to detailed |
Parent Attributes (see framcore.aggregators.Aggregator):
_is_last_call_aggregate (bool | None): Tracks whether the last operation was an aggregation.
_original_data (dict[str, Component | TimeVector | Curve | Expr] | None): Original detailed data before aggregation.
_aggregation_map (dict[str, set[str]] | None): Maps aggregated components to their detailed components. detailed to agg
Source code in framcore/aggregators/WindSolarAggregator.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 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 | |
WindAggregator
Bases: _WindSolarAggregator
Aggregate Wind components into groups based on their power nodes.
Aggregation steps (self._aggregate):
- Group components based on their power nodes (self._group_by_power_node):
- Aggregate grouped components into a single aggregated component for each group (self._aggregate_groups):
- Max_capacity is calculated as the sum of the maximum capacity levels with weighted profiles.
- Variable operation costs (voc) are aggregated using weighted averages based on the weighting method (now ony max_capacity supported).
- TODO: Add support for additional weighting methods (e.g. production instead of capacity).
- Production is aggregated as the sum of production levels with weighted profiles. 2a. Make new hydro module and delete original components from model data.
- Add mapping from detailed to aggregated components to self._aggregation_map.
Disaggregation steps (self._disaggregate):
- Restore original components from self._original_data. NB! Changes to aggregated modules are lost except for results.
- Distribute production from aggregated components back to the original components:
- Results are weighted based on the weighting method (now ony max_capacity supported).
- Delete aggregated components from the model.
See Aggregator for general design notes and rules to follow when using Aggregators.
Attributes:
| Name | Type | Description |
|---|---|---|
_data_dim |
SinglePeriodTimeIndex | None
|
Data dimension for eager evaluation. |
_scen_dim |
FixedFrequencyTimeIndex | None
|
Scenario dimension for eager evaluation. |
_grouped_components |
dict[str, set[str]]
|
Mapping of aggregated components to their detailed components. agg to detailed |
Parent Attributes (see framcore.aggregators.Aggregator):
_is_last_call_aggregate (bool | None): Tracks whether the last operation was an aggregation.
_original_data (dict[str, Component | TimeVector | Curve | Expr] | None): Original detailed data before aggregation.
_aggregation_map (dict[str, set[str]] | None): Maps aggregated components to their detailed components. detailed to agg
Source code in framcore/aggregators/WindSolarAggregator.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
attributes
AvgFlowVolume
Bases: FlowVolume
Concrete class representing an average flow volume attribute, indicating a flow variable with average values.
Subclass of FlowVolume < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
881 882 883 884 885 886 887 888 | |
Coefficient
Bases: LevelProfile
Abstract class representing a coefficient attribute, used as a base class for various coefficient types.
Subclass of LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
730 731 732 733 734 735 736 737 | |
Conversion
Bases: ArrowCoefficient
Concrete class representing a conversion coefficient attribute, used for conversion factors in the model.
Subclass of ArrowCoefficient < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
871 872 873 874 875 876 877 878 | |
Cost
Bases: ObjectiveCoefficient
Concrete class representing a cost attribute, indicating cost coefficients in the objective function.
Subclass of ObjectiveCoefficient < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
795 796 797 798 799 800 801 802 803 | |
Efficiency
Bases: ArrowCoefficient
Concrete class representing an efficiency coefficient attribute, indicating a unitless coefficient.
Subclass of ArrowCoefficient < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
849 850 851 852 853 854 855 856 857 | |
Elasticity
Bases: Coefficient
Concrete class representing an elasticity coefficient attribute, indicating a unitless coefficient.
Subclass of Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
817 818 819 820 821 822 823 824 825 | |
FlowVolume
Bases: LevelProfile
Abstract class representing a flow volume attribute, indicating that the attribute is a flow variable.
Subclass of LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
720 721 722 723 724 725 726 727 | |
Hours
Bases: Coefficient
Concrete class representing an hours coefficient attribute, indicating a time-related coefficient.
Subclass of Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
839 840 841 842 843 844 845 846 | |
HydroBypass
Bases: Base
HydroBypass represents a controlled water way from a HydroModule. Used to bypass main release of the HydroModule.
Source code in framcore/attributes/hydro/HydroBypass.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
__init__(to_module: str | None, capacity: FlowVolume | None = None) -> None
Initialize object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_module
|
str | None
|
Name of the HydroModule the water is released to. |
required |
capacity
|
FlowVolume | None
|
Restrictions on the volume of water which can pass through the bypass at a given moment. Defaults to None. |
None
|
Source code in framcore/attributes/hydro/HydroBypass.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
get_capacity() -> FlowVolume | None
Get the capacity of the bypass.
Source code in framcore/attributes/hydro/HydroBypass.py
40 41 42 | |
get_to_module() -> str | None
Get the name of the module to which the bypass leads.
Source code in framcore/attributes/hydro/HydroBypass.py
31 32 33 | |
get_volume() -> AvgFlowVolume
Get the volume of the bypass.
Source code in framcore/attributes/hydro/HydroBypass.py
44 45 46 | |
set_to_module(to_module: str) -> None
Set the name of the module to which the bypass leads.
Source code in framcore/attributes/hydro/HydroBypass.py
35 36 37 38 | |
HydroGenerator
Bases: Base
Produces power from the main release of a HydroModule.
Produces to a power node, and can have variable costs associated with operation. Other attributes are energy equivalent, PQ curve, nominal head and tailwater elevation.
Source code in framcore/attributes/hydro/HydroGenerator.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
__init__(power_node: str, energy_equivalent: Conversion, pq_curve: Expr | str | Curve | None = None, nominal_head: Expr | str | TimeVector | None = None, tailwater_elevation: Expr | str | TimeVector | None = None, voc: Cost | None = None, production: AvgFlowVolume | None = None) -> None
Initialize a HydroGenerator with parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power_node
|
str
|
Node to supply power to. |
required |
energy_equivalent
|
Conversion
|
Conversion factor of power produced to water released. |
required |
pq_curve
|
Expr | str | Curve | None
|
Expression or curve describing the relationship produced power and water released. Defaults to None. |
None
|
nominal_head
|
Expr | str | TimeVector | None
|
Vertical distance between upstream and dowstream water level. Defaults to None. |
None
|
tailwater_elevation
|
Expr | str | TimeVector | None
|
Elevation at the surface where the water exits the turbine. Defaults to None. |
None
|
voc
|
Cost | None
|
Variable operational costs. Defaults to None. |
None
|
production
|
AvgFlowVolume | None
|
Result of power volume produced. Defaults to None. |
None
|
Source code in framcore/attributes/hydro/HydroGenerator.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
get_energy_equivalent() -> Conversion
Get the energy equivalent of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
70 71 72 | |
get_nominal_head() -> Expr | None
Get the nominal head of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
78 79 80 | |
get_power_node() -> str
Get the power node of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
61 62 63 | |
get_pq_curve() -> Expr | None
Get the PQ curve of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
74 75 76 | |
get_production() -> AvgFlowVolume
Get the generation of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
95 96 97 | |
get_tailwater_elevation() -> Expr | None
Get the tailwater elevation of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
82 83 84 | |
get_voc() -> Cost | None
Get the variable operation and maintenance cost of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
86 87 88 | |
set_power_node(power_node: str) -> None
Set the power node of the pump unit.
Source code in framcore/attributes/hydro/HydroGenerator.py
65 66 67 68 | |
set_voc(voc: Cost) -> None
Set the variable operation and maintenance cost of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
90 91 92 93 | |
HydroPump
Bases: Base
Represent a pump associated with a HydroModule.
The HydroPump can consume power from a power Node to move water upstream between two HydroModules. It has a max power capacity, and mean energy equivalent and water capacity. It can also describe the relationship between head and flow (Q), with min and max head and flow.
Results for water and power consumption are stored as AvgFlowVolume attributes.
Source code in framcore/attributes/hydro/HydroPump.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
__init__(power_node: str, from_module: str, to_module: str, water_capacity: FlowVolume, energy_equivalent: Conversion, power_capacity: FlowVolume | None = None, head_min: Expr | str | TimeVector | None = None, head_max: Expr | str | TimeVector | None = None, q_min: Expr | str | TimeVector | None = None, q_max: Expr | str | TimeVector | None = None) -> None
Initialize a HydroPump object parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power_node
|
str
|
Node to take power from when operating. |
required |
from_module
|
str
|
Source HydroModule to move water from. |
required |
to_module
|
str
|
Destination HydroModule to move water to. |
required |
water_capacity
|
FlowVolume
|
Max pumped water volume given the mean energy equivalent and power capacity. |
required |
energy_equivalent
|
Conversion
|
Mean conversion factor between power consumed and volume of water moved. |
required |
power_capacity
|
FlowVolume | None
|
Max power consumed. Defaults to None. |
None
|
head_min
|
Expr | str | TimeVector | None
|
Minimum elevation difference between upstream and downstream water level. Defaults to None. |
None
|
head_max
|
Expr | str | TimeVector | None
|
Maximum elevation difference between upstream and downstream water level. Defaults to None. |
None
|
q_min
|
Expr | str | TimeVector | None
|
Maximum water flow at head_min. Defaults to None. |
None
|
q_max
|
Expr | str | TimeVector | None
|
Maximum water flow at head_max. Defaults to None. |
None
|
Source code in framcore/attributes/hydro/HydroPump.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
get_energy_equivalent() -> Conversion
Get the energy equivalent of hydro pump.
Source code in framcore/attributes/hydro/HydroPump.py
130 131 132 | |
get_from_module() -> str
Get the module from which the pump unit is pumping.
Source code in framcore/attributes/hydro/HydroPump.py
91 92 93 | |
get_head_max() -> Expr
Get max fall height of hydro pump.
Source code in framcore/attributes/hydro/HydroPump.py
147 148 149 | |
get_head_min() -> Expr
Get min fall height of hydro pump.
Source code in framcore/attributes/hydro/HydroPump.py
139 140 141 | |
get_power_capacity() -> FlowVolume
Get the capacity of the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
78 79 80 | |
get_power_consumption() -> FlowVolume
Get the power consumption of the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
111 112 113 | |
get_power_node() -> str
Get the power node of the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
82 83 84 | |
get_q_max() -> Expr
Get Q max of hydro pump.
Source code in framcore/attributes/hydro/HydroPump.py
163 164 165 | |
get_q_min() -> Expr
Get Q min of hydro pump.
Source code in framcore/attributes/hydro/HydroPump.py
155 156 157 | |
get_to_module() -> str
Get the module to which the pump unit is pumping.
Source code in framcore/attributes/hydro/HydroPump.py
95 96 97 | |
get_water_capacity() -> FlowVolume
Get the capacity of the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
74 75 76 | |
get_water_consumption() -> FlowVolume
Get the water consumption of the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
107 108 109 | |
set_energy_eq(energy_eq: Conversion) -> None
Set the energy equivalent.
Source code in framcore/attributes/hydro/HydroPump.py
134 135 136 137 | |
set_head_max(hmax: Expr | str | None) -> None
Set max fall height.
Source code in framcore/attributes/hydro/HydroPump.py
151 152 153 | |
set_head_min(head_min: Expr | str | None) -> None
Set min fall height.
Source code in framcore/attributes/hydro/HydroPump.py
143 144 145 | |
set_modules(from_module: str, to_module: str) -> None
Set the modules for the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
101 102 103 104 105 | |
set_power_node(power_node: str) -> None
Set the power node of the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
86 87 88 89 | |
set_qmax(q_max: Expr | str | None) -> None
Set Q max.
Source code in framcore/attributes/hydro/HydroPump.py
167 168 169 | |
set_qmin(q_min: Expr | str | None) -> None
Set Q min.
Source code in framcore/attributes/hydro/HydroPump.py
159 160 161 | |
HydroReservoir
Bases: Storage
Represent a hydro reservoir of a HydroModule.
Source code in framcore/attributes/hydro/HydroReservoir.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
__init__(capacity: StockVolume, reservoir_curve: ReservoirCurve = None, volume: StockVolume | None = None) -> None
Initialize a HydroReservoir instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capacity
|
StockVolume
|
The maximum storage capacity of the reservoir. |
required |
reservoir_curve
|
ReservoirCurve
|
The curve describing water level elevation to volume characteristics. |
None
|
volume
|
StockVolume
|
Volume of water in the reservoir. |
None
|
Source code in framcore/attributes/hydro/HydroReservoir.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
LevelProfile
Bases: Base, ABC
Attributes representing timeseries data for Components. Mostly as Level * Profile, where both Level and Profile are Expr (expressions).
Level and Profile represent two distinct dimensions of time. This is because we want to simulate future system states with historical weather patterns. Therefore, Level represents the system state at a given time (data_dim), while Profile represents the scenario dimension (scen_dim). A Level would for example represent the installed capacity of solar plants towards 2030, while the Profile would represent the historical variation between 1991-2020.
Level and Profile can have two main formats: A maximum Level with a Profile that varies between 0-1, and an average Level with a Profile with a mean of 1 (the latter can have a ReferencePeriod). The max format is, for example, used for capacities, while the mean format can be used for prices and flows. The system needs to be able to convert between the two formats. This is especially important for aggregations (for example weighted averages) where all the TimeVectors need to be on the same format for a correct result. One simple example of conversion is pairing a max Level of 100 MW with a mean_one Profile [0, 1, 2]. Asking for this on the max format will return the series 100[0, 0.5, 1] MW, while on the avg format it will return 50[0, 1, 2] MW.
Queries to LevelProfile need to provide a database, the desired target TimeIndex for both dimensions, the target unit and the desired format. At the moment we support these queries for LevelProfile: - self.get_data_value(db, scen_dim, data_dim, unit, is_max_level) - self.get_scenario_vector(db, scen_dim, data_dim, unit, is_float32)
In addition, we have the possibility to shift, scale, and change the intercept of the LevelProfiles. Then we get the full representation: Scale * (Level + Level_shift) * Profile + Intercept. - Level_shift adds a constant value to Level, has the same Profile as Level. - Scale multiplies (Level + Level_shift) by a constant value. - Intercept adds a constant value to LevelProfile, ignoring Level and Profile. This is the only way of supporting a timeseries that crosses zero in our system. This functionality is under development and has not been properly tested.
LevelProfiles also have additional properties that describes their behaviour. These can be used for initialization, validation, and to simplify queries. The properties are: - is_stock: True if attribute is a stock variable. Level Expr should also have is_stock=True. See Expr for details. - is_flow: True if attribute is a flow variable. Level Expr should also have is_flow=True. See Expr for details. - is_not_negative: True if attribute is not allowed to have negative values. Level Expr should also have only non-negative values. - is_max_and_zero_one: Preferred format of Level and Profile. Used for initialization and queries. - is_ingoing: True if attribute is ingoing, False if outgoing, None if neither. - is_cost: True if attribute is objective function cost coefficient. Else None. - is_unitless: True if attribute is known to be unitless. False if known to have a unit that is not None. Else None.
Source code in framcore/attributes/level_profile_attributes.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 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 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 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | |
__eq__(other) -> bool
Return True if other is equal to self.
Source code in framcore/attributes/level_profile_attributes.py
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 | |
__hash__() -> int
Compute hash of self.
Source code in framcore/attributes/level_profile_attributes.py
703 704 705 706 707 708 709 710 711 712 713 714 | |
__init__(level: Expr | TimeVector | str | None = None, profile: Expr | TimeVector | str | None = None, value: float | int | None = None, unit: str | None = None, level_shift: Expr | None = None, intercept: Expr | None = None, scale: Expr | None = None) -> None
Initialize LevelProfile.
See the LevelProfile class docstring for details. A complete LevelProfile is represented as: Scale * (Level + Level_shift) * Profile + Intercept. Normally only Level and Profile are used.
Either give level and profile, or value and unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
Expr | TimeVector | str | None
|
Level Expr. Defaults to None. |
None
|
profile
|
Expr | TimeVector | str | None
|
Profile Expr. Defaults to None. |
None
|
value
|
float | int | None
|
A constant value to initialize Level. Defaults to None. |
None
|
unit
|
str | None
|
Unit of the constant value to initialize Level. Defaults to None. |
None
|
level_shift
|
Expr | None
|
Level_shift Expr. Defaults to None. |
None
|
intercept
|
Expr | None
|
Intercept Expr. Defaults to None. |
None
|
scale
|
Expr | None
|
Scale Expr. Defaults to None. |
None
|
Source code in framcore/attributes/level_profile_attributes.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
add_loaders(loaders: set[Loader]) -> None
Add all loaders stored in expressions to loaders.
Source code in framcore/attributes/level_profile_attributes.py
166 167 168 169 170 171 | |
clear() -> None
Set all internal fields to None.
You may want to use this to get exogenous flow to use capacities instead of volume.
Source code in framcore/attributes/level_profile_attributes.py
173 174 175 176 177 178 179 180 181 182 183 | |
copy_from(other: LevelProfile) -> None
Copy fields from other.
Source code in framcore/attributes/level_profile_attributes.py
259 260 261 262 263 264 265 266 267 | |
get_data_value(db: QueryDB | Model, scenario_horizon: FixedFrequencyTimeIndex, level_period: SinglePeriodTimeIndex, unit: str | None, is_max_level: bool | None = None) -> float
Evaluate LevelProfile to a scalar at the level period of the data dimension, and as an average over the scenario horizon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db
|
QueryDB | Model
|
The database or model instance used to fetch the required data. |
required |
scenario_horizon
|
FixedFrequencyTimeIndex
|
TimeIndex of the scenario dimension to evaluate profiles. |
required |
level_period
|
SinglePeriodTimeIndex
|
TimeIndex of the data dimension to evaluate levels. |
required |
unit
|
str | None
|
The unit to convert the resulting values into (e.g., MW, GWh). If None, the expression should be unitless. |
required |
is_max_level
|
bool | None
|
Whether to evaluate the expression as a maximum level (with a zero_one profile) or as an average level (with a mean_one profile). If None, the default format of the attribute is used. |
None
|
Source code in framcore/attributes/level_profile_attributes.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
get_intercept() -> Expr | None
Get intercept part of (level * profile + intercept).
Source code in framcore/attributes/level_profile_attributes.py
313 314 315 316 317 318 | |
get_level() -> Expr | None
Get level part of (level * profile + intercept).
Source code in framcore/attributes/level_profile_attributes.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
get_level_unit_set(db: QueryDB | Model) -> set[TimeIndex]
Return set with all units behind level expression.
Useful for discovering valid unit input to get_level_value.
Source code in framcore/attributes/level_profile_attributes.py
327 328 329 330 331 332 333 334 335 336 337 338 | |
get_profile() -> Expr | None
Get profile part of (level * profile + intercept).
Source code in framcore/attributes/level_profile_attributes.py
302 303 304 | |
get_profile_timeindex_set(db: QueryDB | Model) -> set[TimeIndex]
Return set with all TimeIndex behind profile expression.
Can be used to run optimized queries, i.e. not asking for finer time resolutions than necessary.
Source code in framcore/attributes/level_profile_attributes.py
340 341 342 343 344 345 346 347 348 349 350 351 352 | |
get_scenario_vector(db: QueryDB | Model, scenario_horizon: FixedFrequencyTimeIndex, level_period: SinglePeriodTimeIndex, unit: str | None, is_float32: bool = True) -> NDArray
Evaluate LevelProfile over the periods in scenario dimension, and at the level period of the data dimension.
Underlying profiles are evalutated over the scenario dimension, and levels are evalutated to scalars over level_period in the data dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db
|
QueryDB | Model
|
The database or model instance used to fetch the required data. |
required |
scenario_horizon
|
FixedFrequencyTimeIndex
|
TimeIndex of the scenario dimension to evaluate profiles. |
required |
level_period
|
SinglePeriodTimeIndex
|
TimeIndex of the data dimension to evaluate levels. |
required |
unit
|
str | None
|
The unit to convert the resulting values into (e.g., MW, GWh). If None, the expression should be unitless. |
required |
is_float32
|
bool
|
Whether to return the vector as a NumPy array with |
True
|
Source code in framcore/attributes/level_profile_attributes.py
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 | |
has_intercept() -> bool
Return True if get_intercept will return value not None.
Source code in framcore/attributes/level_profile_attributes.py
255 256 257 | |
has_level() -> bool
Return True if get_level will return value not None.
Source code in framcore/attributes/level_profile_attributes.py
247 248 249 | |
has_profile() -> bool
Return True if get_profile will return value not None.
Source code in framcore/attributes/level_profile_attributes.py
251 252 253 | |
is_cost() -> bool | None
Return True if attribute is objective function cost coefficient.
Return False if attribute is objective function revenue coefficient.
Return None if not applicable.
Source code in framcore/attributes/level_profile_attributes.py
227 228 229 230 231 232 233 234 235 | |
is_flow() -> bool
Return True if attribute is a flow variable.
Return False if attribute is not a flow variable.
Source code in framcore/attributes/level_profile_attributes.py
193 194 195 196 197 198 199 | |
is_ingoing() -> bool | None
Return True if attribute is ingoing.
Return True if attribute is outgoing.
Return None if not applicable.
Source code in framcore/attributes/level_profile_attributes.py
217 218 219 220 221 222 223 224 225 | |
is_max_and_zero_one() -> bool
When True level should be max (not average) and corresponding profile should be zero_one (not mean_one).
When False level should be average (not max) and corresponding profile should be mean_one (not zero_one).
Source code in framcore/attributes/level_profile_attributes.py
209 210 211 212 213 214 215 | |
is_not_negative() -> bool
Return True if attribute is not allowed to have negative values.
Return False if attribute can have both positive and negative values.
Source code in framcore/attributes/level_profile_attributes.py
201 202 203 204 205 206 207 | |
is_stock() -> bool
Return True if attribute is a stock variable.
Return False if attribute is not a stock variable.
Source code in framcore/attributes/level_profile_attributes.py
185 186 187 188 189 190 191 | |
is_unitless() -> bool | None
Return True if attribute is known to be unitless.
Return False if attribute is known to have a unit that is not None.
Return None if not applicable.
Source code in framcore/attributes/level_profile_attributes.py
237 238 239 240 241 242 243 244 245 | |
scale(value: float | int) -> None
Modify the scale part of (scale * (level + level_shift) * profile + intercept) of an attribute by multiplying with a constant value.
Source code in framcore/attributes/level_profile_attributes.py
455 456 457 458 459 460 461 462 463 464 465 466 467 | |
set_intercept(value: Expr | None) -> None
Set intercept part of (level * profile + intercept).
Source code in framcore/attributes/level_profile_attributes.py
320 321 322 323 324 325 | |
set_level(level: Expr | TimeVector | str | None) -> None
Set level part of (scale * (level + level_shift) * profile + intercept).
Source code in framcore/attributes/level_profile_attributes.py
295 296 297 298 299 300 | |
set_profile(profile: Expr | TimeVector | str | None) -> None
Set profile part of (scale * (level + level_shift) * profile + intercept).
Source code in framcore/attributes/level_profile_attributes.py
306 307 308 309 310 311 | |
shift_intercept(value: float, unit: str | None) -> None
Modify the intercept part of (level * profile + intercept) of an attribute by adding a constant value.
Source code in framcore/attributes/level_profile_attributes.py
403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
shift_level(value: float | int, unit: str | None = None, reference_period: ReferencePeriod | None = None, is_max_level: bool | None = None, use_profile: bool = True) -> None
Modify the level_shift part of (scale * (level + level_shift) * profile + intercept) of an attribute by adding a constant value.
Source code in framcore/attributes/level_profile_attributes.py
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 448 449 450 451 452 453 | |
Loss
Bases: ArrowCoefficient
Concrete class representing a loss coefficient attribute, indicating a unitless coefficient.
Subclass of ArrowCoefficient < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
860 861 862 863 864 865 866 867 868 | |
MaxFlowVolume
Bases: FlowVolume
Concrete class representing a maximum flow volume attribute, indicating a flow variable with maximum values.
Subclass of FlowVolume < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
891 892 893 894 895 896 897 898 899 | |
ObjectiveCoefficient
Bases: Coefficient
Abstract class representing an objective coefficient attribute, indicating cost or revenue coefficients in the objective function.
Subclass of Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
761 762 763 764 765 766 767 768 769 | |
Price
Bases: ShadowPrice
Concrete class representing a price attribute, indicating the price of a commodity at a specific node.
Subclass of ShadowPrice < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
775 776 777 778 779 780 781 782 | |
Proportion
Bases: Coefficient
Concrete class representing a proportion coefficient attribute, indicating a unitless coefficient between 0 and 1.
Subclass of Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
828 829 830 831 832 833 834 835 836 | |
ReservePrice
Bases: ObjectiveCoefficient
Concrete class representing a reserve price attribute, indicating revenue coefficients in the objective function.
Subclass of ObjectiveCoefficient < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
806 807 808 809 810 811 812 813 814 | |
ShadowPrice
Bases: Coefficient
Abstract class representing a shadow price attribute, indicating that the attribute has a unit and might be negative.
Subclass of Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
750 751 752 753 754 755 756 757 758 | |
StockVolume
Bases: LevelProfile
Concrete class representing a stock volume attribute, indicating a stock variable with maximum values.
Subclass of LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
902 903 904 905 906 907 908 909 910 911 | |
WaterValue
Bases: ShadowPrice
Concrete class representing a water value attribute, indicating the value of water in the system.
Subclass of ShadowPrice < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
785 786 787 788 789 790 791 792 | |
Arrow
Arrow
Bases: Base
Arrow class is used by Flows to represent contribution of its commodity to Nodes.
The Arrow has direction to determine input or output (is_ingoing), and parameters for the contribution of the Flow to the Node. The main parameters are conversion, efficiency and loss which together form the coefficient = conversion * (1 / efficiency) * (1 - loss) Arrow has its own implementation of get_scenario_vector and get_data_value to calculate the coefficient shown above.
Source code in framcore/attributes/Arrow.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
__init__(node: str, is_ingoing: bool, conversion: Conversion | None = None, efficiency: Efficiency | None = None, loss: Loss | None = None) -> None
Initialize the Arrow class.
Source code in framcore/attributes/Arrow.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
add_loaders(loaders: set[Loader]) -> None
Add all loaders stored in attributes to loaders.
Source code in framcore/attributes/Arrow.py
301 302 303 304 305 306 307 | |
get_conversion() -> Conversion | None
Get the conversion.
Source code in framcore/attributes/Arrow.py
65 66 67 | |
get_conversion_unit_set(db: QueryDB | Model) -> set[str]
Get set of units behind conversion level expr (if any).
Source code in framcore/attributes/Arrow.py
100 101 102 103 104 105 106 107 | |
get_data_value(db: QueryDB | Model, scenario_horizon: FixedFrequencyTimeIndex, level_period: SinglePeriodTimeIndex, unit: str | None, is_max_level: bool = False) -> float
Return float for level_period.
Source code in framcore/attributes/Arrow.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
get_efficiency() -> Efficiency | None
Get the efficiency.
Source code in framcore/attributes/Arrow.py
74 75 76 | |
get_loss() -> Loss | None
Get the loss.
Source code in framcore/attributes/Arrow.py
83 84 85 | |
get_node() -> str
Get the node the arrow is pointing to.
Source code in framcore/attributes/Arrow.py
47 48 49 | |
get_profile_timeindex_set(db: QueryDB | Model) -> set[TimeIndex]
Get set of timeindexes behind profile.
Can be used to run optimized queries, i.e. not asking for finer time resolutions than necessary.
Source code in framcore/attributes/Arrow.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
get_scenario_vector(db: QueryDB | Model, scenario_horizon: FixedFrequencyTimeIndex, level_period: SinglePeriodTimeIndex, unit: str | None, is_float32: bool = True) -> NDArray
Return vector with values along the given scenario horizon using level over level_period.
Source code in framcore/attributes/Arrow.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
has_profile() -> bool
Return True if any of conversion, efficiency or loss has profile.
Source code in framcore/attributes/Arrow.py
92 93 94 95 96 97 98 | |
is_ingoing() -> bool
Return True if arrow is ingoing.
Ingoing means the flow variable supplies to node. Outgoing means the flow variable takes out of node.
Source code in framcore/attributes/Arrow.py
56 57 58 59 60 61 62 63 | |
set_conversion(value: Conversion | None) -> None
Set the conversion.
Source code in framcore/attributes/Arrow.py
69 70 71 72 | |
set_efficiency(value: Efficiency | None) -> None
Set the efficiency.
Source code in framcore/attributes/Arrow.py
78 79 80 81 | |
set_loss(value: Loss | None) -> None
Set the loss.
Source code in framcore/attributes/Arrow.py
87 88 89 90 | |
set_node(node: str) -> None
Set the node the arrow is pointing to.
Source code in framcore/attributes/Arrow.py
51 52 53 54 | |
ElasticDemand
ElasticDemand attribute class.
ElasticDemand
Bases: Base
ElasticDemand class representing the price elasticity of a demand Component.
Source code in framcore/attributes/ElasticDemand.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
__init__(price_elasticity: Elasticity, min_price: Price, normal_price: Price, max_price: Price) -> None
Initialize the ElasticDemand class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
price_elasticity
|
Elasticity
|
The price elasticity factor of the demand consumer. |
required |
min_price
|
Price
|
Lower limit for price elasticity. |
required |
normal_price
|
Price
|
Price for which the demand is inelastic. If it deviates from this price, the consumer will adjust it's consumption according to the _price_elasticity factor. |
required |
max_price
|
Price
|
Upper limit for price elasticity / reservation price level. |
required |
Source code in framcore/attributes/ElasticDemand.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
add_loaders(loaders: set[Loader]) -> None
Add all loaders stored in attributes to loaders.
Source code in framcore/attributes/ElasticDemand.py
83 84 85 86 87 88 89 90 | |
get_max_price() -> Price
Get the maximum price.
Source code in framcore/attributes/ElasticDemand.py
74 75 76 | |
get_min_price() -> Price
Get the minimum price.
Source code in framcore/attributes/ElasticDemand.py
56 57 58 | |
get_normal_price() -> Price
Get the normal price.
Source code in framcore/attributes/ElasticDemand.py
65 66 67 | |
get_price_elasticity() -> Elasticity
Get the price elasticity.
Source code in framcore/attributes/ElasticDemand.py
47 48 49 | |
set_max_price(max_price: Price) -> None
Set the maximum price.
Source code in framcore/attributes/ElasticDemand.py
78 79 80 81 | |
set_min_price(min_price: Price) -> None
Set the minimum price.
Source code in framcore/attributes/ElasticDemand.py
60 61 62 63 | |
set_normal_price(normal_price: Price) -> None
Set the normal price.
Source code in framcore/attributes/ElasticDemand.py
69 70 71 72 | |
set_price_elasticity(elasticity: Price) -> None
Set the price elasticity.
Source code in framcore/attributes/ElasticDemand.py
51 52 53 54 | |
ReservoirCurve
ReservoirCurve
Bases: Base
Water level elevation to water volume characteristics for HydroStorage.
Source code in framcore/attributes/ReservoirCurve.py
11 12 13 14 15 16 17 18 19 20 21 22 23 | |
__init__(value: str | None) -> None
Initialize a ReservoirCurve instance.
Source code in framcore/attributes/ReservoirCurve.py
16 17 18 19 | |
add_loaders(loaders: set[Loader]) -> None
Add all loaders stored in attributes to loaders.
Source code in framcore/attributes/ReservoirCurve.py
21 22 23 | |
SoftBound
SoftBound
Represents a soft bound attribute. Penalty applied if the bound is violated.
Source code in framcore/attributes/SoftBound.py
9 10 11 12 13 14 15 16 | |
add_loaders(loaders: set[Loader]) -> None
Add all loaders stored in attributes to loaders.
Source code in framcore/attributes/SoftBound.py
14 15 16 | |
StartUpCost
StartUpCost
Bases: Base
Represent the costs associated with starting up the operation of a Component.
Source code in framcore/attributes/StartUpCost.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
__init__(startup_cost: Cost, min_stable_load: Proportion, start_hours: Hours, part_load_efficiency: Efficiency) -> None
Initialize the StartUpCost class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
startup_cost
|
Cost
|
description |
required |
min_stable_load
|
Proportion
|
description |
required |
start_hours
|
Hours
|
description |
required |
part_load_efficiency
|
Efficiency
|
description |
required |
Source code in framcore/attributes/StartUpCost.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
add_loaders(loaders: set[Loader]) -> None
Get all loaders stored in attributes.
Source code in framcore/attributes/StartUpCost.py
58 59 60 61 62 63 64 65 | |
get_fingerprint() -> Fingerprint
Get the fingerprint of the startup cost.
Source code in framcore/attributes/StartUpCost.py
54 55 56 | |
get_startupcost() -> Cost
Get the startup cost.
Source code in framcore/attributes/StartUpCost.py
45 46 47 | |
set_startupcost(startupcost: Cost) -> None
Set the startup cost.
Source code in framcore/attributes/StartUpCost.py
49 50 51 52 | |
Storage
Storage
Bases: Base
Represents all types of storage this system supports.
Subclasses are supposed to restrict which attributes that are used, not add more.
Source code in framcore/attributes/Storage.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
__init__(capacity: StockVolume, volume: StockVolume | None = None, loss: Loss | None = None, reservoir_curve: ReservoirCurve | None = None, max_soft_bound: SoftBound | None = None, min_soft_bound: SoftBound | None = None, target_bound: TargetBound | None = None, initial_storage_percentage: float | None = None) -> None
Create new storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capacity
|
StockVolume
|
Storage capacity. |
required |
volume
|
StockVolume | None
|
Storage filling (actual/result). Defaults to None. |
None
|
loss
|
Loss | None
|
Loss percentage per time. Defaults to None. |
None
|
reservoir_curve
|
ReservoirCurve | None
|
Water level elevation to water volume for HydroStorage. Defaults to None. |
None
|
max_soft_bound
|
SoftBound | None
|
Upper soft boundary that is penalized if broken. Defaults to None. |
None
|
min_soft_bound
|
SoftBound | None
|
Lower soft boundary that is penalized if broken. Defaults to None. |
None
|
target_bound
|
TargetBound | None
|
Target filling, can be penalized if deviation. Defaults to None. |
None
|
initial_storage_percentage
|
float | None
|
Initial storage filling percentage at start of simulation. Defaults to None. |
None
|
Source code in framcore/attributes/Storage.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
add_cost_term(key: str, cost_term: ObjectiveCoefficient) -> None
Add a cost term.
Source code in framcore/attributes/Storage.py
81 82 83 84 85 | |
add_loaders(loaders: set[Loader]) -> None
Add all loaders stored in attributes to loaders.
Source code in framcore/attributes/Storage.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
get_capacity() -> StockVolume
Get the capacity.
Source code in framcore/attributes/Storage.py
73 74 75 | |
get_cost_terms() -> dict[str, ObjectiveCoefficient]
Get the cost terms.
Source code in framcore/attributes/Storage.py
87 88 89 | |
get_initial_storage_percentage() -> float | None
Get the initial storage percentage (float in [0, 1]).
Source code in framcore/attributes/Storage.py
136 137 138 | |
get_loss() -> Loss | None
Get the loss.
Source code in framcore/attributes/Storage.py
91 92 93 | |
get_max_soft_bound() -> SoftBound | None
Get the max soft bound.
Source code in framcore/attributes/Storage.py
109 110 111 | |
get_min_soft_bound() -> SoftBound | None
Get the min soft bound.
Source code in framcore/attributes/Storage.py
118 119 120 | |
get_reservoir_curve() -> ReservoirCurve | None
Get the reservoir curve.
Source code in framcore/attributes/Storage.py
100 101 102 | |
get_target_bound() -> TargetBound | None
Get the target bound.
Source code in framcore/attributes/Storage.py
127 128 129 | |
get_volume() -> StockVolume
Get the volume.
Source code in framcore/attributes/Storage.py
77 78 79 | |
set_initial_storage_percentage(value: float) -> None
Set the initial storage percentage (float in [0, 1]).
Source code in framcore/attributes/Storage.py
140 141 142 143 | |
set_loss(value: Loss | None) -> None
Set the loss.
Source code in framcore/attributes/Storage.py
95 96 97 98 | |
set_max_soft_bound(value: SoftBound | None) -> None
Set the max soft bound.
Source code in framcore/attributes/Storage.py
113 114 115 116 | |
set_min_soft_bound(value: SoftBound | None) -> None
Set the min soft bound.
Source code in framcore/attributes/Storage.py
122 123 124 125 | |
set_reservoir_curve(value: ReservoirCurve | None) -> None
Set the reservoir curve.
Source code in framcore/attributes/Storage.py
104 105 106 107 | |
set_target_bound(value: TargetBound | None) -> None
Set the target bound.
Source code in framcore/attributes/Storage.py
131 132 133 134 | |
TargetBound
TargetBound
Target boundary attribute. Can be penalized if deviation from target.
Source code in framcore/attributes/TargetBound.py
9 10 11 12 13 14 15 16 | |
add_loaders(loaders: set[Loader]) -> None
Add all loaders stored in attributes to loaders.
Source code in framcore/attributes/TargetBound.py
14 15 16 | |
hydro
HydroBypass
HydroBypass
Bases: Base
HydroBypass represents a controlled water way from a HydroModule. Used to bypass main release of the HydroModule.
Source code in framcore/attributes/hydro/HydroBypass.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
__init__(to_module: str | None, capacity: FlowVolume | None = None) -> None
Initialize object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_module
|
str | None
|
Name of the HydroModule the water is released to. |
required |
capacity
|
FlowVolume | None
|
Restrictions on the volume of water which can pass through the bypass at a given moment. Defaults to None. |
None
|
Source code in framcore/attributes/hydro/HydroBypass.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
get_capacity() -> FlowVolume | None
Get the capacity of the bypass.
Source code in framcore/attributes/hydro/HydroBypass.py
40 41 42 | |
get_to_module() -> str | None
Get the name of the module to which the bypass leads.
Source code in framcore/attributes/hydro/HydroBypass.py
31 32 33 | |
get_volume() -> AvgFlowVolume
Get the volume of the bypass.
Source code in framcore/attributes/hydro/HydroBypass.py
44 45 46 | |
set_to_module(to_module: str) -> None
Set the name of the module to which the bypass leads.
Source code in framcore/attributes/hydro/HydroBypass.py
35 36 37 38 | |
HydroGenerator
HydroGenerator
Bases: Base
Produces power from the main release of a HydroModule.
Produces to a power node, and can have variable costs associated with operation. Other attributes are energy equivalent, PQ curve, nominal head and tailwater elevation.
Source code in framcore/attributes/hydro/HydroGenerator.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
__init__(power_node: str, energy_equivalent: Conversion, pq_curve: Expr | str | Curve | None = None, nominal_head: Expr | str | TimeVector | None = None, tailwater_elevation: Expr | str | TimeVector | None = None, voc: Cost | None = None, production: AvgFlowVolume | None = None) -> None
Initialize a HydroGenerator with parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power_node
|
str
|
Node to supply power to. |
required |
energy_equivalent
|
Conversion
|
Conversion factor of power produced to water released. |
required |
pq_curve
|
Expr | str | Curve | None
|
Expression or curve describing the relationship produced power and water released. Defaults to None. |
None
|
nominal_head
|
Expr | str | TimeVector | None
|
Vertical distance between upstream and dowstream water level. Defaults to None. |
None
|
tailwater_elevation
|
Expr | str | TimeVector | None
|
Elevation at the surface where the water exits the turbine. Defaults to None. |
None
|
voc
|
Cost | None
|
Variable operational costs. Defaults to None. |
None
|
production
|
AvgFlowVolume | None
|
Result of power volume produced. Defaults to None. |
None
|
Source code in framcore/attributes/hydro/HydroGenerator.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
get_energy_equivalent() -> Conversion
Get the energy equivalent of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
70 71 72 | |
get_nominal_head() -> Expr | None
Get the nominal head of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
78 79 80 | |
get_power_node() -> str
Get the power node of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
61 62 63 | |
get_pq_curve() -> Expr | None
Get the PQ curve of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
74 75 76 | |
get_production() -> AvgFlowVolume
Get the generation of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
95 96 97 | |
get_tailwater_elevation() -> Expr | None
Get the tailwater elevation of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
82 83 84 | |
get_voc() -> Cost | None
Get the variable operation and maintenance cost of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
86 87 88 | |
set_power_node(power_node: str) -> None
Set the power node of the pump unit.
Source code in framcore/attributes/hydro/HydroGenerator.py
65 66 67 68 | |
set_voc(voc: Cost) -> None
Set the variable operation and maintenance cost of the hydro generator.
Source code in framcore/attributes/hydro/HydroGenerator.py
90 91 92 93 | |
HydroPump
HydroPump
Bases: Base
Represent a pump associated with a HydroModule.
The HydroPump can consume power from a power Node to move water upstream between two HydroModules. It has a max power capacity, and mean energy equivalent and water capacity. It can also describe the relationship between head and flow (Q), with min and max head and flow.
Results for water and power consumption are stored as AvgFlowVolume attributes.
Source code in framcore/attributes/hydro/HydroPump.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
__init__(power_node: str, from_module: str, to_module: str, water_capacity: FlowVolume, energy_equivalent: Conversion, power_capacity: FlowVolume | None = None, head_min: Expr | str | TimeVector | None = None, head_max: Expr | str | TimeVector | None = None, q_min: Expr | str | TimeVector | None = None, q_max: Expr | str | TimeVector | None = None) -> None
Initialize a HydroPump object parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power_node
|
str
|
Node to take power from when operating. |
required |
from_module
|
str
|
Source HydroModule to move water from. |
required |
to_module
|
str
|
Destination HydroModule to move water to. |
required |
water_capacity
|
FlowVolume
|
Max pumped water volume given the mean energy equivalent and power capacity. |
required |
energy_equivalent
|
Conversion
|
Mean conversion factor between power consumed and volume of water moved. |
required |
power_capacity
|
FlowVolume | None
|
Max power consumed. Defaults to None. |
None
|
head_min
|
Expr | str | TimeVector | None
|
Minimum elevation difference between upstream and downstream water level. Defaults to None. |
None
|
head_max
|
Expr | str | TimeVector | None
|
Maximum elevation difference between upstream and downstream water level. Defaults to None. |
None
|
q_min
|
Expr | str | TimeVector | None
|
Maximum water flow at head_min. Defaults to None. |
None
|
q_max
|
Expr | str | TimeVector | None
|
Maximum water flow at head_max. Defaults to None. |
None
|
Source code in framcore/attributes/hydro/HydroPump.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
get_energy_equivalent() -> Conversion
Get the energy equivalent of hydro pump.
Source code in framcore/attributes/hydro/HydroPump.py
130 131 132 | |
get_from_module() -> str
Get the module from which the pump unit is pumping.
Source code in framcore/attributes/hydro/HydroPump.py
91 92 93 | |
get_head_max() -> Expr
Get max fall height of hydro pump.
Source code in framcore/attributes/hydro/HydroPump.py
147 148 149 | |
get_head_min() -> Expr
Get min fall height of hydro pump.
Source code in framcore/attributes/hydro/HydroPump.py
139 140 141 | |
get_power_capacity() -> FlowVolume
Get the capacity of the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
78 79 80 | |
get_power_consumption() -> FlowVolume
Get the power consumption of the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
111 112 113 | |
get_power_node() -> str
Get the power node of the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
82 83 84 | |
get_q_max() -> Expr
Get Q max of hydro pump.
Source code in framcore/attributes/hydro/HydroPump.py
163 164 165 | |
get_q_min() -> Expr
Get Q min of hydro pump.
Source code in framcore/attributes/hydro/HydroPump.py
155 156 157 | |
get_to_module() -> str
Get the module to which the pump unit is pumping.
Source code in framcore/attributes/hydro/HydroPump.py
95 96 97 | |
get_water_capacity() -> FlowVolume
Get the capacity of the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
74 75 76 | |
get_water_consumption() -> FlowVolume
Get the water consumption of the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
107 108 109 | |
set_energy_eq(energy_eq: Conversion) -> None
Set the energy equivalent.
Source code in framcore/attributes/hydro/HydroPump.py
134 135 136 137 | |
set_head_max(hmax: Expr | str | None) -> None
Set max fall height.
Source code in framcore/attributes/hydro/HydroPump.py
151 152 153 | |
set_head_min(head_min: Expr | str | None) -> None
Set min fall height.
Source code in framcore/attributes/hydro/HydroPump.py
143 144 145 | |
set_modules(from_module: str, to_module: str) -> None
Set the modules for the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
101 102 103 104 105 | |
set_power_node(power_node: str) -> None
Set the power node of the pump unit.
Source code in framcore/attributes/hydro/HydroPump.py
86 87 88 89 | |
set_qmax(q_max: Expr | str | None) -> None
Set Q max.
Source code in framcore/attributes/hydro/HydroPump.py
167 168 169 | |
set_qmin(q_min: Expr | str | None) -> None
Set Q min.
Source code in framcore/attributes/hydro/HydroPump.py
159 160 161 | |
HydroReservoir
HydroReservoir
Bases: Storage
Represent a hydro reservoir of a HydroModule.
Source code in framcore/attributes/hydro/HydroReservoir.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
__init__(capacity: StockVolume, reservoir_curve: ReservoirCurve = None, volume: StockVolume | None = None) -> None
Initialize a HydroReservoir instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capacity
|
StockVolume
|
The maximum storage capacity of the reservoir. |
required |
reservoir_curve
|
ReservoirCurve
|
The curve describing water level elevation to volume characteristics. |
None
|
volume
|
StockVolume
|
Volume of water in the reservoir. |
None
|
Source code in framcore/attributes/hydro/HydroReservoir.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
level_profile_attributes
ArrowCoefficient
Bases: Coefficient
Abstract class representing an arrow coefficient attribute, used for efficiency, loss, and conversion coefficients.
Subclass of Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
740 741 742 743 744 745 746 747 | |
AvgFlowVolume
Bases: FlowVolume
Concrete class representing an average flow volume attribute, indicating a flow variable with average values.
Subclass of FlowVolume < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
881 882 883 884 885 886 887 888 | |
Coefficient
Bases: LevelProfile
Abstract class representing a coefficient attribute, used as a base class for various coefficient types.
Subclass of LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
730 731 732 733 734 735 736 737 | |
Conversion
Bases: ArrowCoefficient
Concrete class representing a conversion coefficient attribute, used for conversion factors in the model.
Subclass of ArrowCoefficient < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
871 872 873 874 875 876 877 878 | |
Cost
Bases: ObjectiveCoefficient
Concrete class representing a cost attribute, indicating cost coefficients in the objective function.
Subclass of ObjectiveCoefficient < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
795 796 797 798 799 800 801 802 803 | |
Efficiency
Bases: ArrowCoefficient
Concrete class representing an efficiency coefficient attribute, indicating a unitless coefficient.
Subclass of ArrowCoefficient < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
849 850 851 852 853 854 855 856 857 | |
Elasticity
Bases: Coefficient
Concrete class representing an elasticity coefficient attribute, indicating a unitless coefficient.
Subclass of Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
817 818 819 820 821 822 823 824 825 | |
FlowVolume
Bases: LevelProfile
Abstract class representing a flow volume attribute, indicating that the attribute is a flow variable.
Subclass of LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
720 721 722 723 724 725 726 727 | |
Hours
Bases: Coefficient
Concrete class representing an hours coefficient attribute, indicating a time-related coefficient.
Subclass of Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
839 840 841 842 843 844 845 846 | |
LevelProfile
Bases: Base, ABC
Attributes representing timeseries data for Components. Mostly as Level * Profile, where both Level and Profile are Expr (expressions).
Level and Profile represent two distinct dimensions of time. This is because we want to simulate future system states with historical weather patterns. Therefore, Level represents the system state at a given time (data_dim), while Profile represents the scenario dimension (scen_dim). A Level would for example represent the installed capacity of solar plants towards 2030, while the Profile would represent the historical variation between 1991-2020.
Level and Profile can have two main formats: A maximum Level with a Profile that varies between 0-1, and an average Level with a Profile with a mean of 1 (the latter can have a ReferencePeriod). The max format is, for example, used for capacities, while the mean format can be used for prices and flows. The system needs to be able to convert between the two formats. This is especially important for aggregations (for example weighted averages) where all the TimeVectors need to be on the same format for a correct result. One simple example of conversion is pairing a max Level of 100 MW with a mean_one Profile [0, 1, 2]. Asking for this on the max format will return the series 100[0, 0.5, 1] MW, while on the avg format it will return 50[0, 1, 2] MW.
Queries to LevelProfile need to provide a database, the desired target TimeIndex for both dimensions, the target unit and the desired format. At the moment we support these queries for LevelProfile: - self.get_data_value(db, scen_dim, data_dim, unit, is_max_level) - self.get_scenario_vector(db, scen_dim, data_dim, unit, is_float32)
In addition, we have the possibility to shift, scale, and change the intercept of the LevelProfiles. Then we get the full representation: Scale * (Level + Level_shift) * Profile + Intercept. - Level_shift adds a constant value to Level, has the same Profile as Level. - Scale multiplies (Level + Level_shift) by a constant value. - Intercept adds a constant value to LevelProfile, ignoring Level and Profile. This is the only way of supporting a timeseries that crosses zero in our system. This functionality is under development and has not been properly tested.
LevelProfiles also have additional properties that describes their behaviour. These can be used for initialization, validation, and to simplify queries. The properties are: - is_stock: True if attribute is a stock variable. Level Expr should also have is_stock=True. See Expr for details. - is_flow: True if attribute is a flow variable. Level Expr should also have is_flow=True. See Expr for details. - is_not_negative: True if attribute is not allowed to have negative values. Level Expr should also have only non-negative values. - is_max_and_zero_one: Preferred format of Level and Profile. Used for initialization and queries. - is_ingoing: True if attribute is ingoing, False if outgoing, None if neither. - is_cost: True if attribute is objective function cost coefficient. Else None. - is_unitless: True if attribute is known to be unitless. False if known to have a unit that is not None. Else None.
Source code in framcore/attributes/level_profile_attributes.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 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 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 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | |
__eq__(other) -> bool
Return True if other is equal to self.
Source code in framcore/attributes/level_profile_attributes.py
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 | |
__hash__() -> int
Compute hash of self.
Source code in framcore/attributes/level_profile_attributes.py
703 704 705 706 707 708 709 710 711 712 713 714 | |
__init__(level: Expr | TimeVector | str | None = None, profile: Expr | TimeVector | str | None = None, value: float | int | None = None, unit: str | None = None, level_shift: Expr | None = None, intercept: Expr | None = None, scale: Expr | None = None) -> None
Initialize LevelProfile.
See the LevelProfile class docstring for details. A complete LevelProfile is represented as: Scale * (Level + Level_shift) * Profile + Intercept. Normally only Level and Profile are used.
Either give level and profile, or value and unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
Expr | TimeVector | str | None
|
Level Expr. Defaults to None. |
None
|
profile
|
Expr | TimeVector | str | None
|
Profile Expr. Defaults to None. |
None
|
value
|
float | int | None
|
A constant value to initialize Level. Defaults to None. |
None
|
unit
|
str | None
|
Unit of the constant value to initialize Level. Defaults to None. |
None
|
level_shift
|
Expr | None
|
Level_shift Expr. Defaults to None. |
None
|
intercept
|
Expr | None
|
Intercept Expr. Defaults to None. |
None
|
scale
|
Expr | None
|
Scale Expr. Defaults to None. |
None
|
Source code in framcore/attributes/level_profile_attributes.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
add_loaders(loaders: set[Loader]) -> None
Add all loaders stored in expressions to loaders.
Source code in framcore/attributes/level_profile_attributes.py
166 167 168 169 170 171 | |
clear() -> None
Set all internal fields to None.
You may want to use this to get exogenous flow to use capacities instead of volume.
Source code in framcore/attributes/level_profile_attributes.py
173 174 175 176 177 178 179 180 181 182 183 | |
copy_from(other: LevelProfile) -> None
Copy fields from other.
Source code in framcore/attributes/level_profile_attributes.py
259 260 261 262 263 264 265 266 267 | |
get_data_value(db: QueryDB | Model, scenario_horizon: FixedFrequencyTimeIndex, level_period: SinglePeriodTimeIndex, unit: str | None, is_max_level: bool | None = None) -> float
Evaluate LevelProfile to a scalar at the level period of the data dimension, and as an average over the scenario horizon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db
|
QueryDB | Model
|
The database or model instance used to fetch the required data. |
required |
scenario_horizon
|
FixedFrequencyTimeIndex
|
TimeIndex of the scenario dimension to evaluate profiles. |
required |
level_period
|
SinglePeriodTimeIndex
|
TimeIndex of the data dimension to evaluate levels. |
required |
unit
|
str | None
|
The unit to convert the resulting values into (e.g., MW, GWh). If None, the expression should be unitless. |
required |
is_max_level
|
bool | None
|
Whether to evaluate the expression as a maximum level (with a zero_one profile) or as an average level (with a mean_one profile). If None, the default format of the attribute is used. |
None
|
Source code in framcore/attributes/level_profile_attributes.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
get_intercept() -> Expr | None
Get intercept part of (level * profile + intercept).
Source code in framcore/attributes/level_profile_attributes.py
313 314 315 316 317 318 | |
get_level() -> Expr | None
Get level part of (level * profile + intercept).
Source code in framcore/attributes/level_profile_attributes.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
get_level_unit_set(db: QueryDB | Model) -> set[TimeIndex]
Return set with all units behind level expression.
Useful for discovering valid unit input to get_level_value.
Source code in framcore/attributes/level_profile_attributes.py
327 328 329 330 331 332 333 334 335 336 337 338 | |
get_profile() -> Expr | None
Get profile part of (level * profile + intercept).
Source code in framcore/attributes/level_profile_attributes.py
302 303 304 | |
get_profile_timeindex_set(db: QueryDB | Model) -> set[TimeIndex]
Return set with all TimeIndex behind profile expression.
Can be used to run optimized queries, i.e. not asking for finer time resolutions than necessary.
Source code in framcore/attributes/level_profile_attributes.py
340 341 342 343 344 345 346 347 348 349 350 351 352 | |
get_scenario_vector(db: QueryDB | Model, scenario_horizon: FixedFrequencyTimeIndex, level_period: SinglePeriodTimeIndex, unit: str | None, is_float32: bool = True) -> NDArray
Evaluate LevelProfile over the periods in scenario dimension, and at the level period of the data dimension.
Underlying profiles are evalutated over the scenario dimension, and levels are evalutated to scalars over level_period in the data dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db
|
QueryDB | Model
|
The database or model instance used to fetch the required data. |
required |
scenario_horizon
|
FixedFrequencyTimeIndex
|
TimeIndex of the scenario dimension to evaluate profiles. |
required |
level_period
|
SinglePeriodTimeIndex
|
TimeIndex of the data dimension to evaluate levels. |
required |
unit
|
str | None
|
The unit to convert the resulting values into (e.g., MW, GWh). If None, the expression should be unitless. |
required |
is_float32
|
bool
|
Whether to return the vector as a NumPy array with |
True
|
Source code in framcore/attributes/level_profile_attributes.py
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 | |
has_intercept() -> bool
Return True if get_intercept will return value not None.
Source code in framcore/attributes/level_profile_attributes.py
255 256 257 | |
has_level() -> bool
Return True if get_level will return value not None.
Source code in framcore/attributes/level_profile_attributes.py
247 248 249 | |
has_profile() -> bool
Return True if get_profile will return value not None.
Source code in framcore/attributes/level_profile_attributes.py
251 252 253 | |
is_cost() -> bool | None
Return True if attribute is objective function cost coefficient.
Return False if attribute is objective function revenue coefficient.
Return None if not applicable.
Source code in framcore/attributes/level_profile_attributes.py
227 228 229 230 231 232 233 234 235 | |
is_flow() -> bool
Return True if attribute is a flow variable.
Return False if attribute is not a flow variable.
Source code in framcore/attributes/level_profile_attributes.py
193 194 195 196 197 198 199 | |
is_ingoing() -> bool | None
Return True if attribute is ingoing.
Return True if attribute is outgoing.
Return None if not applicable.
Source code in framcore/attributes/level_profile_attributes.py
217 218 219 220 221 222 223 224 225 | |
is_max_and_zero_one() -> bool
When True level should be max (not average) and corresponding profile should be zero_one (not mean_one).
When False level should be average (not max) and corresponding profile should be mean_one (not zero_one).
Source code in framcore/attributes/level_profile_attributes.py
209 210 211 212 213 214 215 | |
is_not_negative() -> bool
Return True if attribute is not allowed to have negative values.
Return False if attribute can have both positive and negative values.
Source code in framcore/attributes/level_profile_attributes.py
201 202 203 204 205 206 207 | |
is_stock() -> bool
Return True if attribute is a stock variable.
Return False if attribute is not a stock variable.
Source code in framcore/attributes/level_profile_attributes.py
185 186 187 188 189 190 191 | |
is_unitless() -> bool | None
Return True if attribute is known to be unitless.
Return False if attribute is known to have a unit that is not None.
Return None if not applicable.
Source code in framcore/attributes/level_profile_attributes.py
237 238 239 240 241 242 243 244 245 | |
scale(value: float | int) -> None
Modify the scale part of (scale * (level + level_shift) * profile + intercept) of an attribute by multiplying with a constant value.
Source code in framcore/attributes/level_profile_attributes.py
455 456 457 458 459 460 461 462 463 464 465 466 467 | |
set_intercept(value: Expr | None) -> None
Set intercept part of (level * profile + intercept).
Source code in framcore/attributes/level_profile_attributes.py
320 321 322 323 324 325 | |
set_level(level: Expr | TimeVector | str | None) -> None
Set level part of (scale * (level + level_shift) * profile + intercept).
Source code in framcore/attributes/level_profile_attributes.py
295 296 297 298 299 300 | |
set_profile(profile: Expr | TimeVector | str | None) -> None
Set profile part of (scale * (level + level_shift) * profile + intercept).
Source code in framcore/attributes/level_profile_attributes.py
306 307 308 309 310 311 | |
shift_intercept(value: float, unit: str | None) -> None
Modify the intercept part of (level * profile + intercept) of an attribute by adding a constant value.
Source code in framcore/attributes/level_profile_attributes.py
403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
shift_level(value: float | int, unit: str | None = None, reference_period: ReferencePeriod | None = None, is_max_level: bool | None = None, use_profile: bool = True) -> None
Modify the level_shift part of (scale * (level + level_shift) * profile + intercept) of an attribute by adding a constant value.
Source code in framcore/attributes/level_profile_attributes.py
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 448 449 450 451 452 453 | |
Loss
Bases: ArrowCoefficient
Concrete class representing a loss coefficient attribute, indicating a unitless coefficient.
Subclass of ArrowCoefficient < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
860 861 862 863 864 865 866 867 868 | |
MaxFlowVolume
Bases: FlowVolume
Concrete class representing a maximum flow volume attribute, indicating a flow variable with maximum values.
Subclass of FlowVolume < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
891 892 893 894 895 896 897 898 899 | |
ObjectiveCoefficient
Bases: Coefficient
Abstract class representing an objective coefficient attribute, indicating cost or revenue coefficients in the objective function.
Subclass of Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
761 762 763 764 765 766 767 768 769 | |
Price
Bases: ShadowPrice
Concrete class representing a price attribute, indicating the price of a commodity at a specific node.
Subclass of ShadowPrice < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
775 776 777 778 779 780 781 782 | |
Proportion
Bases: Coefficient
Concrete class representing a proportion coefficient attribute, indicating a unitless coefficient between 0 and 1.
Subclass of Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
828 829 830 831 832 833 834 835 836 | |
ReservePrice
Bases: ObjectiveCoefficient
Concrete class representing a reserve price attribute, indicating revenue coefficients in the objective function.
Subclass of ObjectiveCoefficient < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
806 807 808 809 810 811 812 813 814 | |
ShadowPrice
Bases: Coefficient
Abstract class representing a shadow price attribute, indicating that the attribute has a unit and might be negative.
Subclass of Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
750 751 752 753 754 755 756 757 758 | |
StockVolume
Bases: LevelProfile
Concrete class representing a stock volume attribute, indicating a stock variable with maximum values.
Subclass of LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
902 903 904 905 906 907 908 909 910 911 | |
WaterValue
Bases: ShadowPrice
Concrete class representing a water value attribute, indicating the value of water in the system.
Subclass of ShadowPrice < Coefficient < LevelProfile. See LevelProfile for details.
Source code in framcore/attributes/level_profile_attributes.py
785 786 787 788 789 790 791 792 | |
components
Solar
Bases: _WindSolar
Solar power component.
Has attributes for power node, capacity, variable operation cost, and production.
Compatible with WindSolarAggregator.
Source code in framcore/components/wind_solar.py
73 74 75 76 77 78 79 80 81 82 | |
Wind
Bases: _WindSolar
Wind power component.
Has attributes for power node, capacity, variable operation cost, and production.
Compatible with WindSolarAggregator.
Source code in framcore/components/wind_solar.py
61 62 63 64 65 66 67 68 69 70 | |
Component
Component
Bases: Base, ABC
Components describe the main elements in the energy system. Can have additional Attributes and Metadata.
We have high-level and low-level Components. High-level Components, such as a HydroModule, can be decomposed into low-level Components like Flows and Nodes. The high-level description lets analysts work with recognizable domain objects, while the low-level descriptions enable generic algorithms that minimize code duplication and simplify data manipulation.
Some energy market models like JulES, SpineOpt and PyPSA also have a generic description of the system, so this two-tier system can be used to easier adapt the dataset to their required formats.
The method Component.get_simpler_components() is used to decompose high-level Components into low-level Components. This can also be used together with the utility function get_supported_components() to transform a set of Components into a set that only contains supported Component types.
Result attributes are initialized in the high-level Components. When they are transferred to low-level Components, and the results are set by a model like JulES, the results will also appear in the high-level Components.
Nodes, Flows and Arrows are the main building blocks in FRAM's low-level representation of energy systems. Node represent a point where a commodity can possibly be traded, stored or pass through. Movement between Nodes is represented by Flows and Arrows. Flows represent a commodity flow, and can have Arrows that each describe contribution of the Flow into a Node. The Arrows have direction to determine input or output, and parameters for the contribution of the Flow to the Node (conversion, efficiency and loss).
Source code in framcore/components/Component.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
__init__() -> None
Set mandatory private variables.
Source code in framcore/components/Component.py
37 38 39 40 | |
add_meta(key: str, value: Meta) -> None
Add metadata to component. Overwrite if already exist.
Source code in framcore/components/Component.py
42 43 44 45 46 | |
get_meta(key: str) -> Meta | None
Get metadata from component or return None if not exist.
Source code in framcore/components/Component.py
48 49 50 51 | |
get_meta_keys() -> Iterable[str]
Get iterable with all metakeys in component.
Source code in framcore/components/Component.py
53 54 55 | |
get_parent() -> Component | None
Return parent if any, else None.
Source code in framcore/components/Component.py
88 89 90 91 92 | |
get_parents() -> list[Component]
Return list of all parents, including self.
Source code in framcore/components/Component.py
94 95 96 97 98 99 100 101 102 103 104 | |
get_simpler_components(base_name: str) -> dict[str, Component]
Return representation of self as dict of named simpler components.
The base_name should be unique within a model instance, and should be used to prefix name of all simpler components.
Insert self as parent in each child.
Transfer metadata to each child.
Source code in framcore/components/Component.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
get_top_parent() -> Component
Return topmost parent. (May be object self).
Source code in framcore/components/Component.py
106 107 108 109 | |
replace_node(old: str, new: str) -> None
Replace old Node with new. Not error if no match.
Source code in framcore/components/Component.py
111 112 113 114 115 | |
Demand
Demand class.
Demand
Bases: Component
Demand class representing a simple demand with possible reserve price. Subclass of Component.
Source code in framcore/components/Demand.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
__init__(node: str, capacity: FlowVolume | None = None, reserve_price: ReservePrice | None = None, elastic_demand: ElasticDemand | None = None, temperature_profile: Expr | str | TimeVector | None = None, consumption: AvgFlowVolume | None = None) -> None
Initialize the Demand class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
str
|
Node which this Demand consumes power on. |
required |
capacity
|
FlowVolume | None
|
Maximum consumption capacity. Defaults to None. |
None
|
reserve_price
|
ReservePrice | None
|
Price in node at which the Demand will stop consumption. Defaults to None. |
None
|
elastic_demand
|
ElasticDemand | None
|
Describe changes in consumption based on commodity price in node. Defaults to None. |
None
|
temperature_profile
|
Expr | str | TimeVector | None
|
Describe changes in consumption based on temperatures. Defaults to None. |
None
|
consumption
|
AvgFlowVolume | None
|
Actual calculated consumption. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
When both reserve_price and elastic_demand is passed as arguments. This is ambiguous. |
Source code in framcore/components/Demand.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
get_capacity() -> FlowVolume
Get the capacity of the demand component.
Source code in framcore/components/Demand.py
58 59 60 | |
get_consumption() -> AvgFlowVolume
Get the consumption of the demand component.
Source code in framcore/components/Demand.py
62 63 64 | |
get_elastic_demand() -> ElasticDemand | None
Get the elastic demand of the demand component.
Source code in framcore/components/Demand.py
87 88 89 | |
get_node() -> str
Get the node of the demand component.
Source code in framcore/components/Demand.py
66 67 68 | |
get_reserve_price() -> ReservePrice | None
Get the reserve price level of the demand component.
Source code in framcore/components/Demand.py
75 76 77 | |
get_temperature_profile() -> Expr | None
Get the temperature profile of the demand component.
Source code in framcore/components/Demand.py
99 100 101 | |
set_elastic_demand(elastic_demand: ElasticDemand | None) -> None
Set the elastic demand of the demand component.
Source code in framcore/components/Demand.py
91 92 93 94 95 96 97 | |
set_node(node: str) -> None
Set the node of the demand component.
Source code in framcore/components/Demand.py
70 71 72 73 | |
set_reserve_price(reserve_price: ReservePrice | None) -> None
Set the reserve price level of the demand component.
Source code in framcore/components/Demand.py
79 80 81 82 83 84 85 | |
set_temperature_profile(temperature_profile: Expr | str | None) -> None
Set the temperature profile of the demand component.
Source code in framcore/components/Demand.py
103 104 105 106 | |
Flow
Flow
Bases: Component
Represents a commodity flow in or out of one or more nodes. Can have Attributes and Metadata.
Main attributes are arrows, main_node, max_capacity, min_capacity, startupcost and if it is exogenous.
Arrows describes contribution of a Flow into a Node. Has direction to determine input or output, and parameters for the contribution of the Flow to the Node (conversion, efficiency, loss). Nodes, Flows and Arrows are the main building blocks in FRAM's low-level representation of energy systems.
Source code in framcore/components/Flow.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
__init__(main_node: str, max_capacity: FlowVolume | None = None, min_capacity: FlowVolume | None = None, startupcost: StartUpCost | None = None, volume: AvgFlowVolume | None = None, arrow_volumes: dict[Arrow, AvgFlowVolume] | None = None, is_exogenous: bool = False) -> None
Initialize Flow with main node, capacity, and startup cost.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
main_node
|
str
|
Node which the Flow is primarily associated with. |
required |
max_capacity
|
FlowVolume | None
|
Maximum capacity of the Flow. Defaults to None. |
None
|
min_capacity
|
FlowVolume | None
|
Minimum capacity of the Flow. Defaults to None. |
None
|
startupcost
|
StartUpCost | None
|
Costs associated with starting up this Flow. Defaults to None. |
None
|
volume
|
AvgFlowVolume | None
|
The actual volume carried by this Flow at a given moment. Defaults to None. |
None
|
arrow_volumes
|
dict[Arrow, AvgFlowVolume] | None
|
Possibility to store a version of volume for each Arrow. Can account for conversion, |
None
|
is_exogenous
|
bool
|
Flag denoting if a Solver should calculate the volumes associated with this flow or use its predefined volume. Defaults to False. |
False
|
Source code in framcore/components/Flow.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
add_arrow(arrow: Arrow) -> None
Add an arrow to the flow.
Source code in framcore/components/Flow.py
140 141 142 143 | |
add_cost_term(key: str, cost_term: ObjectiveCoefficient) -> None
Add a cost term to the flow.
Source code in framcore/components/Flow.py
145 146 147 148 149 | |
add_loaders(loaders: set[Loader]) -> None
Add loaders stored in attributes to loaders.
Source code in framcore/components/Flow.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
get_arrow_volumes() -> dict[Arrow, AvgFlowVolume]
Get dict of volume converted to volume at node pointed to by Arrow.
Source code in framcore/components/Flow.py
104 105 106 | |
get_arrows() -> set[Arrow]
Get the arrows of the flow.
Source code in framcore/components/Flow.py
136 137 138 | |
get_cost_terms() -> dict[str, ObjectiveCoefficient]
Get the cost terms of the flow.
Source code in framcore/components/Flow.py
151 152 153 | |
get_main_node() -> str
Get the main node of the flow.
Source code in framcore/components/Flow.py
96 97 98 | |
get_max_capacity() -> FlowVolume | None
Get the maximum capacity of the flow.
Source code in framcore/components/Flow.py
108 109 110 | |
get_min_capacity() -> FlowVolume | None
Get the minimum capacity of the flow.
Source code in framcore/components/Flow.py
117 118 119 | |
get_startupcost() -> StartUpCost | None
Get the startup cost of the flow.
Source code in framcore/components/Flow.py
126 127 128 129 | |
get_volume() -> AvgFlowVolume
Get the volume of the flow.
Source code in framcore/components/Flow.py
100 101 102 | |
is_exogenous() -> bool
Return True if Flow is exogenous.
Source code in framcore/components/Flow.py
73 74 75 | |
set_endogenous() -> None
Treat flow as decision variable.
Volume should be updated with results after a solve.
Source code in framcore/components/Flow.py
88 89 90 91 92 93 94 | |
set_exogenous() -> None
Treat flow as fixed variable.
Use volume if it exists. If no volume, then try to use min_capacity and max_capacity, which must be equal. Error if this fails.
Source code in framcore/components/Flow.py
77 78 79 80 81 82 83 84 85 86 | |
set_max_capacity(capacity: FlowVolume | None) -> None
Set the maximum capacity of the flow.
Source code in framcore/components/Flow.py
112 113 114 115 | |
set_min_capacity(capacity: FlowVolume | None) -> None
Set the minimum capacity of the flow.
Source code in framcore/components/Flow.py
121 122 123 124 | |
set_startupcost(startupcost: StartUpCost | None) -> None
Set the startup cost of the flow.
Source code in framcore/components/Flow.py
131 132 133 134 | |
HydroModule
HydroModule
Bases: Component
HydroModules represents a physical element in a river system, with its topology and other attributes.
The hydromodule can contain a HydroReservoir, HydroGenerator, HydroPump, HydroBypass and local inflow, aswell as the topological attributes release_to and spill_to:
- HydroGenerator uses the release pathway of the HydroModule to generate power, while HydroPump has its own water way that consumes power. Both HydroGenerator and HydroPump connects to power nodes.
- HydroBypass also have attributes that define the topology of the river system.
- HydroReservoir represents the water storage of the HydroModule.
- The hydraulic_coupling attribute is used to identify which HydroModules have hydraulic coupled reservoirs.
Results for the release volume, spill volume and the water value are stored directly in the HydroModule, while the production, pumping, reservoir volume and bypass volume are stored in the attributes.
HydroModule is compatible with HydroAggregator for aggregation of multiple HydroModules into one.
Source code in framcore/components/HydroModule.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 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 | |
__init__(release_to: str | None = None, release_capacity: FlowVolume | None = None, generator: HydroGenerator | None = None, pump: HydroPump | None = None, inflow: AvgFlowVolume | None = None, reservoir: HydroReservoir | None = None, hydraulic_coupling: int = 0, bypass: HydroBypass | None = None, spill_to: str | None = None, commodity: str = 'Hydro', water_value: WaterValue | None = None, release_volume: AvgFlowVolume | None = None, spill_volume: AvgFlowVolume | None = None) -> None
Initialize the HydroModule with its parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
release_to
|
str | None
|
Reference to another HydroModule which recieves the water releases through the main release. Defaults to None. |
None
|
release_capacity
|
FlowVolume | None
|
Amount of water which can be released via main release at a given moment. Defaults to None. |
None
|
generator
|
HydroGenerator | None
|
Represents generation of electricity from the movement of water through the Modules main release pathway. Defaults to None. |
None
|
pump
|
HydroPump | None
|
Pump associated with this Module. Can move water to another using power. Defaults to None. |
None
|
inflow
|
AvgFlowVolume | None
|
The local inflow of the HydroModule. Defaults to None. |
None
|
reservoir
|
HydroReservoir | None
|
The Modules water storage. Defaults to None. |
None
|
hydraulic_coupling
|
int
|
Number other than 0 if the HydroModules reservoir is hydraulic coupled to another reservoir. Defaults to 0. TODO: Replace with HydraulicCoupling class |
0
|
bypass
|
HydroBypass | None
|
Bypass water way. Defaults to None. |
None
|
spill_to
|
str | None
|
Reference to another Module recieving this ones spill volume. Defaults to None. |
None
|
commodity
|
str
|
Commodity of the hydro node. Defaults to "Hydro". |
'Hydro'
|
water_value
|
WaterValue | None
|
Water value of the reservoir in currency per water volume. Defaults to None. TODO: Allow water values with multiple demimensions? |
None
|
release_volume
|
AvgFlowVolume | None
|
Volume of water released via main waterway. Defaults to None. |
None
|
spill_volume
|
AvgFlowVolume | None
|
Volume of water spilled. Defaults to None. |
None
|
Source code in framcore/components/HydroModule.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
get_bypass() -> HydroBypass | None
Get the bypass of the hydro module.
Source code in framcore/components/HydroModule.py
141 142 143 | |
get_generator() -> HydroGenerator | None
Get the generator of the hydro module.
Source code in framcore/components/HydroModule.py
132 133 134 | |
get_hydraulic_coupling() -> int
Get the Modules hydraulic code.
Source code in framcore/components/HydroModule.py
110 111 112 | |
get_inflow() -> AvgFlowVolume | None
Get the inflow of the hydro module.
Source code in framcore/components/HydroModule.py
150 151 152 | |
get_pump() -> HydroPump | None
Get the pump of the hydro module.
Source code in framcore/components/HydroModule.py
123 124 125 | |
get_release_capacity() -> FlowVolume | None
Get the capacity of the thermal unit.
Source code in framcore/components/HydroModule.py
106 107 108 | |
get_release_to() -> str | None
Get the release_to module of the hydro module.
Source code in framcore/components/HydroModule.py
159 160 161 | |
get_release_volume() -> FlowVolume
Get the release_volume volume of the thermal unit.
Source code in framcore/components/HydroModule.py
176 177 178 | |
get_reservoir() -> HydroReservoir | None
Get the reservoir of the hydro module.
Source code in framcore/components/HydroModule.py
114 115 116 | |
get_spill_to() -> str | None
Get the spill_to module of the hydro module.
Source code in framcore/components/HydroModule.py
168 169 170 | |
get_spill_volume() -> FlowVolume
Get the spill_volume volume of the thermal unit.
Source code in framcore/components/HydroModule.py
180 181 182 | |
get_water_value() -> WaterValue
Get water value at the hydro node.
Source code in framcore/components/HydroModule.py
172 173 174 | |
set_bypass(bypass: HydroBypass | None) -> None
Set the bypass of the hydro module.
Source code in framcore/components/HydroModule.py
145 146 147 148 | |
set_generator(generator: HydroGenerator | None) -> None
Set the generator of the hydro module.
Source code in framcore/components/HydroModule.py
136 137 138 139 | |
set_inflow(inflow: AvgFlowVolume | None) -> None
Set the inflow of the hydro module.
Source code in framcore/components/HydroModule.py
154 155 156 157 | |
set_pump(pump: HydroPump | None) -> None
Set the pump of the hydro module.
Source code in framcore/components/HydroModule.py
127 128 129 130 | |
set_release_to(release_to: str | None) -> None
Set the release_to module of the hydro module.
Source code in framcore/components/HydroModule.py
163 164 165 166 | |
set_reservoir(reservoir: HydroReservoir | None) -> None
Set the reservoir of the hydro module.
Source code in framcore/components/HydroModule.py
118 119 120 121 | |
Node
Node
Bases: Component
Represents a point in the energy system where a commodity can possibly be traded, stored or pass through.
A node is characterized by the commodity it handles, its price, and optionally storage capabilities. If the node is exogenous, the commodity can be bought and sold at a fixed price determined by the user. If the node is endogenous, the price is determined by the market dynamics at the Node.
Nodes, Flows and Arrows are the main building blocks in FRAM's low-level representation of energy systems. Movement between Nodes is represented by Flows and Arrows. Flows represent a commodity flow, and can have Arrows that each describe contribution of the Flow into a Node. The Arrows have direction to determine input or output, and parameters for the contribution of the Flow to the Node (conversion, efficiency and loss).
Source code in framcore/components/Node.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
__init__(commodity: str, is_exogenous: bool = False, price: ShadowPrice | None = None, storage: Storage | None = None) -> None
Initialize the Node class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commodity
|
str
|
Commodity at the Node. Power/electricity, gas, heat, etc. |
required |
is_exogenous
|
bool
|
Flag used to signal Solvers whether they should simulate the node endogenously or use the pre-set price. Defaults to False. |
False
|
price
|
ShadowPrice | None
|
Actual, calculated price of Commodity in this Node for each moment of simulation. Defaulta to None. |
None
|
storage
|
Storage | None
|
The amount of the Commodity stored on this Node. Defaults to None. |
None
|
Source code in framcore/components/Node.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
add_loaders(loaders: set[Loader]) -> None
Add loaders stored in attributes to loaders.
Source code in framcore/components/Node.py
88 89 90 91 92 93 | |
get_commodity() -> str
Return commodity.
Source code in framcore/components/Node.py
84 85 86 | |
get_price() -> ShadowPrice
Return price.
Source code in framcore/components/Node.py
76 77 78 | |
get_storage() -> Storage | None
Get Storage if any.
Source code in framcore/components/Node.py
80 81 82 | |
is_exogenous() -> bool
Return True if Node is exogenous (i.e. has fixed prices determined outside the model) else False.
Source code in framcore/components/Node.py
72 73 74 | |
set_endogenous() -> None
Set the Node to be endogenous.
Source code in framcore/components/Node.py
67 68 69 70 | |
set_exogenous() -> None
Set the Node to be exogenous.
Source code in framcore/components/Node.py
62 63 64 65 | |
Thermal
Thermal
Bases: _PowerPlant
Represents a thermal power plant, subclassing PowerPlant.
This class models a thermal power plant with attributes inherited from PowerPlant. Additionally, it includes specific attributes such as:
- fuel node
- efficiency
- emission node
- emission coefficient
- startup costs
This class is compatible with ThermalAggregator.
Source code in framcore/components/Thermal.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
__init__(power_node: str, fuel_node: str, efficiency: Efficiency, max_capacity: FlowVolume, emission_node: str | None = None, emission_coefficient: Conversion | None = None, startupcost: StartUpCost | None = None, min_capacity: FlowVolume | None = None, voc: Cost | None = None, production: AvgFlowVolume | None = None, fuel_demand: AvgFlowVolume | None = None, emission_demand: AvgFlowVolume | None = None) -> None
Initialize a Thermal power plant instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
power_node
|
str
|
The power node of the plant. |
required |
fuel_node
|
str
|
The fuel node of the plant. |
required |
efficiency
|
Efficiency
|
Efficiency of the plant. |
required |
emission_node
|
str | None
|
Emission node. |
None
|
emission_coefficient
|
Conversion | None
|
Emission coefficient. |
None
|
startupcost
|
StartUpCost | None
|
Cost associated with starting up the Plant. |
None
|
max_capacity
|
FlowVolume | None
|
Maximum production capacity. |
required |
min_capacity
|
FlowVolume | None
|
Minimum production capacity. |
None
|
voc
|
Cost | None
|
Variable operating cost. |
None
|
production
|
AvgFlowVolume | None
|
Production volume. |
None
|
fuel_demand
|
AvgFlowVolume | None
|
Fuel demand. |
None
|
emission_demand
|
AvgFlowVolume | None
|
Emission demand. |
None
|
Source code in framcore/components/Thermal.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
get_efficiency() -> Efficiency
Get the efficiency of the thermal unit.
Source code in framcore/components/Thermal.py
131 132 133 | |
get_emission_coefficient() -> Conversion | None
Get the emission coefficient of the thermal unit.
Source code in framcore/components/Thermal.py
109 110 111 | |
get_emission_demand() -> AvgFlowVolume | None
Get the emission demand of the thermal unit.
Source code in framcore/components/Thermal.py
122 123 124 | |
get_emission_node() -> str | None
Get the emission node of the thermal unit.
Source code in framcore/components/Thermal.py
100 101 102 | |
get_fuel_demand() -> AvgFlowVolume
Get the fuel demand of the thermal unit.
Source code in framcore/components/Thermal.py
118 119 120 | |
get_fuel_node() -> str
Get the fuel node of the thermal unit.
Source code in framcore/components/Thermal.py
91 92 93 | |
get_startupcost() -> StartUpCost | None
Get the startup cost of the thermal unit.
Source code in framcore/components/Thermal.py
135 136 137 | |
set_emission_coefficient(emission_coefficient: Conversion | None) -> None
Set the emission coefficient of the thermal unit.
Source code in framcore/components/Thermal.py
113 114 115 116 | |
set_emission_demand(value: AvgFlowVolume | None) -> None
Set the emission demand of the thermal unit.
Source code in framcore/components/Thermal.py
126 127 128 129 | |
set_emission_node(emission_node: str | None) -> None
Set the emission node of the thermal unit.
Source code in framcore/components/Thermal.py
104 105 106 107 | |
set_fuel_node(fuel_node: str) -> None
Set the fuel node of the thermal unit.
Source code in framcore/components/Thermal.py
95 96 97 98 | |
set_startupcost(startupcost: StartUpCost | None) -> None
Set the startup cost of the thermal unit.
Source code in framcore/components/Thermal.py
139 140 141 142 | |
Transmission
Contain class describing transmission of Power commodity between nodes.
Transmission
Bases: Component
Transmission component representing a one directional transmission line. Subclass of Component.
An object of this class represents one transmission line where power flows one direction (the other direction is represented by another Transmission object). However, the actual measured power being sent can be higher than the amount being recieved because of loss. One Transmission object therefore represents the viewpoints of both the sender and the reciever of power on this specific line.
Source code in framcore/components/Transmission.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
__init__(from_node: str, to_node: str, max_capacity: FlowVolume = None, min_capacity: FlowVolume | None = None, loss: Loss | None = None, tariff: Cost | None = None, ramp_up: Proportion | None = None, ramp_down: Proportion | None = None, ingoing_volume: AvgFlowVolume | None = None, outgoing_volume: AvgFlowVolume | None = None) -> None
Initialize object of the Transmission class. Perform type checks and convert arguments to expressions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_node
|
str
|
Node which power is transported from. |
required |
to_node
|
str
|
Destination Node. |
required |
max_capacity
|
FlowVolume
|
Maximum transmission capacity. Defaults to None. |
None
|
min_capacity
|
FlowVolume | None
|
Minimum transmission capacity. Defaults to None. |
None
|
loss
|
Loss | None
|
Amount of power lost while transmitting. Defaults to None. |
None
|
tariff
|
Cost | None
|
Costs associated with operating this transmission line. Defaults to None. |
None
|
ramp_up
|
Proportion | None
|
Max upwards change in transmission per time. Defaults to None. |
None
|
ramp_down
|
Proportion | None
|
Max downwards change in transmission per time. Defaults to None. |
None
|
ingoing_volume
|
AvgFlowVolume | None
|
Volume of power recieved by to_node. Defaults to None. |
None
|
outgoing_volume
|
AvgFlowVolume | None
|
Volume of power sent by from_node. Defaults to None. |
None
|
Source code in framcore/components/Transmission.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
get_from_node() -> str
Get the from node of the transmission line.
Source code in framcore/components/Transmission.py
78 79 80 | |
get_ingoing_volume() -> AvgFlowVolume
Get the ingoing (after losses) flow volume of the transmission line.
Source code in framcore/components/Transmission.py
113 114 115 | |
get_loss() -> Loss | None
Get the loss of the transmission line.
Source code in framcore/components/Transmission.py
117 118 119 | |
get_max_capacity() -> FlowVolume
Get the maximum capacity (before losses) of the transmission line.
Source code in framcore/components/Transmission.py
96 97 98 | |
get_min_capacity() -> FlowVolume
Get the minimum capacity (before losses) of the transmission line.
Source code in framcore/components/Transmission.py
100 101 102 | |
get_outgoing_volume() -> AvgFlowVolume
Get the outgoing (before losses) flow volume of the transmission line.
Source code in framcore/components/Transmission.py
109 110 111 | |
get_ramp_down() -> Proportion | None
Get the ramp down of the transmission line.
Source code in framcore/components/Transmission.py
144 145 146 | |
get_ramp_up() -> Proportion | None
Get the ramp up profile level of the transmission line.
Source code in framcore/components/Transmission.py
135 136 137 | |
get_tariff() -> Cost | None
Get the tariff of the transmission line.
Source code in framcore/components/Transmission.py
126 127 128 | |
get_to_node() -> str
Get the to node of the transmission line.
Source code in framcore/components/Transmission.py
87 88 89 | |
set_from_node(node: str) -> None
Set the from node of the transmission line.
Source code in framcore/components/Transmission.py
82 83 84 85 | |
set_loss(loss: Loss | None) -> None
Set the loss of the transmission line.
Source code in framcore/components/Transmission.py
121 122 123 124 | |
set_min_capacity(value: FlowVolume | None) -> None
Set the minimum capacity (before losses) of the transmission line.
Source code in framcore/components/Transmission.py
104 105 106 107 | |
set_ramp_down(value: Proportion | None) -> None
Set the ramp down of the transmission line.
Source code in framcore/components/Transmission.py
148 149 150 151 | |
set_ramp_up(value: Proportion | None) -> None
Set the ramp up of the transmission line.
Source code in framcore/components/Transmission.py
139 140 141 142 | |
set_tariff(tariff: Cost | None) -> None
Set the tariff of the transmission line.
Source code in framcore/components/Transmission.py
130 131 132 133 | |
set_to_node(node: str) -> None
Set the to node of the transmission line.
Source code in framcore/components/Transmission.py
91 92 93 94 | |
wind_solar
Solar
Bases: _WindSolar
Solar power component.
Has attributes for power node, capacity, variable operation cost, and production.
Compatible with WindSolarAggregator.
Source code in framcore/components/wind_solar.py
73 74 75 76 77 78 79 80 81 82 | |
Wind
Bases: _WindSolar
Wind power component.
Has attributes for power node, capacity, variable operation cost, and production.
Compatible with WindSolarAggregator.
Source code in framcore/components/wind_solar.py
61 62 63 64 65 66 67 68 69 70 | |
curves
Curve
Curve interface.
Curve
Bases: Base, ABC
Curve interface class.
Source code in framcore/curves/Curve.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
get_unique_name() -> str | None
abstractmethod
Return unique name of curve.
Source code in framcore/curves/Curve.py
13 14 15 16 | |
get_x_axis(is_float32: bool) -> NDArray
abstractmethod
Get array of x axis values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
is_float32
|
bool
|
Flag for converting the array of values to numpy float32. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
Numpy array of values. |
Source code in framcore/curves/Curve.py
18 19 20 21 22 23 24 25 26 27 28 29 30 | |
get_y_axis(is_float32: bool) -> NDArray
abstractmethod
Get array of y axis values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
is_float32
|
bool
|
Flag for converting the array of values to numpy float32. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
Numpy array of values. |
Source code in framcore/curves/Curve.py
32 33 34 35 36 37 38 39 40 41 42 43 44 | |
LoadedCurve
LoadedCurve
Bases: Curve
Represents a curve loaded from a CurveLoader.
Methods
get_unique_name() Returns the unique name of the curve. get_x_axis(precision=None) Returns the x-axis data. get_y_axis(precision=None) Returns the y-axis data. get_x_unit() Returns the unit for the x-axis. get_y_unit() Returns the unit for the y-axis. get_loader() Returns the loader instance. get_fingerprint() Returns the fingerprint of the curve.
Source code in framcore/curves/LoadedCurve.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
__init__(curve_id: str, loader: CurveLoader) -> None
Initialize a LoadedCurve instance.
Parameters
curve_id : str Identifier for the curve. loader : CurveLoader Loader instance used to retrieve curve data.
Source code in framcore/curves/LoadedCurve.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
__repr__() -> str
Return a string representation of the LoadedCurve instance.
Source code in framcore/curves/LoadedCurve.py
56 57 58 | |
get_fingerprint() -> Fingerprint
Return the fingerprint of the curve.
The method is not implemented yet.
Source code in framcore/curves/LoadedCurve.py
140 141 142 143 144 145 146 | |
get_loader() -> CurveLoader
Return the loader instance used to retrieve curve data.
Returns
CurveLoader The loader instance associated with this curve.
Source code in framcore/curves/LoadedCurve.py
128 129 130 131 132 133 134 135 136 137 138 | |
get_unique_name() -> str
Return the unique name of the curve.
Returns
str The unique name for the curve.
Source code in framcore/curves/LoadedCurve.py
60 61 62 63 64 65 66 67 68 69 70 | |
get_x_axis(is_float32: bool) -> NDArray
Get x axis values of the curve as a numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
is_float32
|
bool
|
Flag for converting the array of values to numpy float32. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
Numpy array of x axis values. |
Source code in framcore/curves/LoadedCurve.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
get_x_unit() -> str
Return the unit for the x-axis.
Returns
str The unit for the x-axis.
Source code in framcore/curves/LoadedCurve.py
104 105 106 107 108 109 110 111 112 113 114 | |
get_y_axis(is_float32: bool) -> NDArray
Get y axis values of the curve as a numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
is_float32
|
bool
|
Flag for converting the array of values to numpy float32. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
Numpy array of y axis values. |
Source code in framcore/curves/LoadedCurve.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
get_y_unit() -> str
Return the unit for the y-axis.
Returns
str The unit for the y-axis.
Source code in framcore/curves/LoadedCurve.py
116 117 118 119 120 121 122 123 124 125 126 | |
events
get_event_handler() -> object | None
Get event handler if any.
Source code in framcore/events/events.py
21 22 23 | |
send_debug_event(sender: object, message: str) -> None
Use this to send debug event.
Source code in framcore/events/events.py
49 50 51 | |
send_error_event(sender: object, message: str, exception_type_name: str, traceback: str) -> None
Use this to send error event.
Source code in framcore/events/events.py
39 40 41 | |
send_event(sender: object, event_type: str, **kwargs: dict[str, object]) -> None
All events in core should use this.
Source code in framcore/events/events.py
26 27 28 29 30 31 | |
send_info_event(sender: object, message: str) -> None
Use this to send info event.
Source code in framcore/events/events.py
44 45 46 | |
send_warning_event(sender: object, message: str) -> None
Use this to send warning event.
Source code in framcore/events/events.py
34 35 36 | |
set_event_handler(handler: object | None) -> None
Set event handler if any.
Source code in framcore/events/events.py
12 13 14 15 16 17 18 | |
events
Event system.
All code in the core use these functions to communicate events.
Calling systems (e.g. workflow codes) can get events by hooking into SEND_EVENT_CHANNEL.
get_event_handler() -> object | None
Get event handler if any.
Source code in framcore/events/events.py
21 22 23 | |
send_debug_event(sender: object, message: str) -> None
Use this to send debug event.
Source code in framcore/events/events.py
49 50 51 | |
send_error_event(sender: object, message: str, exception_type_name: str, traceback: str) -> None
Use this to send error event.
Source code in framcore/events/events.py
39 40 41 | |
send_event(sender: object, event_type: str, **kwargs: dict[str, object]) -> None
All events in core should use this.
Source code in framcore/events/events.py
26 27 28 29 30 31 | |
send_info_event(sender: object, message: str) -> None
Use this to send info event.
Source code in framcore/events/events.py
44 45 46 | |
send_warning_event(sender: object, message: str) -> None
Use this to send warning event.
Source code in framcore/events/events.py
34 35 36 | |
set_event_handler(handler: object | None) -> None
Set event handler if any.
Source code in framcore/events/events.py
12 13 14 15 16 17 18 | |
expressions
ensure_expr(value: Expr | str | Curve | TimeVector | None, is_flow: bool = False, is_stock: bool = False, is_level: bool = False, is_profile: bool = False, profile: Expr | None = None) -> Expr | None
Ensure that the value is an expression of the expected type or create one if possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Expr | str | None
|
The value to check. |
required |
is_flow
|
str
|
If the Expr is a flow. Cannot be True if is_stock is True. |
False
|
is_stock
|
str
|
If the Expr is a stock. Cannot be True if is_flow is True. |
False
|
is_level
|
bool
|
Wether the Expr represents a level. Cannot be True if is_profile is True. |
False
|
is_profile
|
bool
|
Wether the Expr represents a profile. Cannot be True if is_level is True. |
False
|
profile
|
Expr | None
|
If the Expr is a level, this should be its profile. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
value |
Expr | str
|
The value as an expression of the expected type or None. |
Source code in framcore/expressions/Expr.py
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | |
get_leaf_profiles(expr: Expr) -> list[Expr]
Get all leaf profile expressions from an Expr object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr
|
Expr
|
The starting Expr object. |
required |
Returns:
| Type | Description |
|---|---|
list[Expr]
|
list[Expr]: A list of leaf profile expressions. |
Source code in framcore/expressions/Expr.py
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 | |
get_level_value(expr: Expr, db: QueryDB | Model, unit: str | None, data_dim: SinglePeriodTimeIndex, scen_dim: FixedFrequencyTimeIndex, is_max: bool) -> float
Evaluate Expr representing a (possibly aggregated) level.
The follwing will be automatically handled for you: - fetching from different data objecs (from db) - conversion to requested unit - query at requested TimeIndex for data and scenario dimension, and with requested reference period - conversion to requested level type (is_max or is_avg)
Supports all expressions. Will evaluate level Exprs at data_dim (with reference period of scen_dim), and profile Exprs as an average over scen_dim (both as constants). Has optimized fastpath methods for sums, products and aggregations. The rest uses a fallback method with SymPy.
Source code in framcore/expressions/queries.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
get_profile_exprs_from_leaf_levels(expr: Expr) -> list[Expr]
Get all profile expressions from leaf-level Expr objects that are marked as levels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr
|
Expr
|
The starting Expr object. |
required |
Returns:
| Type | Description |
|---|---|
list[Expr]
|
list[Expr]: A list of profile expressions from leaf-level Expr objects. |
Source code in framcore/expressions/Expr.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | |
get_profile_vector(expr: Expr, db: QueryDB | Model, data_dim: SinglePeriodTimeIndex, scen_dim: FixedFrequencyTimeIndex, is_zero_one: bool, is_float32: bool = True) -> NDArray
Evaluate expr representing a (possibly aggregated) profile.
expr = sum(weight[i] * profile[i]) where
weight[i] >= 0 and is unitless, and will be evaluated as a constant
profile[i] is a unitless profile expr
profile[i] is either "zero_one" or "mean_one" type of profile
"zero_one" and "mean_one" profile type must be converted to the
same standard to be added correctly.
The query parameters data_dim and scen_dim are used to evaluate the values
requested TimeIndex for data and scenario dimension, and with requested reference period
weight[i] will be evaluated level Exprs at data_dim (with reference period of scen_dim),
and profile Exprs as an average over scen_dim (both as constants)
profile[i] will be evaluated as profile vectors over scen_dim
The query parameter is_zero_one tells which profile type the output
vector should be converted to.
Source code in framcore/expressions/queries.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
get_timeindexes_from_expr(db: QueryDB | Model, expr: Expr) -> set[TimeIndex]
Find all timeindexes behind an expression.
Useful for optimized queries (not asking for more data than necessary).
Source code in framcore/expressions/queries.py
108 109 110 111 112 113 114 115 116 117 118 119 120 | |
get_unit_conversion_factor(from_unit: str | None, to_unit: str | None) -> float
Get the conversion factor from one unit to another.
Source code in framcore/expressions/units.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
get_units_from_expr(db: QueryDB | Model, expr: Expr) -> set[str]
Find all units behind an expression. Useful for queries involving conversion factors.
Source code in framcore/expressions/queries.py
97 98 99 100 101 102 103 104 105 | |
is_convertable(unit_from: str, unit_to: str) -> bool
Return True if from_unit can be converted to to_unit else False.
Source code in framcore/expressions/units.py
222 223 224 225 226 227 | |
validate_unit_conversion_fastpaths() -> bool
Run-Time validation of fastpaths.
Source code in framcore/expressions/units.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
Expr
Expr
Bases: Base
Mathematical expression with TimeVectors and Curves to represent Levels and Profiles in LevelProfiles.
The simplest Expr is a single TimeVector, while a more complicated expression could be a weighted average of several TimeVectors or Expressions. Expr can also have string references to Expr, TimeVector or Curve in a database (often Model).
Expr are classified as Stock, Flow or None of them. See https://en.wikipedia.org/wiki/Stock_and_flow. In FRAM we only support Flow data as a rate of change. So, for example, a production timeseries has to be in MW, and not in MWh. Converting between the two versions of Flow would add another level of complexity both in Expr and in TimeVector operations.
Expr are also classified as Level, Profile or none of them. This classification, together with Stock or Flow, is used to check if the built Expr are legal operations. - Expr that are Level can contain its connected Profile Expr. This is used in the queries to evaluate Levels according to their ReferencePeriod, and convert between Level formats (max level or average level, see LevelProfile for more details).
Calculations using Expr are evaluated lazily, reducing unnecessary numerical operations during data manipulation. Computations involving values and units occur only when the Expr is queried.
We only support calculations using +, -, *, and / in Expr, and we have no plans to change this. Expanding beyond these would turn Expr into a complex programming language rather than keeping it as a simple and efficient system for common time-series calculations. More advanced operations are still possible through eager evaluation, so this is not a limitation. It simply distributes responsibilities across system components in a way that is practical from a maintenance perspective.
We use SymPy to support unit conversions. Already computed unit conversion factors are cached to minimize redundant calculations.
At the moment we support these queries for Expr (see Aggregators for more about how they are used): - get_level_value(expr, db, unit, data_dim, scen_dim, is_max) - Supports all expressions. Will evaluate level Exprs at data_dim (with reference period of scen_dim), and profile Exprs as an average over scen_dim (both as constants). - Has optimized fastpath methods for sums, products and aggregations. The rest uses a fallback method with SymPy. - get_profile_vector(expr, db, data_dim, scen_dim, is_zero_one, is_float32) - Supports expr = sum(weight[i] * profile[i]) where weight[i] is a unitless constant Expr with value >= 0, and profile[i] is a unitless profile Expr.
Source code in framcore/expressions/Expr.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 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 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 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | |
__eq__(other) -> bool
Check if self and other are equal.
Source code in framcore/expressions/Expr.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
__hash__() -> int
Compute hash value..
Source code in framcore/expressions/Expr.py
456 457 458 459 460 461 462 463 464 465 466 467 468 469 | |
__init__(src: str | Curve | TimeVector | None = None, is_stock: bool = False, is_flow: bool = False, is_profile: bool = False, is_level: bool = False, profile: Expr | None = None, operations: tuple[str, list[Expr]] | None = None) -> None
Create new (immutable) Expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
str | Curve | TimeVector | None
|
Source of the values to be used in the Expression. Either a Curve or TimeVector object, or a reference to one of them. Defaults to None. |
None
|
is_stock
|
bool
|
Flag to signify if the Expr represents a stock type variable. Defaults to False. |
False
|
is_flow
|
bool
|
Flag to signify if the Expr represents a flow type variable. Defaults to False. |
False
|
is_profile
|
bool
|
Flag to signify if the Expr represents a profile. Defaults to False. |
False
|
is_level
|
bool
|
Flag to signify if the Expr represents a level. Defaults to False. |
False
|
profile
|
Expr | None
|
Expr that are Level can contain its connected Profile Expr. This is used in the queries to evaluate Levels according to their ReferencePeriod, and convert between Level formats (max level or average level, see LevelProfile for more details). |
None
|
operations
|
tuple[str, list[Expr]] | None
|
Operations to apply to the expression. Defaults to None. |
None
|
Source code in framcore/expressions/Expr.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
__repr__() -> str
Represent Expr as str.
Source code in framcore/expressions/Expr.py
430 431 432 433 434 435 436 437 438 | |
add_loaders(loaders: set[Loader]) -> None
Add all loaders stored in TimeVector or Curve within Expr to loaders.
Source code in framcore/expressions/Expr.py
471 472 473 474 475 476 477 478 479 480 481 482 | |
get_fingerprint() -> Fingerprint
Return fingerprint.
Source code in framcore/expressions/Expr.py
140 141 142 143 144 145 146 147 148 149 150 151 | |
get_operations(expect_ops: bool, copy_list: bool) -> tuple[str, list[Expr]]
Return ops, args. Users of this (low level) API must supply expect_ops and copy_list args.
Source code in framcore/expressions/Expr.py
161 162 163 164 165 166 167 168 | |
get_profile() -> Expr | None
Return Expr representing profile. Implies self.is_level() is True.
Source code in framcore/expressions/Expr.py
212 213 214 | |
get_src() -> str | Curve | TimeVector | None
Return str, Curve or TimeVector (either reference to Curve/TimeVector or Curve/TimeVector itself) or None if self is an operation expression.
Source code in framcore/expressions/Expr.py
157 158 159 | |
is_flow() -> bool
Return True if flow. Cannot be stock and flow.
Source code in framcore/expressions/Expr.py
196 197 198 | |
is_leaf() -> bool
Return True if self is not an operation expression.
Source code in framcore/expressions/Expr.py
153 154 155 | |
is_level() -> bool
Return True if level. Cannot be level and profile.
Source code in framcore/expressions/Expr.py
204 205 206 | |
is_profile() -> bool
Return True if profile. Cannot be level and profile.
Source code in framcore/expressions/Expr.py
208 209 210 | |
is_stock() -> bool
Return True if stock. Cannot be stock and flow.
Source code in framcore/expressions/Expr.py
200 201 202 | |
set_profile(profile: Expr | None) -> None
Set the profile of the Expr. Implies self.is_level() is True.
Source code in framcore/expressions/Expr.py
216 217 218 219 220 | |
ensure_expr(value: Expr | str | Curve | TimeVector | None, is_flow: bool = False, is_stock: bool = False, is_level: bool = False, is_profile: bool = False, profile: Expr | None = None) -> Expr | None
Ensure that the value is an expression of the expected type or create one if possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Expr | str | None
|
The value to check. |
required |
is_flow
|
str
|
If the Expr is a flow. Cannot be True if is_stock is True. |
False
|
is_stock
|
str
|
If the Expr is a stock. Cannot be True if is_flow is True. |
False
|
is_level
|
bool
|
Wether the Expr represents a level. Cannot be True if is_profile is True. |
False
|
is_profile
|
bool
|
Wether the Expr represents a profile. Cannot be True if is_level is True. |
False
|
profile
|
Expr | None
|
If the Expr is a level, this should be its profile. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
value |
Expr | str
|
The value as an expression of the expected type or None. |
Source code in framcore/expressions/Expr.py
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | |
get_leaf_profiles(expr: Expr) -> list[Expr]
Get all leaf profile expressions from an Expr object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr
|
Expr
|
The starting Expr object. |
required |
Returns:
| Type | Description |
|---|---|
list[Expr]
|
list[Expr]: A list of leaf profile expressions. |
Source code in framcore/expressions/Expr.py
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 | |
get_profile_exprs_from_leaf_levels(expr: Expr) -> list[Expr]
Get all profile expressions from leaf-level Expr objects that are marked as levels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr
|
Expr
|
The starting Expr object. |
required |
Returns:
| Type | Description |
|---|---|
list[Expr]
|
list[Expr]: A list of profile expressions from leaf-level Expr objects. |
Source code in framcore/expressions/Expr.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | |
queries
get_level_value(expr: Expr, db: QueryDB | Model, unit: str | None, data_dim: SinglePeriodTimeIndex, scen_dim: FixedFrequencyTimeIndex, is_max: bool) -> float
Evaluate Expr representing a (possibly aggregated) level.
The follwing will be automatically handled for you: - fetching from different data objecs (from db) - conversion to requested unit - query at requested TimeIndex for data and scenario dimension, and with requested reference period - conversion to requested level type (is_max or is_avg)
Supports all expressions. Will evaluate level Exprs at data_dim (with reference period of scen_dim), and profile Exprs as an average over scen_dim (both as constants). Has optimized fastpath methods for sums, products and aggregations. The rest uses a fallback method with SymPy.
Source code in framcore/expressions/queries.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
get_profile_vector(expr: Expr, db: QueryDB | Model, data_dim: SinglePeriodTimeIndex, scen_dim: FixedFrequencyTimeIndex, is_zero_one: bool, is_float32: bool = True) -> NDArray
Evaluate expr representing a (possibly aggregated) profile.
expr = sum(weight[i] * profile[i]) where
weight[i] >= 0 and is unitless, and will be evaluated as a constant
profile[i] is a unitless profile expr
profile[i] is either "zero_one" or "mean_one" type of profile
"zero_one" and "mean_one" profile type must be converted to the
same standard to be added correctly.
The query parameters data_dim and scen_dim are used to evaluate the values
requested TimeIndex for data and scenario dimension, and with requested reference period
weight[i] will be evaluated level Exprs at data_dim (with reference period of scen_dim),
and profile Exprs as an average over scen_dim (both as constants)
profile[i] will be evaluated as profile vectors over scen_dim
The query parameter is_zero_one tells which profile type the output
vector should be converted to.
Source code in framcore/expressions/queries.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
get_timeindexes_from_expr(db: QueryDB | Model, expr: Expr) -> set[TimeIndex]
Find all timeindexes behind an expression.
Useful for optimized queries (not asking for more data than necessary).
Source code in framcore/expressions/queries.py
108 109 110 111 112 113 114 115 116 117 118 119 120 | |
get_units_from_expr(db: QueryDB | Model, expr: Expr) -> set[str]
Find all units behind an expression. Useful for queries involving conversion factors.
Source code in framcore/expressions/queries.py
97 98 99 100 101 102 103 104 105 | |
units
Define units used in the system, their handling and conversion rules.
We use SymPy to support unit conversions. Already computed unit conversion factors are cached to minimize redundant calculations.
get_unit_conversion_factor(from_unit: str | None, to_unit: str | None) -> float
Get the conversion factor from one unit to another.
Source code in framcore/expressions/units.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
is_convertable(unit_from: str, unit_to: str) -> bool
Return True if from_unit can be converted to to_unit else False.
Source code in framcore/expressions/units.py
222 223 224 225 226 227 | |
validate_unit_conversion_fastpaths() -> bool
Run-Time validation of fastpaths.
Source code in framcore/expressions/units.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
fingerprints
Fingerprint
Fingerprint of various data structures.
Source code in framcore/fingerprints/fingerprint.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
__eq__(other: Fingerprint) -> bool
Determine if two Fingerprint instances are equal based on their hash values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Fingerprint
|
The other Fingerprint instance to compare. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the hash values are equal, False otherwise. |
Source code in framcore/fingerprints/fingerprint.py
263 264 265 266 267 268 269 270 271 272 273 274 | |
__init__(source: object = None) -> None
Initialize a Fingerprint instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
object
|
The source object to fingerprint. Defaults to None. |
None
|
Source code in framcore/fingerprints/fingerprint.py
102 103 104 105 106 107 108 109 110 111 112 | |
add(key: str, value: object) -> None
Add a value to the fingerprint under the specified key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to associate with the value. |
required |
value
|
object
|
The value to add, which can be a Fingerprint, FingerprintRef, or other supported types. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in framcore/fingerprints/fingerprint.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
add_ref(prop: str, ref_key: str) -> None
Add a FingerprintRef to the fingerprint under the specified property key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop
|
str
|
The property key to associate with the reference. |
required |
ref_key
|
str
|
The key referencing another fingerprint. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in framcore/fingerprints/fingerprint.py
153 154 155 156 157 158 159 160 161 162 163 164 165 | |
diff(other: Fingerprint | None) -> FingerprintDiff
Return differences between this and other fingerprint.
Source code in framcore/fingerprints/fingerprint.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
get_hash() -> str
Return the hash value of the fingerprint.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The computed hash value representing the fingerprint. |
Source code in framcore/fingerprints/fingerprint.py
195 196 197 198 199 200 201 202 203 204 | |
get_parts() -> dict
Return the dictionary of parts contained in the fingerprint.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary mapping keys to their associated fingerprint parts. |
Source code in framcore/fingerprints/fingerprint.py
167 168 169 170 171 172 173 174 175 | |
update_ref(ref_key: str, fingerprint: Fingerprint) -> None
Update the reference at the given key with a new Fingerprint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref_key
|
str
|
The key referencing the FingerprintRef to update. |
required |
fingerprint
|
Fingerprint
|
The new Fingerprint to set at the reference. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in framcore/fingerprints/fingerprint.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
FingerprintDiff
Differences between two fingerprints.
Source code in framcore/fingerprints/fingerprint.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
__init__() -> None
Initialize an empty FingerprintDiff.
Source code in framcore/fingerprints/fingerprint.py
43 44 45 | |
add_diff(key: str, diff_type: FingerprintDiffType, obj: object) -> None
Add a difference entry for a fingerprint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key identifying the fingerprint part. |
required |
diff_type
|
FingerprintDiffType
|
The type of difference (NEW, MODIFIED, DELETED). |
required |
obj
|
object
|
The object associated with the difference. |
required |
Source code in framcore/fingerprints/fingerprint.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
get_diffs() -> dict[str, tuple]
Return the dictionary of differences.
Returns:
| Type | Description |
|---|---|
dict[str, tuple]
|
dict[str, tuple]: The differences stored in the FingerprintDiff. |
Source code in framcore/fingerprints/fingerprint.py
74 75 76 77 78 79 80 81 82 | |
is_changed() -> bool
Return True if there are any differences.
Source code in framcore/fingerprints/fingerprint.py
84 85 86 | |
update(other: FingerprintDiff) -> None
Update this FingerprintDiff with differences from another FingerprintDiff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
FingerprintDiff
|
Another FingerprintDiff whose differences will be added. |
required |
Source code in framcore/fingerprints/fingerprint.py
88 89 90 91 92 93 94 95 96 | |
FingerprintDiffType
Bases: Enum
Type of difference between two fingerprints.
Source code in framcore/fingerprints/fingerprint.py
32 33 34 35 36 37 | |
FingerprintRef
Refers to another fingerprint.
Source code in framcore/fingerprints/fingerprint.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
__init__(key: str) -> None
Initialize a FingerprintRef with the given key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key referencing another fingerprint. |
required |
Source code in framcore/fingerprints/fingerprint.py
11 12 13 14 15 16 17 18 19 | |
get_key() -> str
Return the key referencing another fingerprint.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The key referencing another fingerprint. |
Source code in framcore/fingerprints/fingerprint.py
21 22 23 24 25 26 27 28 29 | |
fingerprint
Fingerprint
Fingerprint of various data structures.
Source code in framcore/fingerprints/fingerprint.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
__eq__(other: Fingerprint) -> bool
Determine if two Fingerprint instances are equal based on their hash values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Fingerprint
|
The other Fingerprint instance to compare. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the hash values are equal, False otherwise. |
Source code in framcore/fingerprints/fingerprint.py
263 264 265 266 267 268 269 270 271 272 273 274 | |
__init__(source: object = None) -> None
Initialize a Fingerprint instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
object
|
The source object to fingerprint. Defaults to None. |
None
|
Source code in framcore/fingerprints/fingerprint.py
102 103 104 105 106 107 108 109 110 111 112 | |
add(key: str, value: object) -> None
Add a value to the fingerprint under the specified key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to associate with the value. |
required |
value
|
object
|
The value to add, which can be a Fingerprint, FingerprintRef, or other supported types. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in framcore/fingerprints/fingerprint.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
add_ref(prop: str, ref_key: str) -> None
Add a FingerprintRef to the fingerprint under the specified property key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop
|
str
|
The property key to associate with the reference. |
required |
ref_key
|
str
|
The key referencing another fingerprint. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in framcore/fingerprints/fingerprint.py
153 154 155 156 157 158 159 160 161 162 163 164 165 | |
diff(other: Fingerprint | None) -> FingerprintDiff
Return differences between this and other fingerprint.
Source code in framcore/fingerprints/fingerprint.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
get_hash() -> str
Return the hash value of the fingerprint.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The computed hash value representing the fingerprint. |
Source code in framcore/fingerprints/fingerprint.py
195 196 197 198 199 200 201 202 203 204 | |
get_parts() -> dict
Return the dictionary of parts contained in the fingerprint.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary mapping keys to their associated fingerprint parts. |
Source code in framcore/fingerprints/fingerprint.py
167 168 169 170 171 172 173 174 175 | |
update_ref(ref_key: str, fingerprint: Fingerprint) -> None
Update the reference at the given key with a new Fingerprint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref_key
|
str
|
The key referencing the FingerprintRef to update. |
required |
fingerprint
|
Fingerprint
|
The new Fingerprint to set at the reference. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in framcore/fingerprints/fingerprint.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
FingerprintDiff
Differences between two fingerprints.
Source code in framcore/fingerprints/fingerprint.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
__init__() -> None
Initialize an empty FingerprintDiff.
Source code in framcore/fingerprints/fingerprint.py
43 44 45 | |
add_diff(key: str, diff_type: FingerprintDiffType, obj: object) -> None
Add a difference entry for a fingerprint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key identifying the fingerprint part. |
required |
diff_type
|
FingerprintDiffType
|
The type of difference (NEW, MODIFIED, DELETED). |
required |
obj
|
object
|
The object associated with the difference. |
required |
Source code in framcore/fingerprints/fingerprint.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
get_diffs() -> dict[str, tuple]
Return the dictionary of differences.
Returns:
| Type | Description |
|---|---|
dict[str, tuple]
|
dict[str, tuple]: The differences stored in the FingerprintDiff. |
Source code in framcore/fingerprints/fingerprint.py
74 75 76 77 78 79 80 81 82 | |
is_changed() -> bool
Return True if there are any differences.
Source code in framcore/fingerprints/fingerprint.py
84 85 86 | |
update(other: FingerprintDiff) -> None
Update this FingerprintDiff with differences from another FingerprintDiff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
FingerprintDiff
|
Another FingerprintDiff whose differences will be added. |
required |
Source code in framcore/fingerprints/fingerprint.py
88 89 90 91 92 93 94 95 96 | |
FingerprintDiffType
Bases: Enum
Type of difference between two fingerprints.
Source code in framcore/fingerprints/fingerprint.py
32 33 34 35 36 37 | |
FingerprintRef
Refers to another fingerprint.
Source code in framcore/fingerprints/fingerprint.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
__init__(key: str) -> None
Initialize a FingerprintRef with the given key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key referencing another fingerprint. |
required |
Source code in framcore/fingerprints/fingerprint.py
11 12 13 14 15 16 17 18 19 | |
get_key() -> str
Return the key referencing another fingerprint.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The key referencing another fingerprint. |
Source code in framcore/fingerprints/fingerprint.py
21 22 23 24 25 26 27 28 29 | |
juliamodels
JuliaModel
Manage Julia environment and usage of juliacall for Solvers implemented in the Julia language.
JuliaModel
Bases: Base
Class for running julia code with juliacall.
Source code in framcore/juliamodels/JuliaModel.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
__init__(env_path: Path | str | None = None, depot_path: Path | str | None = None, julia_path: Path | str | None = None, dependencies: list[str | tuple[str, str | None]] | None = None, skip_install_dependencies: bool = False, force_julia_install: bool = True) -> None
Initialize management of Julia model, environment and dependencies.
The three parameters env_path, depot_path and julia_path sets environment variables for locations of your Julia environment, packages and language.
- If user has not specified locations, the default is to use the current python/conda environment.
- If a system installation of Python is used, the default is set to the current user location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_path
|
Path | str | None
|
Path to location of Julia environment. If it doesnt exist it will be created. Defaults to None. |
None
|
depot_path
|
Path | str | None
|
Path to location where JuliaCall shoult install package dependencies. Defaults to None. |
None
|
julia_path
|
Path | str | None
|
Path to Julia language location. Will be installed here if it doesnt exist. Defaults to None. |
None
|
dependencies
|
list[str] | None
|
List of dependencies of the model. The strings in the list can be either urls or Julia package names.. Defaults to None. |
None
|
skip_install_dependencies
|
bool
|
Skip installation of dependencies. Defaults to False. |
False
|
force_julia_install
|
bool
|
Force new Julia install. |
True
|
Source code in framcore/juliamodels/JuliaModel.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
loaders
CurveLoader
Bases: Loader, ABC
Loader API for retrieving curve data from some source.
Source code in framcore/loaders/loaders.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 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 | |
get_x_axis(curve_id: str) -> NDArray
abstractmethod
Return the values of a Curves x axis in the Loader source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve_id
|
str
|
ID of the curve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
Numpy array of all values in the x axis. |
Source code in framcore/loaders/loaders.py
276 277 278 279 280 281 282 283 284 285 286 287 288 | |
get_x_unit(curve_id: str) -> str
abstractmethod
Return the unit of the x axis of a specific curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve_id
|
str
|
ID of the curve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Unit of the curve's x axis. |
Source code in framcore/loaders/loaders.py
290 291 292 293 294 295 296 297 298 299 300 301 302 | |
get_y_axis(curve_id: str) -> NDArray
abstractmethod
Return the values of a Curves y axis in the Loader source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve_id
|
str
|
ID of the curve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
Numpy array of all values in the y axis. |
Source code in framcore/loaders/loaders.py
262 263 264 265 266 267 268 269 270 271 272 273 274 | |
get_y_unit(curve_id: str) -> str
abstractmethod
Return the unit of the y axis of a specific curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve_id
|
str
|
ID of the curve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Unit of the curve's y axis. |
Source code in framcore/loaders/loaders.py
304 305 306 307 308 309 310 311 312 313 314 315 316 | |
FileLoader
Bases: Loader, ABC
Define common functionality and API for Loaders connected to a file as source.
Source code in framcore/loaders/loaders.py
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 405 | |
__init__(source: Path | str, relative_loc: Path | str | None = None) -> None
Check validity of input parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Path | str
|
Full file path or the absolute part of a file path |
required |
relative_loc
|
Optional[Union[Path, str]]
|
The relative part of a file path. Defaults to None. |
None
|
Source code in framcore/loaders/loaders.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
__repr__() -> str
Overwrite repr to get better info.
Source code in framcore/loaders/loaders.py
343 344 345 | |
get_source() -> Path
Combine absolute and relative file path (if relative is defined) to get full source.
Source code in framcore/loaders/loaders.py
347 348 349 350 351 | |
get_supported_suffixes() -> list[str]
classmethod
Return list of supported file types.
Returns:
| Name | Type | Description |
|---|---|---|
list |
list[str]
|
List of filetypes. |
Source code in framcore/loaders/loaders.py
365 366 367 368 369 370 371 372 373 374 | |
set_source(new_source: Path, relative_loc: Path | str | None = None) -> None
Set absolute and relative parts of filepath.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_source
|
Path
|
New absolute part. |
required |
relative_loc
|
Optional[Union[Path, str]]
|
New relative part. Defaults to None. |
None
|
Source code in framcore/loaders/loaders.py
353 354 355 356 357 358 359 360 361 362 363 | |
Loader
Bases: Base, ABC
Base Loader class defining common API and functionality for all Loaders.
Source code in framcore/loaders/loaders.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
__deepcopy__(memo: dict) -> Loader
Overwrite deepcopy.
This is done to enable sharing of loaders. Since a loader is connected to one source, caching can thus be shared between Models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memo
|
dict
|
Required argument. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Loader |
Loader
|
Returns itself. |
Source code in framcore/loaders/loaders.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
__getstate__() -> dict
Return current object state, clearing any cached data.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The object's state dictionary. |
Source code in framcore/loaders/loaders.py
34 35 36 37 38 39 40 41 42 43 | |
__init__() -> None
Set up cache of ids contained in the source of the Loader.
Source code in framcore/loaders/loaders.py
20 21 22 | |
__repr__() -> str
Overwrite string representation.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Object represented as string. |
Source code in framcore/loaders/loaders.py
24 25 26 27 28 29 30 31 32 | |
clear_cache() -> None
abstractmethod
Clear cached data from the loader.
Source code in framcore/loaders/loaders.py
45 46 47 48 | |
get_ids() -> list[str]
Handle caching of ids existing in the loaders source.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: List containing ids in Loader source. |
Source code in framcore/loaders/loaders.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
get_metadata(content_id: str) -> object
abstractmethod
Get metadata from the Loader source.
The metadata could describe behavior of the data in source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content_id
|
str
|
Id of some content. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
object |
object
|
Metadata in some format only the specific Loader knows. |
Source code in framcore/loaders/loaders.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
get_source() -> object
abstractmethod
Return Loader source.
Returns:
| Name | Type | Description |
|---|---|---|
object |
object
|
Whatever the Loader interacts with to retrieve data. |
Source code in framcore/loaders/loaders.py
66 67 68 69 70 71 72 73 74 75 | |
set_source(new_source: object) -> None
abstractmethod
Set the Loader source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_source
|
object
|
Whatever the Loader should interact with to retrieve data. |
required |
Source code in framcore/loaders/loaders.py
77 78 79 80 81 82 83 84 85 86 | |
TimeVectorLoader
Bases: Loader, ABC
Loader API for retrieving time vector data from some source.
Source code in framcore/loaders/loaders.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
get_fingerprint(vector_id: str) -> Fingerprint
Return Loader Fingerprint for given vector id.
Source code in framcore/loaders/loaders.py
250 251 252 253 254 255 256 | |
get_index(vector_id: str) -> TimeIndex
abstractmethod
Return the index a time vector in the Loader source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
ID of the vector. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
TimeIndex
|
TimeIndex object. |
Source code in framcore/loaders/loaders.py
175 176 177 178 179 180 181 182 183 184 185 186 187 | |
get_reference_period(vector_id: str) -> ReferencePeriod | None
abstractmethod
Get the reference period of a given vector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
ID of the vector. |
required |
Returns:
| Type | Description |
|---|---|
ReferencePeriod | None
|
ReferencePeriod - if the vector is a mean one profile or average level, a reference period must exist. |
ReferencePeriod | None
|
None - No reference period if vector is max level, zero one profile or not a level or profile. |
Source code in framcore/loaders/loaders.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
get_unit(vector_id: str) -> str
abstractmethod
Return unit of the values within a time vector in the loader source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
ID of the vector. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
String with unit. |
Source code in framcore/loaders/loaders.py
189 190 191 192 193 194 195 196 197 198 199 200 201 | |
get_values(vector_id: str) -> NDArray
abstractmethod
Return the values of a time vector in the Loader source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
ID of the vector. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
Numpy array of all values. |
Source code in framcore/loaders/loaders.py
161 162 163 164 165 166 167 168 169 170 171 172 173 | |
is_max_level(vector_id: str) -> bool | None
abstractmethod
Check if the given TimeVector is a level representing max Volume/Capacity/Price.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
ID of the vector. |
required |
Returns:
| Type | Description |
|---|---|
bool | None
|
True - vector is a level representing max Volume/Capacity. |
bool | None
|
False - vector is a level representing average Volume/Capacity over a given reference period. |
bool | None
|
None - vector is not a level. |
Source code in framcore/loaders/loaders.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
is_zero_one_profile(vector_id: str) -> bool | None
abstractmethod
Check if the given TimeVector is a profile with values between zero and one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
ID of the vector. |
required |
Returns:
| Type | Description |
|---|---|
bool | None
|
True - vector is a profile with values between zero and one. |
bool | None
|
False - vector is a profile where the mean value is 1 given a reference period. |
bool | None
|
None - vector is not a profile. |
Source code in framcore/loaders/loaders.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
loaders
Classes defining APIs for Loaders.
CurveLoader
Bases: Loader, ABC
Loader API for retrieving curve data from some source.
Source code in framcore/loaders/loaders.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 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 | |
get_x_axis(curve_id: str) -> NDArray
abstractmethod
Return the values of a Curves x axis in the Loader source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve_id
|
str
|
ID of the curve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
Numpy array of all values in the x axis. |
Source code in framcore/loaders/loaders.py
276 277 278 279 280 281 282 283 284 285 286 287 288 | |
get_x_unit(curve_id: str) -> str
abstractmethod
Return the unit of the x axis of a specific curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve_id
|
str
|
ID of the curve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Unit of the curve's x axis. |
Source code in framcore/loaders/loaders.py
290 291 292 293 294 295 296 297 298 299 300 301 302 | |
get_y_axis(curve_id: str) -> NDArray
abstractmethod
Return the values of a Curves y axis in the Loader source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve_id
|
str
|
ID of the curve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
Numpy array of all values in the y axis. |
Source code in framcore/loaders/loaders.py
262 263 264 265 266 267 268 269 270 271 272 273 274 | |
get_y_unit(curve_id: str) -> str
abstractmethod
Return the unit of the y axis of a specific curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve_id
|
str
|
ID of the curve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Unit of the curve's y axis. |
Source code in framcore/loaders/loaders.py
304 305 306 307 308 309 310 311 312 313 314 315 316 | |
FileLoader
Bases: Loader, ABC
Define common functionality and API for Loaders connected to a file as source.
Source code in framcore/loaders/loaders.py
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 405 | |
__init__(source: Path | str, relative_loc: Path | str | None = None) -> None
Check validity of input parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Path | str
|
Full file path or the absolute part of a file path |
required |
relative_loc
|
Optional[Union[Path, str]]
|
The relative part of a file path. Defaults to None. |
None
|
Source code in framcore/loaders/loaders.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
__repr__() -> str
Overwrite repr to get better info.
Source code in framcore/loaders/loaders.py
343 344 345 | |
get_source() -> Path
Combine absolute and relative file path (if relative is defined) to get full source.
Source code in framcore/loaders/loaders.py
347 348 349 350 351 | |
get_supported_suffixes() -> list[str]
classmethod
Return list of supported file types.
Returns:
| Name | Type | Description |
|---|---|---|
list |
list[str]
|
List of filetypes. |
Source code in framcore/loaders/loaders.py
365 366 367 368 369 370 371 372 373 374 | |
set_source(new_source: Path, relative_loc: Path | str | None = None) -> None
Set absolute and relative parts of filepath.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_source
|
Path
|
New absolute part. |
required |
relative_loc
|
Optional[Union[Path, str]]
|
New relative part. Defaults to None. |
None
|
Source code in framcore/loaders/loaders.py
353 354 355 356 357 358 359 360 361 362 363 | |
Loader
Bases: Base, ABC
Base Loader class defining common API and functionality for all Loaders.
Source code in framcore/loaders/loaders.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
__deepcopy__(memo: dict) -> Loader
Overwrite deepcopy.
This is done to enable sharing of loaders. Since a loader is connected to one source, caching can thus be shared between Models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memo
|
dict
|
Required argument. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Loader |
Loader
|
Returns itself. |
Source code in framcore/loaders/loaders.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
__getstate__() -> dict
Return current object state, clearing any cached data.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The object's state dictionary. |
Source code in framcore/loaders/loaders.py
34 35 36 37 38 39 40 41 42 43 | |
__init__() -> None
Set up cache of ids contained in the source of the Loader.
Source code in framcore/loaders/loaders.py
20 21 22 | |
__repr__() -> str
Overwrite string representation.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Object represented as string. |
Source code in framcore/loaders/loaders.py
24 25 26 27 28 29 30 31 32 | |
clear_cache() -> None
abstractmethod
Clear cached data from the loader.
Source code in framcore/loaders/loaders.py
45 46 47 48 | |
get_ids() -> list[str]
Handle caching of ids existing in the loaders source.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: List containing ids in Loader source. |
Source code in framcore/loaders/loaders.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
get_metadata(content_id: str) -> object
abstractmethod
Get metadata from the Loader source.
The metadata could describe behavior of the data in source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content_id
|
str
|
Id of some content. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
object |
object
|
Metadata in some format only the specific Loader knows. |
Source code in framcore/loaders/loaders.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
get_source() -> object
abstractmethod
Return Loader source.
Returns:
| Name | Type | Description |
|---|---|---|
object |
object
|
Whatever the Loader interacts with to retrieve data. |
Source code in framcore/loaders/loaders.py
66 67 68 69 70 71 72 73 74 75 | |
set_source(new_source: object) -> None
abstractmethod
Set the Loader source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_source
|
object
|
Whatever the Loader should interact with to retrieve data. |
required |
Source code in framcore/loaders/loaders.py
77 78 79 80 81 82 83 84 85 86 | |
TimeVectorLoader
Bases: Loader, ABC
Loader API for retrieving time vector data from some source.
Source code in framcore/loaders/loaders.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
get_fingerprint(vector_id: str) -> Fingerprint
Return Loader Fingerprint for given vector id.
Source code in framcore/loaders/loaders.py
250 251 252 253 254 255 256 | |
get_index(vector_id: str) -> TimeIndex
abstractmethod
Return the index a time vector in the Loader source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
ID of the vector. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
TimeIndex
|
TimeIndex object. |
Source code in framcore/loaders/loaders.py
175 176 177 178 179 180 181 182 183 184 185 186 187 | |
get_reference_period(vector_id: str) -> ReferencePeriod | None
abstractmethod
Get the reference period of a given vector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
ID of the vector. |
required |
Returns:
| Type | Description |
|---|---|
ReferencePeriod | None
|
ReferencePeriod - if the vector is a mean one profile or average level, a reference period must exist. |
ReferencePeriod | None
|
None - No reference period if vector is max level, zero one profile or not a level or profile. |
Source code in framcore/loaders/loaders.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
get_unit(vector_id: str) -> str
abstractmethod
Return unit of the values within a time vector in the loader source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
ID of the vector. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
String with unit. |
Source code in framcore/loaders/loaders.py
189 190 191 192 193 194 195 196 197 198 199 200 201 | |
get_values(vector_id: str) -> NDArray
abstractmethod
Return the values of a time vector in the Loader source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
ID of the vector. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
Numpy array of all values. |
Source code in framcore/loaders/loaders.py
161 162 163 164 165 166 167 168 169 170 171 172 173 | |
is_max_level(vector_id: str) -> bool | None
abstractmethod
Check if the given TimeVector is a level representing max Volume/Capacity/Price.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
ID of the vector. |
required |
Returns:
| Type | Description |
|---|---|
bool | None
|
True - vector is a level representing max Volume/Capacity. |
bool | None
|
False - vector is a level representing average Volume/Capacity over a given reference period. |
bool | None
|
None - vector is not a level. |
Source code in framcore/loaders/loaders.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
is_zero_one_profile(vector_id: str) -> bool | None
abstractmethod
Check if the given TimeVector is a profile with values between zero and one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
ID of the vector. |
required |
Returns:
| Type | Description |
|---|---|
bool | None
|
True - vector is a profile with values between zero and one. |
bool | None
|
False - vector is a profile where the mean value is 1 given a reference period. |
bool | None
|
None - vector is not a profile. |
Source code in framcore/loaders/loaders.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
metadata
Div
Div
Bases: Meta
Div class is made for loss-less aggregation of metadata. Subclass of Meta.
It's combine method is made to keep all unique metadata, so that nothing is thrown away in connection with aggregation.
Source code in framcore/metadata/Div.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
__init__(value: Meta | set[Meta] | None = None) -> None
Create Div metadata.
Source code in framcore/metadata/Div.py
16 17 18 19 20 21 22 23 24 25 26 | |
combine(other: Meta | set[Meta]) -> Div
Just consume other and return self.
Source code in framcore/metadata/Div.py
50 51 52 53 54 55 56 57 58 | |
get_fingerprint() -> Fingerprint
Generate and return a Fingerprint representing the current set of Meta values.
Returns
Fingerprint A fingerprint object based on the hashes of the contained Meta values.
Source code in framcore/metadata/Div.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
get_value() -> set[Meta]
Return str value.
Source code in framcore/metadata/Div.py
37 38 39 | |
set_value(value: Meta | set[Meta]) -> None
Set str value. TypeError if not str.
Source code in framcore/metadata/Div.py
41 42 43 44 45 46 47 48 | |
ExprMeta
ExprMeta
Bases: Meta
ExprMeta represent an Expr. Subclass of Meta.
When used, all components must have a ExprMeta.
Source code in framcore/metadata/ExprMeta.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
__eq__(other: object) -> bool
Check equality based on expr.
Source code in framcore/metadata/ExprMeta.py
26 27 28 29 30 | |
__hash__() -> int
Compute the hash of the ExprMeta.
Source code in framcore/metadata/ExprMeta.py
32 33 34 | |
__init__(value: Expr) -> None
Create new ExprMeta with float value.
Source code in framcore/metadata/ExprMeta.py
15 16 17 18 | |
__repr__() -> str
Overwrite repr for better string representation.
Source code in framcore/metadata/ExprMeta.py
20 21 22 23 24 | |
combine(other: Meta) -> Expr | Div
Sum Expr.
Source code in framcore/metadata/ExprMeta.py
45 46 47 48 49 50 51 52 | |
get_fingerprint() -> Fingerprint
Get the fingerprint of the ScalarMeta.
Source code in framcore/metadata/ExprMeta.py
54 55 56 | |
get_value() -> Expr
Return expr.
Source code in framcore/metadata/ExprMeta.py
36 37 38 | |
set_value(value: Expr) -> None
Set expr value. TypeError if not expr.
Source code in framcore/metadata/ExprMeta.py
40 41 42 43 | |
LevelExprMeta
LevelExprMeta
Bases: ExprMeta
LevelExprMeta represent an Expr. Subclass of ExprMeta.
When used, all components must have a ExprMeta.
Source code in framcore/metadata/LevelExprMeta.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
__init__(value: Expr | TimeVector) -> None
Create new LevelExprMeta with Expr value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Expr | TimeVector
|
Accepts Expr with is_level=True or TimeVector with is_max_level=True/False. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If value is not Expr or TimeVector. |
ValueError
|
If value is non-level Expr or TimeVector. |
Source code in framcore/metadata/LevelExprMeta.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
Member
Member
Bases: Meta
Member represent membership to a catergory or group using a str. Subclass of Meta.
Should not have missing values.
When used, all components must have a membership.
Source code in framcore/metadata/Member.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
__eq__(other: object) -> bool
Check equality based on value.
Source code in framcore/metadata/Member.py
26 27 28 29 30 | |
__hash__() -> int
Overwrite hash since its added to sets.
Source code in framcore/metadata/Member.py
32 33 34 | |
__init__(value: str) -> None
Create new member with str value.
Source code in framcore/metadata/Member.py
17 18 19 20 | |
__repr__() -> str
Overwrite repr for better string representation.
Source code in framcore/metadata/Member.py
22 23 24 | |
combine(other: Meta) -> Member | Div
Return self if other == self else return Div containing both.
Source code in framcore/metadata/Member.py
45 46 47 48 49 50 51 | |
get_fingerprint() -> Fingerprint
Get the fingerprint of the Member.
Source code in framcore/metadata/Member.py
53 54 55 | |
get_value() -> str
Return str value.
Source code in framcore/metadata/Member.py
36 37 38 | |
set_value(value: str) -> None
Set str value. TypeError if not str.
Source code in framcore/metadata/Member.py
40 41 42 43 | |
Meta
Meta
Bases: Base, ABC
Metadata-interface class for components.
The interface is there to support validation and aggregation. - Some types of metadata should not have any missing values - Different types of metadata should be aggregated differently (e.g. ignore, sum, mean, keep all in list, etc.)
Source code in framcore/metadata/Meta.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
combine(other: Meta) -> Meta | None
abstractmethod
How should this metadata type be aggregated?.
Source code in framcore/metadata/Meta.py
36 37 38 39 | |
get_fingerprint() -> Fingerprint
abstractmethod
Return fingerprint.
Source code in framcore/metadata/Meta.py
41 42 43 44 | |
get_value() -> Any
abstractmethod
Return metadata value.
Source code in framcore/metadata/Meta.py
19 20 21 22 | |
set_value(value: Any) -> None
abstractmethod
Set metadata value.
Error if incorrect type or value.
Some Meta types may be immutable and thus error if set_value is called with any value.
Source code in framcore/metadata/Meta.py
24 25 26 27 28 29 30 31 32 33 34 | |
populators
Populator
Populator API, for creating a system of Components, TimeVectors and Curves (and Expr) for a Model object.
Populator
Bases: Base, ABC
Populate a model with data from a data source.
Source code in framcore/populators/Populator.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
__init__() -> None
Set up ID and reference registration containers.
These are used to check if IDs and references actually exist in the system.
Source code in framcore/populators/Populator.py
15 16 17 18 19 20 21 22 23 24 | |
populate(model: Model) -> None
Add data objects from a database to an input Model.
These data objects shall be of class Component, TimeVector, and Curve. The method _populate should be overwritten in a subclass of Populator. In this way, it is used to create objects from any database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Model which will have the objects added to it. |
required |
Source code in framcore/populators/Populator.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
querydbs
CacheDB
CacheDB
Bases: QueryDB
Stores models and precomputed values.
Source code in framcore/querydbs/CacheDB.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
__init__(model: Model, *models: tuple[Model]) -> None
Initialize CacheDB with one or more Model instances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The primary Model instance. |
required |
*models
|
tuple[Model]
|
Additional Model instances. |
()
|
Source code in framcore/querydbs/CacheDB.py
8 9 10 11 12 13 14 15 16 17 18 19 | |
get_min_elapsed_seconds() -> float
Values that takes below this threshold to compute, does not get cached.
Source code in framcore/querydbs/CacheDB.py
27 28 29 | |
set_min_elapsed_seconds(value: float) -> None
Values that takes below this threshold to compute, does not get cached.
Source code in framcore/querydbs/CacheDB.py
21 22 23 24 25 | |
ModelDB
ModelDB
Bases: QueryDB
A database-like interface for querying multiple Model instances.
Source code in framcore/querydbs/ModelDB.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
__init__(model: Model, *models: tuple[Model]) -> None
Initialize ModelDB with one or more Model instances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The primary Model instance. |
required |
*models
|
tuple[Model]
|
Additional Model instances. |
()
|
Source code in framcore/querydbs/ModelDB.py
8 9 10 11 12 13 14 15 16 17 | |
QueryDB
QueryDB
Bases: Base, ABC
Abstract base class for database queries.
Provides an interface for getting, putting, and checking keys in a database. Subclasses must implement the _get, _put, and _has_key methods.
Source code in framcore/querydbs/QueryDB.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
get(key: object) -> object
Get value behind key from db.
Source code in framcore/querydbs/QueryDB.py
15 16 17 | |
get_data() -> dict
Return output of get_data called on first underlying model.
Source code in framcore/querydbs/QueryDB.py
27 28 29 | |
has_key(key: str) -> bool
Return True if db has value behind key.
Source code in framcore/querydbs/QueryDB.py
23 24 25 | |
put(key: object, value: object, elapsed_seconds: float) -> None
Put value in db behind key (maybe, depending on implementation).
Source code in framcore/querydbs/QueryDB.py
19 20 21 | |
solvers
Solver
Solver
Bases: Base, ABC
Solver inteface class.
In FRAM we call energy market models for Solvers. They take a populated Model and configurations from a SolverConfig, and transfers this to the solver software. Then it solves the energy market model, and writes results back to the Model.
Source code in framcore/solvers/Solver.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
get_config() -> SolverConfig
abstractmethod
Return the solver's config object.
Source code in framcore/solvers/Solver.py
55 56 57 58 | |
solve(model: Model) -> None
Inititiate the solve.
It takes the populated Model and configurations from self.SolverConfig, and transfers this to the solver software. Then it solves the energy market model, and writes results back to the Model.
At the end of the solve, the Model (now with results) and the Solver object (with configurations) are pickled to the solve folder. - model.pickle can be used to inspect results later. - solver.pickle allows reuse of the same solver configurations (with solve_folder set to None to avoid overwriting). TODO: Could also pickle the Model before solving, to have a record of the input model.
Source code in framcore/solvers/Solver.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
SolverConfig
Definition of SolverConfig interface.
SolverConfig
Bases: Base, ABC
SolverConfig inteface class.
Source code in framcore/solvers/SolverConfig.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
__init__() -> None
Create internal variables with default values.
Source code in framcore/solvers/SolverConfig.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
get_currency() -> str | None
Get currency.
Source code in framcore/solvers/SolverConfig.py
164 165 166 | |
get_data_period() -> TimeIndex | None
Get period used in level value queries.
Source code in framcore/solvers/SolverConfig.py
217 218 219 | |
get_num_cpu_cores() -> int
Return number of cpu cores the Solver can use.
Source code in framcore/solvers/SolverConfig.py
151 152 153 | |
get_simulation_years() -> tuple[int, int]
Get simulation years (first_year, num_years).
Return weather years as fallback if serial simulation.
Source code in framcore/solvers/SolverConfig.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
get_solve_folder() -> Path | None
Get folder where solve related files will be written.
Source code in framcore/solvers/SolverConfig.py
49 50 51 | |
get_unit_flow(commodity: str) -> str | None
Get the flow unit for a given commodity.
Parameters
commodity : str The name of the commodity.
Returns
str or None The flow unit for the commodity, or None if not set.
Source code in framcore/solvers/SolverConfig.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
get_unit_stock(commodity: str) -> str
Get the stock unit for a given commodity.
Parameters
commodity : str The name of the commodity.
Returns
str The stock unit for the commodity.
Raises
ValueError If no stock unit is set for the commodity.
Source code in framcore/solvers/SolverConfig.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
get_weather_years() -> tuple[int, int]
Get weather scenario period (first_year, num_years) used in profiles.
Source code in framcore/solvers/SolverConfig.py
255 256 257 258 259 260 | |
is_diff_policy_backup() -> bool
Return True if backup diff policy.
Source code in framcore/solvers/SolverConfig.py
200 201 202 | |
is_diff_policy_error() -> bool
Return True if error diff policy.
Source code in framcore/solvers/SolverConfig.py
192 193 194 | |
is_diff_policy_ignore() -> bool
Return True if ignore diff policy.
Source code in framcore/solvers/SolverConfig.py
196 197 198 | |
is_float32() -> bool
Return if single precision in data management, else double precision.
Source code in framcore/solvers/SolverConfig.py
270 271 272 | |
is_simulation_mode_serial() -> bool
Return True if serial simulation mode.
Source code in framcore/solvers/SolverConfig.py
208 209 210 | |
set_commodity_units(commodity: str, stock_unit: str, flow_unit: str | None = None, is_default: bool | None = None) -> None
Set the stock and flow units for a commodity.
Parameters
commodity : str The name of the commodity. stock_unit : str The unit for the commodity stock. flow_unit : str or None, optional The unit for the commodity flow, representing the rate of change of the stock unit over time. is_default : bool or None, optional If True, set these units as the default for all commodities.
Raises
ValueError If the flow unit is incompatible with the stock unit.
Source code in framcore/solvers/SolverConfig.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
set_currency(currency: str) -> None
Set currency.
Source code in framcore/solvers/SolverConfig.py
159 160 161 162 | |
set_data_period(period: TimeIndex) -> None
Set period used in level value queries.
Source code in framcore/solvers/SolverConfig.py
212 213 214 215 | |
set_diff_policy_backup() -> None
Copy existing folder to folder/backup_[timestamp] folder if non-empty diff during solve.
Source code in framcore/solvers/SolverConfig.py
188 189 190 | |
set_diff_policy_error() -> None
Error if non-empty diff during solve.
Source code in framcore/solvers/SolverConfig.py
180 181 182 | |
set_diff_policy_ignore() -> None
Ignore if non-empty diff during solve.
Source code in framcore/solvers/SolverConfig.py
184 185 186 | |
set_num_cpu_cores(n: int) -> int
Set number of cpu cores the Solver can use.
Source code in framcore/solvers/SolverConfig.py
155 156 157 | |
set_screen_output_off() -> None
Only print output from Solver to logfile.
Source code in framcore/solvers/SolverConfig.py
172 173 174 | |
set_screen_output_on() -> None
Print output from Solver to stdout and logfile.
Source code in framcore/solvers/SolverConfig.py
168 169 170 | |
set_simulation_mode_serial() -> None
Activate serial simulation mode.
Source code in framcore/solvers/SolverConfig.py
204 205 206 | |
set_simulation_years(first_year: int, num_years: int) -> None
Set subset of scenario years. For serial simulation.
Source code in framcore/solvers/SolverConfig.py
221 222 223 224 225 226 227 228 | |
set_solve_folder(folder: Path | str | None) -> None
Set folder where solve related files will be written.
Source code in framcore/solvers/SolverConfig.py
42 43 44 45 46 47 | |
set_weather_years(first_year: int, num_years: int) -> None
Set weather scenario period used in profiles.
Source code in framcore/solvers/SolverConfig.py
246 247 248 249 250 251 252 253 | |
show_screen_output() -> bool
Return True if screen output is set to be shown.
Source code in framcore/solvers/SolverConfig.py
176 177 178 | |
use_float32() -> None
Use single precision floating point numbers in data management.
Source code in framcore/solvers/SolverConfig.py
262 263 264 | |
use_float64() -> None
Use double precision floating point numbers in data management.
Source code in framcore/solvers/SolverConfig.py
266 267 268 | |
timeindexes
FRAM time indexes package provides functionality for handling time-related data.
AverageYearRange
AverageYearRange
Bases: SinglePeriodTimeIndex
AverageYearRange represents a period over a range of years. No extrapolation and represents full iso calendar years.
Source code in framcore/timeindexes/AverageYearRange.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
__init__(start_year: int, num_years: int) -> None
Initialize AverageYearRange with a year range. No extrapolation and represents full iso calendar years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_year
|
int
|
First year in the range. |
required |
num_years
|
int
|
Number of years in the range. |
required |
Source code in framcore/timeindexes/AverageYearRange.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
ConstantTimeIndex
ConstantTimeIndex
Bases: SinglePeriodTimeIndex
ConstantTimeIndex that is constant over time. For use in ConstantTimeVector.
Represents a period of 52 weeks starting from the iso calendar week 1 of 1985. Extrapolates both first and last point.
Source code in framcore/timeindexes/ConstantTimeIndex.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
__init__() -> None
Initialize ConstantTimeIndex.
Source code in framcore/timeindexes/ConstantTimeIndex.py
14 15 16 17 18 19 20 21 22 | |
DailyIndex
DailyIndex
Bases: ProfileTimeIndex
ProfileTimeIndex with one or more whole years with daily resolution. Either years with 52 weeks or full iso calendar years.
No extrapolation inherited from ProfileTimeIndex.
Source code in framcore/timeindexes/DailyIndex.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
__init__(start_year: int, num_years: int, is_52_week_years: bool = True) -> None
Initialize DailyIndex over a number of years. Either years with 52 weeks or full iso calendar years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_year
|
int
|
First year in the index. |
required |
num_years
|
int
|
Number of years in the index. |
required |
is_52_week_years
|
bool
|
Whether to use 52-week years. If False, full iso calendar years are used. Defaults to True. |
True
|
Source code in framcore/timeindexes/DailyIndex.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
FixedFrequencyTimeIndex
FixedFrequencyTimeIndex
Bases: TimeIndex
TimeIndex with fixed frequency.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 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 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 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | |
__eq__(other) -> bool
Check if equal to other.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
58 59 60 61 62 63 64 65 66 67 68 69 | |
__hash__() -> int
Return the hash value for the FixedFrequencyTimeIndex.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
71 72 73 74 75 76 77 78 79 80 81 82 | |
__init__(start_time: datetime, period_duration: timedelta, num_periods: int, is_52_week_years: bool, extrapolate_first_point: bool, extrapolate_last_point: bool) -> None
Initialize a FixedFrequencyTimeIndex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_time
|
datetime
|
The starting datetime of the time index. |
required |
period_duration
|
timedelta
|
The duration of each period. |
required |
num_periods
|
int
|
The number of periods in the time index. Must be greater than 0. |
required |
is_52_week_years
|
bool
|
Whether to use 52-week years. |
required |
extrapolate_first_point
|
bool
|
Whether to allow extrapolation of the first point. |
required |
extrapolate_last_point
|
bool
|
Whether to allow extrapolation of the last point. |
required |
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
__repr__() -> str
Return a string representation of the FixedFrequencyTimeIndex.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
84 85 86 87 88 89 90 91 92 93 94 | |
copy_as_reference_period(reference_period: ReferencePeriod) -> FixedFrequencyTimeIndex
Create a copy of the FixedFrequencyTimeIndex with one period matching the given reference period.
Parameters
reference_period : ReferencePeriod The reference period to match for the output.
Returns
FixedFrequencyTimeIndex A new instance with the updated attributes.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
copy_with(start_time: datetime | None = None, period_duration: timedelta | None = None, num_periods: int | None = None, is_52_week_years: bool | None = None, extrapolate_first_point: bool | None = None, extrapolate_last_point: bool | None = None) -> FixedFrequencyTimeIndex
Create a copy of the FixedFrequencyTimeIndex with the same attributes, allowing specific fields to be overridden.
Parameters
start_time : datetime, optional Override for the start time. period_duration : timedelta, optional Override for the period duration. num_periods : int, optional Override for the number of periods. is_52_week_years : bool, optional Override for 52-week years flag. extrapolate_first_point : bool, optional Override for extrapolate first point flag. extrapolate_last_point : bool, optional Override for extrapolate last point flag.
Returns
FixedFrequencyTimeIndex A new instance with the updated attributes.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 | |
extrapolate_first_point() -> bool
Return True if first value can be extrapolated backwards to fill missing values.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
195 196 197 | |
extrapolate_last_point() -> bool
Return True if last value can be extrapolated forward to fill missing values.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
199 200 201 | |
get_datetime_list() -> list[datetime]
Return list of datetime including stop time.
Note: When is_52_week_years is True, the returned list will skip any datetimes that fall in week 53.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | |
get_fingerprint() -> Fingerprint
Get the fingerprint.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
96 97 98 | |
get_num_periods() -> int
Get the number of points.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
112 113 114 | |
get_period_average(vector: NDArray, start_time: datetime, duration: timedelta, is_52_week_years: bool) -> float
Get the average over the period from the vector.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
get_period_duration() -> timedelta
Get the period duration.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
108 109 110 | |
get_reference_period() -> ReferencePeriod | None
Get the reference period (only if is_whole_years() is True).
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
157 158 159 160 161 162 163 164 165 166 167 | |
get_start_time() -> datetime
Get the start time.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
104 105 106 | |
get_stop_time() -> datetime
Get the stop time of the TimeIndex.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
451 452 453 454 455 456 457 458 459 460 | |
get_timezone() -> tzinfo | None
Get the timezone.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
100 101 102 | |
is_52_week_years() -> bool
Return True if 52-week years and False if real ISO time.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
169 170 171 | |
is_constant() -> bool
Return True if the time index is constant (single period and both extrapolation flags are True).
Returns
bool True if the time index is constant, False otherwise.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
116 117 118 119 120 121 122 123 124 125 126 | |
is_one_year() -> bool
Return True if exactly one whole year.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
is_same_resolution(other: FixedFrequencyTimeIndex) -> bool
Check if the period duration is the same.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
447 448 449 | |
is_whole_years() -> bool
Return True if index covers one or more full years.
The start_time must be the first week and weekday of a year. For real ISO time, the stop_time must also be the first week and weekday of a year. For 52-week years, the total duration must be an integer number of 52-week years.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
slice(input_vector: NDArray, start_year: int, num_years: int, target_start_year: int, target_num_years: int) -> NDArray
Periodize the input vector to match the target timeindex.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
462 463 464 465 466 467 468 469 470 471 472 473 | |
total_duration() -> timedelta
Get the duration of the TimeIndex.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
514 515 516 | |
write_into_fixed_frequency(target_vector: NDArray, target_timeindex: FixedFrequencyTimeIndex, input_vector: NDArray) -> None
Write the given input_vector into the target_vector according to the target_timeindex, applying necessary transformations.
Parameters
target_vector : NDArray The array where the input_vector will be written to, modified in place. target_timeindex : FixedFrequencyTimeIndex The time index defining the fixed frequency structure for writing the input_vector into the target_vector. input_vector : NDArray The array containing the data to be written into the target_vector.
Notes
- If the object is constant (as determined by
self.is_constant()), the input_vector is expected to have a single value, which will be used to fill the entire target_vector. - Otherwise, the method delegates the operation to
_write_into_fixed_frequency_recursivefor handling more complex cases.
Source code in framcore/timeindexes/FixedFrequencyTimeIndex.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
HourlyIndex
HourlyIndex
Bases: ProfileTimeIndex
ProfileTimeIndex with one or more whole years with hourly resolution. Either years with 52 weeks or full iso calendar years.
No extrapolation inherited from ProfileTimeIndex.
Source code in framcore/timeindexes/HourlyIndex.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
__init__(start_year: int, num_years: int, is_52_week_years: bool = True) -> None
Initialize HourlyIndex over a number of years. Either years with 52 weeks or full iso calendar years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_year
|
int
|
First year in the index. |
required |
num_years
|
int
|
Number of years in the index. |
required |
is_52_week_years
|
bool
|
Whether to use 52-week years. If False, full iso calendar years are used. Defaults to True. |
True
|
Source code in framcore/timeindexes/HourlyIndex.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
IsoCalendarDay
IsoCalendarDay
Bases: SinglePeriodTimeIndex
Represents a single ISO calendar day using year, week, and day values.
Inherits from SinglePeriodTimeIndex and provides a time index for one day, constructed from datetime.fromisocalendar(year, week, day).
Source code in framcore/timeindexes/IsoCalendarDay.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
__init__(year: int, week: int, day: int) -> None
IsoCalendarDay represent a day from datetime.fromisocalendar(year, week, day).
No extrapolation and is_52_week_years=False. Useful for testing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
The ISO year. |
required |
week
|
int
|
The ISO week number (1-53). |
required |
day
|
int
|
The ISO weekday (1=Monday, 7=Sunday). |
required |
Source code in framcore/timeindexes/IsoCalendarDay.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
ListTimeIndex
ListTimeIndex
Bases: TimeIndex
ListTimeIndex class for TimeIndexes with a list of timestamps. Subclass of TimeIndex.
This TimeIndex is defined by a list of timestamps, with possible irregular intervals.The last timestamp is not necessarily the end of the time vector, and the first timestamp is not necessarily the start of the time vector if extrapolation is enabled.
ListTimeIndex is not recommended for large time vectors, as it is less efficient.
Source code in framcore/timeindexes/ListTimeIndex.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
__eq__(other) -> bool
Check if two ListTimeIndexes are equal.
Source code in framcore/timeindexes/ListTimeIndex.py
63 64 65 66 67 68 69 70 71 | |
__hash__() -> int
Return the hash of the ListTimeIndex.
Source code in framcore/timeindexes/ListTimeIndex.py
73 74 75 76 77 78 79 80 81 | |
__init__(datetime_list: list[datetime], is_52_week_years: bool, extrapolate_first_point: bool, extrapolate_last_point: bool) -> None
Initialize the ListTimeIndex class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datetime_list
|
list[datetime]
|
List of datetime objects defining the time index. Must be ordered and contain more than one element. |
required |
is_52_week_years
|
bool
|
Whether to use 52-week years. If False, full iso calendar years are used. |
required |
extrapolate_first_point
|
bool
|
Whether to extrapolate the first point. |
required |
extrapolate_last_point
|
bool
|
Whether to extrapolate the last point. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If datetime_list has less than two elements or is not ordered. |
Source code in framcore/timeindexes/ListTimeIndex.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
__repr__() -> str
Return the string representation of the ListTimeIndex.
Source code in framcore/timeindexes/ListTimeIndex.py
83 84 85 86 87 88 89 90 | |
extrapolate_first_point() -> bool
Check if the TimeIndex should extrapolate the first point.
Source code in framcore/timeindexes/ListTimeIndex.py
157 158 159 | |
extrapolate_last_point() -> bool
Check if the TimeIndex should extrapolate the last point.
Source code in framcore/timeindexes/ListTimeIndex.py
161 162 163 | |
get_datetime_list() -> list[datetime]
Get a list of all periods (num_periods + 1 datetimes).
Source code in framcore/timeindexes/ListTimeIndex.py
101 102 103 | |
get_fingerprint() -> Fingerprint
Get the fingerprint of the ListTimeIndex.
Source code in framcore/timeindexes/ListTimeIndex.py
92 93 94 95 96 97 98 99 | |
get_num_periods() -> int
Get the number of periods in the TimeIndex.
Source code in framcore/timeindexes/ListTimeIndex.py
109 110 111 | |
get_period_average(vector: NDArray, start_time: datetime, duration: timedelta, is_52_week_years: bool) -> float
Get the average over the period from the vector.
Source code in framcore/timeindexes/ListTimeIndex.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
get_timezone() -> tzinfo | None
Get the timezone of the TimeIndex.
Source code in framcore/timeindexes/ListTimeIndex.py
105 106 107 | |
is_52_week_years() -> bool
Check if the TimeIndex is based on 52-week years.
Source code in framcore/timeindexes/ListTimeIndex.py
113 114 115 | |
is_constant() -> bool
Return True if the time index is constant (single period and both extrapolation flags are True).
Returns
bool True if the time index is constant, False otherwise.
Source code in framcore/timeindexes/ListTimeIndex.py
267 268 269 270 271 272 273 274 275 276 277 | |
is_one_year() -> bool
Return True if exactly one whole year.
Source code in framcore/timeindexes/ListTimeIndex.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
is_whole_years() -> bool
Return True if index covers one or more full years.
Source code in framcore/timeindexes/ListTimeIndex.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
total_duration() -> timedelta
Return the total duration covered by the time index.
Returns
timedelta The duration from the first to the last datetime in the index, skipping all weeks 53 periods if 52-week time format.
Source code in framcore/timeindexes/ListTimeIndex.py
250 251 252 253 254 255 256 257 258 259 260 261 262 | |
write_into_fixed_frequency(target_vector: NDArray, target_timeindex: FixedFrequencyTimeIndex, input_vector: NDArray) -> None
Write the input vector into the target vector using the target FixedFrequencyTimeIndex.
Source code in framcore/timeindexes/ListTimeIndex.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
ModelYear
ModelYear
Bases: SinglePeriodTimeIndex
ModelYear represent a period of 52 weeks starting from the iso calendar week 1 of a specified year. No extrapolation.
Source code in framcore/timeindexes/ModelYear.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
__init__(year: int) -> None
Initialize ModelYear to a period of 52 weeks starting from the iso calendar week 1 of the specified year. No extrapolation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Year to represent. |
required |
Source code in framcore/timeindexes/ModelYear.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
ModelYears
ModelYears
Bases: ListTimeIndex
ModelYears represents a collection of years as a ListTimeIndex. Extrapolation is enabled and full iso calendar is used.
Source code in framcore/timeindexes/ModelYears.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
__init__(years: list[int]) -> None
Initialize ModelYears with a list of years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
years
|
list[int]
|
List of years to represent. |
required |
Source code in framcore/timeindexes/ModelYears.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
OneYearProfileTimeIndex
OneYearProfileTimeIndex
Bases: ProfileTimeIndex
ProfileTimeIndex with fixed frequency over one year of either 52 or 53 weeks. No extrapolation inherited from ProfileTimeIndex.
Attributes:
| Name | Type | Description |
|---|---|---|
period_duration |
timedelta
|
Duration of each period. |
is_52_week_years |
bool
|
Whether to use 52-week years. |
Source code in framcore/timeindexes/OneYearProfileTimeIndex.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
__init__(period_duration: timedelta, is_52_week_years: bool) -> None
Initialize a ProfileTimeIndex with a fixed frequency over one year.
If is_52_week_years is True, the period_duration must divide evenly into 52 weeks. If False, it must divide evenly into 53 weeks. We use 1982 for 52-week years and 1981 for 53-week years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
period_duration
|
timedelta
|
Duration of each period. |
required |
is_52_week_years
|
bool
|
Whether to use 52-week years. |
required |
Source code in framcore/timeindexes/OneYearProfileTimeIndex.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
ProfileTimeIndex
ProfileTimeIndex
Bases: FixedFrequencyTimeIndex
ProfileTimeIndex represent one or more whole years with fixed time resolution standard. No extrapolation.
Source code in framcore/timeindexes/ProfileTimeIndex.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
__init__(start_year: int, num_years: int, period_duration: timedelta, is_52_week_years: bool) -> None
Initialize the ProfileTimeIndex. No extrapolation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_year
|
int
|
First year in the index. |
required |
num_years
|
int
|
Number of years in the index. |
required |
period_duration
|
timedelta
|
Duration of each period in the index. |
required |
is_52_week_years
|
bool
|
Whether to use 52-week years. If False, full iso calendar years are used. |
required |
Source code in framcore/timeindexes/ProfileTimeIndex.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
SinglePeriodTimeIndex
SinglePeriodTimeIndex
Bases: FixedFrequencyTimeIndex
FixedFrequencyTimeIndex with just one single step.
Source code in framcore/timeindexes/SinglePeriodTimeIndex.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
__init__(start_time: datetime, period_duration: timedelta, is_52_week_years: bool = False, extrapolate_first_point: bool = False, extrapolate_last_point: bool = False) -> None
Initialize a SinglePeriodTimeIndex with a single time period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_time
|
datetime
|
The start time of the period. |
required |
period_duration
|
timedelta
|
The duration of the period. |
required |
is_52_week_years
|
bool
|
Whether to use 52-week years. Defaults to False. |
False
|
extrapolate_first_point
|
bool
|
Whether to extrapolate the first point. Defaults to False. |
False
|
extrapolate_last_point
|
bool
|
Whether to extrapolate the last point. Defaults to False. |
False
|
Source code in framcore/timeindexes/SinglePeriodTimeIndex.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
TimeIndex
TimeIndex
Bases: Base, ABC
TimeIndex interface for TimeVectors.
Source code in framcore/timeindexes/TimeIndex.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
__eq__(other) -> bool
abstractmethod
Check if two TimeIndexes are equal.
Source code in framcore/timeindexes/TimeIndex.py
16 17 18 19 | |
__hash__() -> int
abstractmethod
Compute hash value..
Source code in framcore/timeindexes/TimeIndex.py
21 22 23 24 | |
extrapolate_first_point() -> bool
abstractmethod
Check if the TimeIndex should extrapolate the first point. Must be False if is_one_year is True.
Source code in framcore/timeindexes/TimeIndex.py
62 63 64 65 | |
extrapolate_last_point() -> bool
abstractmethod
Check if the TimeIndex should extrapolate the last point. Must be False if is_one_year is True.
Source code in framcore/timeindexes/TimeIndex.py
67 68 69 70 | |
get_fingerprint() -> Fingerprint
abstractmethod
Get the fingerprint of the TimeIndex.
Source code in framcore/timeindexes/TimeIndex.py
26 27 28 29 | |
get_num_periods() -> bool
abstractmethod
Get the number of periods in the TimeIndex.
Source code in framcore/timeindexes/TimeIndex.py
36 37 38 39 | |
get_period_average(vector: NDArray, start_time: datetime, duration: timedelta, is_52_week_years: bool) -> float
abstractmethod
Get the average over the period from the vector.
Source code in framcore/timeindexes/TimeIndex.py
72 73 74 75 | |
get_timezone() -> tzinfo | None
abstractmethod
Get the timezone of the TimeIndex.
Source code in framcore/timeindexes/TimeIndex.py
31 32 33 34 | |
is_52_week_years() -> bool
abstractmethod
Check if the TimeIndex is based on 52-week years.
Source code in framcore/timeindexes/TimeIndex.py
41 42 43 44 | |
is_constant() -> bool
abstractmethod
Check if the TimeIndex is constant.
Source code in framcore/timeindexes/TimeIndex.py
100 101 102 103 | |
is_one_year() -> bool
abstractmethod
Check if the TimeIndex represents a single year.
Must be False if extrapolate_first_point and or extrapolate_last_point is True.
When True, can be repeted in profiles.
Source code in framcore/timeindexes/TimeIndex.py
46 47 48 49 50 51 52 53 54 55 | |
is_whole_years() -> bool
abstractmethod
Check if the TimeIndex represents whole years.
Source code in framcore/timeindexes/TimeIndex.py
57 58 59 60 | |
write_into_fixed_frequency(target_vector: NDArray, target_timeindex: FixedFrequencyTimeIndex, input_vector: NDArray) -> None
abstractmethod
Write the input vector into the target vector based on the target FixedFrequencyTimeIndex.
Main functionality in FRAM to extracts data to the correct time period and resolution. A conversion of the data into a specific time period and resolution follows these steps: - If the TimeIndex is not a FixedFrequencyTimeIndex, convert the TimeIndex and the vector to this format. - Then convert the data according to the target TimeIndex. - It is easier to efficiently do time series operations between FixedFrequencyTimeIndex and we only need to implement all the other conversion functionality once here. For example, converting between 52-week and ISO-time TimeVectors, selecting a period, extrapolation or changing the resolution. - And when we implement a new TimeIndex, we only need to implement the conversion to FixedFrequencyTimeIndex and the rest of the conversion functionality can be reused.
Source code in framcore/timeindexes/TimeIndex.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
WeeklyIndex
WeeklyIndex
Bases: ProfileTimeIndex
ProfileTimeIndex with one or more whole years with weekly resolution. Either years with 52 weeks or full iso calendar years.
No extrapolation inherited from ProfileTimeIndex.
Source code in framcore/timeindexes/WeeklyIndex.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
__init__(start_year: int, num_years: int, is_52_week_years: bool = True) -> None
Initialize WeeklyIndex with one or more whole years with weekly resolution. Either years with 52 weeks or full iso calendar years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_year
|
int
|
First year in the index. |
required |
num_years
|
int
|
Number of years in the index. |
required |
is_52_week_years
|
bool
|
Whether to use 52-week years. If False, full iso calendar years are used. Defaults to True. |
True
|
Source code in framcore/timeindexes/WeeklyIndex.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
timevectors
ConstantTimeVector
ConstantTimeVector
Bases: TimeVector
ConstantTimeVector class for TimeVectors that are constant over time. Subclass of TimeVector.
Source code in framcore/timevectors/ConstantTimeVector.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
__eq__(other: object) -> bool
Check equality between two ConstantTimeVector objects.
Source code in framcore/timevectors/ConstantTimeVector.py
66 67 68 69 70 71 72 73 74 75 76 | |
__hash__() -> int
Compute the hash of the ConstantTimeVector.
Source code in framcore/timevectors/ConstantTimeVector.py
78 79 80 | |
__init__(scalar: float, unit: str | None = None, is_max_level: bool | None = None, is_zero_one_profile: bool | None = None, reference_period: ReferencePeriod | None = None) -> None
Initialize the ConstantTimeVector class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scalar
|
float
|
Constant float value of the TimeVector. |
required |
unit
|
str | None
|
Unit of the value in the vector. |
None
|
is_max_level
|
bool | None
|
Whether the vector represents the maximum level, average level given a reference period, or not a level at all. |
None
|
is_zero_one_profile
|
bool | None
|
Whether the vector represents a profile with values between 0 and 1, a profile with values averaging to 1 over a given reference period, or is not a profile. |
None
|
reference_period
|
ReferencePeriod | None
|
Given reference period if the vector represents average level or mean one profile. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
When both is_max_level and is_zero_one_profile is not None. This would mean the TimeVector represents both a level and a profile, which is not allowed. |
Source code in framcore/timevectors/ConstantTimeVector.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
__repr__() -> str
Return the string representation of the ConstantTimeVector.
Source code in framcore/timevectors/ConstantTimeVector.py
54 55 56 57 58 59 60 61 62 63 64 | |
get_expr_str() -> str
Simpler representation of self to show in Expr.
Source code in framcore/timevectors/ConstantTimeVector.py
82 83 84 85 86 87 | |
get_fingerprint() -> Fingerprint
Get the Fingerprint of the TimeVector.
Source code in framcore/timevectors/ConstantTimeVector.py
125 126 127 | |
get_loader() -> None
Interface method Not applicable for this type. Return None.
Source code in framcore/timevectors/ConstantTimeVector.py
129 130 131 | |
get_reference_period() -> ReferencePeriod | None
Get the reference period of the TimeVector.
Source code in framcore/timevectors/ConstantTimeVector.py
116 117 118 119 120 121 122 123 | |
get_timeindex() -> ConstantTimeIndex
Get the TimeIndex of the TimeVector.
Source code in framcore/timevectors/ConstantTimeVector.py
96 97 98 | |
get_unit() -> str | None
Get the unit of the TimeVector.
Source code in framcore/timevectors/ConstantTimeVector.py
112 113 114 | |
get_vector(is_float32: bool) -> NDArray
Get the values of the TimeVector.
Source code in framcore/timevectors/ConstantTimeVector.py
89 90 91 92 93 94 | |
is_constant() -> bool
Check if the TimeVector is constant.
Source code in framcore/timevectors/ConstantTimeVector.py
100 101 102 | |
is_max_level() -> bool | None
Check if TimeVector is a level representing maximum Volume/Capacity.
Source code in framcore/timevectors/ConstantTimeVector.py
104 105 106 | |
is_zero_one_profile() -> bool | None
Check if TimeVector is a profile with values between zero and one.
Source code in framcore/timevectors/ConstantTimeVector.py
108 109 110 | |
LinearTransformTimeVector
LinearTransformTimeVector
Bases: TimeVector
LinearTransformTimeVector represents a TimeVector as scale * timevector + shift. Immutable.
Source code in framcore/timevectors/LinearTransformTimeVector.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
__eq__(other) -> bool
Check if self and other are equal.
Source code in framcore/timevectors/LinearTransformTimeVector.py
105 106 107 108 109 110 111 112 113 114 115 116 117 | |
__hash__() -> int
Compute the hash of the LinearTransformTimeVector.
Source code in framcore/timevectors/LinearTransformTimeVector.py
119 120 121 122 123 124 125 126 127 128 129 130 131 | |
__init__(timevector: TimeVector, scale: float, shift: float, unit: str | None, is_max_level: bool | None = None, is_zero_one_profile: bool | None = None, reference_period: ReferencePeriod | None = None) -> None
Initialize LinearTransformTimeVector with a TimeVector, scale and shift.
May also override unit, is_max_level, is_zero_one_profile and reference_period of the original timevector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timevector
|
TimeVector
|
TimeVector. |
required |
scale
|
float
|
Scale factor. |
required |
shift
|
float
|
Shift value. |
required |
unit
|
str | None
|
Unit of the values in the transformed vector. |
required |
is_max_level
|
bool | None
|
Whether the transformed vector represents the maximum level, average level given a reference period, or not a level at all. Defaults to None. |
None
|
is_zero_one_profile
|
bool | None
|
Whether the transformed vector represents a profile with values between 0 and 1, a profile with values averaging to 1 over a given reference period, or is not a profile. Defaults to None. |
None
|
reference_period
|
ReferencePeriod | None
|
Given reference period if the transformed vector represents average level or mean one profile. Defaults to None. |
None
|
Source code in framcore/timevectors/LinearTransformTimeVector.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
get_fingerprint() -> Fingerprint
Get the Fingerprint of the TimeVector.
Source code in framcore/timevectors/LinearTransformTimeVector.py
73 74 75 | |
get_loader() -> TimeVectorLoader | None
Call get_loader on underlying time vector.
Source code in framcore/timevectors/LinearTransformTimeVector.py
101 102 103 | |
get_reference_period() -> ReferencePeriod | None
Get the reference period of the TimeVector.
Source code in framcore/timevectors/LinearTransformTimeVector.py
97 98 99 | |
get_timeindex() -> ConstantTimeIndex
Get the TimeIndex of the TimeVector.
Source code in framcore/timevectors/LinearTransformTimeVector.py
77 78 79 | |
get_unit() -> str | None
Get the unit of the TimeVector.
Source code in framcore/timevectors/LinearTransformTimeVector.py
93 94 95 | |
get_vector(is_float32: bool) -> NDArray
Get the values of the TimeVector.
Source code in framcore/timevectors/LinearTransformTimeVector.py
61 62 63 64 65 66 67 68 69 70 71 | |
is_constant() -> bool
Check if the TimeVector is constant.
Source code in framcore/timevectors/LinearTransformTimeVector.py
81 82 83 | |
is_max_level() -> bool | None
Check if TimeVector is a level representing maximum Volume/Capacity.
Source code in framcore/timevectors/LinearTransformTimeVector.py
85 86 87 | |
is_zero_one_profile() -> bool | None
Check if TimeVector is a profile with values between zero and one.
Source code in framcore/timevectors/LinearTransformTimeVector.py
89 90 91 | |
ListTimeVector
ListTimeVector
Bases: TimeVector
TimeVector with a numpy array of values paired with a timeindex.
Source code in framcore/timevectors/ListTimeVector.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
__eq__(other: object) -> None
Check equality between two ListTimeVector objects.
Source code in framcore/timevectors/ListTimeVector.py
63 64 65 66 67 68 69 70 71 72 73 74 | |
__hash__() -> int
Return hash of ListTimeVector object.
Source code in framcore/timevectors/ListTimeVector.py
76 77 78 | |
__init__(timeindex: TimeIndex, vector: NDArray, unit: str | None, is_max_level: bool | None, is_zero_one_profile: bool | None, reference_period: ReferencePeriod | None = None) -> None
Initialize the ListTimeVector class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeindex
|
TimeIndex
|
Index of timestamps for the vector. |
required |
vector
|
NDArray
|
Array of vector values. |
required |
unit
|
str | None
|
Unit of the values in the vector. |
required |
is_max_level
|
bool | None
|
Whether the vector represents the maximum level, average level given a reference period, or not a level at all. |
required |
is_zero_one_profile
|
bool | None
|
Whether the vector represents aprofile with values between 0 and 1, a profile with values averaging to 1 over a given reference period, or is not a profile. |
required |
reference_period
|
ReferencePeriod | None
|
Given reference period if the vector represents average level or mean one profile. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
When both is_max_level and is_zero_one_profile is not None. This would mean the TimeVector represents both a level and a profile, which is not allowed. |
ValueError
|
When the shape of the vector does not match the number of periods in the timeindex. |
Source code in framcore/timevectors/ListTimeVector.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
__repr__() -> str
Return the string representation of the ListTimeVector.
Source code in framcore/timevectors/ListTimeVector.py
80 81 82 | |
get_fingerprint() -> Fingerprint
Get the fingerprint of the ListTimeVector.
Returns:
| Name | Type | Description |
|---|---|---|
Fingerprint |
Fingerprint
|
The fingerprint of the ListTimeVector, excluding the reference period. |
Source code in framcore/timevectors/ListTimeVector.py
114 115 116 117 118 119 120 121 122 123 | |
get_loader() -> None
Interface method Not applicable for this type. Return None.
Source code in framcore/timevectors/ListTimeVector.py
125 126 127 | |
get_reference_period() -> ReferencePeriod | None
Get the reference period of the TimeVector.
Source code in framcore/timevectors/ListTimeVector.py
110 111 112 | |
get_timeindex() -> TimeIndex
Get the TimeIndex of the TimeVector.
Source code in framcore/timevectors/ListTimeVector.py
90 91 92 | |
get_unit() -> str | None
Get the unit of the TimeVector.
Source code in framcore/timevectors/ListTimeVector.py
106 107 108 | |
get_vector(is_float32: bool) -> NDArray
Get the vector of the TimeVector as a numpy array.
Source code in framcore/timevectors/ListTimeVector.py
84 85 86 87 88 | |
is_constant() -> bool
Check if the TimeVector is constant.
Source code in framcore/timevectors/ListTimeVector.py
94 95 96 | |
is_max_level() -> bool
Check if TimeVector is a level representing maximum Volume/Capacity.
Source code in framcore/timevectors/ListTimeVector.py
98 99 100 | |
is_zero_one_profile() -> bool
Check if TimeVector is a profile with vector between zero and one.
Source code in framcore/timevectors/ListTimeVector.py
102 103 104 | |
LoadedTimeVector
LoadedTimeVector
Bases: TimeVector
TimeVector which gets its data from a data source via a TimeVectorLoader. Subclass of TimeVector.
Source code in framcore/timevectors/LoadedTimeVector.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
__eq__(other: object) -> bool
Check equality between two LoadedTimeVector objects.
Source code in framcore/timevectors/LoadedTimeVector.py
44 45 46 47 48 | |
__hash__() -> int
Return hash of LoadedTimeVector object.
Source code in framcore/timevectors/LoadedTimeVector.py
50 51 52 | |
__init__(vector_id: str, loader: TimeVectorLoader) -> None
Store vector id and loader in instance variables, get unit from loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector_id
|
str
|
Unique name of this vector. |
required |
loader
|
TimeVectorLoader
|
Object connected to a data source where vector_id is associated with a time vector. The Loader object must also implement the TimeVectorLoader API. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
When metadata in the TimeVectorLoader for both is_max_level and is_zero_one_profile for the given vector_id is not None. This would mean the TimeVector represents both a level and a profile, which is not allowed. |
Source code in framcore/timevectors/LoadedTimeVector.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
__repr__() -> str
Overwrite string representation of LoadedTimeVector objects.
Source code in framcore/timevectors/LoadedTimeVector.py
40 41 42 | |
get_fingerprint() -> Fingerprint
Get the Fingerprint of this TimeVector.
Source code in framcore/timevectors/LoadedTimeVector.py
95 96 97 | |
get_loader() -> TimeVectorLoader
Get the Loader this TimeVector retrieves its data from.
Source code in framcore/timevectors/LoadedTimeVector.py
79 80 81 | |
get_reference_period() -> ReferencePeriod | None
Get the reference period which the data of this TimeVector is from.
Source code in framcore/timevectors/LoadedTimeVector.py
83 84 85 | |
get_timeindex() -> TimeIndex
Get this time vectors index.
Returns:
| Name | Type | Description |
|---|---|---|
TimeIndex |
TimeIndex
|
Object describing the index. |
Source code in framcore/timevectors/LoadedTimeVector.py
61 62 63 64 65 66 67 68 69 | |
get_unit() -> str
Get the unit of this TimeVector.
Source code in framcore/timevectors/LoadedTimeVector.py
75 76 77 | |
get_vector(is_float32: bool) -> NDArray
Get the vector of the TimeVector as a numpy array.
Source code in framcore/timevectors/LoadedTimeVector.py
54 55 56 57 58 59 | |
is_constant() -> bool
Signify if this TimeVector is constant.
Source code in framcore/timevectors/LoadedTimeVector.py
71 72 73 | |
is_max_level() -> bool | None
Check if TimeVector is a level representing maximum Volume/Capacity.
Source code in framcore/timevectors/LoadedTimeVector.py
87 88 89 | |
is_zero_one_profile() -> bool | None
Check if TimeVector is a profile with values between zero and one.
Source code in framcore/timevectors/LoadedTimeVector.py
91 92 93 | |
ReferencePeriod
ReferencePeriod
Bases: Base
ReferencePeriod class represents a period of one or more years.
Source code in framcore/timevectors/ReferencePeriod.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
__eq__(other) -> bool
Check if self and other are equal.
Source code in framcore/timevectors/ReferencePeriod.py
38 39 40 41 42 | |
__hash__() -> int
Compute hash value..
Source code in framcore/timevectors/ReferencePeriod.py
44 45 46 47 48 49 50 51 | |
__init__(start_year: int, num_years: int) -> None
Initialize a ReferencePeriod with the start year and number of years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_year
|
int
|
The first year in the reference period. Must be a positive integer. |
required |
num_years
|
int
|
The number of years in the reference period. Must be a positive non-zero integer. |
required |
Source code in framcore/timevectors/ReferencePeriod.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
get_num_years() -> int
Get the number of years in the ReferencePeriod.
Source code in framcore/timevectors/ReferencePeriod.py
34 35 36 | |
get_start_year() -> int
Get the start_year from a ReferencePeriod instance.
Source code in framcore/timevectors/ReferencePeriod.py
30 31 32 | |
TimeVector
TimeVector
Bases: Base, ABC
TimeVector interface class for defining timeseries data.
Source code in framcore/timevectors/TimeVector.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
__eq__(other) -> bool
abstractmethod
Check if two TimeVectors are equal.
Source code in framcore/timevectors/TimeVector.py
25 26 27 28 | |
__hash__() -> int
abstractmethod
Compute hash value.
Source code in framcore/timevectors/TimeVector.py
30 31 32 33 | |
__init__() -> None
Initialize the TimeVector class.
Source code in framcore/timevectors/TimeVector.py
21 22 23 | |
get_fingerprint() -> Fingerprint
abstractmethod
Get the fingerprint of the TimeVector.
Source code in framcore/timevectors/TimeVector.py
75 76 77 78 | |
get_loader() -> TimeVectorLoader | None
abstractmethod
Get the TimeVectorLoader of the TimeVector if self has one.
TimeVectors can store timeseries data in Loaders that point to databases. Data is only retrieved and cached when the TimeVector is queried.
Source code in framcore/timevectors/TimeVector.py
85 86 87 88 89 90 91 92 | |
get_reference_period() -> ReferencePeriod | None
abstractmethod
Get the reference period of the TimeVector.
Source code in framcore/timevectors/TimeVector.py
80 81 82 83 | |
get_timeindex() -> TimeIndex | None
abstractmethod
Get the TimeIndex of the TimeVector.
Source code in framcore/timevectors/TimeVector.py
40 41 42 43 | |
get_unit() -> str | None
abstractmethod
Get the unit of the TimeVector.
Source code in framcore/timevectors/TimeVector.py
70 71 72 73 | |
get_vector(is_float32: bool) -> NDArray
abstractmethod
Get the values of the TimeVector.
Source code in framcore/timevectors/TimeVector.py
35 36 37 38 | |
is_constant() -> bool
abstractmethod
Check if the TimeVector is constant.
Source code in framcore/timevectors/TimeVector.py
45 46 47 48 | |
is_max_level() -> bool | None
abstractmethod
Whether the TimeVector represents the maximum level, average level given a reference period, or not a level at all.
See LevelProfile for a description of Level (max or avg) and Profile (max one or mean one), and their formats.
Source code in framcore/timevectors/TimeVector.py
50 51 52 53 54 55 56 57 58 | |
is_zero_one_profile() -> bool | None
abstractmethod
Whether the TimeVector represents a profile with values between 0 and 1, a profile with average 1 over a given reference period, or is not a profile.
See LevelProfile for a description of Level (max or avg) and Profile (max one or mean one), and their formats.
Source code in framcore/timevectors/TimeVector.py
60 61 62 63 64 65 66 67 68 | |
utils
FlowInfo
Bases: Base
Holds info about one or two related Arrows of a Flow.
Source code in framcore/utils/node_flow_utils.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
__init__(category: str, node_out: str | None = None, commodity_out: str | None = None, node_in: str | None = None, commodity_in: str | None = None) -> None
Based on its arrows, we derive properties about a Flow.
We use this class to store such info.
Source code in framcore/utils/node_flow_utils.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
RegionalVolumes
Container for regional energy volumes.
Stores production, consumption, import, and export vectors for each node and category. Provides methods to access these aggregated results.
Source code in framcore/utils/get_regional_volumes.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
__init__() -> None
Initialize the RegionalVolumes instance with empty dictionaries for production, consumption, import, and export.
Source code in framcore/utils/get_regional_volumes.py
32 33 34 35 36 37 | |
get_consumption() -> dict[str, dict[str, NDArray]]
Return dict with consumption vector by category for each node.
Source code in framcore/utils/get_regional_volumes.py
43 44 45 | |
get_export() -> dict[str, dict[str, NDArray]]
Return nested dict with export vector for each trade partner to an exporting node.
Source code in framcore/utils/get_regional_volumes.py
47 48 49 | |
get_import() -> dict[str, dict[str, NDArray]]
Return nested dict with import vector for each trade partner to an importing node.
Source code in framcore/utils/get_regional_volumes.py
51 52 53 | |
get_production() -> dict[str, dict[str, NDArray]]
Return dict with production vector by category for each node.
Source code in framcore/utils/get_regional_volumes.py
39 40 41 | |
add_loaders(loaders: set[Loader], model: Model) -> None
Add all loaders stored in Model to loaders set.
Source code in framcore/utils/loaders.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
add_loaders_if(loaders: set, value: object | None) -> None
Call value.add_loaders(loaders) if value is not None.
Source code in framcore/utils/loaders.py
13 14 15 16 17 18 | |
get_component_to_nodes(data: Model | dict[str, object]) -> dict[str, set[str]]
For each str key in data where value is a Component find all Node id str in data directly connected to the Component.
Source code in framcore/utils/node_flow_utils.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
get_flow_infos(flow: Flow, node_to_commodity: dict[str, str]) -> list[FlowInfo]
Get flow infos from analysis of all its arrows.
Source code in framcore/utils/node_flow_utils.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
get_hydro_downstream_energy_equivalent(data: dict[str, Component | TimeVector | Curve | Expr], module_name: str, power_node: str | None = None) -> Expr
Get the expression for the sum downstream energy equivalent for a hydro module.
- If power node is given, only count downstream energy equivalents that are connected to the power node.
- Energy equivalents are collected from hydro generators downstream, and the main topology follows the release_to attribute.
- Transport pumps are included in the downstream topology, but counted as negative energy equivalents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Component | TimeVector | Curve | Expr]
|
The dict containing the components. |
required |
module_name
|
str
|
The name of the hydro module to start from. |
required |
power_node
|
str
|
Optional power node to filter energy equivalents. |
None
|
Source code in framcore/utils/global_energy_equivalent.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
get_node_to_commodity(data: dict[str, object]) -> dict[str, str]
Return dict with commodity (str) for each node id (str) in data.
Source code in framcore/utils/node_flow_utils.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
get_one_commodity_storage_subsystems(graph: dict[str, Node | Flow], include_boundaries: bool) -> dict[str, tuple[str, set[str], set[str]]]
Group all storage subsystems belonging to same commodity.
Returns dict[subsystem_id, (domain_commodity, member_component_ids, boundary_domain_commodities)]
The boundary_domain_commodities of the output is a set of boundary commodities. Some algorithms can only handle one boundary commodity, so this output is useful to verify that those conditions apply, and to derive conversion factor unit, which need both storage_commodity unit and boundray_commodity unit.
If include_boundaries is False only nodes with same commodity as storage_node will be included in the subsystem.
Source code in framcore/utils/storage_subsystems.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
get_transports_by_commodity(data: Model | dict[str, object], commodity: str) -> dict[str, tuple[str, str]]
Return dict with key component_id and value (from_node_id, to_node_id) where both nodes belong to given commodity.
Source code in framcore/utils/node_flow_utils.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
is_transport_by_commodity(flow: Flow, node_to_commodity: dict[str, str], commodity: str) -> bool
Return True if flow is a transport of the given commodity.
Source code in framcore/utils/node_flow_utils.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
replace_loader_path(loaders: set[Loader], old: Path, new: Path) -> None
Replace old path with new for all loaders using old path.
Source code in framcore/utils/loaders.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
set_global_energy_equivalent(data: dict[str, Component | TimeVector | Curve | Expr], metakey_energy_eq_downstream: str) -> None
Loop through data dict and set the downstream energy equivalent for all HydroModules.
Send a warning event if a HydroModule has no downstream energy equivalents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Component | TimeVector | Curve | Expr]
|
The dict containing the components. |
required |
metakey_energy_eq_downstream
|
str
|
The meta key to use for storing the downstream energy equivalent. |
required |
Source code in framcore/utils/global_energy_equivalent.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
get_regional_volumes
RegionalVolumes
Container for regional energy volumes.
Stores production, consumption, import, and export vectors for each node and category. Provides methods to access these aggregated results.
Source code in framcore/utils/get_regional_volumes.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
__init__() -> None
Initialize the RegionalVolumes instance with empty dictionaries for production, consumption, import, and export.
Source code in framcore/utils/get_regional_volumes.py
32 33 34 35 36 37 | |
get_consumption() -> dict[str, dict[str, NDArray]]
Return dict with consumption vector by category for each node.
Source code in framcore/utils/get_regional_volumes.py
43 44 45 | |
get_export() -> dict[str, dict[str, NDArray]]
Return nested dict with export vector for each trade partner to an exporting node.
Source code in framcore/utils/get_regional_volumes.py
47 48 49 | |
get_import() -> dict[str, dict[str, NDArray]]
Return nested dict with import vector for each trade partner to an importing node.
Source code in framcore/utils/get_regional_volumes.py
51 52 53 | |
get_production() -> dict[str, dict[str, NDArray]]
Return dict with production vector by category for each node.
Source code in framcore/utils/get_regional_volumes.py
39 40 41 | |
get_regional_volumes(db: Model | QueryDB, commodity: str, node_category: str, production_category: str, consumption_category: str, data_period: SinglePeriodTimeIndex, scenario_period: FixedFrequencyTimeIndex, unit: str, is_float32: bool = True) -> RegionalVolumes
Calculate aggregated production, consumption, import and export for member in node_category.
Decompose the model components into nodes and flows. Analyze the flows to determine their contribution to production, consumption, import, and export if they are associated with the specified commodity. Group these contributions based on the provided node_category, production_category, and consumption_category metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db
|
Model | QueryDB
|
Model or QueryDB to use |
required |
commodity
|
str
|
Commodity to consider |
required |
node_category
|
str
|
Meta key for node category to group the results by |
required |
production_category
|
str
|
Meta key for production category to group the results by |
required |
consumption_category
|
str
|
Meta key for consumption category to group the results by |
required |
data_period
|
SinglePeriodTimeIndex
|
Consider results for this data period |
required |
scenario_period
|
FixedFrequencyTimeIndex
|
Consider results for this scenario period |
required |
unit
|
str
|
Unit to use for the results |
required |
is_float32
|
bool
|
Use float32 for calculations and results if True |
True
|
Source code in framcore/utils/get_regional_volumes.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 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 385 386 387 | |
get_supported_components
get_supported_components(components: dict[str, Component], supported_types: tuple[type[Component]], forbidden_types: tuple[type[Component]]) -> dict[str, Component]
Return simplified version of components in compliance with specified component types.See description in Component.
Source code in framcore/utils/get_supported_components.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
global_energy_equivalent
get_hydro_downstream_energy_equivalent(data: dict[str, Component | TimeVector | Curve | Expr], module_name: str, power_node: str | None = None) -> Expr
Get the expression for the sum downstream energy equivalent for a hydro module.
- If power node is given, only count downstream energy equivalents that are connected to the power node.
- Energy equivalents are collected from hydro generators downstream, and the main topology follows the release_to attribute.
- Transport pumps are included in the downstream topology, but counted as negative energy equivalents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Component | TimeVector | Curve | Expr]
|
The dict containing the components. |
required |
module_name
|
str
|
The name of the hydro module to start from. |
required |
power_node
|
str
|
Optional power node to filter energy equivalents. |
None
|
Source code in framcore/utils/global_energy_equivalent.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
set_global_energy_equivalent(data: dict[str, Component | TimeVector | Curve | Expr], metakey_energy_eq_downstream: str) -> None
Loop through data dict and set the downstream energy equivalent for all HydroModules.
Send a warning event if a HydroModule has no downstream energy equivalents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Component | TimeVector | Curve | Expr]
|
The dict containing the components. |
required |
metakey_energy_eq_downstream
|
str
|
The meta key to use for storing the downstream energy equivalent. |
required |
Source code in framcore/utils/global_energy_equivalent.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
isolate_subnodes
Demo to show how we can use the core to write some functions we need.
isolate_subnodes(model: Model, commodity: str, meta_key: str, members: list[str]) -> None
For components in model, delete all nodes of commodity except member nodes, and their flows and boundary nodes.
- Keep member nodes and all flows between them.
- Set boundary nodes exogenous and keep boundary flows into or out from member nodes.
- Delete all other nodes of commodity and all other flows pointing to them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Model to modify |
required |
commodity
|
str
|
Commodity of nodes to consider |
required |
meta_key
|
str
|
Meta key to use to identify members |
required |
members
|
List[str]
|
List of meta key values identifying member nodes |
required |
Source code in framcore/utils/isolate_subnodes.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
loaders
add_loaders(loaders: set[Loader], model: Model) -> None
Add all loaders stored in Model to loaders set.
Source code in framcore/utils/loaders.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
add_loaders_if(loaders: set, value: object | None) -> None
Call value.add_loaders(loaders) if value is not None.
Source code in framcore/utils/loaders.py
13 14 15 16 17 18 | |
replace_loader_path(loaders: set[Loader], old: Path, new: Path) -> None
Replace old path with new for all loaders using old path.
Source code in framcore/utils/loaders.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
node_flow_utils
FlowInfo
Bases: Base
Holds info about one or two related Arrows of a Flow.
Source code in framcore/utils/node_flow_utils.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
__init__(category: str, node_out: str | None = None, commodity_out: str | None = None, node_in: str | None = None, commodity_in: str | None = None) -> None
Based on its arrows, we derive properties about a Flow.
We use this class to store such info.
Source code in framcore/utils/node_flow_utils.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
get_component_to_nodes(data: Model | dict[str, object]) -> dict[str, set[str]]
For each str key in data where value is a Component find all Node id str in data directly connected to the Component.
Source code in framcore/utils/node_flow_utils.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
get_flow_infos(flow: Flow, node_to_commodity: dict[str, str]) -> list[FlowInfo]
Get flow infos from analysis of all its arrows.
Source code in framcore/utils/node_flow_utils.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
get_node_to_commodity(data: dict[str, object]) -> dict[str, str]
Return dict with commodity (str) for each node id (str) in data.
Source code in framcore/utils/node_flow_utils.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
get_transports_by_commodity(data: Model | dict[str, object], commodity: str) -> dict[str, tuple[str, str]]
Return dict with key component_id and value (from_node_id, to_node_id) where both nodes belong to given commodity.
Source code in framcore/utils/node_flow_utils.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
is_transport_by_commodity(flow: Flow, node_to_commodity: dict[str, str], commodity: str) -> bool
Return True if flow is a transport of the given commodity.
Source code in framcore/utils/node_flow_utils.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
storage_subsystems
get_one_commodity_storage_subsystems(graph: dict[str, Node | Flow], include_boundaries: bool) -> dict[str, tuple[str, set[str], set[str]]]
Group all storage subsystems belonging to same commodity.
Returns dict[subsystem_id, (domain_commodity, member_component_ids, boundary_domain_commodities)]
The boundary_domain_commodities of the output is a set of boundary commodities. Some algorithms can only handle one boundary commodity, so this output is useful to verify that those conditions apply, and to derive conversion factor unit, which need both storage_commodity unit and boundray_commodity unit.
If include_boundaries is False only nodes with same commodity as storage_node will be included in the subsystem.
Source code in framcore/utils/storage_subsystems.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |