Esempio n. 1
0
        'nearestIndex': modNearestIndex.values,
        'depth': obsDepth,
        'layer': modLayer
    },
    index=tf_index)

lonsize = [np.amin(lons), np.amax(lons)]
latsize = [np.amin(lats), np.amax(lats)]
errorNum = []
for i in range(
        9):  # just create a list with all zero to calculate error number
    j = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    errorNum.append(j)
fig = plt.figure()
ax = fig.add_subplot(111)
draw_basemap(fig, ax, lonsize, latsize)
plt.plot([lonA, lonB, lonC, lonD, lonA], [latA, latB, latC, latD, latA], 'b-')
for i in range(
        0, 75,
        10):  # Here use num smller than 81 because the last grid is too small
    plt.plot([lons[i][0], lons[i][129]], [lats[i][0], lats[i][129]], 'b--')
for i in range(0, 129, 10):
    plt.plot([lons[0][i], lons[81][i]], [lats[0][i], lats[81][i]],
             'b--')  # plot the box
r1 = range(0, 81, 10)
r2 = range(0, 129, 10)
nearestIndex = []
'''
for i in data.index:
    diff = np.array(data['obstemp'][i]) - np.array(data['modtemp'][i])
    indx = np.where(abs(diff)>criteria)[0]
Esempio n. 2
0
    161301,
    161304,
    172179,
    172188,
    175938,
    175932,
    175936,
    175940
]  #tu_102

lonsize = [-79, -69]  #tu99
latsize = [35, 42]  #tu199
obsdata = pd.read_csv(path1)  # has both observed and modeled profiles
obstime = pd.Series(
    (datetime.strptime(x, '%Y-%m-%d %H:%M:%S') for x in obsdata['datetime']))
obsLat = obsdata['lat']
obsLon = obsdata['lon']
obsturtle_id = obsdata['vessel_num']
ids = obsturtle_id.unique()  # this is the interest turtle id

fig = plt.figure()
ax = fig.add_subplot(111)

plt.scatter(lon, lat, s=15, linewidths=None)  #
draw_basemap(fig, ax, lonsize, latsize, interval_lon=2, interval_lat=2)

plt.title(
    'ship_scatterplot')  #('%s profiles(%s~%s)'% (e,obsTime[0],obsTime[-1]))
plt.legend(loc='lower right', ncol=2, fontsize='xx-small')
plt.savefig(path2 + 'ship_ScatterPlot.png', dpi=200)
Esempio n. 3
0
    if depthBottom[i]>200:
        depthBottom[i]=200
'''
lonsize = [-79.5, -64]
latsize = [33, 46]
#lonsize = [np.amin(lonGoodCTD), np.amax(lonGoodCTD)]
#latsize = [np.amin(latGoodCTD), np.amax(latGoodCTD)]
fig = plt.figure()
ax = fig.add_subplot(111)
plt.scatter(lonGoodCTD,
            latGoodCTD,
            color='g',
            s=1,
            label='Turtle(good position)')
plt.scatter(lonship, latship, color='y', s=1, label='Ship')
draw_basemap(fig, ax, lonsize, latsize, interval_lon=4, interval_lat=4)

lon_is = np.linspace(lonsize[0], lonsize[1], 150)
lat_is = np.linspace(latsize[0], latsize[1], 150)  #use for depth line
depth_i = griddata(np.array(contour_lon),
                   np.array(contour_lat),
                   np.array(contour_depth),
                   lon_is,
                   lat_is,
                   interp='linear')
cs = plt.contour(lon_is,
                 lat_is,
                 depth_i,
                 levels=[100],
                 colors='r',
                 linewidths=1.5,
Esempio n. 4
0
        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'))
                p1=Rectangle((0, 0), 1, 1, fc="blue")
            if 50<=number[q][i][j]<100:
                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='yellow'))
                p2=Rectangle((0, 0), 1, 1, fc="yellow")
            if 100<=number[q][i][j]<150:
                lat_10m=int(min(lat))+ten_minute*j
                lon_10m=int(min(lon))+ten_minute*i
from mpl_toolkits.basemap import Basemap
from turtleModule import draw_basemap
from matplotlib.mlab import griddata
import glob
import time
import csv
lonsize = [-90, 0]
latsize = [25, 70]
color = ['g', 'darkviolet', 'orange', 'b', 'hotpink', 'r', 'peru', 'lime']
fig = plt.figure()
ax = fig.add_subplot(111)
csv_list = glob.glob('*_Summary.csv')  #search csv files in current folder
print('%s csvfiles searched in total' % len(csv_list))
k = 0
for g in csv_list:  #g is a filename which is processed
    df = pd.read_csv(g)
    latmin = df['lat_min'].min()
    lonmin = df['lon_min'].min()
    latmax = df['lat_max'].max()
    lonmax = df['lon_max'].max()
    plt.plot([lonmin, lonmax, lonmax, lonmin, lonmin],
             [latmin, latmin, latmax, latmax, latmin],
             color=color[k])
    a = csv_list[k].find('_')  #locate '_'
    plt.text(lonmax, latmax, csv_list[k][0:a], size=13, color=color[k])
    k += 1
draw_basemap(fig, ax, lonsize, latsize, interval_lon=20, interval_lat=10)
plt.title('database_boundary_comparison')
plt.savefig('visualize_db_boundary.png', dpi=200)
plt.show()
Esempio n. 6
0
SEASON=[SUMMER,FALL,SPRING,WINTER]
lon_i = np.linspace(lonsize[0],lonsize[1],1000)
lat_i = np.linspace(latsize[0],latsize[1],1000)                #use for mean error,absolute mean error and rms
lon_is = np.linspace(lonsize[0],lonsize[1],100)
lat_is = np.linspace(latsize[0],latsize[1],100)                #use for depth line
depth_i = griddata(np.array(obsLons),np.array(obsLats),np.array(depthBottom),lon_is,lat_is,interp='linear')   #use for plotting 100m depth line.
for i in [0,2]:        #two seasons together plot.
    modtemps=pd.Series(modtemp[SEASON[i]],index=SEASON[i])
    obstemps=pd.Series(obstemp[SEASON[i]],index=SEASON[i])
    print(str(len(modtemps)))
    obsLon, obsLat = obsData['LON'][SEASON[i]], obsData['LAT'][SEASON[i]]
    modtemp_i = griddata(np.array(obsLon),np.array(obsLat),np.array(modtemps),lon_i,lat_i,interp='linear')
    obstemp_i = griddata(np.array(obsLon),np.array(obsLat),np.array(obstemps),lon_i,lat_i,interp='linear')  
    fig = plt.figure()
    ax = fig.add_subplot(221)              #plot model temperature 
    draw_basemap(fig, ax, lonsize, latsize)
    CS = ax.contourf(lon_i, lat_i, modtemp_i, np.arange(modtemp_i.min(),modtemp_i.max(),0.1), cmap=plt.cm.rainbow,
                  vmax=modtemp_i.max(), vmin=modtemp_i.min())
    CS1=ax.contour(lon_is, lat_is,depth_i,1,colors = 'r',linestyles=':',linewidths=2)
    cbar=plt.colorbar(CS,ticks=np.arange(int(modtemp_i.min())-1,int(modtemp_i.max())+1,2))
    cbar.ax.tick_params(labelsize=20)
    cbar.ax.set_ylabel('Temperature($^\circ$C)', fontsize=20)
    #plt.scatter(np.array(obsLon),np.array(obsLat), marker='o', c='b', s=5, zorder=10)
    ax.set_title('Model_'+season[i])
    ax.annotate('100m depth',xy=(-75.289,35.0395),xytext=(-75.0034,34.9842),arrowprops=dict(facecolor='black'))    
    
    ax1 = fig.add_subplot(222)             #plot model temperature
    draw_basemap(fig, ax1, lonsize, latsize)
    CS = ax1.contourf(lon_i, lat_i, obstemp_i, np.arange(obstemp_i.min(),obstemp_i.max(),0.1), cmap=plt.cm.rainbow,
                  vmax=obstemp_i.max(), vmin=obstemp_i.min())
    CS1=ax1.contour(lon_is, lat_is,depth_i,1,colors = 'r',linestyles=':',linewidths=2)
Esempio n. 7
0
                      np.array(obsLat),
                      np.array(modtemps),
                      lon_i,
                      lat_i,
                      interp='linear')
 obstemp_i = griddata(np.array(obsLon),
                      np.array(obsLat),
                      np.array(obstemps),
                      lon_i,
                      lat_i,
                      interp='linear')
 m_mod = modtemp_i.max()
 m_obs = obstemp_i.max()
 fig = plt.figure()
 ax = fig.add_subplot(221)  #plot model temperature
 draw_basemap(fig, ax, lonsize, latsize, fontsize=8)
 CS = ax.contourf(lon_i,
                  lat_i,
                  modtemp_i,
                  np.arange(0, m_mod, 0.1),
                  cmap=plt.cm.rainbow,
                  vmax=m_mod,
                  vmin=0)
 CS1 = ax.contour(lon_is,
                  lat_is,
                  depth_i,
                  1,
                  colors='r',
                  linestyles=':',
                  linewidths=2)
 cbar = plt.colorbar(CS, ticks=np.arange(0, int(m_mod), 3))
Esempio n. 8
0
    gps = pd.read_csv('2014_04_16_rawgps.csv')
    lonRawGPS, latRawGPS = gps['LON'], gps['LAT']
    lonsize = [np.amin(lonRawGPS), np.amax(lonRawGPS)]
    latsize = [np.amin(latRawGPS), np.amax(latRawGPS)]
    plt.plot(lonRawGPS, latRawGPS, 'b.', label='RawGPS')
    plt.title('RawGPS Positons', fontsize=FONTSIZE)
elif option == '5':
    diag = pd.read_csv('2014_04_16_rawdiag.csv')
    diagV = diag['V_MASK']
    lonGoodDiag, latGoodDiag = diag['LON'][diagV != 20], diag['LAT'][
        diagV != 20]
    # lonsize = [-81, -62]
    # latsize = [30, 42]
    lonsize = [np.amin(lonGoodDiag), -25]
    latsize = [np.amin(latGoodDiag), np.amax(latGoodDiag)]
    plt.plot(lonGoodDiag, latGoodDiag, 'y.', label='GoodDiag')
    plt.title('GoodDiag Positions Within the Mid-Atlantic Region',
              fontsize=FONTSIZE)
elif option == '6':
    diag = pd.read_csv('2014_04_16_rawdiag.csv')
    lonRawDiag, latRawDiag = diag['LON'], diag['LAT']
    lonsize = [np.amin(lonRawDiag), np.amax(lonRawDiag)]
    latsize = [np.amin(latRawDiag), np.amax(latRawDiag)]
    plt.plot(lonRawDiag, latRawDiag, 'ro', label='RawDiag')
    plt.title('RawDiag Positions', fontsize=FONTSIZE)
elif option == '0':
    sys.exit()
draw_basemap(fig, ax, lonsize, latsize, interval_lon=1, interval_lat=1)
plt.legend()
plt.show()
Esempio n. 9
0
    plt.title('GoodGPS Positions', fontsize=FONTSIZE)
elif option == '4':
    gps = pd.read_csv('2014_04_16_rawgps.csv')
    lonRawGPS, latRawGPS = gps['LON'], gps['LAT']
    lonsize = [np.amin(lonRawGPS), np.amax(lonRawGPS)]
    latsize = [np.amin(latRawGPS), np.amax(latRawGPS)]
    plt.plot(lonRawGPS, latRawGPS, 'b.', label='RawGPS')
    plt.title('RawGPS Positons', fontsize=FONTSIZE)
elif option == '5':
    diag = pd.read_csv('2014_04_16_rawdiag.csv')
    diagV = diag['V_MASK']
    lonGoodDiag, latGoodDiag = diag['LON'][diagV!=20], diag['LAT'][diagV!=20]
    # lonsize = [-81, -62]
    # latsize = [30, 42]
    lonsize = [np.amin(lonGoodDiag), -25]
    latsize = [np.amin(latGoodDiag), np.amax(latGoodDiag)]
    plt.plot(lonGoodDiag, latGoodDiag, 'y.', label='GoodDiag')
    plt.title('GoodDiag Positions Within the Mid-Atlantic Region', fontsize=FONTSIZE)
elif option == '6':
    diag = pd.read_csv('2014_04_16_rawdiag.csv')
    lonRawDiag, latRawDiag = diag['LON'], diag['LAT']
    lonsize = [np.amin(lonRawDiag), np.amax(lonRawDiag)]
    latsize = [np.amin(latRawDiag), np.amax(latRawDiag)]
    plt.plot(lonRawDiag, latRawDiag, 'ro', label='RawDiag')
    plt.title('RawDiag Positions', fontsize=FONTSIZE)
elif option=='0':
    sys.exit()
draw_basemap(fig, ax, lonsize, latsize, interval_lon=1, interval_lat=1)
plt.legend()
plt.show()