Skip to content

Add new-format costs_connection templating (VRE new entrants)#107

Open
EllieKallmier wants to merge 5 commits into
mainfrom
new-format-connection-cost-table
Open

Add new-format costs_connection templating (VRE new entrants)#107
EllieKallmier wants to merge 5 commits into
mainfrom
new-format-connection-cost-table

Conversation

@EllieKallmier
Copy link
Copy Markdown
Member

Summary

  1. Adds _template_connection_costs and supporting helpers in a new connection_and_build_costs.py module, templating the costs_connection table for VRE (wind and solar) new entrants in the new-format IASR workflow.
  2. Adds _fuzzy_map_to_canonical (many-to-one canonical fuzzy matching) and two supporting helpers to helpers.py — set up for robust scenario name matching against raw IASR data, but hoping to apply to lots of cases as we progress
  3. Updates _ISP_SCENARIOS to current IASR workbook scenario names (Slower Growth, Step Change, Accelerated Transition)
  4. Small updates to costs_connection validation schema.
  5. todo notes: some todo's left in here for me to apply when other changes/updates come through - e.g. Add new-format network_expansion templater #102 has some updates to structural stuff that I haven't touched in this PR.

Scope note:

Connection cost templating for non-VRE technologies is split out to come in a follow-up PR. The reasons:

  • Non-VRE connection capacity data aren't directly reported in the IASR workbook - compiled across ENOR instead. So requires a bit of specific/fuzzy handling that I didn't want to chunk up this PR with.
  • Batteries - being now defined for REZs as well just means the regional granularity stuff will also need to be handled kind of specifically, so thought easier to just split out into another PR.

The follow-up PR should build directly on this one. There are a few other things like more assertive canonicalisation to come as the rest of generator/storage templater updates built out, but for the sake of smaller chunks I'm leaning on the feature flag approach to more incrementally implement stuff - hope that's ok, and very happy to change that workflow/interpretation if it doesn't work long term!

@EllieKallmier EllieKallmier requested a review from nick-gorman May 25, 2026 03:58
@EllieKallmier EllieKallmier added the type: feature New feature or request label May 25, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/ispypsa/iasr_table_caching/local_cache.py 74.28% <ø> (ø)
...rc/ispypsa/templater/connection_and_build_costs.py 100.00% <100.00%> (ø)
src/ispypsa/templater/create_template.py 89.61% <100.00%> (+0.42%) ⬆️
src/ispypsa/templater/helpers.py 100.00% <100.00%> (+1.83%) ⬆️
src/ispypsa/templater/lists.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@nick-gorman nick-gorman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good Ellie. Some nice extensions to the fuzzy maping infrastructure. And very much apprecaite the chunking into a smallish PR! Just some tiny comments from me.

Comment thread tests/test_templater/test_create_ispypsa_inputs_template.py Outdated
"renewable_energy_zones": renewable_energy_zones,
"flow_path_transfer_capability": flow_path_transfer_capability,
"initial_transmission_limits": initial_transmission_limits,
"connection_cost_forecast_wind_and_solar": csv_str_to_df(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no check for corresponding output?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops yep not intentional! It'll return an empty costs df so I just blanked on checking that it actually exists. Will fix up :)

Comment thread src/ispypsa/templater/helpers.py Outdated
lambda v: match_dict[v] if match_dict[v] is not None else v
)
_log_fuzzy_match(name_series, matched, task_desc)
_warn_unmatched_fuzzy_values(name_series, match_dict, task_desc)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought really. But if canonicalisation fails, this kind of implies that dataset produced will contain in consistencies and maybe shouldn't be used as is? Or maybe I'm missing something. But I guess validation would pick this up later.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think that's right, and I was thinking validation would pick it up but prob better to just raise as it happens (or drop?). The case that was in my mind is in the connection costs table for non-vre, 'BOTN - Cethana' has it's own entry in what is otherwise only standard 'technology'-labelled entries - so thought I'd just leave unmatched/unconverted so we could handle as a special case later. But I don't know how common that kind of case might be (and assume probably not very) so yeah probably better to handle known special cases before canonicalisation and just error out if canonicalisation fails. Will update!

].reset_index(drop=True)


def _enforce_numeric_cols(df: pd.DataFrame, numeric_cols: list[str]) -> pd.DataFrame:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good for me to remember this is here. Could be extracted to helpers down the track.

@EllieKallmier EllieKallmier force-pushed the new-format-connection-cost-table branch from 822d517 to fe60215 Compare May 27, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants