Tuesday, June 28, 2011

Contrast Curves (Monday-Tuesday)

Yesterday wasn't too exciting (as in I thought more than twice the work I produced), so I didn't blog.
First of all, I fixed up my point sources function. Now there are less points that are likely point sources, but there are still a few too many. I also started working on a contrast curve function yesterday, but didn't get far on the actual coding.

I'm still working on the contrast curve function(s) today... and will tomorrow as well.
-----
The idea is to create a contrast curve that plots contrast (basically magnitude of flux against some background noise) versus radial distance away from the star's center. The center is defined by fitting a Gaussian to the data and finding the x and y coordinates of the peak. The actual gaussianfit(...) function is found here: http://www.scipy.org/Cookbook/FittingData.

Now, in order to plot the magnitude and account for some differences in background noise near the star, we need to find annuli around the PSF of the star, and figure out the "background noise" in each annulus. I say this with quotes since a bit of the star's flux will leak out into this region and affect the overall flux level. We need many different concentric annuli since the flux varies in this region.

The annuli will have a width of two FWHM's to get a complete curve of other stars' PSF (if there are other stars in the picture). I will also calculate the background noise of overlapping annuli so that if we do see another star in the picture, we can hopefully get a PSF that isn't cut off by at least one annulus.

Anyways, I made a function called ann_meanbg(...). Given a center (cx,cy) and inner and outer radii (ann_in, ann_out) it can find the mean background flux of an annulus defined by the center coordinates and radii. Since there might be times where the annulus contains another fainter star that significantly increases the background flux, I have included a darkpix factor that will only take the darkest darkpix percentage of pixels in order to ignore the fainter star. 


def ann_meanbg(self,cx,cy,ann_in,ann_out,darkpix=1): Finds the average background noise of an annulus.

I also started a contrastcurve(...) method. It is supposed to return one array of radii that is the average of ann_in and ann_out, and one corresponding array that contains the annulus background noise at each radius. 


A third function I made is called subplot(...):
def subplot(self,cx,cy,xsz=50,ysz=50): Makes a cropped image from the original image with cx, cy as center coordinates and with a width of xsz and height of ysz.

Finally, because of the way my original class was defined, I had to completely redesign it so that contrastcurve(...) would be able to be a function of the class. Now the Image class takes the data array of the FITS file as opposed to the FITS file itself. I have defined a subclass called GuiderImage(Image) to take care of the FITS file header. 


Example: (assuming we have an Image (the new class) object called im)
>>>im.show()
This returns:
>>>sim=im.subplot(21,99,40,40)
>>>sim.show()
This returns:
>>>a=u.fitgaussian(sim.data)
>>>a
array([685.03745756, 20.29637509, 19.94028319, 27.96468548, 27.93414018])
>>>sim.ann_meanbg(a[1],a[0],5,8)
557.72357723577238

Learned:
-A little bit about the Gaussian/Bi-Variate Normal Distributions
-Python subclasses
-The use of lambda in Python functions
-How to dezero an array (take out all the zeros in an array) efficiently - using a[a!=0]
-Background about Contrast Curves
Problems/To-Do:
-Complete the contrastcurve(...) function
-Figure out how to find the difference in magnitude and plot the contrast curve

No comments:

Post a Comment