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

Enhancement/plant repr #248

Merged
merged 18 commits into from
Sep 2, 2023
Merged

Conversation

RHammond2
Copy link
Collaborator

This PR creates a pretty printed version of the PlantData and PlantMetaData objects, to offer a better visual representation of the data contained in each.

A snippet of the new PlantData output can be seen below.
image

And, a snippet of the new PlantMetaData output can seen below.
image

Resolves #242 for the vast majority of use cases. @ejsimley, do you think this addresses the legibility of the underlying data, or would some other rendering be more helpful? Now that I have the scaffolding set up, changing what the displayed data look like is fairly easy.

@RHammond2 RHammond2 added enhancement v3 All updates and changes for OpenOA v3 labels Jul 11, 2023
@RHammond2 RHammond2 requested a review from ejsimley July 11, 2023 23:11
@codecov-commenter
Copy link

codecov-commenter commented Jul 11, 2023

Codecov Report

Patch coverage: 20.00% and project coverage change: -1.05% ⚠️

Comparison is base (7493b96) 62.89% compared to head (16d514d) 61.85%.

Additional details and impacted files
@@              Coverage Diff               @@
##           develop_v3     #248      +/-   ##
==============================================
- Coverage       62.89%   61.85%   -1.05%     
==============================================
  Files              29       29              
  Lines            4210     4315     +105     
==============================================
+ Hits             2648     2669      +21     
- Misses           1562     1646      +84     
Files Changed Coverage Δ
openoa/plant.py 73.68% <11.94%> (-7.93%) ⬇️
openoa/schema/metadata.py 87.98% <34.21%> (-9.29%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Dynorat Dynorat requested a review from jordanperr August 3, 2023 20:34
Copy link
Collaborator

@jordanperr jordanperr left a comment

Choose a reason for hiding this comment

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

Overall I think this is a great start and think it could be merged as-is. I don't want to be too nitpicky over the information printed out of the repr, as I think what you have now is a huge improvement over the old repr, and we can always add new information and features incrementally.

  • For the PlantData repr, I aiways envisioned a list of assets in there, and even a little embedded map showing the locations of the turbines. I see that asset is supported in the code, is there any reason why the asset table was not included in the snippet in your pull request?
  • Would be great to demonstrate the new repr function in the PlantData 101 notebook: https://openoa--248.org.readthedocs.build/en/248/examples/examplesout.html#PlantData-and-PlantMetaData-101
  • Can we use pandas built-in reprs instead of using a new library (tabulate?)

from attrs import field, define
from tabulate import tabulate
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason to use an external library as opposed to Panda's own rendering? I believe they support ASCII rendering as print(df) and also support rich HTML rendering in Jupyter using display(df).

  • I think using Panda's built in rendering is preferable, as we'd reduce the number of OpenOA dependencies.
  • It would be slick, but unnecessary, to detect which environment (Jupyter notebook vs Terminal) and render HTML if possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the comments, I didn't include the full listing because it was so long, but there's no reason it couldn't be shown other than it being a snippet to highlight the change in perspective. I think it'd be easy enough to list the assets (I assume by type), so that could be included. I like the idea of a really a basic plot, but that may be difficult to get a consistent render between the terminal and a Jupyter notebook.

I fully intend to integrate it into the intro notebook once the form is more or less final.

As for tabulate, this is already a Pandas dependency for some of their rendering, and so we're not getting rid of it anytime soon, whichever way we ultimately go. The decision to use it directly, and in place of Pandas, is to have a consistent data view in a terminal and a jupyter notebook, something Pandas doesn't do well out of the box. I tried to also avoid the slick solutions because they're typically harder to maintain over time, but a quick search seems to suggest might be as simple as is_terminal = sys.stderr.isatty() and when True, just do normal pandas printing, and if False, print the text rendering.

@RHammond2
Copy link
Collaborator Author

@jordanperr, the latest update was a little tricky to manage, so I decided to add a markdown method that can be called, like the below.

plant.markdown()

PlantData

analysis_type

  • MonteCarloAEP

asset

asset_id latitude longitude elevation rated_power hub_height rotor_diameter Manufacturer Model type
R80711 48.4569 5.5847 411 2050 80 82 Senvion MM82 turbine
R80721 48.4497 5.5869 411 2050 80 82 Senvion MM82 turbine
R80736 48.4461 5.5925 411 2050 80 82 Senvion MM82 turbine
R80790 48.4536 5.5875 411 2050 80 82 Senvion MM82 turbine

scada

count mean std min 25% 50% 75% max
WROT_BlPthAngVal 417829 10.0334 23.2343 -165.31 -0.99 -0.99 0.14 120.04
WTUR_W 417829 353.609 430.367 -17.92 35.36 192.15 508.3 2051.87
WMET_HorWdSpd 417829 5.44736 2.48741 0 4.1 5.45 6.77 19.31
Va_avg 417829 0.113797 23.0327 -179.95 -5.88 -0.2 5.9 179.99
WMET_EnvTmp 417829 12.7394 7.17616 -6.26 7.3 12.52 17.47 39.89
Ya_avg 417829 179.906 93.1645 0 105.19 194.34 247.4 360
WMET_HorWdDir 417829 177.996 92.4549 0 103.65 191.47 243.75 360
energy_kwh 417829 58.9348 71.7279 -2.98667 5.89333 32.025 84.7167 341.978
WTUR_SupWh 417829 58.9348 71.7279 -2.98667 5.89333 32.025 84.7167 341.978

meter

count mean std min 25% 50% 75% max
MMTR_SupWh 105120 229.579 271.906 -8.893 27.7635 130.635 331.149 1347.18

tower

no data

status

no data

curtail

count mean std min 25% 50% 75% max
net_energy_kwh 105120 229.579 271.906 -8.893 27.7635 130.635 331.149 1347.18
IAVL_DnWh 105120 2.92777 21.5486 0 0 0 0 828.19
IAVL_ExtPwrDnWh 105120 0.161518 9.80474 0 0 0 0 1012.89

reanalysis
era5

count mean std min 25% 50% 75% max
WMETR_HorWdSpdU 187172 1.13927 4.72926 -14.9816 -2.36933 1.43596 4.61772 26.0787
WMETR_HorWdSpdV 187172 1.10765 4.39909 -12.9526 -2.33807 0.765297 4.35094 20.6916
WMETR_EnvTmp 187172 283.566 7.53883 258.218 277.955 283.392 288.874 312.173
WMETR_EnvPres 187172 97740.7 817.576 93459.1 97284.7 97790.9 98266.9 100383
ws_100m 187172 6.04099 2.7837 0.00328114 4.04821 5.80999 7.73064 26.7948
dens_100m 187172 1.19845 0.0352755 1.0707 1.17348 1.19645 1.22293 1.33056
WMETR_HorWdDir 187172 185.846 95.604 0.00191019 89.7974 206.692 255.341 359.993
WMETR_HorWdSpd 187172 6.04099 2.7837 0.00328114 4.04821 5.80999 7.73064 26.7948
WMETR_AirDen 187172 1.19842 0.0352745 1.07067 1.17344 1.19641 1.2229 1.33053

merra2

count mean std min 25% 50% 75% max
WMETR_EnvPres 195720 97824.1 826.941 93182.6 97355.5 97875.5 98361.1 100471
surface_skin_temperature 195720 282.452 8.33084 254.834 276.159 281.946 288.411 317.59
u_10 195720 1.0973 3.33816 -11.577 -1.37919 1.08179 3.25537 22.3319
v_10 195720 0.805023 3.23138 -11.7316 -1.62791 0.664757 2.99603 17.0065
WMETR_HorWdSpdU 195720 1.47187 4.7413 -15.3375 -2.04887 1.60502 4.86207 28.2489
WMETR_HorWdSpdV 195720 1.13452 4.57016 -15.3061 -2.41186 0.961586 4.53251 21.8515
WMETR_EnvTmp 195720 282.515 7.85631 255.915 276.469 282.276 288.369 311.673
temp_10m 195720 282.771 7.73835 256.412 276.764 282.62 288.595 310.308
u_850 195720 3.98599 7.92127 -30.3709 -1.09976 3.67055 8.85558 41.9465
v_850 195720 0.667629 5.89822 -25.0578 -3.14127 0.382695 4.07756 34.9646
temp_850 195720 277.566 6.39469 254.825 272.997 277.754 282.13 298.494
ws_50m 195720 6.16986 2.95847 0.0271478 4.06728 5.95081 7.86064 29.4037
dens_50m 195720 1.2042 0.0369871 1.08193 1.17673 1.20233 1.23045 1.35085
WMETR_HorWdDir 195720 187.82 95.8037 0.000978537 99.5413 209.234 256.224 359.999
WMETR_HorWdSpd 195720 6.16986 2.95847 0.0271478 4.06728 5.95081 7.86064 29.4037
WMETR_AirDen 195720 1.20417 0.036986 1.0819 1.1767 1.20229 1.23041 1.35082

The other notebook option is to print(plant), which produces a modified version of the original, seen below.
image

Copy link
Collaborator

@ejsimley ejsimley left a comment

Choose a reason for hiding this comment

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

Impressive work! The pretty printing is a really nice addition to the code. This looks good to me.

@RHammond2 RHammond2 merged commit daf42ac into NREL:develop_v3 Sep 2, 2023
4 checks passed
@RHammond2 RHammond2 deleted the enhancement/plant_repr branch September 2, 2023 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement v3 All updates and changes for OpenOA v3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants