opendrift
opendrift copied to clipboard
How to use sea_floor_depth_below_sea_level variable from 2DH hydrodynamic model with netcdf generic reader
Hello,
I am trying to run a case using 2DH hydrodynamic data. I formatted this netcdf file to be loaded as netcdf generic reader. correntes_delft.zip
The Opendrift reader can load all my dataset (z, sea_floor_depth_below_sea_level, x_sea_water_velocity, y_sea_water_velocity)
Reader: correntes_delft.nc Projection: EPSG:32622 Coverage: [degrees] xmin: 827182.000000 xmax: 841182.000000 step: 70.375 numx: 199 ymin: -81173.000000 ymax: -67173.000000 step: 70.3516 numy: 200 Corners (lon, lat): (-48.06, -0.61) (-47.94, -0.61) (-48.06, -0.73) (-47.94, -0.73) Vertical levels [m]: Not specified Available time range: start: 2000-12-02 00:00:00 end: 2000-12-03 00:00:00 step: 0:59:59.999785 25 times (0 missing) Variables: z sea_floor_depth_below_sea_level x_sea_water_velocity y_sea_water_velocity ===========================
The problem is that sea_floor_depth_below_sea_level data is not being loaded in the simulation by the OceanDrift model. However, if I run the same case with PellagicEgg model the depth data is loaded correctly.
Where is my real problem?
Thank you for any help.
With best regards,
Taoan
Hi,
I cannot see why OceanDrift module should not detect sea_floor_depth_below_sea_level from this reader.
However, when testing your file, I get output like this, where corner points are corrrupted/wrong:
Reader: correntes_delft.nc
Projection:
+proj=latlong
Coverage: [degrees]
xmin: 826822.000000 xmax: 840822.000000 step: 70.375 numx: 199
ymin: -81173.000000 ymax: -67173.000000 step: 70.3516 numy: 200
Corners (lon, lat):
(826822.00, -67173.00) (840822.00, -67173.00)
(826822.00, -81173.00) (840822.00, -81173.00)
Vertical levels [m]:
Not specified
Available time range:
start: 2000-12-02 00:00:00 end: 2000-12-03 00:00:00 step: 0:59:59.999785
25 times (0 missing)
Variables:
z
sea_floor_depth_below_sea_level
x_sea_water_velocity
y_sea_water_velocity
===========================
Latitudes are here in the range from -81173 to -67173, so something is clearly wrong. And there is no projection information in the file, whereas your snippet shows EPSG:32622
Also, sea_floor_depth_below_sea_levelhas dimensions time, y, z, however, I guess this should not change with time?
Hi Knut,
Some codes consider a changing sea floor depth (in time) when they study sediment transport, for example. Moving sand dunes in some areas (Columbia river, USA) can have a height on the order of meters, I've been told.
Yes, you are right, this could well be the case here - file shows a river-like environment. However, coordinates (longitudes/latitudes) are clearly wrong.
Hello Knut,
Yes I am aware that my data have projection utm EPSG:32622, so I need to declare this projection to Opendrift get it using proj4 variable. Like this: reader = reader_netCDF_CF_generic.Reader("correntes_delft.nc",proj4='EPSG:32622')
My case is a estuarine waterbody, so we have sea_floor_depth_below_sea_level varying on space and time due to tidal flows.
This figure ilustrate my problem. You can observe that OceanDrift only get the default fallback values for sea_floor_depth_below_sea_level

The figure shows that all elements are at surface all times when using OceanDrift. This is presumably where you seeded them. But why should elements eventually sink? Do you have negative current velocities or buoyancy, or vertical turbulence specified? Note that PelagicEgg elements do (e.g.) have vertical swimming velocities, but no such thing for passive OceanDrift elements. It would be useful to see your invoking script, or the log of this run.
Hello,
Yes, I set a terminal velocity, but it is not working. This is my simulation code: reader = reader_netCDF_CF_generic.Reader("correntes_delft.nc",proj4='EPSG:32622') start_time = datetime(2000,12,2,1,0,0) o = OceanDrift(loglevel=20) o.add_reader(reader) o.seed_elements(lon=lon, lat=lat, z=0.0, radius=50.0, number=100, time=start_time) o.set_config('seed:terminal_velocity', 0.0025)#m/s o.set_config('drift:horizontal_diffusivity', 0.1176)#m2/s o.set_config('vertical_mixing:diffusivitymodel','constant')#m2/s o.set_config('vertical_mixing:background_diffusivity',0.01)#m2/s o.set_config('drift:vertical_advection',True) o.set_config('general:seafloor_action','deactivate') outfile = 'test.nc' o.run(time_step=timedelta(seconds=90),time_step_output=timedelta(minutes=30),duration=timedelta(days=1),outfile=outfile)
Note that vertical mixing does not affect elements at the very surface, and your elements will always stay there, as the buoyancy is also positive/upwards. Do you see a difference if you seed your elements e.g. at 1m depth?
Ok, I tried to change the signal of terminal velocity to negative, but it did not make changes. I also tested to seed at 1m depth, but the results are the similar, except the fact that the particles stay at -1m instead 0m.
When I plot the results for z=-1.0 and terminal_velocity=-0.0025 I get this figure:

Ok. But looking at your config settings, it seems that vertical mixing has not been switched on (only vertical advection).
Please try to add: o.set_config('drift:vertical_mixing',True)
Ok, After add o.set_config('drift:vertical_mixing',True) the results remain the same.
Ok, maybe you can share a part of the output log (or the whole if not too large) from such a simulation.
Hello, here is my log oceandrift_log.zip
The logs shows lines like this:
DEBUG:opendrift.models.oceandrift:Using constant diffusivity specified by fallback_values[ocean_vertical_diffusivity] = 0 m2.s-1
which explains why there are no vertical mixing.
In your config you specify this, which was probably intended for vertical diffusivity instead?
o.set_config('drift:horizontal_diffusivity', 0.1176)#m2/s
Then you should instead add this line to use this value for vertical diffusivity:
o.set_config('environment:fallback:ocean_vertical_diffusivity', 0.1176)
Yes, thank you
My intention was to set horizontal and vertical constant diffusivity values. I tested your suggestion to set vertical diffusivity and now the Oceandrift is working ok! I am using this settings:
o.set_config('seed:terminal_velocity', -0.0025)#m/s
o.set_config('drift:horizontal_diffusivity', 0.1176)#m2/s
o.set_config('drift:vertical_mixing',True)
o.set_config('vertical_mixing:diffusivitymodel','constant')#m2/s
o.set_config('environment:fallback:ocean_vertical_diffusivity',0.01)#m2/s
o.set_config('drift:vertical_advection',True)
o.set_config('general:seafloor_action','deactivate')
