OpenDrift / opendrift

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

Backtracking wind blow model #1243

Open jacktang opened 8 months ago

jacktang commented 8 months ago

Hello,

I try to backtrack the wind blow model. The forward processes is described at https://opendrift.github.io/gallery/example_windblow.html. I used the backwards simulation method. But it couldn't find the possible source(16, 68.5) in the forward process.

image

And the code is quite simple:

o = WindBlow(loglevel=50)
reader_arome = reader_netCDF_CF_generic.Reader('wind-fwd.nc') # wind-fwd.nc is generated from forward process

o.add_reader([reader_arome])

duration = timedelta(hours=48)
start_time = reader_arome.start_time
end_time = start_time + duration

object_type = 26  # 26 = Life-raft, no ballast
outfile = 'wind-init.nc'
ilon = 19  # Incident position
ilat = 70.02
text = [{'s': 'Observation', 'x': ilon, 'y': ilat, 'fontsize': 20, 'color': 'g', 'zorder': 1000}]

# Define domain of possible origin
lons = np.arange(13, 19.5, .1/20)
lats = np.arange(68, 70.5, .1/20)
corners = [lons[0], lons[-1], lats[0], lats[-1]]
lons, lats = np.meshgrid(lons, lats)

o.seed_elements(lon=ilon, lat=ilat, radius=1000, radius_type='uniform', number=30000, time=end_time)
o.run(duration=duration, time_step=-900, time_step_output=3600, outfile=outfile)
od = opendrift.open_xarray(outfile)
density_backwards = od.get_histogram(pixelsize_m=5000).isel(time=-1).isel(origin_marker=0)
density_backwards = density_backwards.where(density_backwards>0)
density_backwards = density_backwards/density_backwards.sum()*100
vmax = density_backwards.max()
o.plot(background=density_backwards, clabel='Probability of origin [%]', text=text, corners=corners, fast=True, markersize=.5, lalpha=.02, vmin=0, vmax=vmax)
os.remove(outfile)

Could you please give me some hits how to fix it? Thanks!

knutfrode commented 8 months ago

You should change loglevel to 0, so that you can see if something went wrong during simulation. E.g. you are using a custom file for wind, so something might perhaps be wrong with this one.