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

Feature: Energy ratio polar plots and wind speed distributions #72

Merged
merged 12 commits into from
Mar 16, 2023

Conversation

Bartdoekemeijer
Copy link
Collaborator

Feature or improvement description
This PR adds two useful functionalities to the energy ratio plotting library:

  1. The possibility for polar plots. This is based on an article by K. Gunn, "Improvements to the Eddy Viscosity Wind Turbine Wake Model", where the power ratios are plotted over a polar coordinate system.
  2. The plotting of the wind speed bins in the energy ratio bin plots. In the current plots, all wind speed bin counts are thrown on a single pile and then plotted. It would be extremely insightful to also see the wind speed distribution within each energy ratio. We do this now. This immediately makes the bottom plot better represent the actual wind conditions.

Combining (1) and (2) turns the bin count plot into a proper wind rose plot. Here's an example from the flasc_cookiecutter_template repository with the new functionality:
image

image

Related issue, if one exists
None.

Impacted areas of the software
Energy ratio classes and energy ratio visualization classes. No fundamental changes in how energy ratios are calculated or used.

Additional supporting information
N/A.

Test results, if applicable

@Bartdoekemeijer Bartdoekemeijer added the enhancement An improvement of an existing feature label Mar 7, 2023
@misi9170
Copy link
Collaborator

misi9170 commented Mar 8, 2023

@Bartdoekemeijer nice! What version of matplotlib are you running? I found that I needed to update so that ax.legend() would accept the "ncols" keyword argument, and once updated, I found that ax.grid() no longer accepted the "b" keyword argument (this seems to have been replaced with "visible"). I have gone ahead and changed the "b" to "visible" and committed to your branch. This seems to run fine for me now with the latest matplotlib (3.7.1). (I was on 3.5.3 before, an the "ncols" keyword argument was failing).

We don't specify an exact version for matplotlib in the setup/requirements, which to me is fine---users should just grab the latest.

@misi9170
Copy link
Collaborator

misi9170 commented Mar 8, 2023

@Bartdoekemeijer @paulf81 I see that there is now a merge conflict due to fig no longer being passed out from vis.plot()---Bart, are you fine with also removing the plt.gcf() return from vis.plot()? I'll let you manage the conflict, but I'll approve now anyway.

@paulf81
Copy link
Collaborator

paulf81 commented Mar 10, 2023

This is really cool @Bartdoekemeijer thanks for pushing this up! I downloaded the code and ran the two modified examples and those looked nice (following upgrading matplotlib like Misha, maybe we should boost the requirement?)

Sorry about the merge conflict! I can help with that if you like. Then also, does the example wake_steering_example.py work for you? I'm getting an error on this one thinking it could be to do with the new bar plots per wind speed?

Then final comment, when we plot two dfs, do you think we should still have side-by-side bars as an option to show balancing?

@Bartdoekemeijer
Copy link
Collaborator Author

Thanks for the feedback @misi9170 @paulf81! I have updated the requirements to use at least my version of matplotlib>=3.6.3 and removed plt.gcf() from the function return statement and now to only return the axarr variable. Also, I don't have any issues with the wake steering examples in flasc, and there are no wake steering examples in the public flasc_cookiecutter_template repo. Which example are you refering to @paulf81?

@Bartdoekemeijer
Copy link
Collaborator Author

Then final comment, when we plot two dfs, do you think we should still have side-by-side bars as an option to show balancing?

That function still exists. The thing now is that it reduces to single bars if the two underlying distributions are the same. I think keeping it makes sense because it can give a good insight into the underlying distributions.

Also, I merged the latest develop branch and things should be good to merge now, if you all agree.

@paulf81
Copy link
Collaborator

paulf81 commented Mar 10, 2023

HI @Bartdoekemeijer when I try running: examples/energy_ratio/wake_steering_example.py

I get an error:

ValueError: shape mismatch: objects cannot be broadcast to a single shape. Mismatch is between arg 0 with shape (29,) and arg 1 with shape (20,).

@Bartdoekemeijer
Copy link
Collaborator Author

@paulf81 good catch, OK this should do it now! I do wonder how to deal with the bar plots when using superimpose=True, because I think they will be plotted on top of one another currently, but that's a logical result of using superimpose=True I guess.

@paulf81
Copy link
Collaborator

paulf81 commented Mar 14, 2023

hi @Bartdoekemeijer it runs for me now, thanks! So looking at this plot:

image

What if we mapped which df each bar belonged to a color, and then split wind speeds on alpha? Then maybe we could have it both ways?

@Bartdoekemeijer
Copy link
Collaborator Author

Bartdoekemeijer commented Mar 16, 2023

@paulf81 how about this, using colors to correspond the energy ratios to the bar plots and using hatching and transparency to distinguish between wind speed bins?

image

@Bartdoekemeijer
Copy link
Collaborator Author

And for the wake steering example, it becomes:
image

@paulf81
Copy link
Collaborator

paulf81 commented Mar 16, 2023

I think it's great! Thank you @Bartdoekemeijer !! @misi9170 good for you if I merge?

@misi9170
Copy link
Collaborator

@paulf81 yes, go for it

@Bartdoekemeijer
Copy link
Collaborator Author

Hold on. I still have to push up these actual commits!

@misi9170
Copy link
Collaborator

@Bartdoekemeijer haha oops, thanks

@Bartdoekemeijer
Copy link
Collaborator Author

OK good to go now, I think! :)

@misi9170 misi9170 merged commit 602431c into NREL:develop Mar 16, 2023
@Bartdoekemeijer Bartdoekemeijer deleted the feature/energy_ratio_polarplot branch March 17, 2023 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants