/
timeseries.py
29 lines (24 loc) · 1.12 KB
/
timeseries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import makerlib
def time_series_maker(vwnd_file, uwnd_file, startdate, enddate, level, lon, lat, variable, print_vars=False, myWindow=24, running_mean=False):
try:
df = makerlib.wind_direction_df(vwnd_file=vwnd_file, uwnd_file=uwnd_file, startdate=startdate, enddate=enddate,
level=level, lat=lat, lon=lon, s=False, ret=True)
except:
raise KeyboardInterrupt, 'dataframe maker has failed'
if print_vars == True:
print('valid variables: ', list(df.columns.values))
return
if running_mean == True:
try:
fig = df[variable].plot()
mw = df[variable].rolling(window=myWindow,center=True).mean()
mw.plot(style='-r', label = "{0}hr Moving Window".format(myWindow))
return fig
except:
raise KeyboardInterrupt, 'enter valid variable from list: {0})'.format(list(df.columns.values))
else:
try:
fig = df[variable].plot()
return fig
except:
raise KeyboardInterrupt, 'enter valid variable from list: {0})'.format(list(df.columns.values))