feat: update logic for general EI translation approach#255
Conversation
…are enabled for it
… when no time series are found
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates the Sienna→PLEXOS translation to better support EI-style data by adding reference-node handling, creating missing pumped-hydro storages, and expanding translation/membership support for zones and dispatch generators.
Changes:
- Add
ensure_reference_node_membershipsand invoke it during translation to create oneReferenceNodeper region. - Synthesize missing head/tail
PLEXOSStoragefor pumped-hydro generators and attach memberships. - Extend translation rules/getters for zones and generator unit activation based on time-series presence; update/expand test coverage accordingly.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/r2x-sienna-to-plexos/tests/test_translation_rule_application.py | Adds coverage for hydro reservoir head/tail storage creation and new translation steps. |
| packages/r2x-sienna-to-plexos/tests/test_getters_utils.py | Adds tests for reference-node memberships, pumped-hydro storage synthesis, and zone-name extraction behavior. |
| packages/r2x-sienna-to-plexos/tests/test_getters.py | Adds tests for category resolution, time-series-based activation, zone membership resolution, and reservoir naming rules. |
| packages/r2x-sienna-to-plexos/src/r2x_sienna_to_plexos/translation.py | Wires new post-translation steps into the main translation pipeline. |
| packages/r2x-sienna-to-plexos/src/r2x_sienna_to_plexos/getters_utils.py | Implements reference-node membership creation, pumped-hydro storage synthesis, and improves bus zone-name extraction. |
| packages/r2x-sienna-to-plexos/src/r2x_sienna_to_plexos/getters.py | Adds cached defaults loading, fuel-based thermal category resolution, time-series usability checks, zone getters, and updated reservoir naming logic. |
| packages/r2x-sienna-to-plexos/src/r2x_sienna_to_plexos/config/rules.json | Adds LoadZone→PLEXOSZone translation and node→zone membership rules; updates generator unit/category getters. |
| packages/r2x-sienna-to-plexos/src/r2x_sienna_to_plexos/config/defaults.json | Updates prime-mover mappings and introduces reeds_thermal_mapping. |
| packages/r2x-sienna-to-plexos/src/r2x_sienna_to_plexos/init.py | Exports newly added translation utilities. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "WASTE_COAL", | ||
| "SYNTHESIS_GAS_COAL" | ||
| ], | ||
| "natural-gas": [ |
| def _has_explicit_side_reservoir_for_base( | ||
| source_component: HydroReservoir, | ||
| context: PluginContext, | ||
| side: str, | ||
| ) -> bool: | ||
| """Return True when another reservoir with same base explicitly maps the requested side.""" | ||
| this_base = _get_reservoir_storage_base_name(source_component).casefold() | ||
| this_uuid = getattr(source_component, "uuid", None) | ||
|
|
||
| for other in _source_system(context).get_components(HydroReservoir): | ||
| other_uuid = getattr(other, "uuid", None) | ||
| if this_uuid is not None and other_uuid == this_uuid: | ||
| continue | ||
| if _get_reservoir_storage_base_name(other).casefold() != this_base: | ||
| continue | ||
| if _get_reservoir_name_suffix_location(other) == side: | ||
| return True | ||
|
|
||
| return False |
| bus_index = _bus_name_to_area_and_zone(context) | ||
| regions_by_name = {r.name: r for r in _target_system(context).get_components(PLEXOSRegion)} |
| nodes_by_region: dict[str, list[PLEXOSNode]] = {} | ||
| for node in _target_system(context).get_components(PLEXOSNode): | ||
| area_name, _ = bus_index.get(node.name, (None, None)) | ||
| if area_name is None: | ||
| continue | ||
| nodes_by_region.setdefault(area_name, []).append(node) |
| storage = PLEXOSStorage( | ||
| name=storage_name, | ||
| category="pumped-hydro", | ||
| units=1, | ||
| max_volume=max_volume, | ||
| initial_volume=initial_volume, | ||
| ) |
| else [] | ||
| ) | ||
|
|
||
| context.source_system.get_components = monkeypatch_get_components |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #255 +/- ##
==========================================
+ Coverage 84.22% 84.76% +0.54%
==========================================
Files 19 19
Lines 4101 4391 +290
==========================================
+ Hits 3454 3722 +268
- Misses 647 669 +22
🚀 New features to boost your workflow:
|
This reverts commit d07ee35.
pesap
left a comment
There was a problem hiding this comment.
Looks good, @mcllerena. Just fix the merge conflicts and we can merge
Yeah, just a need a couple of commits more to close the EI updates |
Signed-off-by: Marck Llerena V. <140716266+mcllerena@users.noreply.github.com>
No description provided.