def test_plotting(pset_mode, mode, tmpdir): if mode == '3d' and sys.platform in ['linux', 'linux2']: logger.info( 'Skipping 3d test in linux Travis, since it fails to find display to connect' ) return fp = create_outputfiles(tmpdir, pset_mode) plotTrajectoriesFile(fp, mode=mode, show_plt=False)
def plot_parcles_run(k, v): """k,v from Kafka message""" L.info(f'Received Input: {v}') L.info(f"Plotting results from: {v['filepath']}") plotpath = Path(__file__).parent.parent / 'plots' filename = v['id'] + '.png' plotfile = str(plotpath / filename) plotTrajectoriesFile(v['filepath'], mode='2d', show_plt=False) f = plt.gcf() f.savefig(plotfile) L.info(f'Saved plot to: {plotfile}')
def test_plotting(mode, tmpdir, fp_type): fp_index, fp_array = create_outputfiles(tmpdir) fp = fp_array if fp_type == 'array' else fp_index plotTrajectoriesFile(fp + '.nc', mode=mode, show_plt=False)
def plot_timing(self): """ plot the results of the timing test """ #plt.close("all") fig, ax = plt.subplots(1, 1) fs = 14 ind = np.arange(0, 3) tt, ti, tw = ax.bar( ind, [self.time_total, self.time_integration, self.time_writing]) tt.set_facecolor('k') ti.set_facecolor('tomato') tw.set_facecolor('lime') ax.set_xticks(ind) ax.set_xticklabels(['Total', 'Integration', 'Writing'], fontsize=fs) ax.set_ylabel("time [s]", fontsize=fs) ax.set_title("Number of particles: " + str(self.test_particle_number)) #%% if __name__ == "__main__": tt = tests(particle_number=1000) tt.timing(integration_time_days=6) tt.plot_timing() plotTrajectoriesFile("output.nc") dataset = xr.open_dataset("output.nc") print dataset
#criando o que fazer em condição de recovery# def OutOfBounds(particle, fieldset, time): particle.delete() output_file = pset.ParticleFile(name=outname, outputdt=timedelta(seconds=3600)) # mostrando partículas #executando o modelo# #pset.Kernel(AdvectionRK4) + kernels = pset.Kernel(AdvectionRK4) # + DiffusionUniformKh pset.execute( kernels, #runtime=timedelta(seconds=7592400), dt=timedelta(hours=1), output_file=output_file, recovery={ErrorCode.ErrorOutOfBounds: OutOfBounds}) ############################################################################# ############################## Plotando Resultados ########################## ############################################################################# # plotando resultados# plotTrajectoriesFile(outname) # tracerfile=ncdf, # tracerlon='Lon', # tracerlat='Lat', # tracerfield='MAG');
def test_plotting(mode, tmpdir): fp = create_outputfiles(tmpdir) plotTrajectoriesFile(fp, mode=mode, show_plt=False)
def deleteParticle(particle, fieldset, time): # Recovery kernel to delete a particle if it leaves the domain # (possible in certain configurations) particle.delete() ############################################################################## # INITIALISE SIMULATION AND RUN # ############################################################################## pset = ParticleSet.from_list(fieldset=fieldset, pclass=JITParticle, lon=lon0, lat=lat0, time=t0) traj = pset.ParticleFile(name=fh['traj'], outputdt=param['dt_out']) kernels = (pset.Kernel(AdvectionRK4)) pset.execute(kernels, endtime=param['endtime'], dt=param['dt_RK4'], recovery={ErrorCode.ErrorOutOfBounds: deleteParticle}, output_file=traj) traj.export() from parcels import plotTrajectoriesFile plotTrajectoriesFile(fh['traj'])
from parcels import plotTrajectoriesFile import matplotlib.pyplot as plt plotTrajectoriesFile("tBelize_nemo_particles.nc") plt.savefig('./pFIGURES/postTrajPlotT1.png', dpi=100)