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

Improve shadow price plotting module #206

Merged
merged 7 commits into from
Jan 19, 2021
Merged

Improve shadow price plotting module #206

merged 7 commits into from
Jan 19, 2021

Conversation

rouille
Copy link
Collaborator

@rouille rouille commented Jan 15, 2021

Purpose

Improve plot_shadowprice_map module. Changes are mostly related to docstring

Testing

Ran associated notebook

Where to look

  • plot_shadowprice_map:
    • format docstring
    • check type of parameters and raise errors
    • rename variable hour to date
    • change query for index in data frame and name of column
  • shadowprice_map_demo:
    • import show from bokeh.io and encapsulate the call to plot_shadowprice
    • import pandas and use pd.Timestamp to pass the timestamp of the hour to plot to plot_shadowprice

Usage Example/Visuals

shadowprice_map_demo notebook

Time estimate

10 min

@rouille rouille added the documentation Documentation related to package label Jan 15, 2021
@rouille rouille added this to the Serenity Now milestone Jan 15, 2021
@rouille rouille changed the title Ben/docstring Improve shadow price plotting module Jan 15, 2021
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.

Looks good. Thanks.

@danielolsen
Copy link
Contributor

There are a few places in the code where we use range(len(foo)), where I think enumerate would be cleaner.

@rouille
Copy link
Collaborator Author

rouille commented Jan 16, 2021

There are a few places in the code where we use range(len(foo)), where I think enumerate would be cleaner.

I have simplified the for loops. In particular the one dealing with the color bar. The only difference with the previous version is that all bins spanning more than 5 $/MWh have size 5 now. Previously it would be only set for the first and last bins, resulting eventually in oversized bins in the middle (see plot below):

Before

Screen Shot 2021-01-15 at 3 39 59 PM

After

Screen Shot 2021-01-15 at 10 27 57 PM


:param list/tuple/set/numpy.array lmp_split_points: lmp values chosen to split
the bus data
:param list x_range: the x-range for the vertical bar
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that this parameter is never actually used in this function, and the relevant info could be added to the bars dict within _construct_bus_legend, after the return from _get_bus_legend_bars_and_labels.

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 I saw that. Same thing with bar_length_sum, it is equal to max(bars.values) and hence does not need to be returned.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

color=SHADOW_PRICE_COLORS[: (len(bars) - 1)],
source=bars,
color=shadow_price_pallette[: len(bars)],
source={**{"x_range": [""]}, **bars},
Copy link
Contributor

Choose a reason for hiding this comment

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

Clever.

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.

Looks good, thanks.

@rouille rouille merged commit 0f5b89d into develop Jan 19, 2021
@rouille rouille deleted the ben/docstring branch January 19, 2021 23:28
@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
documentation Documentation related to package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants