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

MITgcm Reader #977

Closed erickfredj closed 1 year ago

erickfredj commented 2 years ago

I tried to read the following velocity file using a the generic reader without success:

netcdf state.0000366288.t001 { dimensions: T = UNLIMITED ; // (1055 currently) Xp1 = 37 ; Y = 58 ; Z = 47 ; X = 36 ; Yp1 = 59 ; Zl = 47 ; variables: double T(T) ; T:long_name = "model_time" ; T:units = "seconds since 2021-01-01 00:00:00" ; int iter(T) ; iter:long_name = "iteration_count" ; double Xp1(Xp1) ; Xp1:long_name = "X-Coordinate of cell corner" ; Xp1:units = "meters" ; double Y(Y) ; Y:long_name = "Y-Coordinate of cell center" ; Y:units = "meters" ; double Z(Z) ; Z:long_name = "vertical coordinate of cell center" ; Z:units = "meters" ; Z:positive = "up" ; float U(T, Z, Y, Xp1) ; U:units = "m/s" ; U:coordinates = "XU YU RC iter" ; double X(X) ; X:long_name = "X-coordinate of cell center" ; X:units = "meters" ; double Yp1(Yp1) ; Yp1:long_name = "Y-Coordinate of cell corner" ; Yp1:units = "meters" ; float V(T, Z, Yp1, X) ; V:units = "m/s" ; V:coordinates = "XV YV RC iter" ; float Temp(T, Z, Y, X) ; Temp:units = "degC" ; Temp:long_name = "potential_temperature" ; Temp:coordinates = "XC YC RC iter" ; float S(T, Z, Y, X) ; S:long_name = "salinity" ; S:coordinates = "XC YC RC iter" ; float Eta(T, Y, X) ; Eta:long_name = "free-surface_r-anomaly" ; Eta:units = "m" ; Eta:coordinates = "XC YC iter" ; double Zl(Zl) ; Zl:long_name = "vertical coordinate of upper cell interface" ; Zl:units = "meters" ; Zl:positive = "up" ; float W(T, Zl, Y, X) ; W:units = "m/s" ; W:coordinates = "XC YC RC iter" ; double U_A(T, Z, Y, X) ; U_A:units = "m/s" ; U_A:coordinates = "X Y Z iter" ; double V_A(T, Z, Y, X) ; V_A:units = "m/s" ; V_A:coordinates = "X Y Z iter" ; double W_A(T, Z, Y, X) ; W_A:units = "m/s" ; W_A:coordinates = "X Y Z iter" ;

// global attributes: :MITgcm_version = "checkpoint67l" ; :build_user = "administrator" ; :build_host = "t-yael-a" ; :build_date = "Sun Apr 24 15:25:27 IDT 2022" ; :MITgcm_URL = "http://mitgcm.org" ; :MITgcm_tag_id = "" ; :MITgcm_mnc_ver = 0.9 ; :tile_number = 1 ; :bi = 1 ; :bj = 1 ; :sNx = 36 ; :sNy = 58 ; :OLx = 4 ; :OLy = 4 ; :nSx = 1 ; :nSy = 1 ; :nPx = 1 ; :nPy = 1 ; :Nx = 36 ; :Ny = 58 ; :Nr = 47 ; } erick@espresso:/mnt/volume/CORE/Projects/Kinneret/archives/mitgcm$ ls state.0000366288.t001.nc state.0000391608.t001.nc erick@espresso:/mnt/volume/CORE/Projects/Kinneret/archives/mitgcm$ pwd /mnt/volume/CORE/Projects/Kinneret/archives/mitgcm

from datetime import timedelta, datetime from opendrift.readers import reader_global_landmask from opendrift.models.oceandrift import OceanDrift from opendrift.readers.reader_netCDF_CF_generic import Reader

o = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information

mitgcm_dir = f'/mnt/volume/CORE/Projects/Kinneret/archives/mitgcm'

try: reader_mitgcm = Reader(mitgcm_dir+'/state.0000366288.t001.nc', standard_name_mapping={'U_A': 'x_sea_water_velocity', 'V_A': 'y_sea_water_velocity'}) except: print('MITgcm Data not available, cannot run simulation')

Do I need to modify the netcdf file if yes what is wrong? How do I add the W_A vertical velocity component?

knutfrode commented 2 years ago

Hi, the variables here are missing the important attribute standard_name