Thanks for responding. I have tried several ways of adding the command, one of which is:
for i in TSFC: if N.any(N.isnan(TSFC)): break else: pass but nothing is happening, is there some particular way I need to add this command? I have posted all below: netCDF_list=[] for dir in glob.glob(MainFolder + '*/01/')+ glob.glob(MainFolder + '*/02/')+ glob.glob(MainFolder + '*/12/'): #print dir for ncfile in glob.glob(dir + '*.nc'): netCDF_list.append(ncfile) slice_counter=0 print netCDF_list for filename in netCDF_list: ncfile=netCDF4.Dataset(filename) TSFC=ncfile.variables['T_SFC'][:] fillvalue=ncfile.variables['T_SFC']._FillValue TSFC=MA.masked_values(TSFC, fillvalue) for a in TSFC: if N.any(N.isnan(TSFC)): break else: pass for i in xrange(0,len(TSFC)-1,1): slice_counter +=1 #print slice_counter try: running_sum=N.add(running_sum, TSFC[i]) except NameError: print "Initiating the running total of my variable..." running_sum=N.array(TSFC[i]) TSFC_avg=N.true_divide(running_sum, slice_counter) N.set_printoptions(threshold='nan') print "the TSFC_avg is:", TSFC_avg On Tue, Dec 6, 2011 at 9:45 AM, David Cournapeau <courn...@gmail.com> wrote: > On Mon, Dec 5, 2011 at 5:29 PM, questions anon <questions.a...@gmail.com> > wrote: > > Maybe I am asking the wrong question or could go about this another way. > > I have thousands of numpy arrays to flick through, could I just identify > > which arrays have NAN's and for now ignore the entire array. is there a > > simple way to do this? > > Doing np.any(np.isnan(a)) for an array a should answer this exact question > > David > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion