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

Changes to AnalyzePG #40

Merged
merged 10 commits into from
Nov 5, 2019
Merged

Changes to AnalyzePG #40

merged 10 commits into from
Nov 5, 2019

Conversation

rouille
Copy link
Collaborator

@rouille rouille commented Oct 28, 2019

  • Storage is added to stack and chart plots.
  • Solar and wind curtailments are added to stack plot (from @dmuldrew).
  • Mean curtailment is added to curtailment plot (from @dmuldrew).

Changes can be seen running the following code:

from powersimdata.scenario.scenario import Scenario
from postreise.plot.analyze_pg import AnalyzePG as apg

s = Scenario('160')
s.state.print_scenario_info()
s.state.print_infeasibilities()

# CHART
chart = apg(s,
            (s.info['start_date'], s.info['end_date'], 'utc', 'H'),
            ['Washington', 'Oregon', 'California', 'Nevada', 'Arizona', 'Utah',
             'New Mexico Western', 'Colorado', 'Wyoming', 'Idaho',
             'Montana Western', 'El Paso', 'Western'],
            ['nuclear', 'hydro', 'coal', 'ng', 'solar', 'wind', 'geothermal', 'storage'],
            'chart', normalize=False)
chart.get_plot(save=False)

# GENERATION
stack = apg(s,
            ('2016-04-23 00:00:00', '2016-04-28 23:00:00', 'local', 'H'),
            ['California', 'Western', 'Wyoming'],
            ['nuclear', 'hydro', 'coal', 'ng', 'solar', 'wind', 'geothermal', 'storage'],
            'stacked', normalize=False)
stack.get_plot(save=False)

# CURTAILMENT
curtailment = apg(s,
                  (s.info['start_date'], s.info['end_date'], 'utc', 'W'),
                  ['California', 'Western'],
                  ['solar'],
                  'curtailment', normalize=False)
curtailment.get_plot(save=False)

@rouille rouille added the new feature Feature that is currently in progress. label Oct 28, 2019
@rouille rouille requested review from dmuldrew and kasparm October 28, 2019 23:10
@rouille rouille self-assigned this Oct 28, 2019
@merrielle merrielle self-requested a review October 29, 2019 23:19
Copy link
Collaborator

@merrielle merrielle left a comment

Choose a reason for hiding this comment

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

This looks good. I have a lot of ideas for updating the rest of the file but they're not related to the changes you're making here. If you can merge this into develop soon then I can start adding in the code from spot check.

By the way, I clicked "approve" because even though I had some comments the changes are very small. That means once you make the changes as long as they work you can merge without showing them to me. If I had clicked "request changes" it would mean you should show me your changes to get another round of feedback.

Anyway, as they say in the software world, ship it! 👍

:return: (*tuple*) -- date frame of PG and associated capacity for all
storage units located in zone.
"""
storage_id = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Small nitpick: could you rename this to storage_ids? I think it's easier to understand.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can but the function returns the power generated by all storage devices in zone and the corresponding total capacity.

Comment on lines +1030 to +1025
for c, bus in enumerate(self.grid.storage['gen'].bus_id.values):
if self.grid.bus.loc[bus].zone_id in self._get_zone_id(zone):
storage_id.append(c)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This method works just fine, but I think you can use a where clause here.
storage_ids = self.grid.bus.where(id in self.grid.storage.gen.bus_id & id in self._get_zone_id(zone))
I kind of fudged the table locations but I think you get the general idea.

If you're feeling rushed don't worry about figuring this out, but keep it as an idea for next time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree. I will implement this tomorrow

Comment on lines +689 to +682
ax.xaxis.set_major_locator(mdates.MonthLocator())
ax.xaxis.set_major_formatter(mdates.DateFormatter('%b'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

How does this work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure. It is from @dmuldrew. I believe it set the tick mark and tick label to month-year (e.g. Jan 2016, Feb 2016, ...)

Comment on lines 484 to 498
for t in type2label.keys():
if t == 'solar':
pg_solar = self._get_pg(zone, ['solar'])[0].sum(axis=1)
net_demand['net_demand'] = net_demand['net_demand'] - \
pg_solar
curtailment_solar = self._get_profile(zone, 'solar').sum(
axis=1).tolist() - pg_solar
pg_stack['sc'] = curtailment_solar
elif t == 'wind':
pg_wind = self._get_pg(zone, ['wind'])[0].sum(axis=1)
net_demand['net_demand'] = net_demand['net_demand'] - \
pg_wind
curtailment_wind = self._get_profile(zone, 'wind').sum(
axis=1).tolist() - pg_wind
pg_stack['wc'] = curtailment_wind
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's optimize some duplicate code here. Do you think this would work?

# Add solar and wind curtailment
for (t, key) in [('solar', 'sc'), ('wind', 'wc')]:
    if t in type2label.keys():
        pg_t = self._get_pg(zone, [t])[0].sum(axis=1)
        net_demand['net_demand'] = net_demand['net_demand'] - pg_t
        curtailment_t = self._get_profile(zone, t).sum(axis=1).tolist() - pg_t
        pg_stack[key] = curtailment_t

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes it should. I will implement it tomorrow.

Do not hesitate to make changes and commit. I would say it is preferable that you do it it now instead of merging now, then creating a new branch wit a new PR and CR.

@rouille rouille merged commit b71ed06 into develop Nov 5, 2019
@rouille rouille deleted the add_storage branch November 5, 2019 19:25
@ahurli ahurli mentioned this pull request Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Feature that is currently in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants