OpenDrift / opendrift

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

Cannot read variable 'sea_floor_depth_below_sea_level' from unstructured FVCOM nc file #690

Closed qianmosugar closed 1 year ago

qianmosugar commented 3 years ago

Dear Developers,

I am working on a FVCOM model for water exchange, which the interaction with bathymetry is directly affect the particle's z position. However, I found that _reader_netCDF_CFunstructured did not actually read the bathymetry data, which provided by input nc file. Just take the example_fvcom.py file as an example. I can run this code without any problem, however, when I read the output nc file, the variable 'sea_floor_depth_below_sea_level' of all the particles was assigned the default value of 10000.

image

Then, I print the model and find that _Readers not added for the following variables: sea_floor_depth_below_sea_level. However, I print the reader and find that sea_floor_depth_below_geoid_ is in variables.

image

If I understand correct, these two variables need a mapping from one to another. I follow the suggestion from Gaute, add the variable alias manually on line 58 (variable_aliases) in reader_netCDF_CF_unstructured.py. Unfortunately, as long as I add the variable alias, the particles do not move. This is because the variables group will error by tuple index out of range so that x_sea_water_velocity and y_sea_water_velocity are missing.

Please forgive me for posting this question again. I think share it would help more people.

Looking forward to your reply. Thanks in advance. Yachen

knutfrode commented 3 years ago

Hi Yachen,

Can you post the full log output from this run, and also an ncdump (the detailed contents) of your netCDF-file?

qianmosugar commented 3 years ago

Hi,

The log file of running model and the output of print(reader) and print(model) is attached.

I use the origin akvaplan file which used in your _examplefvcom.py. The output of ncdump will be the same.

Thanks in advanced.

print_model_issue#690.txt run_script_issue#690.txt print_reader_issue#690.txt

gauteh commented 3 years ago

Hi, @knutfrode hopefully fixed the issue in #692. Please try latest master.

qianmosugar commented 3 years ago

Hi,

Sorry for not replying earlier. Thank you for updating the code. I have tried the latest code and am pleased to find it works as long as adding the mapping from 'sea_floor_depth_below_sea_level' to 'sea_floor_depth_below_geoid' manually.

By the way, I noticed one thing that deserves improvement. I found that the latest version can only read the data in the Cartesian coordinate system, which makes me have to convert the coordinate system of the input file manually every time. However, I have a version that I do not remember where and when I downloaded which seems to be one of your past versions and It can read the input file of the spherical coordinate system. Could you please consider merging the two versions of the code so that the reader can read the two coordinate systems, saving users the time to convert the coordinate system?

The special code is attached for your information.

Thanks in advanced. Best, Yachen

reader_netCDF_CF_unstructured_for_spherical.zip