NREL / flasc

A rich floris-driven suite for SCADA analysis
https://nrel.github.io/flasc/
BSD 3-Clause "New" or "Revised" License
32 stars 18 forks source link

Add feature to plot data with angle wrapping #8

Closed Bartdoekemeijer closed 2 years ago

Bartdoekemeijer commented 2 years ago

Add a feature that allows users to easily plot timeseries data that wraps around 0/360 deg (or 0/2 pi) without the erroneous vertical lines crossing the plot. Here is an example with a sinusoidal signal, wrapping around 0 and 360 deg:

y = 180.0 + 200.0 * np.sin(np.linspace(0.0, 10.0, 50))
y = np.remainder(y, 360.0)
t = np.arange(len(y))

fig, ax = plt.subplots()
ax.plot(t, y, color="gray", label="Raw")
ax.grid(True)
ax.set_xlabel("Time")
ax.set_ylabel("Wind direction (deg)")
plot_with_wrapping(t, y, ax=ax, high=360.0, color="orange", marker="o", label="Wrapped")
ax.legend()
ax.set_ylim([0, 360.0])
plt.show()

image

By accounting for wrapping, we can prevent sharp vertical lines that incorrectly connect data points that wrap around 360 deg.

codecov-commenter commented 2 years ago

Codecov Report

Merging #8 (c196523) into main (0710eed) will decrease coverage by 0.72%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main       #8      +/-   ##
==========================================
- Coverage   39.46%   38.74%   -0.73%     
==========================================
  Files          33       34       +1     
  Lines        3370     3433      +63     
==========================================
  Hits         1330     1330              
- Misses       2040     2103      +63     
Impacted Files Coverage Δ
flasc/visualization.py 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0710eed...c196523. Read the comment docs.