Skip to content

NetCDF Error: attribute units for longitude #23

@hanggoro-litbang

Description

@hanggoro-litbang

Dear trondkr,
I'm having this issue when trying to run "runM2R.py" For your information, I'm using my own ROMS grid (created with grid builder) which I rename as the template. My simulation date is 2020-01-01 to 2020-01-03 using Glorys data.

Regards,

ROMS grid

netcdf tes {
dimensions:
	xi_rho = 10 ;
	eta_rho = 20 ;
	xi_u = 9 ;
	eta_u = 20 ;
	xi_v = 10 ;
	eta_v = 19 ;
	xi_psi = 9 ;
	eta_psi = 19 ;
	one = 1 ;
	s_rho = 25 ;
	s_w = 26 ;
variables:
	double xl(one) ;
		xl:long_names = "domain length in the XI-direction" ;
		xl:units = "meter" ;
	double el(one) ;
		el:long_names = "domain length in the ETA-direction" ;
		el:units = "meter" ;
	double depthmin(one) ;
		depthmin:long_names = "Shallow bathymetry clipping depth" ;
		depthmin:units = "meter" ;
	double depthmax(one) ;
		depthmax:long_names = "Deep bathymetry clipping depth" ;
		depthmax:units = "meter" ;
	char spherical(one) ;
		spherical:long_names = "grid type logical switch" ;
		spherical:units = "" ;
	double angle(eta_rho, xi_rho) ;
		angle:long_names = "angle between XI-axis and EAST" ;
		angle:units = "radians" ;
	double h(eta_rho, xi_rho) ;
		h:long_names = "bathymetry at RHO-points" ;
		h:units = "meter" ;
	double hraw(eta_rho, xi_rho) ;
		hraw:long_names = "Working bathymetry at RHO-points" ;
		hraw:units = "meter" ;
	double f(eta_rho, xi_rho) ;
		f:long_names = "Coriolis parameter at RHO-points" ;
		f:units = "second-1" ;
	double pm(eta_rho, xi_rho) ;
		pm:long_names = "curvilinear coordinate metric in XI" ;
		pm:units = "meter-1" ;
	double pn(eta_rho, xi_rho) ;
		pn:long_names = "curvilinear coordinate metric in ETA" ;
		pn:units = "meter-1" ;
	double dndx(eta_rho, xi_rho) ;
		dndx:long_names = "xi derivative of inverse metric factor pn" ;
		dndx:units = "meter-2" ;
	double dmde(eta_rho, xi_rho) ;
		dmde:long_names = "eta derivative of inverse metric factor pm" ;
		dmde:units = "meter-2" ;
	double lon_rho(eta_rho, xi_rho) ;
		lon_rho:long_names = "longitude of RHO-points" ;
		lon_rho:units = "degree_east" ;
	double lon_u(eta_u, xi_u) ;
		lon_u:long_names = "longitude of U-points" ;
		lon_u:units = "degree_east" ;
	double lon_v(eta_v, xi_v) ;
		lon_v:long_names = "longitude of V-points" ;
		lon_v:units = "degree_east" ;
	double lon_psi(eta_psi, xi_psi) ;
		lon_psi:long_names = "longitude of PSI-points" ;
		lon_psi:units = "degree_east" ;
	double lat_rho(eta_rho, xi_rho) ;
		lat_rho:long_names = "latitude of RHO-points" ;
		lat_rho:units = "degree_north" ;
	double lat_u(eta_u, xi_u) ;
		lat_u:long_names = "latitude of U-points" ;
		lat_u:units = "degree_north" ;
	double lat_v(eta_v, xi_v) ;
		lat_v:long_names = "latitude of V-points" ;
		lat_v:units = "degree_north" ;
	double lat_psi(eta_psi, xi_psi) ;
		lat_psi:long_names = "latitude of PSI-points" ;
		lat_psi:units = "degree_north" ;
	double mask_rho(eta_rho, xi_rho) ;
		mask_rho:long_names = "mask on RHO-points" ;
		mask_rho:units = "" ;
	double mask_u(eta_u, xi_u) ;
		mask_u:long_names = "mask on U-points" ;
		mask_u:units = "" ;
	double mask_v(eta_v, xi_v) ;
		mask_v:long_names = "mask on V-points" ;
		mask_v:units = "" ;
	double mask_psi(eta_psi, xi_psi) ;
		mask_psi:long_names = "mask on psi-points" ;
		mask_psi:units = "" ;
	double hc ;
		hc:long_names = "S-coordinate parameter, critical depth" ;
		hc:units = "meter" ;
	double Cs_r(s_rho) ;
		Cs_r:long_names = "S-coordinate stretching curves at RHO-points" ;
		Cs_r:units = "" ;
	double Cs_w(s_w) ;
		Cs_w:long_names = "S-coordinate stretching curves at W-points" ;
		Cs_w:units = "" ;
	double s_rho(s_rho) ;
		s_rho:long_names = "S-coordinate at RHO-points" ;
		s_rho:units = "" ;
	double s_w(s_w) ;
		s_w:long_names = "S-coordinate at W-points" ;
		s_w:units = "" ;
	double Vtransform ;
		Vtransform:long_names = "vertical terrain-following transformation equation" ;
		Vtransform:units = "" ;
	double Vstretching ;
		Vstretching:long_names = "vertical terrain-following stretching function" ;
		Vstretching:units = "" ;
	double theta_s ;
		theta_s:long_names = "S-coordinate surface control parameter" ;
		theta_s:units = "" ;
	double theta_b ;
		theta_b:long_names = "S-coordinate bottom control parameter" ;
		theta_b:units = "" ;
	double Tcline ;
		Tcline:long_names = "S-coordinate surface/bottom layer width" ;
		Tcline:units = "" ;

// global attributes:
		:title = "CustomGrid" ;
		:date = "18 Jun 2025" ;
		:type = "ROMS grid file" ;
}

Glorys Data

netcdf CMEMS_So_monthly_MERCATOR_2020-01 {
dimensions:
	time = 217 ;
	depth = 1 ;
	latitude = 481 ;
	longitude = 1081 ;
variables:
	float uo(time, depth, latitude, longitude) ;
		uo:_FillValue = 9.96921e+36f ;
		string uo:standard_name = "eastward_sea_water_velocity" ;
		string uo:units = "m s-1" ;
		uo:valid_max = 10.f ;
		string uo:long_name = "Eastward surface velocity" ;
		uo:valid_min = -10.f ;
		string uo:unit_long = "Meters per second" ;
	float vo(time, depth, latitude, longitude) ;
		vo:_FillValue = 9.96921e+36f ;
		string vo:standard_name = "northward_sea_water_velocity" ;
		string vo:units = "m s-1" ;
		vo:valid_max = 10.f ;
		string vo:long_name = "Northward surface velocity" ;
		vo:valid_min = -10.f ;
		string vo:unit_long = "Meters per second" ;
	float so(time, depth, latitude, longitude) ;
		so:_FillValue = 9.96921e+36f ;
		string so:standard_name = "sea_water_salinity" ;
		string so:units = "1e-3" ;
		so:valid_max = 50.f ;
		string so:long_name = "sea surface salinity" ;
		so:valid_min = 0.f ;
		string so:unit_long = "Practical Salinity Unit" ;
	float thetao(time, depth, latitude, longitude) ;
		thetao:_FillValue = 9.96921e+36f ;
		string thetao:standard_name = "sea_water_potential_temperature" ;
		string thetao:units = "degrees_C" ;
		thetao:valid_max = 40.f ;
		string thetao:long_name = "sea_surface_temperature" ;
		thetao:valid_min = -10.f ;
		string thetao:unit_long = "Degrees Celsius" ;
	float zos(time, depth, latitude, longitude) ;
		zos:_FillValue = 9.96921e+36f ;
		string zos:standard_name = "sea_surface_height_above_geoid" ;
		string zos:units = "m" ;
		zos:valid_max = 5.f ;
		string zos:long_name = "Sea surface height" ;
		zos:valid_min = -5.f ;
		string zos:unit_long = "Meters" ;
	float depth(depth) ;
		string depth:standard_name = "depth" ;
		string depth:units = "m" ;
		string depth:positive = "down" ;
		string depth:long_name = "Depth" ;
		string depth:axis = "Z" ;
		string depth:unit_long = "Meters" ;
	float latitude(latitude) ;
		string latitude:standard_name = "latitude" ;
		string latitude:units = "degrees_north" ;
		string latitude:long_name = "Latitude" ;
		string latitude:axis = "Y" ;
		string latitude:unit_long = "Degrees North" ;
	float longitude(longitude) ;
		string longitude:standard_name = "longitude" ;
		string longitude:units = "degrees_east" ;
		string longitude:long_name = "Longitude" ;
		string longitude:axis = "X" ;
		string longitude:unit_long = "Degrees East" ;
	float time(time) ;
		string time:unit_long = "Hours Since 1950-01-01" ;
		string time:axis = "T" ;
		string time:standard_name = "time" ;
		string time:long_name = "Time" ;
		string time:units = "hours since 1950-01-01" ;
		string time:calendar = "gregorian" ;

// global attributes:
		string :source = "MOI GLO12" ;
		string :producer = "CMEMS - Global Monitoring and Forecasting Centre" ;
		string :contact = "https://marine.copernicus.eu/contact" ;
		string :Conventions = "CF-1.8" ;
		string :institution = "Mercator Ocean International" ;
		string :title = "hourly mean fields from Global Ocean Physics Analysis and Forecast updated Daily" ;
		string :references = "http://marine.copernicus.eu" ;
		string :credit = "E.U. Copernicus Marine Service Information (CMEMS)" ;
		string :copernicusmarine_version = "2.1.2" ;
}

Error messages

INFO:root:[M2R_grd] ---> Using dimension names longitude and latitude and depth
NetCDF Error: attribute units for longitude in oceanography/copernicus-marine-data/Global/so/CMEMS_So_monthly_MERCATOR_2020-01.nc : NetCDF: Attempt to convert between text & numbers
Traceback (most recent call last):
  File "/home/litbang/model2roms/runM2R.py", line 51, in <module>
    run()
  File "/home/litbang/model2roms/runM2R.py", line 34, in run
    model2roms.convert_MODEL2ROMS(confM2R)
  File "/home/litbang/model2roms/model2roms.py", line 402, in convert_MODEL2ROMS
    confM2R.grdMODEL.create_object(confM2R, filenamein)
  File "/home/litbang/model2roms/grd.py", line 76, in create_object
    self.esmfgrid = ESMF.Grid(filename=grd_filename, filetype=ESMF.FileFormat.GRIDSPEC,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/litbang/.conda/envs/model2roms/lib/python3.12/site-packages/esmpy/util/decorators.py", line 59, in new_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/litbang/.conda/envs/model2roms/lib/python3.12/site-packages/esmpy/api/grid.py", line 347, in __init__
    self._struct = ESMP_GridCreateFromFile(filename, filetype,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/litbang/.conda/envs/model2roms/lib/python3.12/site-packages/esmpy/util/decorators.py", line 71, in new_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/litbang/.conda/envs/model2roms/lib/python3.12/site-packages/esmpy/interface/cbindings.py", line 745, in ESMP_GridCreateFromFile
    raise NameError('ESMC_GridCreateFromFile() failed with rc = '+str(rc))
NameError: ESMC_GridCreateFromFile() failed with rc = -1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions