Friday, August 5, 2011

Saving Text Files and Figures

Today I finished a function that will allow me to save text files of some important data associated with the contrast curve plots I made.

When a user saves a figure, an associated text file will save the lists of data returned from phot3.contrastcurve(...). That is, it will save a list of points used in the creation of a contrast curve as well as any point sources the program may have found in the annuli of the main star. The text file will also save the center coordinates of that star.

The text file will save to the name of x-y_fitsfilename-results.txt, where x,y are the center coordinates, and fitsfilename is the name of the fits file.

Here's an example of the kind of text file it will save:

C:\[Your path here]>IPhot CK00012_snap_20110412.fits
Press Q/q to quit, or any other key to load next image.

Clicking on point (22,100) and pressing W will save this picture... well as a .txt file containing this information:

Center Pts
(22, 100)
Coordiates (Radius,Contrast)
[(1.0310396072149, 1.2019494856629946), (1.2028795417507165, 1.8693450269793654), (1.3747194762865333, 2.1077248753625968), (1.5465594108223499, 2.3778325825061946), (1.718399345358167, 2.4598854750345436), (1.8902392798939833, 2.5393921380320639), (2.0620792144297999, 2.5689754466690302), (2.2339191489656169, 2.5851800258224134), (2.4057590835014335, 2.5950414542085398), (2.5775990180372501, 2.5998551889539634), (2.7494389525730667, 2.6055135477309928), (2.9212788871088833, 2.6096344474456359), (3.0931188216446999, 2.6104568644975972)]
Additional Point Sources at Each Radius (if any)
[[], [], [], [], [], [], [], [], [], [], [], [], []]

Saved to C:\Documents and Settings\Administrator\Desktop\CC22-100_CK00012_snap_2
Saved to C:\Documents and Settings\Administrator\Desktop\22-100_CK00012_snap_201
Quitting program...

C:\[Your path here]>

Note that I also created a little compass on the lower right corner of each Image object. =]

-Somehow scale the axis ticks of the subplot images to arcseconds as opposed to pixels.
-Maybe at some point figure out how to load directories of FITS files into my command line as opposed to a list of file names (which are very tedious to type).

I have changed the output of the text file so that it no longer returns a list of lists of point sources. It will simply return a list of point sources, or an empty list if there are none.

Wednesday, August 3, 2011

IPhot Changes

I successfully linked the two functions together in IPhot's createfigure(...) today after working on it for the past two days.

def createfigure(x,y): Creates a figure with a cropped image centering on the clicked point source by using phot3.plotptsmarking(...). If there are no other point sources in the cropped image, this function will plot a contrast curve using phot3.plotcontrastcurve(...), and the cropped image will be an inset on the top right corner of the contrast curve. Both of these functions were described in the previous post. x,y are the x and y coordinates of the mouse click. The cropped image specifications are specified by what the user enters in the command line and the mouse click, which indicates which point to center on. 

Example: (Using command line)

C:\[Your path here]>IPhot CK00012_snap_20110412.fits -s 2
Press Q/q to quit, or any other key to load next image.

Clicking on the center point source at around (94,72), we get this:
Detected point source: (94, 76)

Clicking on the point source at around (22,100), we get this:

Quitting program...

C:\[Your path here]>

Note that I used an annulus spacing of 2. This shows up in both of the cropped images. The inner circle around the point source represents the aperture radius. The larger circle around the point source indicates the innermost annulus radius, or where the program will begin to sample the contrast between the point source and the background around it. 

In the first cropped image, there is also a smaller circle (with a fixed radius of 1) that indicates where other point sources are in the image.

-How to create inset graphs (in two ways actually!). I can either use the axes(...) function from pylab or the inset_axes(...) function from mpl_toolkits
-Test my program and debug it. There are probably still some minor problems or aesthetic issues I still need to fix. 

Tuesday, August 2, 2011 - Two Functions

Today I finished coding two plotting functions.
def plotcontrastcurve(self,ann_space=0,darkpix=0.95,adj=3,thresh=5,fig=1): The original plotcontrastcurve(...) function wasn't nearly as fancy as this one. This function also allows the user to specify the number of adjacent pixels (adj) and the number of deviations from the mean background (thresh) that determines whether a pixel is a point source or not. The math behind the contrast curve has also changed. The shape looks pretty good, but I'm concerned that a lot of the curve is up in the negatives for contrast...

def plotptsmarking(self,cx,cy,filename="",ann_space=0,darkpix=0.95,adj=3,thresh=5): This function makes one of those subplot images that circles the aperture, the innermost annulus, and other point sources in the picture (if possible). It also has arguments for thresh and adj

Tomorrow I will link these two methods together in IPhot.