PyPSA / pypsa-usa

PyPSA-USA: An Open-Source Energy System Optimization Model for the United States
https://pypsa-usa.readthedocs.io
MIT License
35 stars 15 forks source link

Refactor cost multiplier functions #61

Open trevorb1 opened 9 months ago

trevorb1 commented 9 months ago

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

ktehranchi commented 4 months ago

209 Address some of this refactoring