def plot_isobaths(self, ax, lims): topo = sp.loadmat('/home/rsoutelino/misc/etopo/etopo1_atlsul.mat') xb, yb, zb = topo['lon'], topo['lat'], topo['topo'] xb, yb = np.meshgrid(xb, yb) xb, yb, zb = romslab.subset(xb, yb, zb, lims) cs = ax.contour(xb, yb, -zb, [100, 200, 1000], colors='k', alpha=0.7) plt.clabel(cs, fmt='%i')
ax2 = fig.add_axes(logo_position) logofile = Image.open('logo-left.png') logo = np.asarray(logofile) im = plt.imshow(logo) ax2.set_axis_off() ################################################################################ xmin, xmax, ymin, ymax = -44, -40.5, -25, -22 lims = (xmin, xmax, ymin, ymax) m = Basemap(projection='cyl',llcrnrlat=ymin,urcrnrlat=ymax, llcrnrlon=xmin,urcrnrlon=xmax,lat_ts=0,resolution='h') topo = sp.loadmat('/home/rsoutelino/misc/etopo/etopo1_atlsul.mat') xb, yb, zb = topo['lon'], topo['lat'], topo['topo'] xb, yb = np.meshgrid(xb, yb) xb, yb, zb = subset(xb, yb, zb, xmin, xmax, ymin, ymax) filename = 'mosaico_20120919.mat' data = sp.loadmat(filename) lon, lat, sst = data['lon'], data['lat'], data['sst'] sst = mask_nans(sst, missing_value=18) f = np.where(sst < 0) sst[f] = 18 lon, lat, sst = refine(lon, lat, sst, lims, res=0.02) base = -42.097463607788086, -22.817603940087874 outA = -42.296874999999993, -24.568749999999998 outB = -42.66718749999999, -24.245312499999997 inA = -42.146874999999994, -23.237499999999997 inB = -42.254687499999996, -23.209374999999994 eddy = np.loadtxt('eddy.txt')
p1.text(ax, ay, "Mar 2005", ha="center", va="center", size=10,bbox=bbox_props) ax,ay = m(-37.2,-22); p1.text(ax, ay, "OEII ADCP-derived", ha="center", va="center", size=10,bbox=bbox_props) bbox_props = dict(boxstyle="round", fc="w", ec="0.5", alpha=0.8) ax,ay = m(-40.5,-22) p1.text(ax, ay, "a", ha="center", va="center", size=12,bbox=bbox_props) ###################################################################### # get roms velocity for day 30 of CONTROL run outname = "/home/rsoutelino/myroms/phd_run/phd15_avg.nc" roms = romslab.RomsHis(outname) lims = [-41, -34.5, -20, -12] U, V = roms.u[30, ...], roms.v[30,...] zlevs = romslab.get_depths(roms.ncfile, 0, 'temp') lon, lat, U = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], U, lims) lon, lat, V = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], V, lims) lon, lat, zlevs = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], zlevs, lims) u, v = romslab.get_hslice(50, zlevs, U), romslab.get_hslice(50, zlevs, V) u, v = mask_nans(u), mask_nans(v) u, v = np.ma.masked_where(u > 10, u), np.ma.masked_where(v > 10, v) xgi = xgi[:-10, :]; ygi = ygi[:-10, :]; u = griddata(lon.ravel(), lat.ravel(), u.ravel(), xgi, ygi) v = griddata(lon.ravel(), lat.ravel(), v.ravel(), xgi, ygi) p2 = plt.subplot(132) #m.contourf(xgi,ygi,psiob,scale,linewidth=0,alpha = 0.5); m.quiver(xgi[::g,::g], ygi[::g,::g], u[::g,::g]*s, v[::g,::g]*s, scale=10); m.contourf(xb,yb,zb,colors=('0.9'),linewidth=0);
va="center", size=10, bbox=bbox_props) bbox_props = dict(boxstyle="round", fc="w", ec="0.5", alpha=0.8) ax, ay = m(-40.5, -22) p1.text(ax, ay, "a", ha="center", va="center", size=12, bbox=bbox_props) ###################################################################### # get roms velocity for day 30 of CONTROL run outname = "/home/rsoutelino/myroms/phd_run/phd15_avg.nc" roms = romslab.RomsHis(outname) lims = [-41, -34.5, -20, -12] U, V = roms.u[30, ...], roms.v[30, ...] zlevs = romslab.get_depths(roms.ncfile, 0, 'temp') lon, lat, U = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], U, lims) lon, lat, V = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], V, lims) lon, lat, zlevs = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], zlevs, lims) u, v = romslab.get_hslice(50, zlevs, U), romslab.get_hslice(50, zlevs, V) u, v = mask_nans(u), mask_nans(v) u, v = np.ma.masked_where(u > 10, u), np.ma.masked_where(v > 10, v) xgi = xgi[:-10, :] ygi = ygi[:-10, :] u = griddata(lon.ravel(), lat.ravel(), u.ravel(), xgi, ygi) v = griddata(lon.ravel(), lat.ravel(), v.ravel(), xgi, ygi) p2 = plt.subplot(132) #m.contourf(xgi,ygi,psiob,scale,linewidth=0,alpha = 0.5); m.quiver(xgi[::g, ::g],
lonr = grd.variables['lon_rho'][:] latr = grd.variables['lat_rho'][:] latu = grd.variables['lat_u'][:] latv = grd.variables['lat_v'][:] lonu = grd.variables['lon_u'][:] lonv = grd.variables['lon_v'][:] h = grd.variables['h'][:] print ' \n' + '==> ' + ' READING CHOSEN ROMS OUTPUT NETCDF FILE ...\n' + ' ' avg = netCDF4.Dataset(roms.rundir + roms.run_name + '_avg.nc') lm, km, im, jm = avg.variables['temp'].shape tmp = avg.variables['temp'][0, 0, ...] lon, lat, tmp = subset(lonr, latr, tmp, lims[0], lims[1], lims[2], lims[3]) # AVG =============================================================== zu = get_depths(avg, grd, 0, 'u') zv = get_depths(avg, grd, 0, 'v') zt = get_depths(avg, grd, 0, 't') times = np.arange(1800, lm, 10) U = np.zeros((times.size, lon.shape[0], lon.shape[1]), dtype=np.float64) V = np.zeros((times.size, lon.shape[0], lon.shape[1]), dtype=np.float64) T = np.zeros((times.size, lon.shape[0], lon.shape[1]), dtype=np.float64) print "\n\n Slicing %s eddy, at %s m, in AVG.... may take a while.......\n\n" % ( eddy, zlev)
# METEOSAT SST ############################ pathname = "/home/rsoutelino/ieapm/eumetsat/" pattern = "20120918" filelist2 = [] # list of total files matching above pattern imagelist = [] filelist = glob.glob("*.nc") filelist.sort() for File in filelist: if pattern in File and "grb" not in File: print File filelist2.append(File) msg = MsgSST(pathname + File, File) msg.lon, msg.lat, msg.sst = romslab.subset(msg.lon, msg.lat, msg.sst, lims2) imagelist.append(msg) # Broad Area ++++++++++++++++++++++++ msg.plot_image(m1, np.arange(-90, 10, 10), np.arange(-70, 30, 10), -2, 30, [0.6, 0.12, 0.15, 0.15]) plt.savefig("figures/" + File + ".png") plt.close('all') # Zoom into Cabo Frio +++++++++++++++ msg.plot_image(m2, np.arange(-90, 10, 2), np.arange(-70, 30, 2), 16, 26, [0.13, 0.62, 0.15, 0.15]) plt.savefig("figures/zoom_" + File + ".png") plt.close('all') mosaic = Mosaic(imagelist) mosaic.plot_image(m1, np.arange(-90, 10, 10), np.arange(-70, 30, 10), -2, 30, [0.6, 0.12, 0.15, 0.15])
grid = romslab.RomsGrid(gridname) roms = romslab.RomsHis(outname) # limits for the Abrolhos, Royal-Charlotte and Ilheus Eddies lims = -40, -36, -19.5, -14.0 # lims = -40, -36, -18, -14.0 M = Basemap(projection='cyl', llcrnrlon=lims[0], urcrnrlon=lims[1], llcrnrlat=lims[2], urcrnrlat=lims[3], lat_ts=0, resolution='i') depths = 0, 400 print "\nComputing run-averaged fields =======================\n\n" lon, lat, U = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], roms.u, lims) lon, lat, V = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], roms.v, lims) lon, lat, T = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], roms.temp, lims) lon, lat, h = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], roms.h, lims) UbarS, VbarS, TbarS = U.mean(axis=0), V.mean(axis=0), T.mean(axis=0) zlevs = romslab.get_depths(roms.ncfile, 30, 'temp') lon, lat, zlevs = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], zlevs, lims) Tbar, Ubar, Vbar = [], [], [] for k in depths: aux = romslab.get_hslice(k, zlevs, TbarS) aux = mask_nans(aux) Tbar.append(aux) aux = romslab.get_hslice(k, zlevs, UbarS) aux = mask_nans(aux)
filelist = os.listdir("data") lims = (-70, 0, -60, 20) m = Basemap(projection='cyl', llcrnrlon=lims[0], urcrnrlon=lims[1], llcrnrlat=lims[2], urcrnrlat=lims[3], lat_ts=0, resolution='l') LON, LAT, SST = [], [], [] filelist2 = [] # list of total files matching above pattern filelist3 = [] # list of files inside desired area for File in filelist: if pattern in File: data = nc.Dataset("data/" + File) lon, lat = data.variables['lon'][::5], data.variables['lat'][::5] sst = data.variables['sea_surface_temperature'][::5] lon, lat, sst = romslab.subset(lon, lat, sst, lims) if lon != None: LON.append( list(lon.ravel()) ) LAT.append( list(lat.ravel()) ) SST.append( list(sst.ravel()) ) print File + " --> OK!" filelist2.append(File) filelist3.append(File) else: print File + " --> Out of Range!" filelist2.append(File) LON = np.array( list(flatten(LON)) ) LAT = np.array( list(flatten(LAT)) ) SST = np.array( list(flatten(SST)) ) - 273.5
pathname = "/home/rsoutelino/ieapm/eumetsat/" pattern = "201401" filelist2 = [] # list of total files matching above pattern imagelist = [] filelist = glob.glob("*0000*.nc") filelist.sort() for File in filelist: print File filelist2.append(File) msg = MsgSST(pathname + File, File) msg.lon, msg.lat, msg.sst = romslab.subset(msg.lon, msg.lat, msg.sst, lims) imagelist.append(msg) logo_position = [0.134, 0.6, 0.2, 0.2] msg.plot_image(m1, np.arange(-90, 10, 2), np.arange(-70, 30, 2), 17, 29, logo_position, lims) plt.savefig("upwelling_figs/" + File + ".png", dpi=90) plt.close('all') mosaic = Mosaic(imagelist) mosaic.plot_image(m1, np.arange(-90, 10, 2), np.arange(-70, 30, 2), 18, 29, logo_position, lims) plt.savefig("upwelling_figs/mosaico_%s.png" %mosaic.day, dpi=90) plt.close('all') mdict = {'lon':mosaic.lon, 'lat':mosaic.lat, 'sst':mosaic.sst} sp.savemat('mosaico_%s.mat' %mosaic.day, mdict)
# run-averaged ROMS fields ######## gridname = mainpath + "myroms/phd_run/phd15_grd.nc" outname = mainpath + "myroms/phd_run/azores_run/phd15_avg-1.nc" grid = romslab.RomsGrid(gridname) roms = romslab.RomsHis(outname) # limits for the Abrolhos, Royal-Charlotte and Ilheus Eddies lims = -40, -36, -19.5, -14.0 # lims = -40, -36, -18, -14.0 M = Basemap(projection='cyl', llcrnrlon=lims[0], urcrnrlon=lims[1], llcrnrlat=lims[2], urcrnrlat=lims[3], lat_ts=0, resolution='i') depths = 0, 400 print "\nComputing run-averaged fields =======================\n\n" lon, lat, U = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], roms.u, lims) lon, lat, V = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], roms.v, lims) lon, lat, T = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], roms.temp, lims) lon, lat, h = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], roms.h, lims) UbarS, VbarS, TbarS = U.mean(axis=0), V.mean(axis=0), T.mean(axis=0) zlevs = romslab.get_depths(roms.ncfile, 30, 'temp') lon, lat, zlevs = romslab.subset(roms.lon_rho[:], roms.lat_rho[:], zlevs, lims) Tbar, Ubar, Vbar = [],[],[] for k in depths: aux = romslab.get_hslice(k, zlevs, TbarS) aux = mask_nans(aux) Tbar.append( aux ) aux = romslab.get_hslice(k, zlevs, UbarS) aux = mask_nans(aux)
h = grd.variables['h'][:] print ' \n' + '==> ' + ' READING CHOSEN ROMS OUTPUT NETCDF FILE ...\n' + ' ' avg1 = netCDF4.Dataset(roms.rundir + roms.run_name + '_avg-1.nc') avg2 = netCDF4.Dataset(roms.rundir + roms.run_name + '_avg-2.nc') avg3 = netCDF4.Dataset(roms.rundir + roms.run_name + '_avg-3.nc') lm1, km, im, jm = avg1.variables['temp'].shape lm2, km, im, jm = avg2.variables['temp'].shape lm3, km, im, jm = avg3.variables['temp'].shape tmp = avg1.variables['temp'][0,0,...] lon, lat, tmp = subset(lonr, latr, tmp, lims[0], lims[1], lims[2], lims[3]) # AVG1 output =============================================================== zu = get_depths(avg1, grd, 0, 'u') zv = get_depths(avg1, grd, 0, 'v') zt = get_depths(avg1, grd, 0, 't') times = np.arange(1800, lm1, 10) U1 = np.zeros((times.size, lon.shape[0], lon.shape[1]), dtype=np.float64) V1 = np.zeros((times.size, lon.shape[0], lon.shape[1]), dtype=np.float64) T1 = np.zeros((times.size, lon.shape[0], lon.shape[1]), dtype=np.float64) print "\n\n Slicing %s eddy, at %s m, in AVG-1.... may take a while.......\n\n" %(eddy, zlev)
lon = np.ma.masked_where(lat > -12.5, lon) lat = np.ma.masked_where(lat > -12.5, lat) #################################################################### leste1, leste2, proab = Leste1(), Leste2(), ProAbro() for dataset in [leste1, leste2, proab]: dataset.mlon, dataset.mlat = m(dataset.lon, dataset.lat) print " " print "Loading etopo data ....... " etopo = sp.loadmat('/home/rsoutelino/prod/grl_msc/proc/etopo2_atlsul.mat') xb = etopo.pop('xb') yb = etopo.pop('yb') zb = etopo.pop('zb') xb, yb, zb = romslab.subset(xb, yb, zb, lims[0], lims[1], lims[2], lims[3]) xb,yb = m(xb,yb) fig1 = plt.figure(1,figsize=(15, 8),facecolor='w') gs =gridspec.GridSpec(1, 3) p1 = plt.subplot(gs[0, 0]) m.contourf(xb, yb, zb, np.arange(-5000, 0, 500), cmap=plt.cm.Blues_r) m.plot(leste1.lon, leste1.lat, '*y', markersize=8) m.drawcoastlines(zorder=5) m.drawcountries(zorder=4) m.fillcontinents(zorder=3) m.drawparallels(np.arange(-24,0,2), labels=[1, 0, 0, 0],dashes=[1,1000],zorder=6)