Thursday, June 23, 2011

Finding Point Sources

Thursdays are the best. We get free donuts/bagels. :D

I continued to modify my file while munching on a delicious bagel.
Today my main focus was on creating a function that would plot potential point sources. However, in order to do that, I had to create a lot of little sub-methods.

First though, I made two more plotting methods:

def fluxcol(self,col,cx,title="Flux v. Radial Distance from Object Center",fig=1): Plots flux v. radial distance from object along a specified column

Assuming we have an im Image object: (im.xc, im.yc are the 'coordinates' of the brightest pixel in the array)
>>> fluxcol(im.yc,im.xc)
def fluxrow(self,row,cy,title="Flux v. Radial Distance from Object Center",fig=1): Plots flux v. radial distance from object along a specified row

Assuming we have an im Image object:
>>> fluxcol(im.xc,im.yc)

Here are the sub-methods I worked on today:

def bg(self,darkpix=0.95): Finds all the pixels that are in the background, where the number of background pixels is specified by the percentage of darkpix

def get_bgsigma(self,darkpix=0.95): Gets background sigma (excludes bright objects)

def get_bgmean(self,darkpix=0.95): Gets background mean value (excludes bright objects)

def potptsources(self,dataarr,darkpix=0.95): Finds a list of potential point sources

The goal is to eventually use all of these methods in a method called findptsources(). My rough outline of what to do goes somewhat along these lines:
-Use bg() and get_bgsigma() to find the average background variation across the image.
-Then we can use potptsources( to find the potential point sources (the method will return an array of potential point sources). The method will take all pixels that have a brightness value greater than 5*sigma of the average background brightness and return their coordinates.
-However, we cannot just assume that all bright points are point sources - occasionally cosmic rays might strike one of the CCD wells and produce a shower of electrons, resulting in a very high measurement for that certain well. However, this will be a well with a single incredibly bright pixel surrounded by pixels that have the same brightness as the background. Thus we have to create another function that checks the adjacent pixels for values > 5*sigma+im.get_bgmean(darkpix). The function will keep only those pixels that satisfy these requirements.
-Finally, we will write a recursive function that starts at a pixel, and if it finds a brighter value in one of the adjacent pixels, moves to that pixels and again looks for brighter adjacent pixels. Eventually we will get a few pixels that are brighter than all of their respectively surrounding pixels. These will be the point sources we are looking for.


-the histogram plotting function actually can take a range of values for bin as well. For example, if we set a = arange(0,10,0.01), the function will create bins spanning 0-10 that differ by 0.01. Basically, when the function sees an array for bins, it will only make bars at those values in the array. Very neat!
-sorting algorithms (a.sort(), sort(a), etc)
-Figuring out the recursive methods/how to code the sub-methods
-Finish the findptsources() code.

No comments:

Post a Comment