latc = nc.variables['latc'][:] lonc = nc.variables['lonc'][:] time=nc.variables['time'][:] Dist=[] for i in range(len(lons[:])): Dist.append(DIST(lons[i],lats[i],alon,alat)) index_nearest=np.argmin(Dist) layer=0 u = nc.variables['u'][:,layer,index_nearest] v = nc.variables['v'][:,layer,index_nearest] T=[] for i in range(len(time)): t=datetime.datetime(1858,11,17)+datetime.timedelta(days=int(time[i]))+datetime.timedelta(seconds=int(time[i]%1*24*3600)) t=gmt_to_loc(t) T.append(t) q = stick_plot(T, u, v) maxvel =np.sqrt(np.max(abs(u))*np.max(abs(u))+np.max(abs(v))*np.max(abs(v))) qk = plt.quiverkey(q, 0.1, 0.85, maxvel,"%s m/s$^{-2}$" % round(maxvel,2),labelpos='W', coordinates='axes') plt.xlabel('Time(month/day)',fontsize=20) plt.title('Loc:'+str(round(alon,1))+','+str(round(alat,1))+',current',fontsize=20) plt.savefig('/var/www/html/ioos/sf/fig/'+method+'.png') except: nc1='Model does`t work now' if method=='Current': url='http://www.smast.umassd.edu:8080/thredds/dodsC/FVCOM/NECOFS/Forecasts/NECOFS_FVCOM_OCEAN_MASSBAY_FORECAST.nc' try: nc=netCDF4.Dataset(url) lons=nc.variables['lon'][:] lats=nc.variables['lat'][:] latc = nc.variables['latc'][:] lonc = nc.variables['lonc'][:]
alat)) #calculate distance index_nearest = np.argmin(Dist) #find index of nearest distance index_one, index_two = index_nearest / len( lons[0]), index_nearest % len(lons[0]) layer = 0 starttime = datetime.datetime.now(pytz.timezone("America/New_York")) T = [] for i in range(len(time)): t = datetime.datetime(2009, 6, 14, 4, 0, 0) + datetime.timedelta( days=int(time[i])) + datetime.timedelta( seconds=int(time[i] % 1 * 24 * 3600)) t = gmt_to_loc(t) T.append(t) u = nc.variables['u'][13:274, layer, index_one, index_two] v = nc.variables['v'][13:274, layer, index_one, index_two] q = stick_plot(T, u, v) maxvel = np.sqrt( np.max(abs(u)) * np.max(abs(u)) + np.max(abs(v)) * np.max(abs(v))) qk = plt.quiverkey(q, 0.1, 0.85, maxvel, "%s m/s$^{-2}$" % round(maxvel, 2), labelpos='W', coordinates='axes') plt.xlabel('Time(month/day)', fontsize=20) plt.title('Location:' + str(alon) + ',' + str(alat) + ',current', fontsize=20) plt.savefig('/var/www/html/ioos/sf/fig/' + method + '.png') except: nc1 = 'Model does`t work now'