OpenDrift / opendrift

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

Trouble reading current netcdf files in OceanDrift #1393

Closed PerharicC closed 2 months ago

PerharicC commented 2 months ago

Discussed in https://github.com/OpenDrift/opendrift/discussions/1380

Originally posted by **PerharicC** August 22, 2024 Hi. I am trying to run a simulation in OceanDrift, where one of the inputs is a netcdf file containing x and y sea water velocity info. Upon checking the output .nc file I have found, that the velocities at the specified seeding location do not match the ones in the reader at all. In fact they differ by 2 orders of magnitude, thus I am guessing it is not a result of interpolation. Furthermore I have found, that the values in the output match reader values at a completely different location, as if there was some sort of shift in the reader. Bellow I am providing the current file for the reader and a condensed working example to show the issue. This is the link to the current file that OceanDrift reads: https://drive.google.com/file/d/1O4_U9SE48injbRvZDvUUE1S-MjgIeIgs/view?usp=sharing This is the link to a working example of the problem: https://drive.google.com/file/d/1Qx1Y0k-QeaOvXgO5TQ-3DExfHhC7W2Te/view?usp=sharing Any insight would be much appreciated. Thank you! Best regards, Crtomir Perharic
knutfrode commented 2 months ago

Hi,

This took some time to debug - but turned out to be a dateline issue in reader_netCDF_CF_generic. Since the dataset has a coarse time resolution (monthly), a quite large buffer is read around the given particle, and this was crossing the dateline. This resulted in non-monotonic longitude in the returned datablock, and thus erroneous interpolation.

This commit should fix the issue: https://github.com/OpenDrift/opendrift/commit/9621459e4ddf5542fce80b50621c57eb99c1e557

Thank you for the bug report, with data and reproducible example.

PerharicC commented 2 months ago

Dear Knut.

Thank you so much, it indeed works! I am closing the issue.

Crtomir