for i in TEMP_hycom: if i > 0: Temp_hycom.append(i) # get rid of bad data modtemp_i = [modtemp_i_roms, modtemp_i_fvcom, modtemp_i_hycom] TEMP = [TEMP_roms, TEMP_fvcom, Temp_hycom] temp_max, temp_min = [], [] for i in range(len(TEMP)): MAX = np.amax(TEMP[i]) MIN = np.amin(TEMP[i]) temp_max.append(MAX) temp_min.append(MIN) # let three pictures use one legend MODEL = ["ROMS", "FVCOM", "HYCOM"] fig = plt.figure() ax = fig.add_subplot(111) draw_basemap(fig, ax, lonsize, latsize) # plt.scatter(LON_roms,LAT_roms) fig = plt.figure() for i in range(len(modtemp_i)): ax = fig.add_subplot(1, 3, i + 1) CS = ax.contourf( dis_i, dep_i, modtemp_i[i], np.arange(int(min(temp_min)), int(max(temp_max)) + 2, temp_interval), cmap=plt.cm.rainbow, vmax=modtemp_i[i].max(), vmin=modtemp_i[i].min(), ) # +2 wants to make range of colorbar bigger than range of temperature ax.plot(distance, H_roms) plt.ylim([int(max(dep_i)) + 2, int(min(dep_i)) - 2])
import pandas as pd import numpy as np import matplotlib.pyplot as plt from my_modules import draw_basemap ##################################################### option1=input('please input which model you want to plot(ROMS or FVCOM):') if option1=='ROMS': url='http://tds.marine.rutgers.edu:8080/thredds/dodsC/roms/espresso/2009_da/his' nc=netCDF4.Dataset(url) lon=nc.variables['lon_rho'][:] lat=nc.variables['lat_rho'][:] #lat,lon lonsize=[np.amin(lon),np.amax(lon)] latsize=[np.amin(lat),np.amax(lat)] #ROMS range fig=plt.figure() ax=fig.add_subplot(111) draw_basemap(fig,ax,lonsize,latsize) for i in range(len(lon)): plt.plot([lon[i][0], lon[i][129]], [lat[i][0], lat[i][129]],color='r') for i in range(len(lon[0])): plt.plot([lon[0][i], lon[81][i]], [lat[0][i], lat[81][i]],color='r') #plot grid plt.title('ROMS EXPRESSO',fontsize=25) if option1=='FVCOM': option2=input('please input which area you want to plot(GOM3 or MASSBAY):') if option2=='GOM3': url='http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3/mean' nc=netCDF4.Dataset(url) lon=nc.variables['lon'][:] lat=nc.variables['lat'][:] #lat,lon nbsn=nc.variables['nbsn'][:] #nodes surrounding each node lonsize=[np.amin(lon),np.amax(lon)] latsize=[np.amin(lat),np.amax(lat)]
import pandas as pd import numpy as np import matplotlib.pyplot as plt from my_modules import draw_basemap ##################################################### option1 = input('please input which model you want to plot(ROMS or FVCOM):') if option1 == 'ROMS': url = 'http://tds.marine.rutgers.edu:8080/thredds/dodsC/roms/espresso/2009_da/his' nc = netCDF4.Dataset(url) lon = nc.variables['lon_rho'][:] lat = nc.variables['lat_rho'][:] #lat,lon lonsize = [np.amin(lon), np.amax(lon)] latsize = [np.amin(lat), np.amax(lat)] #ROMS range fig = plt.figure() ax = fig.add_subplot(111) draw_basemap(fig, ax, lonsize, latsize) for i in range(len(lon)): plt.plot([lon[i][0], lon[i][129]], [lat[i][0], lat[i][129]], color='r') for i in range(len(lon[0])): plt.plot([lon[0][i], lon[81][i]], [lat[0][i], lat[81][i]], color='r') #plot grid plt.title('ROMS EXPRESSO', fontsize=25) if option1 == 'FVCOM': option2 = input( 'please input which area you want to plot(GOM3 or MASSBAY):') if option2 == 'GOM3': url = 'http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3/mean' nc = netCDF4.Dataset(url) lon = nc.variables['lon'][:] lat = nc.variables['lat'][:] #lat,lon nbsn = nc.variables['nbsn'][:] #nodes surrounding each node
for i in TEMP_hycom: if i > 0: Temp_hycom.append(i) #get rid of bad data modtemp_i = [modtemp_i_roms, modtemp_i_fvcom, modtemp_i_hycom] TEMP = [TEMP_roms, TEMP_fvcom, Temp_hycom] temp_max, temp_min = [], [] for i in range(len(TEMP)): MAX = np.amax(TEMP[i]) MIN = np.amin(TEMP[i]) temp_max.append(MAX) temp_min.append(MIN) #let three pictures use one legend MODEL = ['ROMS', 'FVCOM', 'HYCOM'] fig = plt.figure() ax = fig.add_subplot(111) draw_basemap(fig, ax, lonsize, latsize) #plt.scatter(LON_roms,LAT_roms) fig = plt.figure() for i in range(len(modtemp_i)): ax = fig.add_subplot(1, 3, i + 1) CS = ax.contourf( dis_i, dep_i, modtemp_i[i], np.arange(int(min(temp_min)), int(max(temp_max)) + 2, temp_interval), cmap=plt.cm.rainbow, vmax=modtemp_i[i].max(), vmin=modtemp_i[i].min() ) #+2 wants to make range of colorbar bigger than range of temperature ax.plot(distance, H_roms)