OpenDrift / opendrift

Open source framework for ocean trajectory modelling
https://opendrift.github.io
GNU General Public License v2.0
248 stars 121 forks source link

openoil plot concentration #994

Closed oceandiff closed 1 year ago

oceandiff commented 2 years ago

Hello all, I'm trying to plot the concentration of the spilled oil, it is possible to do with the same method used in the example (not related to oil):

oa = opendrift.open_xarray(outfile) h = oa.get_histogram(pixelsize_m=200) b=h.isel(origin_marker=0).sum(dim='time') oa.plot(background=b.where(b>0), fast=False, show_particles=False, vmin=0, vmax=1000, filename = outdir + str(Current_Date) + '/' + str(Current_Date) + + '_totconc'+ '.jpg') bg=h.isel(origin_marker=0) oa.animation(background=bg.where(bg>0), bgalpha=1, fast=False, show_elements=False, vmin=0, vmax=1000, filename = outdir + str(Current_Date) + '/' + str(Current_Date) + '_conc'+ '.mp4') o.animation_profile(markersize=1, filename = outdir + str(Current_Date) + '/' + str(Current_Date) + '_profile'+ '.mp4') The second question is correlated to the porductions time of the plot and the animatio. As I'm trying to do run with over a million of particles, the time to produce the plot are biggest than the simulation time. I've tried to read in the netcdf file, but I don't understand where and with wich name are saved the variables relative at the position of all the particles. Is it possible to use an external script to generate the plots?

knutfrode commented 2 years ago

Yes, with a million particles, plotting will be slow if you try to show them all. Then it is better to calculate histograms/densities, as in the given example. And yes, you may well do the plotting with external code.

oceandiff commented 2 years ago

Thanks Knutfrode for the reply. In the netcdf outfile what is the variable name I can use to plot the particles distribution in a precise time step? I like to plot the distribution every 2 time steps, or similar. Thanks in advance