This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Dr. Segal, > I am trying to read NCEP reanalysis files (for example air.1987.nc ) > > I am using 64 bit Matlab on 64bit windows 7 machine. > > The procedure I have wrote is: > > ncid = > netcdf.open('C:\Users\user\Documents\Wales\Regional\1987\air.1987.nc','NC_NOWRITE'); > [varname, xtype, varDimIDs, varAtts] = netcdf.inqVar(ncid,4); > varid = netcdf.inqVarID(ncid,varname); > air = netcdf.getVar(ncid,varid'); > > air is expected to contain temperatures in int16 variable, however when > I check the values they don't come in K units, for example: > >> air(1,1,1,1) > > ans = > > -24166 > > which is expected to be something about 250K. > > It is important to note that other variables, for example: > > [varname, xtype, varDimIDs, varAtts] = netcdf.inqVar(ncid,0); > varid = netcdf.inqVarID(ncid,varname); > level = netcdf.getVar(ncid,varid); > > and here the data is accurate > > level > > level = > > 1000 > 925 > 850 > 700 > 600 > 500 > 400 > 300 > 250 > 200 > 150 > 100 > 70 > 50 > 30 > 20 > 10 Does the "air" variable have the attributes "scale_factor" or "add_offset"? If so, it would indicate that the data is packed, and should be unpacked by applying the formula unpacked_data_value = packed_data_value * scale_factor + add_offset If that doesn't explain the problem, try using the "ncdump" program to see the values of the air variable. If ncdump gets the right values but your Matlab program doesn't, then that indicates a problem in your program or Matlab. If ncdump shows the wrong values, we might be able to determine the problem by looking at the air.1987.nc file, if you could make it available. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: COH-743209 Department: Support netCDF Priority: Normal Status: Closed