Home > Software design >  Plotting Windrose from csv
Plotting Windrose from csv

Time:02-16

I would like to plot a windrose from data in .csv file. From the Windrose documentation, it looks like I need the wind speed, wind direction, and date as index column (csv here).

I tried multiple ways around it but always run into errors. The error I have now: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Should I just leave out the index column or what would be the best option to plot a windrose from csv?

from windrose import WindroseAxes
from matplotlib import pyplot as plt
import matplotlib.cm as cm
import numpy as np
import pandas as pd
from windrose import plot_windrose

df = pd.read_csv("Wind2.csv",index_col='Date', names = ["Date", "speed", "direction"], sep=";")

ws = df["speed"].values
wd = df["direction"].values

plot_windrose(df, kind='contour', bins=np.arange(0.01,8,1), cmap=cm.hot, lw=3)
plot.show()

CodePudding user response:

You have missing data - for instance, in line 182970, you're missing speed data.

Try manually filtering or filling in the data, or try using pandas' filter function to remove the offending lines.

  • Related