I am working with monthly rainfall data from University of Delaware which is available as a NetCDF from NOAA and raw text from UDel's homepage. I would prefer to use the NetCDF format but when I extract values, these don't match what the ones in the raw data files.
Can you suggest why the comparison might not be working?
# Extract data
from netCDF4 import Dataset
ncfile = "C:/precip.mon.total.v401.nc"
fnc = Dataset(ncfile, 'r')
print fnc.variables
lat = fnc.variables['lat']
lon = fnc.variables['lon']
monthyear = fnc.variables['time']
rain = fnc.variables['precip']
# Manually check values / example one
print lat[37] # 71.250
print lon[0]-180 # -179.750 (need to subtract 180 because the lon values in the nc file range from 0 to 360)
print rain[0:12, 37, 0]*10
# Wrong output: [-- -- -- -- -- -- -- -- -- -- -- --]
# Another example
print lat[46] # 66.750
print lon[54]-180 # -152.750 (need to subtract 180 because the lon values in the nc file range from 0 to 360)
print rain[0:12, 46, 54]*10
# Wrong output: [26.6 30.5 23.6 27.1 29.7 26.1 101.9 44.4 31. 79.8 49.9 29.7]
Acc to the raw data the values corresponding to lon -179.750 and lat 71.250 are:
0.0 5.4 0.0 4.0 7.3 3.9 33.5 63.2 9.4 4.0 8.0 23.6
In case of lon -152.75 and lat 66.75, the extracted data should have been:
11.6 11.4 26.4 28.5 14.3 31.7 30.5 67.0 59.6 22.9 9.1 33.3
(The netCDF may be downloaded from https://www.dropbox.com/s/6zi0imr5i1qlqgs/precip.mon.total.v401.nc?dl=0 and the raw data file is available here https://www.dropbox.com/s/6klwmj37kvwj46w/precip.1900?dl=0)