Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to import netCDF ROMS current in pygnome? #134

Open
kinsnow opened this issue Oct 18, 2022 · 3 comments
Open

How to import netCDF ROMS current in pygnome? #134

kinsnow opened this issue Oct 18, 2022 · 3 comments

Comments

@kinsnow
Copy link

kinsnow commented Oct 18, 2022

Dear all,

I want to input ROMS current data into pygnome.
I write this code,

`from gnome.movers import PyCurrentMover

print('adding a current mover:)
curr_file = get_datafile(os.path.join(base_dir,'ROMS_2021_avg_L1_0001.nc'))
model.movers += PyCurrentMover(curr_file)`

But, Error occured.
adding a current mover:
Traceback (most recent call last):
File "E:\Pygnome\Temp\script_Temp_Current\script_temp_current_rev.py", line 90, in
model = make_model()
File "E:\Pygnome\Temp\script_Temp_Current\script_temp_current_rev.py", line 71, in make_model
curr_file = PyCurrentMover(cf)
File "c:\users\ksh\pygnome\py_gnome\gnome\movers\py_current_movers.py", line 106, in init
self.current = GridCurrent.from_netCDF(filename=self.filename,
File "c:\users\ksh\pygnome\py_gnome\gnome\environment\gridded_objects_base.py", line 893, in from_netCDF
var.init_from_netCDF(*args, **kwargs)
File "c:\users\ksh\pygnome\py_gnome\gnome\environment\gridded_objects_base.py", line 831, in init_from_netCDF
depth = Depth.from_netCDF(grid_file=grid_file,
File "c:\users\ksh\pygnome\py_gnome\gnome\environment\gridded_objects_base.py", line 400, in from_netCDF
return gridded.depth.Depth.from_netCDF(*args, **kwargs)
File "C:\Users\KSH\anaconda3\envs\gnome\lib\site-packages\gridded\depth.py", line 677, in from_netCDF
cls = Depth._get_depth_type(df, depth_type, topology, _default_types)
File "C:\Users\KSH\anaconda3\envs\gnome\lib\site-packages\gridded\depth.py", line 725, in _get_depth_type
L_Depth.from_netCDF(dataset=dataset)
File "C:\Users\KSH\anaconda3\envs\gnome\lib\site-packages\gridded\depth.py", line 140, in from_netCDF
vname = cls._gen_varname(filename, dataset, [tn], [tln])
File "C:\Users\KSH\anaconda3\envs\gnome\lib\site-packages\gridded\depth.py", line 92, in _gen_varname
raise KeyError("Default names not found.")
KeyError: 'Default names not found.'

How can I fix this error?
ROMS NetCDF header is as follows:

dimensions:
xi_rho = 700;
xi_u = 699;
xi_v = 700;
xi_psi = 699;
eta_rho = 720;
eta_u = 720;
eta_v = 719;
eta_psi = 719;
s_rho = 20;
s_w = 21;
tracer = 2;
boundary = 4;
ocean_time = UNLIMITED; // (1 currently)
variables:
int ntimes;
:long_name = "number of long time-steps";

int ndtfast;
  :long_name = "number of short time-steps";

double dt;
  :long_name = "size of long time-steps";
  :units = "second";

double dtfast;
  :long_name = "size of short time-steps";
  :units = "second";

double dstart;
  :long_name = "time stamp assigned to model initilization";
  :units = "days since 2021-01-01 00:00:00";
  :calendar = "proleptic_gregorian";

int nHIS;
  :long_name = "number of time-steps between history records";

int ndefHIS;
  :long_name = "number of time-steps between the creation of history files";

int nRST;
  :long_name = "number of time-steps between restart records";
  :cycle = "only latest two records are maintained";

int ntsAVG;
  :long_name = "starting time-step for accumulation of time-averaged fields";

int nAVG;
  :long_name = "number of time-steps between time-averaged records";

int ndefAVG;
  :long_name = "number of time-steps between the creation of average files";

double Falpha;
  :long_name = "Power-law shape barotropic filter parameter";

double Fbeta;
  :long_name = "Power-law shape barotropic filter parameter";

double Fgamma;
  :long_name = "Power-law shape barotropic filter parameter";

double nl_tnu4(tracer=2);
  :long_name = "nonlinear model biharmonic mixing coefficient for tracers";
  :units = "meter4 second-1";

double nl_visc4;
  :long_name = "nonlinear model biharmonic mixing coefficient for momentum";
  :units = "meter4 second-1";

int LuvSponge;
  :long_name = "horizontal viscosity sponge activation switch";
  :flag_values = 0, 1; // int
  :flag_meanings = ".FALSE. .TRUE.";

int LtracerSponge(tracer=2);
  :long_name = "horizontal diffusivity sponge activation switch";
  :flag_values = 0, 1; // int
  :flag_meanings = ".FALSE. .TRUE.";

double Akt_bak(tracer=2);
  :long_name = "background vertical mixing coefficient for tracers";
  :units = "meter2 second-1";

double Akv_bak;
  :long_name = "background vertical mixing coefficient for momentum";
  :units = "meter2 second-1";

double Akk_bak;
  :long_name = "background vertical mixing coefficient for turbulent energy";
  :units = "meter2 second-1";

double Akp_bak;
  :long_name = "background vertical mixing coefficient for length scale";
  :units = "meter2 second-1";

double rdrg;
  :long_name = "linear drag coefficient";
  :units = "meter second-1";

double rdrg2;
  :long_name = "quadratic drag coefficient";

double Zob;
  :long_name = "bottom roughness";
  :units = "meter";

double Zos;
  :long_name = "surface roughness";
  :units = "meter";

double gls_p;
  :long_name = "stability exponent";

double gls_m;
  :long_name = "turbulent kinetic energy exponent";

double gls_n;
  :long_name = "turbulent length scale exponent";

double gls_cmu0;
  :long_name = "stability coefficient";

double gls_c1;
  :long_name = "shear production coefficient";

double gls_c2;
  :long_name = "dissipation coefficient";

double gls_c3m;
  :long_name = "buoyancy production coefficient (minus)";

double gls_c3p;
  :long_name = "buoyancy production coefficient (plus)";

double gls_sigk;
  :long_name = "constant Schmidt number for TKE";

double gls_sigp;
  :long_name = "constant Schmidt number for PSI";

double gls_Kmin;
  :long_name = "minimum value of specific turbulent kinetic energy";

double gls_Pmin;
  :long_name = "minimum Value of dissipation";

double Charnok_alpha;
  :long_name = "Charnok factor for surface roughness";

double Zos_hsig_alpha;
  :long_name = "wave amplitude factor for surface roughness";

double sz_alpha;
  :long_name = "surface flux from wave dissipation";

double CrgBan_cw;
  :long_name = "surface flux due to Craig and Banner wave breaking";

double Znudg;
  :long_name = "free-surface nudging/relaxation inverse time scale";
  :units = "day-1";

double M2nudg;
  :long_name = "2D momentum nudging/relaxation inverse time scale";
  :units = "day-1";

double M3nudg;
  :long_name = "3D momentum nudging/relaxation inverse time scale";
  :units = "day-1";

double Tnudg(tracer=2);
  :long_name = "Tracers nudging/relaxation inverse time scale";
  :units = "day-1";

double FSobc_in(boundary=4);
  :long_name = "free-surface inflow, nudging inverse time scale";
  :units = "second-1";

double FSobc_out(boundary=4);
  :long_name = "free-surface outflow, nudging inverse time scale";
  :units = "second-1";

double M2obc_in(boundary=4);
  :long_name = "2D momentum inflow, nudging inverse time scale";
  :units = "second-1";

double M2obc_out(boundary=4);
  :long_name = "2D momentum outflow, nudging inverse time scale";
  :units = "second-1";

double Tobc_in(boundary=4, tracer=2);
  :long_name = "tracers inflow, nudging inverse time scale";
  :units = "second-1";

double Tobc_out(boundary=4, tracer=2);
  :long_name = "tracers outflow, nudging inverse time scale";
  :units = "second-1";

double M3obc_in(boundary=4);
  :long_name = "3D momentum inflow, nudging inverse time scale";
  :units = "second-1";

double M3obc_out(boundary=4);
  :long_name = "3D momentum outflow, nudging inverse time scale";
  :units = "second-1";

double rho0;
  :long_name = "mean density used in Boussinesq approximation";
  :units = "kilogram meter-3";

double gamma2;
  :long_name = "slipperiness parameter";

int LuvSrc;
  :long_name = "momentum point sources and sink activation switch";
  :flag_values = 0, 1; // int
  :flag_meanings = ".FALSE. .TRUE.";

int LwSrc;
  :long_name = "mass point sources and sink activation switch";
  :flag_values = 0, 1; // int
  :flag_meanings = ".FALSE. .TRUE.";

int LtracerSrc(tracer=2);
  :long_name = "tracer point sources and sink activation switch";
  :flag_values = 0, 1; // int
  :flag_meanings = ".FALSE. .TRUE.";

int LsshCLM;
  :long_name = "sea surface height climatology processing switch";
  :flag_values = 0, 1; // int
  :flag_meanings = ".FALSE. .TRUE.";

int Lm2CLM;
  :long_name = "2D momentum climatology processing switch";
  :flag_values = 0, 1; // int
  :flag_meanings = ".FALSE. .TRUE.";

int Lm3CLM;
  :long_name = "3D momentum climatology processing switch";
  :flag_values = 0, 1; // int
  :flag_meanings = ".FALSE. .TRUE.";

int LtracerCLM(tracer=2);
  :long_name = "tracer climatology processing switch";
  :flag_values = 0, 1; // int
  :flag_meanings = ".FALSE. .TRUE.";

int LnudgeM2CLM;
  :long_name = "2D momentum climatology nudging activation switch";
  :flag_values = 0, 1; // int
  :flag_meanings = ".FALSE. .TRUE.";

int LnudgeM3CLM;
  :long_name = "3D momentum climatology nudging activation switch";
  :flag_values = 0, 1; // int
  :flag_meanings = ".FALSE. .TRUE.";

int LnudgeTCLM(tracer=2);
  :long_name = "tracer climatology nudging activation switch";
  :flag_values = 0, 1; // int
  :flag_meanings = ".FALSE. .TRUE.";

int spherical;
  :long_name = "grid type logical switch";
  :flag_values = 0, 1; // int
  :flag_meanings = "Cartesian spherical";

double xl;
  :long_name = "domain length in the XI-direction";
  :units = "meter";

double el;
  :long_name = "domain length in the ETA-direction";
  :units = "meter";

int Vtransform;
  :long_name = "vertical terrain-following transformation equation";

int Vstretching;
  :long_name = "vertical terrain-following stretching function";

double theta_s;
  :long_name = "S-coordinate surface control parameter";

double theta_b;
  :long_name = "S-coordinate bottom control parameter";

double Tcline;
  :long_name = "S-coordinate surface/bottom layer width";
  :units = "meter";

double hc;
  :long_name = "S-coordinate parameter, critical depth";
  :units = "meter";

int grid;
  :cf_role = "grid_topology";
  :topology_dimension = 2; // int
  :node_dimensions = "xi_psi eta_psi";
  :face_dimensions = "xi_rho: xi_psi (padding: both) eta_rho: eta_psi (padding: both)";
  :edge1_dimensions = "xi_u: xi_psi eta_u: eta_psi (padding: both)";
  :edge2_dimensions = "xi_v: xi_psi (padding: both) eta_v: eta_psi";
  :node_coordinates = "lon_psi lat_psi";
  :face_coordinates = "lon_rho lat_rho";
  :edge1_coordinates = "lon_u lat_u";
  :edge2_coordinates = "lon_v lat_v";
  :vertical_dimensions = "s_rho: s_w (padding: none)";

double Cs_r(s_rho=20);
  :long_name = "S-coordinate stretching curves at RHO-points";
  :valid_min = -1.0; // double
  :valid_max = 0.0; // double
  :field = "Cs_r, scalar";

double Cs_w(s_w=21);
  :long_name = "S-coordinate stretching curves at W-points";
  :valid_min = -1.0; // double
  :valid_max = 0.0; // double
  :field = "Cs_w, scalar";

double h(eta_rho=720, xi_rho=700);
  :long_name = "bathymetry at RHO-points";
  :units = "meter";
  :grid = "grid";
  :location = "face";
  :coordinates = "lon_rho lat_rho";
  :field = "bath, scalar";

double f(eta_rho=720, xi_rho=700);
  :long_name = "Coriolis parameter at RHO-points";
  :units = "second-1";
  :grid = "grid";
  :location = "face";
  :coordinates = "lon_rho lat_rho";
  :field = "coriolis, scalar";

double pm(eta_rho=720, xi_rho=700);
  :long_name = "curvilinear coordinate metric in XI";
  :units = "meter-1";
  :grid = "grid";
  :location = "face";
  :coordinates = "lon_rho lat_rho";
  :field = "pm, scalar";

double pn(eta_rho=720, xi_rho=700);
  :long_name = "curvilinear coordinate metric in ETA";
  :units = "meter-1";
  :grid = "grid";
  :location = "face";
  :coordinates = "lon_rho lat_rho";
  :field = "pn, scalar";

double angle(eta_rho=720, xi_rho=700);
  :long_name = "angle between XI-axis and EAST";
  :units = "radians";
  :grid = "grid";
  :location = "face";
  :coordinates = "lon_rho lat_rho";
  :field = "angle, scalar";

double mask_rho(eta_rho=720, xi_rho=700);
  :long_name = "mask on RHO-points";
  :flag_values = 0.0, 1.0; // double
  :flag_meanings = "land water";
  :grid = "grid";
  :location = "face";
  :coordinates = "lon_rho lat_rho";

double mask_u(eta_u=720, xi_u=699);
  :long_name = "mask on U-points";
  :flag_values = 0.0, 1.0; // double
  :flag_meanings = "land water";
  :grid = "grid";
  :location = "edge1";
  :coordinates = "lon_u lat_u";

double mask_v(eta_v=719, xi_v=700);
  :long_name = "mask on V-points";
  :flag_values = 0.0, 1.0; // double
  :flag_meanings = "land water";
  :grid = "grid";
  :location = "edge2";
  :coordinates = "lon_v lat_v";

double mask_psi(eta_psi=719, xi_psi=699);
  :long_name = "mask on psi-points";
  :flag_values = 0.0, 1.0; // double
  :flag_meanings = "land water";
  :grid = "grid";
  :location = "node";
  :coordinates = "lon_psi lat_psi";

float zeta(ocean_time=1, eta_rho=720, xi_rho=700);
  :long_name = "time-averaged free-surface";
  :units = "meter";
  :time = "ocean_time";
  :grid = "grid";
  :location = "face";
  :coordinates = "lon_rho lat_rho ocean_time";
  :field = "free-surface, scalar, series";
  :_FillValue = 1.0E37f; // float

float ubar(ocean_time=1, eta_u=720, xi_u=699);
  :long_name = "time-averaged vertically integrated u-momentum component";
  :units = "meter second-1";
  :time = "ocean_time";
  :grid = "grid";
  :location = "edge1";
  :coordinates = "lon_u lat_u ocean_time";
  :field = "ubar-velocity, scalar, series";
  :_FillValue = 1.0E37f; // float

float vbar(ocean_time=1, eta_v=719, xi_v=700);
  :long_name = "time-averaged vertically integrated v-momentum component";
  :units = "meter second-1";
  :time = "ocean_time";
  :grid = "grid";
  :location = "edge2";
  :coordinates = "lon_v lat_v ocean_time";
  :field = "vbar-velocity, scalar, series";
  :_FillValue = 1.0E37f; // float

float u(ocean_time=1, s_rho=20, eta_u=720, xi_u=699);
  :long_name = "time-averaged u-momentum component";
  :units = "meter second-1";
  :time = "ocean_time";
  :grid = "grid";
  :location = "edge1";
  :coordinates = "lon_u lat_u s_rho ocean_time";
  :field = "u-velocity, scalar, series";
  :_FillValue = 1.0E37f; // float

float v(ocean_time=1, s_rho=20, eta_v=719, xi_v=700);
  :long_name = "time-averaged v-momentum component";
  :units = "meter second-1";
  :time = "ocean_time";
  :grid = "grid";
  :location = "edge2";
  :coordinates = "lon_v lat_v s_rho ocean_time";
  :field = "v-velocity, scalar, series";
  :_FillValue = 1.0E37f; // float

float omega(ocean_time=1, s_w=21, eta_rho=720, xi_rho=700);
  :long_name = "time-averaged S-coordinate vertical momentum component";
  :units = "meter3 second-1";
  :time = "ocean_time";
  :grid = "grid";
  :location = "face";
  :coordinates = "lon_rho lat_rho s_w ocean_time";
  :field = "omega, scalar, series";
  :_FillValue = 1.0E37f; // float

float w(ocean_time=1, s_w=21, eta_rho=720, xi_rho=700);
  :long_name = "time-averaged vertical momentum component";
  :units = "meter second-1";
  :time = "ocean_time";
  :standard_name = "upward_sea_water_velocity";
  :grid = "grid";
  :location = "face";
  :coordinates = "lon_rho lat_rho s_w ocean_time";
  :field = "w-velocity, scalar, series";
  :_FillValue = 1.0E37f; // float

float temp(ocean_time=1, s_rho=20, eta_rho=720, xi_rho=700);
  :long_name = "time-averaged potential temperature";
  :units = "Celsius";
  :time = "ocean_time";
  :grid = "grid";
  :location = "face";
  :coordinates = "lon_rho lat_rho s_rho ocean_time";
  :field = "temperature, scalar, series";
  :_FillValue = 1.0E37f; // float

float salt(ocean_time=1, s_rho=20, eta_rho=720, xi_rho=700);
  :long_name = "time-averaged salinity";
  :time = "ocean_time";
  :grid = "grid";
  :location = "face";
  :coordinates = "lon_rho lat_rho s_rho ocean_time";
  :field = "salinity, scalar, series";
  :_FillValue = 1.0E37f; // float

float rho(ocean_time=1, s_rho=20, eta_rho=720, xi_rho=700);
  :long_name = "time-averaged density anomaly";
  :units = "kilogram meter-3";
  :time = "ocean_time";
  :grid = "grid";
  :location = "face";
  :coordinates = "lon_rho lat_rho s_rho ocean_time";
  :field = "density, scalar, series";
  :_FillValue = 1.0E37f; // float

double s_rho(s_rho=20);
  :long_name = "S-coordinate at RHO-points";
  :valid_min = -1.0; // double
  :valid_max = 0.0; // double
  :positive = "up";
  :standard_name = "ocean_s_coordinate_g2";
  :formula_terms = "s: s_rho C: Cs_r eta: zeta depth: h depth_c: hc";
  :field = "s_rho, scalar";
  :_CoordinateTransformType = "Vertical";
  :_CoordinateAxes = "s_rho";
  :_CoordinateAxisType = "GeoZ";
  :_CoordinateZisPositive = "up";

double s_w(s_w=21);
  :long_name = "S-coordinate at W-points";
  :valid_min = -1.0; // double
  :valid_max = 0.0; // double
  :positive = "up";
  :standard_name = "ocean_s_coordinate_g2";
  :formula_terms = "s: s_w C: Cs_w eta: zeta depth: h depth_c: hc";
  :field = "s_w, scalar";
  :_CoordinateTransformType = "Vertical";
  :_CoordinateAxes = "s_w";
  :_CoordinateAxisType = "GeoZ";
  :_CoordinateZisPositive = "up";

double lon_rho(eta_rho=720, xi_rho=700);
  :long_name = "longitude of RHO-points";
  :units = "degree_east";
  :standard_name = "longitude";
  :field = "lon_rho, scalar";
  :_CoordinateAxisType = "Lon";

double lat_rho(eta_rho=720, xi_rho=700);
  :long_name = "latitude of RHO-points";
  :units = "degree_north";
  :standard_name = "latitude";
  :field = "lat_rho, scalar";
  :_CoordinateAxisType = "Lat";

double lon_u(eta_u=720, xi_u=699);
  :long_name = "longitude of U-points";
  :units = "degree_east";
  :standard_name = "longitude";
  :field = "lon_u, scalar";
  :_CoordinateAxisType = "Lon";

double lat_u(eta_u=720, xi_u=699);
  :long_name = "latitude of U-points";
  :units = "degree_north";
  :standard_name = "latitude";
  :field = "lat_u, scalar";
  :_CoordinateAxisType = "Lat";

double lon_v(eta_v=719, xi_v=700);
  :long_name = "longitude of V-points";
  :units = "degree_east";
  :standard_name = "longitude";
  :field = "lon_v, scalar";
  :_CoordinateAxisType = "Lon";

double lat_v(eta_v=719, xi_v=700);
  :long_name = "latitude of V-points";
  :units = "degree_north";
  :standard_name = "latitude";
  :field = "lat_v, scalar";
  :_CoordinateAxisType = "Lat";

double lon_psi(eta_psi=719, xi_psi=699);
  :long_name = "longitude of PSI-points";
  :units = "degree_east";
  :standard_name = "longitude";
  :field = "lon_psi, scalar";
  :_CoordinateAxisType = "Lon";

double lat_psi(eta_psi=719, xi_psi=699);
  :long_name = "latitude of PSI-points";
  :units = "degree_north";
  :standard_name = "latitude";
  :field = "lat_psi, scalar";
  :_CoordinateAxisType = "Lat";

double ocean_time(ocean_time=1);
  :long_name = "averaged time since initialization";
  :units = "seconds since 2021-01-01 00:00:00";
  :calendar = "proleptic_gregorian";
  :field = "time, scalar, series";
  :_CoordinateAxisType = "Time";

// global attributes:
:file = "rst/L1/ROMS_2021_avg_L1_0001.nc";
:format = "netCDF-3 64bit offset file";
:Conventions = "CF-1.4, SGRID-0.3";
:type = "ROMS/TOMS nonlinear model averages file";
:title = "test07";
:var_info = "varinfo.dat";
:rst_file = "rst/L1/ROMS_2021_rst_L1.nc";
:his_base = "rst/L1/ROMS_2021_his_L1";
:avg_base = "rst/L1/ROMS_2021_avg_L1";
:grd_file = "grid_3min_7000m_smoothing4.nc";
:ini_file = "roms_ini_hycom_2021.nc";
:frc_file_01 = "roms_forcing_Pair_ERA5_2021.nc";
:frc_file_02 = "roms_forcing_Qair_ERA5_2021.nc";
:frc_file_03 = "roms_forcing_Tair_ERA5_2021.nc";
:frc_file_04 = "roms_forcing_rain_ERA5_2021.nc";
:frc_file_05 = "roms_forcing_swrad_ERA5_2021.nc";
:frc_file_06 = "roms_forcing_Uwind_ERA5_2021.nc";
:frc_file_07 = "roms_forcing_Vwind_ERA5_2021.nc";
:bry_file = "roms_bry_hycom_2021_daily.nc";
:script_file = "test07_2021.in";
:NLM_LBC = "\nEDGE: WEST SOUTH EAST NORTH \nzeta: Cha Cha Cha Cha \nubar: Fla Fla Fla Fla \nvbar: Fla Fla Fla Fla \nu: RadNud RadNud RadNud RadNud \nv: RadNud RadNud RadNud RadNud \ntemp: RadNud RadNud RadNud RadNud \nsalt: RadNud RadNud RadNud RadNud \ntke: Cha Cha Cha Cha";
:svn_url = "https://www.myroms.org/svn/src/trunk";
:svn_rev = "980";
:code_dir = "/home/snr-2019/ROMS/trunk";
:header_dir = "/data2/ROMS/2021_02-12";
:header_file = "test07.h";
:os = "Linux";
:cpu = "x86_64";
:compiler_system = "ifort";
:compiler_command = "/usr/local/mpi/intel18/mvapich2-2.2/bin/mpif90";
:compiler_flags = "-fp-model precise -heap-arrays -ip -O3 -traceback -check uninit";
:tiling = "010x010";
:history = "ROMS/TOMS, Version 3.8, Wednesday - September 21, 2022 - 10:38:00 PM";
:ana_file = "ROMS/Functionals/ana_btflux.h, ROMS/Functionals/ana_cloud.h, ROMS/Functionals/ana_tobc.h";
:CPP_options = "test07, ANA_BSFLUX, ANA_BTFLUX, ANA_CLOUD, ANA_TOBC, !ASSEMBLE_ALL..., ASSUMED_SHAPE, ATM_PRESS, AVERAGES, !BOUNDARY_A BULK_FLUXES, CANUTO_A !COLLECT_ALL..., CHARNOK, CRAIG_BANNER, CURVGRID, DIFF_GRID, DJ_GRADPS, DOUBLE_PRECISION, EMINUSP, GLS_MIXING, IMPLICIT_NUDGING, LIMIT_BSTRESS, LIMIT_STFLX_COOLING, KANTHA_CLAYSON, LONGWAVE, MASKING, MIX_ISO_TS, MIX_GEO_UV, MPI, NESTING, NONLINEAR, NONLIN_EOS, N2S2_HORAVG, ONE_WAY, PRESS_COMPENSATE, POWER_LAW, PROFILE, K_GSCHEME, REDUCE_ALLGATHER, RI_SPLINES, !RST_SINGLE, SALINITY, SOLAR_SOURCE, SOLVE3D, SPLINES_VDIFF, SPLINES_VVISC, TS_U3HADVECTION, TS_C4VADVECTION, TS_DIF4, UV_ADV, UV_COR, UV_U3HADVECTION, UV_C4VADVECTION, UV_LOGDRAG, UV_VIS4, VAR_RHO_2D, VISC_GRID";
:_CoordSysBuilder = "ucar.nc2.dataset.conv.CF1Convention";
}

@jay-hennen
Copy link
Contributor

The error is stating that it is trying to create a L_Depth (level depth) object, when the correct type of object for this file would be a S_Depth (sigma layer depth) object. Unfortunately I haven't yet pinpointed what exactly is causing this misidentification, but I hope the explanation of the error helps.

@jay-hennen
Copy link
Contributor

I believe the error can be circumvented by doing the following:

d_obj = gnome.environment.gridded_objects_base.Depth.from_netCDF(filename=filename, depth_type = 'sigma')
current = gnome.environment.environment_objects.GridCurrent.from_netCDF(filename=filename, depth=d_obj)
mover = gnome.mover.py_current_mover.PyCurrentMover.from_netCDF(current=current)

@kinsnow
Copy link
Author

kinsnow commented Oct 21, 2022

I believe the error can be circumvented by doing the following:

d_obj = gnome.environment.gridded_objects_base.Depth.from_netCDF(filename=filename, depth_type = 'sigma')
current = gnome.environment.environment_objects.GridCurrent.from_netCDF(filename=filename, depth=d_obj)
mover = gnome.mover.py_current_mover.PyCurrentMover.from_netCDF(current=current)

@jay-hennen Thanks for the advice. Unfortunately, the problem was not resolved..
I modified the code as follows:
curr_obj = gnome.environment.gridded_objects_base.Depth.from_netCDF( filename='ROMS_2021_his_L1_0001.nc', depth_type='sigma' ) current = gnome.environment.environment_objects.GridCurrent.from_netCDF( filename='ROMS_2021_his_L1_0001.nc', depth=curr_obj ) curr_file = PyCurrentMover.from_netCDF(current=current) model.movers += curr_file

and the following error message appears:
"Traceback (most recent call last):
File "E:\Pygnome\Temp\script_Temp_Current\script_temp_current_test.py", line 102, in
model = make_model()
File "E:\Pygnome\Temp\script_Temp_Current\script_temp_current_test.py", line 77, in make_model
curr_obj = gnome.environment.gridded_objects_base.Depth.from_netCDF(
File "c:\users\ksh\pygnome\py_gnome\gnome\environment\gridded_objects_base.py", line 400, in from_netCDF
return gridded.depth.Depth.from_netCDF(*args, **kwargs)
File "C:\Users\KSH\anaconda3\envs\gnome\lib\site-packages\gridded\depth.py", line 679, in from_netCDF
return cls.from_netCDF(filename=filename,
File "C:\Users\KSH\anaconda3\envs\gnome\lib\site-packages\gridded\depth.py", line 348, in from_netCDF
bathy_name = varnames.get('bathymetry', None)
AttributeError: 'NoneType' object has no attribute 'get'

Process finished with exit code 1"

Is there any problem my NetCDF ROMS output file's variables name?
If not, how can I solve these problem?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants