PyPSA/pypsa-usa

Refactor cost multiplier functions

Open

#61 opened on Sep 25, 2023

 (1 comment) (0 reactions) (0 assignees)Python (52 forks)auto 404
enhancementgood first issue

Repository metrics

Stars
 (140 stars)
PR merge metrics
 (PR metrics pending)

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