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 which arrays have NAN's and for now ignore the entire array. is there a simple way to do this?<br>
any feedback will be greatly appreciated. <br><br><div class="gmail_quote">On Thu, Dec 1, 2011 at 12:16 PM, questions anon <span dir="ltr"><<a href="mailto:questions.anon@gmail.com">questions.anon@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;">I am trying to calculate the mean across many netcdf files. I cannot use numpy.mean because there are too many files to concatenate and I end up with a memory error. I have enabled the below code to do what I need but I have a few nan values in some of my arrays. Is there a way to ignore these somewhere in my code. I seem to face this problem often so I would love a command that ignores blanks in my array before I continue on to the next processing step.<br>

Any feedback is greatly appreciated.<br><br><br>netCDF_list=[]<br>for dir in glob.glob(MainFolder + '*/01/')+ glob.glob(MainFolder + '*/02/')+ glob.glob(MainFolder + '*/12/'):<br>        for ncfile in glob.glob(dir + '*.nc'):<br>

            netCDF_list.append(ncfile)<br><br>slice_counter=0<br>print netCDF_list<br><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 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>
</blockquote></div><br>