if not indx.size: continue nearestIndex.extend([modNearestIndex[i]] * indx.size) # calculate all error data ''' for i in data.index: if data['layer'][i][0] - data['layer'][i][-1] != 0: d_each = (data['depth'][i][-1] - data['depth'][i][0]) * 1.0 / ( data['layer'][i][0] - data['layer'][i][-1]) if 36 * d_each - data['depth'][i][-1] < 10: diff = np.array(data['obstemp'][i][-1]) - np.array( data['modtemp'][i][-1]) indx = np.where(abs(diff) > criteria)[0] if not indx.size: continue nearestIndex.extend([modNearestIndex[i]] * indx.size) #calculate error data in bottom for i in nearestIndex: m = whichArea(i[0], r1) n = whichArea(i[1], r2) errorNum[m][n] += 1 m1, m2 = 34.05, 39.84 # m1, m2 are the location to put Text. n1, n2 = -75.83, -67.72 # n1, n2 are the location to put Text. for s in range(8): # a = np.arange(-75.83, -67.72, 0.631) # b = np.arange(34.05, 39.84, 0.47) a = np.arange(n1, n2, 0.631) b = np.arange(m1, m2, 0.47) for i, j, k in zip(a, b, errorNum[s]): if k > 0: print(i, j, k) plt.text(i, j, str(round(k, 1)),
for i in range(len(data)): data['datet'][i]=datetime.strptime(data['datet'][i],'%Y-%m-%d %H:%M:%S') lat_i=np.arange(int(min(lat)),int(max(lat)),ten_minute) lon_i=np.arange(int(min(lon)),int(max(lon)),ten_minute) number=[] for q in range(10): number.append([]) for i in range(len(lon_i)): j=[0]*len(lat_i) number[q].append(j) lat_n=[] lon_m=[] for i in range(len(lat)): for j in range(10): #10 is 10 years,from 2006 to 2015 if data['datet'][i].year==2006+j: n=whichArea(lat[i],lat_i) m=whichArea(lon[i],lon_i) number[j][m][n]+=1 # calculate number in 10 minute square lonsize=[min(lon),max(lon)] latsize=[min(lat),max(lat)] for q in range(len(number)): fig=plt.figure(figsize=(12,10)) ax=fig.add_subplot(111) draw_basemap(fig,ax,lonsize,latsize) for i in range(len(number[q])): for j in range(len(number[q][i])): if 0<number[q][i][j]<50: lat_10m=int(min(lat))+ten_minute*j lon_10m=int(min(lon))+ten_minute*i ax.add_patch(patches.Rectangle((lon_10m, lat_10m),ten_minute,ten_minute,color='blue'))
from turtleModule import draw_basemap, whichArea ######################################################################## one_minute = 1.0 / 60 #1.0/60 is 1 minute data = pd.read_csv('binned_td_hoey.csv') lat, lon = dm2dd(data['LATITUDE'], data['LONGITUDE']) #convert ddmm.m to dd.ddd lat_i = np.arange(min(lat), max(lat), one_minute) lon_i = np.arange(min(lon), max(lon), one_minute) number = [] for i in range(len(lon_i)): j = [0] * len(lat_i) number.append(j) lat_n = [] lon_m = [] for i in range(len(lat)): n = whichArea(lat[i], lat_i) m = whichArea(lon[i], lon_i) number[m][n] += 1 # calculate number in 1 minute square lonsize = [min(lon), max(lon)] latsize = [min(lat), max(lat)] lon_is = np.linspace(lonsize[0], lonsize[1], 1000) lat_is = np.linspace(latsize[0], latsize[1], 1000) LON, LAT, NUMBER = [], [], [] for j in range(len(lon_i)): for i in range(len(lat_i)): LON.append(lon_i[j]) LAT.append(lat_i[i]) NUMBER.append(number[j][i]) #use for griddata number_i = griddata(np.array(LON), np.array(LAT), np.array(NUMBER),
''' for a in data.index: diff = np.array(data['obstemp'][a]) - np.array(data['modtemp'][a]) indx = np.where(abs(diff)>criteria)[0] if not indx.size: continue nearestIndex.extend([modNearestIndex[a]] * indx.size) # calculate all error data ''' for i in data.index: if abs(obsDepth[i][-1]-depthBottom[i])<10: #diff<10m,wo can use the data diff = np.array(data['obstemp'][i][-1]) - np.array(data['modtemp'][i][-1]) indx = np.where(abs(diff)>criteria)[0] if not indx.size: continue nearestIndex.extend([modNearestIndex[i]] * indx.size) #calculate error data in bottom for b in nearestIndex: m = whichArea(b[0], r1) n = whichArea(b[1], r2) errorNum[m][n] += 1 #calculate error data in bottom m1, m2 = 34.05, 39.84 # m1, m2 are the location to put Text. n1, n2 = -75.83, -67.72 # n1, n2 are the location to put Text. for s in range(8): a = np.arange(n1, n2, 0.631) b = np.arange(m1, m2, 0.47) for i, j, q in zip(a, b, errorNum[s]): plt.text(i, j, str(q), color='r',multialignment='center') m1 = m1 + 0.408 m2 = m2 + 0.408 n1 = n1 - 0.45 n2 = n2 - 0.45 CS1=plt.contour(lon_i, lat_i,depth_i,1,colors = 'r') ax.annotate('100m depth',xy=(-72.0963,38.9144),xytext=(-71.5662,38.8756),arrowprops=dict(facecolor='black'))