I want to perform statistics on an annulus around a central portion of a 2D array (performing statistics on the background around a star in an image,for instance). I know how to obtain a 2D slice of a region inside of the array and return the indices of that slice, but is there any way of obtaining the indices of the values outside of the slice?
I have a 2D array called 'Z' and some box size (PSF_box) around which I want to perform some statistics. This is what I've got so far:
center = np.ceil(np.shape(Z)[0]/2.0) # center of the array
# Make a 2d slice of the star, and convert those pixels to nan
annulus[center-ceil(PSF_size/2.0):center+ceil(PSF_size/2.0)-1,\
center-ceil(PSF_size/2.0):center+ceil(PSF_size/2.0)-1] = np.nan
np.savetxt('annulus.dat',annulus,fmt='%s')
I convert the pixels inside of this box slice to nan, but I don't know how to output the indices of pixels outside of the box that are not 'nan'. Or better yet, is there a way to perform some operations on just the area around the slice directly? (As opposed to outputting pixel values that aren't nan)