-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_speed_csv_density_sctr.py
More file actions
68 lines (50 loc) · 1.63 KB
/
plot_speed_csv_density_sctr.py
File metadata and controls
68 lines (50 loc) · 1.63 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
import csv
import math
import datetime
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import gaussian_kde
from matplotlib.dates import HourLocator, DayLocator, DateFormatter
from datetime import datetime
dt,uw,vw = [],[],[]
dt1,uw1,vw1 = [],[],[]
speed_x,speed1_x = [],[]
file = open('201503/asct_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('201503/rsct_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)
speed_x = ((uw_x)**2+(vw_x)**2)**0.5
speed1_x = ((uw1_x)**2+(vw1_x)**2)**0.5
# Calculate the point density
xy = np.vstack([speed_x,speed1_x])
z = gaussian_kde(xy)(xy)
# Sort the points by density, so that the densest points are plotted last
idx = z.argsort()
speed_x, speed1_x, z = speed_x[idx], speed1_x[idx], z[idx]
dt_time = [datetime.strptime(tim_temp,'%Y%m%d%H%M') for tim_temp in dt]
#print dt_time
plt.scatter(speed_x, speed1_x, c=z, s=50, edgecolor='')
plt.plot([0,20], [0,20], color='black', linestyle='--')
plt.plot(np.unique(speed_x),np.poly1d(np.polyfit(speed_x,speed1_x,1))(np.unique(speed_x)), color='black',linewidth=1.0 )
plt.axis([0,20,0,20])
plt.colorbar()
plt.title('SPEED Scatter plot May 2015')
plt.xlabel('Ascat:speed_290')
plt.ylabel('Rscat:speed_285')
#plt.locator_params(axis='x', nticks=30)
plt.show()