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