-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_uvwndts_csv_sctr_fltr.py
More file actions
98 lines (76 loc) · 2.41 KB
/
plot_uvwndts_csv_sctr_fltr.py
File metadata and controls
98 lines (76 loc) · 2.41 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import csv
import datetime
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.dates import HourLocator, DayLocator, DateFormatter
from datetime import datetime
dt,uw,vw = [],[],[]
dt1,uw1,vw1 = [],[],[]
msk_uw, msk_vw = [],[]
msk_uw1,msk_vw1= [],[]
#csv_reader = csv.reader(open('ascat_sort_20150330.csv'), delimiter='\t')
#columns = list(zip(*csv_reader))
#print columns
#col_2 = [x[1] for x in csv_reader]
#print x
#############################################
def han_smoother(inx,window_len=30):
x = np.ma.masked_invalid(inx)
msk = np.ma.getmask(x)
s = x * 0.0
sz = s.size
w=np.hanning(window_len)
for i in np.arange(sz):
st = max([0,i-window_len/2])
stcor=(window_len/2)-min([window_len/2,i])+1
en = min([sz-1, st+window_len-stcor])
wst=stcor-1
wen=min([window_len/2,sz-i])+(window_len/2 - 1)
#print(st,en,wst,wen)
#print(st,en,en-st)
if (np.isfinite(inx[i])):
crms = x[st:en]
cmsk = np.ma.getmask(crms)
cwin = w[wst:wen]
#print(cmsk,crms,cwin)
cwin = np.ma.array(cwin,mask=cmsk)
cwin = cwin/cwin.sum()
for cw,rs in zip(cwin,crms):
if (np.isfinite(rs)):
s[i] = s[i] + cw*rs
else:
s[i] = float('NaN')
return s
########################################
file = open('asct_sort_201503.csv','rU')
for line in file:
cells = line.split( "\t" )
dt.append((cells[0]))
uw.append((cells[1]))
vw.append((cells[2]))
file.close()
file1 = open('rsct_sort_201503.csv','rU')
for line1 in file1:
cells1 = line1.split( "\t" )
dt1.append((cells1[0]))
uw1.append((cells1[1]))
vw1.append((cells1[2]))
file1.close()
#print dt1, uw1
uw_x = np.array(uw,dtype=float)
uw1_x = np.array(uw1,dtype=float)
vw_x = np.array(vw,dtype=float)
vw1_x = np.array(vw1,dtype=float)
win_len = 60
ham_uw = han_smoother(uw_x, window_len=win_len)
ham_uw1 = han_smoother(uw1_x, window_len=win_len)
dt_time = [datetime.strptime(tim_temp,'%Y%m%d%H%M') for tim_temp in dt]
#print dt_time
plt.scatter(ham_uw,ham_uw1, color = 'blue',alpha=0.5 )
plt.plot([-10,10], [-10,10], color='black', alpha=0.5, linestyle='--')
plt.axis([-10,10,-10,10])
plt.title('UWind Scatter plot Mar 2015')
plt.xlabel('Ascat:u_290')
plt.ylabel('Rscat:u_285')
#plt.locator_params(axis='x', nticks=30)
plt.show()