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

Use transformed grid in scaling procedure #261

Merged
merged 3 commits into from
Aug 21, 2020
Merged

Use transformed grid in scaling procedure #261

merged 3 commits into from
Aug 21, 2020

Conversation

rouille
Copy link
Collaborator

@rouille rouille commented Aug 21, 2020

Purpose

Fix bug discussed in issue (#260)

What is the code doing?

Use the transformed grid in place of the base grid when retrieving the plant id of a given type in a given zone_id. New plants that are added to the network must be removed from the query since those are not in the base profile that will be scaled.

I have also remove 2 variables that were unnecessary in test_transform_profile.py.

Time estimate

30 min. I would say it is the time it takes to understand the issue raised in #260

Test

All tests pass. Also, we are now able to retrieve the solar profile of scenario 462 (see issue #260)

Python 3.8.3 (default, Jul 17 2020, 11:03:54) 
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from powersimdata.scenario.scenario import Scenario
>>> s = Scenario("462")
SCENARIO: base | USABase_2016_new_HVDC_2

--> State
analyze
--> Loading grid
Loading bus
Loading plant
Loading heat_rate_curve
Loading gencost_before
Loading gencost_after
Loading branch
Loading dcline
Loading sub
Loading bus2sub
--> Loading ct
>>> s.state.get_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 solar
                        375       376       390       391       403       404       405       440    ...  13719  13720  13721  13722  13723  13724  13725  13726
UTC                                                                                                  ...                                                        
2016-01-01 00:00:00  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  ...    0.0    0.0    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.000000  0.000000  0.000000  0.000000  0.000000  ...    0.0    0.0    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.000000  0.000000  0.000000  0.000000  0.000000  ...    0.0    0.0    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.000000  0.000000  0.000000  0.000000  0.000000  ...    0.0    0.0    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.000000  0.000000  0.000000  0.000000  0.000000  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
...                       ...       ...       ...       ...       ...       ...       ...       ...  ...    ...    ...    ...    ...    ...    ...    ...    ...
2016-12-31 19:00:00  1.822070  1.822070  1.240034  1.116202  1.029190  1.029190  1.029190  0.425183  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 20:00:00  0.794502  0.794502  0.476513  0.428928  0.330236  0.330236  0.330236  0.111934  ...    0.0    0.0    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.000000  0.000000  0.000000  0.000000  0.000000  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0
2016-12-31 22:00:00  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  ...    0.0    0.0    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.000000  0.000000  0.000000  0.000000  0.000000  ...    0.0    0.0    0.0    0.0    0.0    0.0    0.0    0.0

[8784 rows x 1083 columns]
>>> 

@rouille rouille added the bug Something isn't working label Aug 21, 2020
@rouille rouille added this to the WTT90s milestone Aug 21, 2020
@rouille rouille linked an issue Aug 21, 2020 that may be closed by this pull request
@rouille rouille self-assigned this Aug 21, 2020
@@ -41,7 +44,7 @@ def _get_renewable_profile(self, resource):
if not bool(self.ct):
return power_output
else:
if "new_plant" in self.ct.keys():
Copy link
Collaborator

Choose a reason for hiding this comment

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

So here it is possible that "new_plant" exists in the keys but it is an empty dict?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No it is not possible. If there is a new_plant key then the value is a list of dict enclosing the information of the new plants. The list can have a single element, i.e., one new plant. Example:

>>> from powersimdata.input.change_table import ChangeTable
>>> from powersimdata.input.grid import Grid
>>> grid = Grid(["USA"])
Reading bus.csv
Reading plant.csv
Reading gencost.csv
Reading branch.csv
Reading dcline.csv
Reading sub.csv
Reading bus2sub.csv
Reading zone.csv
>>> ct = ChangeTable(grid)
>>> new_plant = [{"type": "hydro", "bus_id": 3001001, "Pmin": 60, "Pmax": 85}]
>>> ct.add_plant(new_plant)
>>> ct.ct
{'new_plant': [{'type': 'hydro', 'bus_id': 3001001, 'Pmin': 60, 'Pmax': 85, 'plant_id_neighbor': 13462}]}

Copy link
Collaborator

@BainanXia BainanXia left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this.

@rouille rouille merged commit 81f020c into develop Aug 21, 2020
@rouille rouille deleted the ben/profiles branch August 21, 2020 19:09
scaled_zone = list(ct[resource]["zone_id"].keys())
scaling_factor_for_zone = list(ct[resource]["zone_id"].values())
for z, f in zip(scaled_zone, scaling_factor_for_zone):
for z, f in ct[resource]["zone_id"].items():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice

@ahurli ahurli mentioned this pull request Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Base grid should not be used when scaling profile
3 participants