PyPSA / PyPSA/pypsa-usa

Refactor cost multiplier functions

Open
#61 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Python
Stars
148
Forks
55
Avg merge
2d 11h
Merged PRs (30d)
18

Description

Feature Request

We can combine quite a bit of the cost multiplier functions (update_marginal_costs(...) and update_capital_costs(...)). Specifically, the logic that maps each generator to a state, as it needs to extract out the state label from the bus dataframe. If this logic is packaged into its own function, it may be useful later in the workflow as well :)

Suggested Solution

Here is the code that I think should be simplified.

https://github.com/PyPSA/pypsa-usa/blob/6f37e32de0b19b349e6ba134e1bcfa0f48e5b93a/workflow/scripts/add_electricity.py#L312-L420

Moreover, here is the portion that I think should be extracted into its own funtion

https://github.com/PyPSA/pypsa-usa/blob/6f37e32de0b19b349e6ba134e1bcfa0f48e5b93a/workflow/scripts/add_electricity.py#L315-L324

Additional Info

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in workflow/scripts/add_electricity.py around lines 312-420, focusing first on the repeated generator-to-state logic at lines 315-324. Extract that mapping for reuse by update_marginal_costs(...) and update_capital_costs(...), then verify the electricity workflow still produces the expected cost calculations.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-engineering
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.