-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: powerflow snapshot figure #241
Conversation
Should we add the loadzone_centers.csv file to the data folder and rename it something like loadzone_center_usa_tamu_model.csv? |
That's a good idea. Default behavior remains the same (don't plot), but we have these data available if the user wants to use them? |
In fact the data frame could be part of the |
@danielolsen @rouille I would suggest we handle the csvs in the same way as we do in the shortfall plot, i.e. make the plot function taking a dataframe as inputs and use the csv file as an example input in the demo notebook. The current demand center csv is generated by my simple back of envelope algorithm with many manual adjustments and should not be tied to the |
Demo locations and a script are added. |
|
||
:param bokeh.plotting.figure.Figure bokeh_figure: figure to plot arrows onto. | ||
:param pandas.DataFrame branch: data frame containing: | ||
'pf', 'dist', 'arrow_size', 'from_x', 'from_y', 'to_x', 'to_y'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add here that :func:postreise.plot.projection_helpers.project_branch
can be used to obtain the coordinates of a branch from its (lat, lon).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
"""Plot a snapshot of powerflow. | ||
|
||
:param powersimdata.scenario.scenario.Scenario scenario: scenario to plot. | ||
:param str hour: interval to use for snapshot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other plotting routines, we pass a pandas.Timestamp/numpy.datetime64/datetime.datetime
as hour to avoid any issue related to weird string formatting when locating the indices. So instead of passing "2016-11-02 22:00:00",
, the user would pass pd.Timestamp(2016, 11, 2, 22)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if hour
is a pandas.Timestamp/numpy.datetime64/datetime.datetime
then later you can use _check_date_range_in_scenario
to make sure the query hour is in the scenario
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
:param tuple(float, float) x_range: x range to zoom plot to (EPSG:3857). | ||
:param tuple(float, float) y_range: y range to zoom plot to (EPSG:3857). | ||
:param int/str legend_font_size: size to display legend specified as e.g. 12/'12pt'. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check that the scnario is in analyze state here using _check_scenario_is_in_analyze_state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice. You are now a bokeh expert, congratulations!
3c7289f
to
0bdd128
Compare
0bdd128
to
ed313cf
Compare
Purpose
Add plot of powerflow snapshot to the codebase.
What the code is doing
plot_powerflow_snapshot
is the main function,aggregate_plant_generation
andplot_arrows
are helper functions.Testing
Tested against the notebooks that @victoriahunt used to generate figures for the Macro Grid report, the results are nearly identical (small differences in plot order, some line thicknesses, etc.). I figure that those small details can be ironed out in parallel with the main code review.
Usage Example/Visuals
Using a CSV of demand center locations, we can reproduce the USA powerflow snapshots with e.g.:
Original notebook:
Reproduction:
To reproduce the Texas figure, which features a zoomed-in area, different scalings, and four arrows per DC line:
Original notebook:
Reproduction:
Time estimate
30 minutes. By line count, it's a bit heavier than we'd usually like for a PR, but a lot of that is due to documentation and code formatting. The code itself is fairly straightforward I think.