Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregate curtailment time series by area #173

Merged
merged 9 commits into from
Oct 1, 2020
Merged

Conversation

rouille
Copy link
Collaborator

@rouille rouille commented Sep 22, 2020

Purpose

Calculate curtailment time series by area (interconnect, state name/abbreviation, load zone).

What is the code doing?

it generates a dictionary of the form: {area name: {resource name: curtailment}}, where curtailment is a data frame with UTC timestamps as indices and plant id as columns ore eventually a time series if there is only one plant for the resource in the area. The area and resource names will reflect what is passed to the function calculate_curtailment_time_series_by_area, e.g.:

>>> from postreise.analyze.generation.curtailment import calculate_curtailment_time_series_by_areas_and_resources
>>> from powersimdata.scenario.scenario import Scenario
>>> s = Scenario("87")
SCENARIO: base | WesternBase_2016_noHVDC_Final_2019Sep

--> State
analyze
--> Loading grid
Loading bus
Loading plant
Loading heat_rate_curve
Loading gencost_before
Loading gencost_after
Loading branch
Loading sub
Loading bus2sub
--> Loading ct
>>> curtailment = calculate_curtailment_time_series_by_areas_and_resources(s, areas={"state": {"California", "Washington", "OR"}, "loadzone": {"Bay Area", "El Paso"}}, resources={"wind", "solar"})
--> Loading PG
Reading bus.csv
Reading plant.csv
Reading gencost.csv
Reading branch.csv
Reading dcline.csv
Reading sub.csv
Reading bus2sub.csv
Reading zone.csv
--> Loading solar
Reading bus.csv
Reading plant.csv
Reading gencost.csv
Reading branch.csv
Reading dcline.csv
Reading sub.csv
Reading bus2sub.csv
Reading zone.csv
--> Loading wind
>>> curtailment
{'Washington': {'wind':                         10397     10400     10401     10428     10442  10458     10463  ...     10572  10617  10618     10623     10624     10629     10630
UTC                                                                                     ...                                                                
2016-01-01 00:00:00  0.000001  0.000002  0.000001  0.000000  0.000001    0.0  0.000000  ...  0.000002    0.0    0.0  0.000000  0.000000  0.000000  0.000000
2016-01-01 01:00:00  0.000001  0.000000  0.000000  0.000001  0.000000    0.0  0.000001  ...  0.000000    0.0    0.0  0.000000  0.000000  0.000000  0.000000
2016-01-01 02:00:00  0.000000  0.000000  0.000000  0.000001  0.000000    0.0  0.000000  ...  0.000000    0.0    0.0  0.000000  0.000000  0.000000  0.000000
2016-01-01 03:00:00  0.000000  0.000000  0.000003  0.000001  0.000000    0.0  0.000000  ...  0.000000    0.0    0.0  0.000000  0.000000  0.000000  0.000000
2016-01-01 04:00:00  0.000000  0.000000  0.000000  0.000000  0.000000    0.0  0.000001  ...  0.000000    0.0    0.0  0.000000  0.000000  0.000000  0.000000
...                       ...       ...       ...       ...       ...    ...       ...  ...       ...    ...    ...       ...       ...       ...       ...
2016-12-31 19:00:00  0.000000  0.000000  0.000000  0.000000  0.000000    0.0  0.000000  ...  0.000003    0.0    0.0  0.000000  0.000000  0.000000  0.000003
2016-12-31 20:00:00  0.000000  0.000000  0.000000  0.000000  0.000000    0.0  0.000001  ...  0.000003    0.0    0.0  0.000001  0.000001  0.000000  0.000000
2016-12-31 21:00:00  0.000001  0.000000  0.000000  0.000000  0.000004    0.0  0.000001  ...  0.000005    0.0    0.0  0.000000  0.000000  0.000000  0.000000
2016-12-31 22:00:00  0.000002  0.000003  0.000000  0.000000  0.000000    0.0  0.000000  ...  0.000005    0.0    0.0  0.000001  0.000001  0.000000  0.000000
2016-12-31 23:00:00  0.000000  0.000002  0.000002  0.000001  0.000000    0.0  0.000003  ...  0.000000    0.0    0.0  0.000000  0.000000  0.000002  0.000000

[8784 rows x 22 columns], 'solar':                      10441  10447  10448  10451  10452  10453  10454  10455  10456  10457  10473  10474  10484  10544  10545  10546  10602  10603  10604  10605
UTC                                                                                                                                                            
2016-01-01 00:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 01:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 02:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 03:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 04:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
...                    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...
2016-12-31 19:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 20:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 21:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 22:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 23:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0

[8784 rows x 20 columns]}, 'California': {'wind':                         10819  10872  11033  11034  11035  11036  11041  11042  11043  ...  11888  11889  11890  11891  11900  11901  11902     11903     11904
UTC                                                                                    ...                                                                     
2016-01-01 00:00:00  0.000001    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0  0.000001  0.000000
2016-01-01 01:00:00  0.000000    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0  0.000000  0.000000
2016-01-01 02:00:00  0.000000    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0  0.000000  0.000000
2016-01-01 03:00:00  0.000000    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0  0.000000  0.000000
2016-01-01 04:00:00  0.000003    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0  0.000001  0.000001
...                       ...    ...    ...    ...    ...    ...    ...    ...    ...  ...    ...    ...    ...    ...    ...    ...    ...       ...       ...
2016-12-31 19:00:00  0.000000    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0  0.000000  0.000000
2016-12-31 20:00:00  0.000000    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0  0.000000  0.000000
2016-12-31 21:00:00  0.000001    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0  0.000000  0.000000
2016-12-31 22:00:00  0.000000    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0  0.000000  0.000000
2016-12-31 23:00:00  0.000000    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0  0.000000  0.000000

[8784 rows x 96 columns], 'solar':                         10825     10826     10827  10828  10829  10858  10859  10860  ...  11842     11866  11892  11893  11894  11895  11896  11905
UTC                                                                                   ...                                                           
2016-01-01 00:00:00  0.000001  0.000001  0.000001    0.0    0.0    0.0    0.0    0.0  ...    0.0  0.000000    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 01:00:00  0.000000  0.000000  0.000000    0.0    0.0    0.0    0.0    0.0  ...    0.0  0.000000    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 02:00:00  0.000000  0.000000  0.000000    0.0    0.0    0.0    0.0    0.0  ...    0.0  0.000000    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 03:00:00  0.000000  0.000000  0.000000    0.0    0.0    0.0    0.0    0.0  ...    0.0  0.000000    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 04:00:00  0.000000  0.000000  0.000000    0.0    0.0    0.0    0.0    0.0  ...    0.0  0.000000    0.0    0.0    0.0    0.0    0.0    0.0
...                       ...       ...       ...    ...    ...    ...    ...    ...  ...    ...       ...    ...    ...    ...    ...    ...    ...
2016-12-31 19:00:00  0.000002  0.000002  0.000000    0.0    0.0    0.0    0.0    0.0  ...    0.0  0.000000    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 20:00:00  0.000000  0.000000  0.000002    0.0    0.0    0.0    0.0    0.0  ...    0.0  0.000002    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 21:00:00  0.000000  0.000000  0.000000    0.0    0.0    0.0    0.0    0.0  ...    0.0  0.000000    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 22:00:00  0.000000  0.000000  0.000001    0.0    0.0    0.0    0.0    0.0  ...    0.0  0.000002    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 23:00:00  0.000000  0.000000  0.000000    0.0    0.0    0.0    0.0    0.0  ...    0.0  0.000000    0.0    0.0    0.0    0.0    0.0    0.0

[8784 rows x 221 columns]}, 'Oregon': {'wind':                         10642  10652     10653     10660     10661     10662  10681  ...     10768     10769  10789  10790     10806     10807     10808
UTC                                                                                  ...                                                                
2016-01-01 00:00:00  0.000000    0.0  0.000000  0.000000  0.000000  0.000000    0.0  ...  0.000000  0.000000    0.0    0.0  0.000003  0.000003  0.000002
2016-01-01 01:00:00  0.000000    0.0  0.000001  0.000000  0.000000  0.000000    0.0  ...  0.000000  0.000000    0.0    0.0  0.000000  0.000000  0.000005
2016-01-01 02:00:00  0.000000    0.0  0.000000  0.000000  0.000001  0.000001    0.0  ...  0.000000  0.000000    0.0    0.0  0.000000  0.000000  0.000000
2016-01-01 03:00:00  0.000000    0.0  0.000000  0.000000  0.000001  0.000001    0.0  ...  0.000000  0.000000    0.0    0.0  0.000000  0.000000  0.000000
2016-01-01 04:00:00  0.000000    0.0  0.000000  0.000000  0.000001  0.000001    0.0  ...  0.000000  0.000000    0.0    0.0  0.000001  0.000001  0.000000
...                       ...    ...       ...       ...       ...       ...    ...  ...       ...       ...    ...    ...       ...       ...       ...
2016-12-31 19:00:00  0.000000    0.0  0.000000  0.000000  0.000000  0.000000    0.0  ...  0.000000  0.000000    0.0    0.0  0.000003  0.000003  0.000001
2016-12-31 20:00:00  0.000000    0.0  0.000000  0.000001  0.000000  0.000000    0.0  ...  0.000001  0.000000    0.0    0.0  0.000001  0.000001  0.000000
2016-12-31 21:00:00  0.000000    0.0  0.000000  0.000000  0.000000  0.000000    0.0  ...  0.000001  0.000000    0.0    0.0  0.000007  0.000007  0.000004
2016-12-31 22:00:00  0.000001    0.0  0.000001  0.000001  0.000000  0.000000    0.0  ...  0.000000  0.000001    0.0    0.0  0.000000  0.000000  0.000000
2016-12-31 23:00:00  0.000000    0.0  0.000000  0.000000  0.000000  0.000000    0.0  ...  0.000001  0.000000    0.0    0.0  0.000000  0.000000  0.000000

[8784 rows x 32 columns], 'solar':                      10666  10667  10668  10678  10705  10706  10707  10708  10709  10710  ...  10721  10723  10724  10763  10764  10765  10809  10810  10811  10812
UTC                                                                                        ...                                                                      
2016-01-01 00:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 01:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 02:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 03:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 04:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
...                    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...  ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...
2016-12-31 19:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 20:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 21:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 22:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 23:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0

[8784 rows x 25 columns]}, 'El Paso': {'wind': Empty DataFrame
Columns: []
Index: [2016-01-01 00:00:00, 2016-01-01 01:00:00, 2016-01-01 02:00:00, 2016-01-01 03:00:00, 2016-01-01 04:00:00, 2016-01-01 05:00:00, 2016-01-01 06:00:00, 2016-01-01 07:00:00, 2016-01-01 08:00:00, 2016-01-01 09:00:00, 2016-01-01 10:00:00, 2016-01-01 11:00:00, 2016-01-01 12:00:00, 2016-01-01 13:00:00, 2016-01-01 14:00:00, 2016-01-01 15:00:00, 2016-01-01 16:00:00, 2016-01-01 17:00:00, 2016-01-01 18:00:00, 2016-01-01 19:00:00, 2016-01-01 20:00:00, 2016-01-01 21:00:00, 2016-01-01 22:00:00, 2016-01-01 23:00:00, 2016-01-02 00:00:00, 2016-01-02 01:00:00, 2016-01-02 02:00:00, 2016-01-02 03:00:00, 2016-01-02 04:00:00, 2016-01-02 05:00:00, 2016-01-02 06:00:00, 2016-01-02 07:00:00, 2016-01-02 08:00:00, 2016-01-02 09:00:00, 2016-01-02 10:00:00, 2016-01-02 11:00:00, 2016-01-02 12:00:00, 2016-01-02 13:00:00, 2016-01-02 14:00:00, 2016-01-02 15:00:00, 2016-01-02 16:00:00, 2016-01-02 17:00:00, 2016-01-02 18:00:00, 2016-01-02 19:00:00, 2016-01-02 20:00:00, 2016-01-02 21:00:00, 2016-01-02 22:00:00, 2016-01-02 23:00:00, 2016-01-03 00:00:00, 2016-01-03 01:00:00, 2016-01-03 02:00:00, 2016-01-03 03:00:00, 2016-01-03 04:00:00, 2016-01-03 05:00:00, 2016-01-03 06:00:00, 2016-01-03 07:00:00, 2016-01-03 08:00:00, 2016-01-03 09:00:00, 2016-01-03 10:00:00, 2016-01-03 11:00:00, 2016-01-03 12:00:00, 2016-01-03 13:00:00, 2016-01-03 14:00:00, 2016-01-03 15:00:00, 2016-01-03 16:00:00, 2016-01-03 17:00:00, 2016-01-03 18:00:00, 2016-01-03 19:00:00, 2016-01-03 20:00:00, 2016-01-03 21:00:00, 2016-01-03 22:00:00, 2016-01-03 23:00:00, 2016-01-04 00:00:00, 2016-01-04 01:00:00, 2016-01-04 02:00:00, 2016-01-04 03:00:00, 2016-01-04 04:00:00, 2016-01-04 05:00:00, 2016-01-04 06:00:00, 2016-01-04 07:00:00, 2016-01-04 08:00:00, 2016-01-04 09:00:00, 2016-01-04 10:00:00, 2016-01-04 11:00:00, 2016-01-04 12:00:00, 2016-01-04 13:00:00, 2016-01-04 14:00:00, 2016-01-04 15:00:00, 2016-01-04 16:00:00, 2016-01-04 17:00:00, 2016-01-04 18:00:00, 2016-01-04 19:00:00, 2016-01-04 20:00:00, 2016-01-04 21:00:00, 2016-01-04 22:00:00, 2016-01-04 23:00:00, 2016-01-05 00:00:00, 2016-01-05 01:00:00, 2016-01-05 02:00:00, 2016-01-05 03:00:00, ...]

[8784 rows x 0 columns], 'solar':                      12874
UTC                       
2016-01-01 00:00:00    0.0
2016-01-01 01:00:00    0.0
2016-01-01 02:00:00    0.0
2016-01-01 03:00:00    0.0
2016-01-01 04:00:00    0.0
...                    ...
2016-12-31 19:00:00    0.0
2016-12-31 20:00:00    0.0
2016-12-31 21:00:00    0.0
2016-12-31 22:00:00    0.0
2016-12-31 23:00:00    0.0

[8784 rows x 1 columns]}, 'Bay Area': {'wind':                      11033  11034  11035  11036  11041  11042  11043  11044  11045  11046  11080  11081  11082  11083  11087  11100  11101  11122  11123  11135
UTC                                                                                                                                                            
2016-01-01 00:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 01:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 02:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 03:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-01-01 04:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
...                    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...
2016-12-31 19:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 20:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 21:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 22:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 23:00:00    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0

[8784 rows x 20 columns], 'solar':                      11066     11067
UTC                                 
2016-01-01 00:00:00    0.0  0.000000
2016-01-01 01:00:00    0.0  0.000000
2016-01-01 02:00:00    0.0  0.000000
2016-01-01 03:00:00    0.0  0.000000
2016-01-01 04:00:00    0.0  0.000000
...                    ...       ...
2016-12-31 19:00:00    0.0  0.000001
2016-12-31 20:00:00    0.0  0.000000
2016-12-31 21:00:00    0.0  0.000000
2016-12-31 22:00:00    0.0  0.000000
2016-12-31 23:00:00    0.0  0.000000

[8784 rows x 2 columns]}}

@danielolsen
Copy link
Contributor

danielolsen commented Sep 23, 2020

I may be wrong here, but it seems like calculate_curtailment_time_series_by_area() doesn't do anything curtailment-specific, it's mostly just a way to select certain plant_ids from a dict of time series dataframes and provide a nested output dict of dataframes. If so, maybe this function (or part of this function) should be renamed and should live in analyze/helpers.py.

So to get the same results we'd do something like:

curtailment = calculate_curtailment_time_series(scenario, resources)
curtailment_by_resource_area = {r: aggregate_by_area(ts, grid) for r, ts in curtailment.items()} #new function
curtailment_by_area_resource = #some fancy list comprehension to go from [resource][area] to [area][resource] nesting

Or maybe we want to refactor calculate_curtailment_time_series() to return a flat dataframe with all the plant_ids from the selected resources, and then have a helper function to aggregate this time series by resource (to get the current function return, when desired) and a different helper function to aggregate by [area][resource]. Either way I think the dictionary nesting part of this should be generalized out of curtailment.py

@rouille
Copy link
Collaborator Author

rouille commented Sep 24, 2020

I may be wrong here, but it seems like calculate_curtailment_time_series_by_area() doesn't do anything curtailment-specific, it's mostly just a way to select certain plant_ids from a dict of time series dataframes and provide a nested output dict of dataframes. If so, maybe this function (or part of this function) should be renamed and should live in analyze/helpers.py.

So to get the same results we'd do something like:

curtailment = calculate_curtailment_time_series(scenario, resources)
curtailment_by_resource_area = {r: aggregate_by_area(ts, grid) for r, ts in curtailment.items()} #new function
curtailment_by_area_resource = #some fancy list comprehension to go from [resource][area] to [area][resource] nesting

Or maybe we want to refactor calculate_curtailment_time_series() to return a flat dataframe with all the plant_ids from the selected resources, and then have a helper function to aggregate this time series by resource (to get the current function return, when desired) and a different helper function to aggregate by [area][resource]. Either way I think the dictionary nesting part of this should be generalized out of curtailment.py

I like the idea. I will work on it.

@rouille rouille force-pushed the ben/curtailment branch 2 times, most recently from bd0f53d to 1626aae Compare September 24, 2020 17:04
@rouille rouille force-pushed the ben/curtailment branch 3 times, most recently from 2b59b47 to bd00a2c Compare September 28, 2020 22:34
Copy link
Contributor

@danielolsen danielolsen left a comment

Choose a reason for hiding this comment

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

The new helpers functions are great, thank you for going through the work to refactor my curtailment code to be more generalizable for future features.

@rouille
Copy link
Collaborator Author

rouille commented Oct 1, 2020

The new helpers functions are great, thank you for going through the work to refactor my curtailment code to be more generalizable for future features.

We will use them to calculate the net demand and the PG. Then the plotting should be straightforward for any pair area-resource

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@rouille rouille force-pushed the ben/curtailment branch 2 times, most recently from 379a8e2 to 5756d20 Compare October 1, 2020 18:16
@rouille rouille merged commit d60c8b7 into develop Oct 1, 2020
@rouille rouille deleted the ben/curtailment branch October 1, 2020 18:22
@ahurli ahurli mentioned this pull request Mar 16, 2021
@rouille rouille changed the title Ben/curtailment Aggregate curtailment time series by area Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants