I am very new to netCDF operators and generally ignorant, but I've got to trace the source of an error so that I can eliminate it. Does anyone have any tips for me?
I want to pull out the value of a variable at a given set of coordinates from a file (ultimately from a whole bunch of files, but first things first). When i use ncks -v MinSurfAirTemp -d months,0,0 -d longitude,10,10 -d latitude,19,19 MidHolo2_1901_1950.nc the variable for the selected month at the selected coordinates appears on screen as requested, but then i get the following error message:
nco_err_exit(): ERROR Short NCO-generated message (usually name of function that triggered error): nco_get_vara()
nco_err_exit(): ERROR Error code is -40. Translation into English with nc_strerror(-40) is "NetCDF: Index exceeds dimension bound"
nco_err_exit(): ERROR NCO will now exit with system call exit(EXIT_FAILURE)
The problem with this is when i run the command in order to save the output to a new file, then the file is empty -- the error is interfering with my ability to generate a new output file with the selected data.
an earlier post suggested that i need to make sure that latitude and longitude aren't the names of both a variable and a dimension. I renamed the lat and lon variables so that they were not the same as the dimension names. The error persists.
Below is the complete output from the command <ncks -v MinSurfAirTemp -d months,0,0 -d longitude,10,10 -d latitude,19,19 MidHolo2_1901_1950.nc>:
MinSurfAirTemp: # dim. = 3, NC_FLOAT, # att. = 2, ID = 7
MinSurfAirTemp dimension 0: months, size = 13 NC_CHAR, dim. ID = 2 (CRD)
MinSurfAirTemp dimension 1: latitude, size = 24, dim. ID = 1
MinSurfAirTemp dimension 2: longitude, size = 36, dim. ID = 0
MinSurfAirTemp memory size is 13*24*36*nco_typ_lng(NC_FLOAT) = 11232*4 = 44928 bytes
MinSurfAirTemp attribute 0: long_name, size = 31 NC_CHAR, value = Minimum surface air temperature
MinSurfAirTemp attribute 1: units, size = 1 NC_CHAR, value = K
months[0]= latitude[19] longitude[10] MinSurfAirTemp[694]=244.116 K
nco_err_exit(): ERROR Short NCO-generated message (usually name of function that triggered error): nco_get_vara()
nco_err_exit(): ERROR Error code is -40. Translation into English with nc_strerror(-40) is "NetCDF: Index exceeds dimension bound"
nco_err_exit(): ERROR NCO will now exit with system call exit(EXIT_FAILURE)
-----------------------------------------------------------------------------
Below are the variables and dimensions contained in the file:
ncks -m MidHolo2_1901_1950.nc
MaxSurfAirTemp: # dim. = 3, NC_FLOAT, # att. = 2, ID = 6
MaxSurfAirTemp dimension 0: months, size = 13 NC_CHAR, dim. ID = 2 (CRD)
MaxSurfAirTemp dimension 1: latitude, size = 24, dim. ID = 1
MaxSurfAirTemp dimension 2: longitude, size = 36, dim. ID = 0
MaxSurfAirTemp memory size is 13*24*36*nco_typ_lng(NC_FLOAT) = 11232*4 = 44928 bytes
MaxSurfAirTemp attribute 0: long_name, size = 27 NC_CHAR, value = Max surface air temperature
MaxSurfAirTemp attribute 1: units, size = 1 NC_CHAR, value = K
MinSurfAirTemp: # dim. = 3, NC_FLOAT, # att. = 2, ID = 7
MinSurfAirTemp dimension 0: months, size = 13 NC_CHAR, dim. ID = 2 (CRD)
MinSurfAirTemp dimension 1: latitude, size = 24, dim. ID = 1
MinSurfAirTemp dimension 2: longitude, size = 36, dim. ID = 0
MinSurfAirTemp memory size is 13*24*36*nco_typ_lng(NC_FLOAT) = 11232*4 = 44928 bytes
MinSurfAirTemp attribute 0: long_name, size = 31 NC_CHAR, value = Minimum surface air temperature
MinSurfAirTemp attribute 1: units, size = 1 NC_CHAR, value = K
The problem is that you use 'months', a two-dimensional variable,
as a _coordinate variable_,which, by convention, must be one-dimensional.
This confuses NCO. We should probably make NCO print a better
warning message when someone tries to hyperslab on a 2-D coordinate.
You can work around the problem by removing or renaming the 'months' variable
from your file first, so it is not interpreted as a coordinate variable:
zender@virga:~/Desktop$ ncrename -O -v months,months_names MidHolo2_1901_1950.nc
zender@virga:~/Desktop$ ncks -v MinSurfAirTemp -d months,0,0 -d longitude,10,10 -d latitude,19,19 MidHolo2_1901_195
MinSurfAirTemp: # dim. = 3, NC_FLOAT, # att. = 2, ID = 1
MinSurfAirTemp dimension 0: months, size = 13, dim. ID = 0
MinSurfAirTemp dimension 1: latitude, size = 24, dim. ID = 1
MinSurfAirTemp dimension 2: longitude, size = 36, dim. ID = 2
MinSurfAirTemp memory size is 13*24*36*nco_typ_lng(NC_FLOAT) = 11232*4 = 44928 bytes
MinSurfAirTemp attribute 0: long_name, size = 31 NC_CHAR, value = Minimum surface air temperature
MinSurfAirTemp attribute 1: units, size = 1 NC_CHAR, value = K
months[0] latitude[19] longitude[10] MinSurfAirTemp[694]=244.116 K
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am very new to netCDF operators and generally ignorant, but I've got to trace the source of an error so that I can eliminate it. Does anyone have any tips for me?
I want to pull out the value of a variable at a given set of coordinates from a file (ultimately from a whole bunch of files, but first things first). When i use ncks -v MinSurfAirTemp -d months,0,0 -d longitude,10,10 -d latitude,19,19 MidHolo2_1901_1950.nc the variable for the selected month at the selected coordinates appears on screen as requested, but then i get the following error message:
nco_err_exit(): ERROR Short NCO-generated message (usually name of function that triggered error): nco_get_vara()
nco_err_exit(): ERROR Error code is -40. Translation into English with nc_strerror(-40) is "NetCDF: Index exceeds dimension bound"
nco_err_exit(): ERROR NCO will now exit with system call exit(EXIT_FAILURE)
The problem with this is when i run the command in order to save the output to a new file, then the file is empty -- the error is interfering with my ability to generate a new output file with the selected data.
an earlier post suggested that i need to make sure that latitude and longitude aren't the names of both a variable and a dimension. I renamed the lat and lon variables so that they were not the same as the dimension names. The error persists.
Below is the complete output from the command <ncks -v MinSurfAirTemp -d months,0,0 -d longitude,10,10 -d latitude,19,19 MidHolo2_1901_1950.nc>:
MinSurfAirTemp: # dim. = 3, NC_FLOAT, # att. = 2, ID = 7
MinSurfAirTemp dimension 0: months, size = 13 NC_CHAR, dim. ID = 2 (CRD)
MinSurfAirTemp dimension 1: latitude, size = 24, dim. ID = 1
MinSurfAirTemp dimension 2: longitude, size = 36, dim. ID = 0
MinSurfAirTemp memory size is 13*24*36*nco_typ_lng(NC_FLOAT) = 11232*4 = 44928 bytes
MinSurfAirTemp attribute 0: long_name, size = 31 NC_CHAR, value = Minimum surface air temperature
MinSurfAirTemp attribute 1: units, size = 1 NC_CHAR, value = K
months: # dim. = 2, NC_CHAR, # att. = 1, ID = 3
months dimension 0: months, size = 13 NC_CHAR, dim. ID = 2 (CRD)
months dimension 1: cbounds, size = 10, dim. ID = 4
months memory size is 13*10*nco_typ_lng(NC_CHAR) = 130*1 = 130 bytes
months attribute 0: long_name, size = 23 NC_CHAR, value = month or seasonal phase
months[0]= latitude[19] longitude[10] MinSurfAirTemp[694]=244.116 K
nco_err_exit(): ERROR Short NCO-generated message (usually name of function that triggered error): nco_get_vara()
nco_err_exit(): ERROR Error code is -40. Translation into English with nc_strerror(-40) is "NetCDF: Index exceeds dimension bound"
nco_err_exit(): ERROR NCO will now exit with system call exit(EXIT_FAILURE)
-----------------------------------------------------------------------------
Below are the variables and dimensions contained in the file:
ncks -m MidHolo2_1901_1950.nc
MaxSurfAirTemp: # dim. = 3, NC_FLOAT, # att. = 2, ID = 6
MaxSurfAirTemp dimension 0: months, size = 13 NC_CHAR, dim. ID = 2 (CRD)
MaxSurfAirTemp dimension 1: latitude, size = 24, dim. ID = 1
MaxSurfAirTemp dimension 2: longitude, size = 36, dim. ID = 0
MaxSurfAirTemp memory size is 13*24*36*nco_typ_lng(NC_FLOAT) = 11232*4 = 44928 bytes
MaxSurfAirTemp attribute 0: long_name, size = 27 NC_CHAR, value = Max surface air temperature
MaxSurfAirTemp attribute 1: units, size = 1 NC_CHAR, value = K
MinSurfAirTemp: # dim. = 3, NC_FLOAT, # att. = 2, ID = 7
MinSurfAirTemp dimension 0: months, size = 13 NC_CHAR, dim. ID = 2 (CRD)
MinSurfAirTemp dimension 1: latitude, size = 24, dim. ID = 1
MinSurfAirTemp dimension 2: longitude, size = 36, dim. ID = 0
MinSurfAirTemp memory size is 13*24*36*nco_typ_lng(NC_FLOAT) = 11232*4 = 44928 bytes
MinSurfAirTemp attribute 0: long_name, size = 31 NC_CHAR, value = Minimum surface air temperature
MinSurfAirTemp attribute 1: units, size = 1 NC_CHAR, value = K
Precip: # dim. = 3, NC_FLOAT, # att. = 2, ID = 4
Precip dimension 0: months, size = 13 NC_CHAR, dim. ID = 2 (CRD)
Precip dimension 1: latitude, size = 24, dim. ID = 1
Precip dimension 2: longitude, size = 36, dim. ID = 0
Precip memory size is 13*24*36*nco_typ_lng(NC_FLOAT) = 11232*4 = 44928 bytes
Precip attribute 0: long_name, size = 13 NC_CHAR, value = Precipitation
Precip attribute 1: units, size = 6 NC_CHAR, value = mm/day
SurfAirTemp: # dim. = 3, NC_FLOAT, # att. = 2, ID = 5
SurfAirTemp dimension 0: months, size = 13 NC_CHAR, dim. ID = 2 (CRD)
SurfAirTemp dimension 1: latitude, size = 24, dim. ID = 1
SurfAirTemp dimension 2: longitude, size = 36, dim. ID = 0
SurfAirTemp memory size is 13*24*36*nco_typ_lng(NC_FLOAT) = 11232*4 = 44928 bytes
SurfAirTemp attribute 0: long_name, size = 23 NC_CHAR, value = Surface Air Temperature
SurfAirTemp attribute 1: units, size = 5 NC_CHAR, value = deg C
bounds_lat: # dim. = 2, NC_FLOAT, # att. = 0, ID = 2
bounds_lat dimension 0: latitude, size = 24, dim. ID = 1
bounds_lat dimension 1: bounds, size = 2, dim. ID = 3
bounds_lat memory size is 24*2*nco_typ_lng(NC_FLOAT) = 48*4 = 192 bytes
lat2d: # dim. = 1, NC_FLOAT, # att. = 3, ID = 1
lat2d dimension 0: latitude, size = 24, dim. ID = 1
lat2d memory size is 24*nco_typ_lng(NC_FLOAT) = 24*4 = 96 bytes
lat2d attribute 0: long_name, size = 8 NC_CHAR, value = Latitude
lat2d attribute 1: units, size = 13 NC_CHAR, value = degrees_north
lat2d attribute 2: bounds, size = 10 NC_CHAR, value = bounds_lat
lon2d: # dim. = 1, NC_FLOAT, # att. = 4, ID = 0
lon2d dimension 0: longitude, size = 36, dim. ID = 0
lon2d memory size is 36*nco_typ_lng(NC_FLOAT) = 36*4 = 144 bytes
lon2d attribute 0: long_name, size = 9 NC_CHAR, value = Longitude
lon2d attribute 1: units, size = 12 NC_CHAR, value = degrees_east
lon2d attribute 2: topology, size = 8 NC_CHAR, value = circular
lon2d attribute 3: modulo, size = 1 NC_FLOAT, value = 360
months: # dim. = 2, NC_CHAR, # att. = 1, ID = 3
months dimension 0: months, size = 13 NC_CHAR, dim. ID = 2 (CRD)
months dimension 1: cbounds, size = 10, dim. ID = 4
months memory size is 13*10*nco_typ_lng(NC_CHAR) = 130*1 = 130 bytes
months attribute 0: long_name, size = 23 NC_CHAR, value = month or seasonal phase
NCO's behavior here is perplexing.
What version of NCO are you using?
Does this command give the same results? (it should):
ncks -v MinSurfAirTemp -d months,0 -d longitude,10 -d latitude,19
MidHolo2_1901_1950.nc
If the problem persists please make the input file available to us.
Charlie
I am using version 3.9.0-1.2 on Ubuntu 8.10.
when i try ncks -v MinSurfAirTemp -d months,0 -d longitude,10 -d latitude,19 MidHolo2_1901_1950.nc i get the same output with the same error message.
I have made the input file available here:
http://www.buffalo.edu/~evahulse/MidHolo2_1901_1950.nc
It was created using EdGCM.
Thanks for your quick response!
The problem is that you use 'months', a two-dimensional variable,
as a _coordinate variable_,which, by convention, must be one-dimensional.
This confuses NCO. We should probably make NCO print a better
warning message when someone tries to hyperslab on a 2-D coordinate.
You can work around the problem by removing or renaming the 'months' variable
from your file first, so it is not interpreted as a coordinate variable:
zender@virga:~/Desktop$ ncrename -O -v months,months_names MidHolo2_1901_1950.nc
zender@virga:~/Desktop$ ncks -v MinSurfAirTemp -d months,0,0 -d longitude,10,10 -d latitude,19,19 MidHolo2_1901_195
MinSurfAirTemp: # dim. = 3, NC_FLOAT, # att. = 2, ID = 1
MinSurfAirTemp dimension 0: months, size = 13, dim. ID = 0
MinSurfAirTemp dimension 1: latitude, size = 24, dim. ID = 1
MinSurfAirTemp dimension 2: longitude, size = 36, dim. ID = 2
MinSurfAirTemp memory size is 13*24*36*nco_typ_lng(NC_FLOAT) = 11232*4 = 44928 bytes
MinSurfAirTemp attribute 0: long_name, size = 31 NC_CHAR, value = Minimum surface air temperature
MinSurfAirTemp attribute 1: units, size = 1 NC_CHAR, value = K
months[0] latitude[19] longitude[10] MinSurfAirTemp[694]=244.116 K
It works! Thank you so much. I really would not have figured that one out on my own.