Getting a strange result trying to divide two 3d arrays. I am getting
a matrix of NaNs regardless of how I divide and I can't determine why.
#opened a NetCDF file using python-netcdf4
var1 = nc_file.variables['var1'] ###shape = [31,181,360] with a
values ranging from 0 - 243 and NO NaNs in the array, dtype float32
var2 = nc_file.variables['var2'] ###shape = [31,181,360] with a
values ranging from 0 - 4 (mostly zeros) and NO NaNs in the array,
dtype float32
np.seterr(all='ignore') #in case problem has something do to with
dividing by zero
var1/var2 ###gives array of NaNs with shape of 31,181,360
#doing the division one slice at a time doesn't help...
for x in range(1,var1.shape[0]):
var[x,:,:] = var1[x,:,:]/var2[x,:,:] ###gives array of
NaNs with shape of 31,181,360
var = np.divide(var1,var2) ###gives array of NaNs with shape of 31,181,360
print "<p>where max: " + np.where(var1 == np.max(var1)) #prints
(array([28]), array([79]), array([182]))
print var1[28,79,182] #print 545
print var2[28,79,182] ##prints 6
#so there are values in this location that should not result in an
NaN. Instead I get an entire array of NaNs
What am I missing?
Bruce
···
---------------------------------------
Bruce W. Ford
Clear Science, Inc.
bruce@...2905...