#nc.close() print('load px,py,pz.................', tm.time() - tstart) tstart = tm.time() coord = part.subsection(px, py, ny=simul.coordmax[1], nx=simul.coordmax[3], offset=10) ################################################################################### # Get depth (z_w) from simulation file ################################################################################### [_, z_w] = part.get_depths(simul, coord=coord, x_periodic=x_periodic, y_periodic=y_periodic, ng=ng) del _ if not meanflow and alpha_time != 0: simul.update(np.ceil(filetime)) [_, z_w2] = part.get_depths(simul, coord=coord, x_periodic=x_periodic, y_periodic=y_periodic, ng=ng) del _ simul.update(np.floor(filetime)) z_w = linear(z_w, z_w2, alpha_time)
x, y, z, z_w, ng=ng) ############################## # Release particles on iso-surfaces of a variable # Typically isopycnals if initial_surf: [temp, salt] = part.get_ts_io(simul, x_periodic=x_periodic, y_periodic=y_periodic, ng=ng) [z_r, z_w] = part.get_depths(simul, x_periodic=x_periodic, y_periodic=y_periodic, ng=ng) roms_rho0 = simul.rho0 rho = rho1_eos(temp, salt, z_r, z_w, roms_rho0) ## temporary box used for sigma-interpolation onto surf0 lev1 = rho.shape[2] # Needed to get all levels if preserved_meter: z, y, x = seeding_part.seed_meter(ic=ic, jc=jc, lev0=lev0, lev1=lev1, nnlev=nnlev, nx_box=nx_box, ny_box=ny_box, dx_box=dx_box, simul=simul,
def plot_selection(alldomain=True): plt.figure(figsize=(6.0, 4.0)) ax1 = plt.subplot(1, 1, 1) nc = Dataset(simul.ncfile, 'r') if alldomain: if adv3d or advdepth == 0: sst = np.squeeze( simul.Forder(nc.variables['temp'][simul.infiletime, -1, :, :])) else: [z_r, z_w] = part.get_depths(simul) temp = simul.Forder( np.squeeze(nc.variables['temp'][simul.infiletime, :, :, :])) sst = part.vinterp(temp, [advdepth], z_r, z_w)[:, :, 0] sst[sst == 0.] = np.nan sst *= simul.mask topo = simul.topo else: [ny1, ny2, nx1, nx2] = np.array(coord) - ng if adv3d or advdepth == 0: sst = np.squeeze( simul.Forder(nc.variables['temp'][simul.infiletime, -1, ny1:ny2, nx1:nx2])) else: [z_r, z_w] = part.get_depths(simul, coord=[ny1, ny2, nx1, nx2]) temp = simul.Forder( np.squeeze(nc.variables['temp'][simul.infiletime, :, ny1:ny2, nx1:nx2])) sst = part.vinterp(temp, [advdepth], z_r, z_w)[:, :, 0] sst[sst == 0.] = np.nan sst *= simul.mask[nx1:nx2, ny1:ny2] topo = simul.topo[nx1:nx2, ny1:ny2] nc.close() sst[sst < 0] = 0. #plt.imshow(sst[:,::1].T); plt.colorbar(shrink=0.25); plt.pcolormesh(ma.masked_invalid(sst[:, :].T), cmap='jet', rasterized=True) plt.colorbar(shrink=0.25) if not adv3d and advdepth < -topo.min(): plt.contourf(topo.T, [0, -advdepth], cmap=col.LinearSegmentedColormap.from_list( 'my_colormap', ['white', 'lightgray'], 256)) plt.contourf(topo.T, [0, topo.min()], cmap=col.LinearSegmentedColormap.from_list( 'my_colormap', ['Gainsboro', 'gray'], 256)) plt.contour(topo.T, [topo.min()], colors=('k', ), linewidths=(0.5, )) plt.contour(topo.T, [-advdepth], colors=('k', ), linewidths=(0.2, )) if alldomain: plt.plot(px[::1] + 0.5, (py[::1] + 0.5), 'o', markersize=2, markeredgecolor='k', markerfacecolor='k') plt.axis([0, sst.shape[0] - 1, 0, sst.shape[1] - 1]) else: plt.plot(px[::1] - coord[2] + 0.5, (py[::1] - coord[0] + 0.5), 'o', markersize=1, markerfacecolor='white') #plt.axis('scaled'); #plt.axis([nx1-coord[2]+0.5,nx2-coord[2]+0.5,ny1-coord[0]+0.5,ny2-coord[0]+0.5]); ''' for isub,jsub in product(range(nsub_x),range(nsub_y)): try: plot_rect(subtightcoord_saves[jsub+isub*nsub_y],'r') plot_rect(subcoord_saves[jsub+isub*nsub_y],'k--') except: print 'no subdomains to plot' ''' color = 'w' box = 'round,pad=0.1' props = dict(boxstyle=box, fc=color, ec='k', lw=1, alpha=1.) #JC ax1.text(0.95,0.05,simul.date[:-8], horizontalalignment='right', verticalalignment='bottom', bbox=props, transform=ax1.transAxes) plt.title(format(np.sum(px > 0)) + ' pyticles ') plt.savefig(folderout + simulname + '_' + format(nproc) + '_' + '{0:04}'.format(time + dfile) + '.png', size=None, figure=None, magnification='auto', dpi=150, bbox_inches='tight') plt.clf()
simul = load(simul=parameters) depths = simul.coord[4] ################################################################################### # get depth, lon, lat ################################################################################### coord = simul.coord[: 4] #= part.subsection(px,py,ny=simul.coordmax[1],nx=simul.coordmax[3],offset=10) #simul.VertCoordType='OLD' #[z_r,z_w] = part.get_depths(simul,coord=coord,x_periodic=x_periodic,y_periodic=y_periodic,ng=ng) simul.VertCoordType = 'NEW' [z_r_new, z_w_new] = part.get_depths(simul, coord=coord, x_periodic=x_periodic, y_periodic=y_periodic, ng=ng) #simul.VertCoordType='OLD' ''' #--------------------------del sys.modules["- plt.subplot(1,2,1) plt.plot(z_w_old[480,213,:].T); plt.subplot(1,2,2) plt.plot(z_w_new[480,213,:].T); plt.savefig('test.png'); plt.clf() #--------------------------- '''