tag:blogger.com,1999:blog-75140661980063736462024-03-12T23:03:29.305-07:00ExolabHi there! This is Sandra Fang's blog in which she'll discuss her work on Photometry/Contrast Curves with Tim Morton and Professor Johnson at Caltech's Astronomy Department for the summer of 2011.Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.comBlogger38125tag:blogger.com,1999:blog-7514066198006373646.post-13622768289002935922011-09-01T17:14:00.000-07:002011-09-01T17:14:21.073-07:00I think it's finally done.My contrast curve plotter/point source detector finally works as intended!<br />
<br />
To detect a point source companion or plot a contrast curve requires the program to first determine the background noise in the image. The program does so by first determining the aperture of the star (radius of one FWHM) and then determining the pixels that make up annuli that are 2 FWHM wide around the star. The radius of each annulus is defined as the midpoint between the inner and outer radii that define the annulus. Each annulus increases in radius by FWHM/2. This overlap of annuli allow us to find point sources that might have been on the edge of an annulus and otherwise missed.<br />
<br />
For the point source detector, we further break up each annulus into spheres arranged in a ring in the annulus. Each sphere has a radius of 1 FWHM and the spheres overlap each other by half a FWHM. We determine the background of the spherical regions and then find point sources according to the <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">darkpix, thresh</span><span class="Apple-style-span" style="font-family: inherit;">, and</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> adj</span><span class="Apple-style-span" style="font-family: inherit;"> values I've mentioned in previous posts. </span>By breaking up the annuli into regions, we can more accurately determine the local background noise in each region and see if any region contains a point source.<br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">(To refresh: </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">darkpix</span><span class="Apple-style-span" style="font-family: inherit;"> is a decimal that determines the percent of darkest pixels used to find the mean noise of the background. t</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">hresh</span><span class="Apple-style-span" style="font-family: inherit;"> is the threshhold, or the multiplier we use with sigma, the standard deviation of the flux. Only pixels with intensity values greater than </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thresh</span><span class="Apple-style-span" style="font-family: inherit;">*sigma+background mean will be labeled as potential point sources. </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">adj</span><span class="Apple-style-span" style="font-family: inherit;"> determines the number of adjacent pixels greater than </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thresh</span><span class="Apple-style-span" style="font-family: inherit;">*sigma+background mean</span> a potential point source has to have in order for a pixel to be labeled as the position of the point source. )<br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
For the contrast curve graph, we measure the difference in magnitude in each annulus with the peak flux of the central star. We call this difference contrast, or delta M. The graph plots contrast with respect to the radius of each annulus (the midpoint between the inner and outer radii). The magnitude value in each annulus is calculated in this way:<br />
<br />
After getting the mean background of the regions in each annulus, we average the values of each region to get the average intensity of the annulus itself. We then convert this to a delta mag number by using the equation:<br />
<br />
<div style="text-align: center;"><i>Contrast = -2.5*log10(flux1/flux2)</i></div><i><br />
</i><br />
Flux 1 is the average flux of the annulus; flux 2 is the peak flux of the star. Finally, we plot the contrast with respect to magnitude on our graph.<br />
<br />
If there is no companion point source, the program will plot a contrast curve; otherwise, the program will label the location of the main point source and its companion(s). The user can opt to save either of these figures by pressing "w". A text file with some important information will be saved along with the figure.<br />
-----<br />
This serves as a general description of what my program does. There are some specific details that I also need to mention:<br />
<br />
- The darkpix value in my program, when used to detect extra point sources, has been set as 0.8 to increase robustness of the point source detector. The darkpix value is generally set to 0.95 when determining which pixels constitute the "background" of the FITS file.<br />
- The ratio of arcseconds to pixels changes for each fits file. However, due to the variety of FITS files I am working with (some of them without headers as well), I cannot create subclasses for each FITS file (as I originally intended) and automatically make my program look for the arcseconds to pixels ratio. Thus the user needs to manually type it in into the phot4.py module. Hopefully this process will become more user-friendly as I clean up the program a bit.<br />
-When the user enters multiple fits files into the command line when working with IPhot, the user needs to make sure that all files are working correctly. If not, the program will exit as it reaches that file. I have decided as of now to not let my program simply "<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">pass</span>" over these files as it would let a silent error through.<br />
-I will post more as I find more errors.<br />
<br />
<br />
Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com1tag:blogger.com,1999:blog-7514066198006373646.post-42133191601574816152011-08-26T21:56:00.000-07:002011-08-26T21:56:28.765-07:00Matching Justin's ResultsSo it turns out that I actually wasn't able to match Justin's results because we forgot that Justin had sent me images that had intensities on a square-root scale (square-root because it makes fainter companions stick out). Thus, all I needed to do to correct for this would be to square the original FITS array before making some contrast curves.<br />
<br />
So: here are the new results for two different contrast curves:<br />
<br />
(Properties: threshold=3 sigma)<br />
<br />
KIC109:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEa2kqptwVCveqnqGgL84KbLIiZnp4TKLNkOL9b58A_wfxwU_T9zQXNs6LXUmLuz3odZALmD0tYogeFEPywN4IdJmBHQEemg8pSyuwWTMXJg1S2E_N6ASJXVNP37cVoo9YNDmSSWYkSoc/s1600/KIC109adjusted.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEa2kqptwVCveqnqGgL84KbLIiZnp4TKLNkOL9b58A_wfxwU_T9zQXNs6LXUmLuz3odZALmD0tYogeFEPywN4IdJmBHQEemg8pSyuwWTMXJg1S2E_N6ASJXVNP37cVoo9YNDmSSWYkSoc/s320/KIC109adjusted.png" width="320" /></a></div><span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">KIC118:</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgonC1y02_X4f8MNq8OQS1tBaqbH6me9E_RRAl2eFyE2tIiF3LJUnoCOhX4KKRkq_cdMZxacf8NBSKy9M-DgEedEcoE-I0LyT1QL_-mDeZ0EJAUNG2F4D3egdfH83b8CLz-KnD1fb5r128/s1600/KIC118adjusted.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgonC1y02_X4f8MNq8OQS1tBaqbH6me9E_RRAl2eFyE2tIiF3LJUnoCOhX4KKRkq_cdMZxacf8NBSKy9M-DgEedEcoE-I0LyT1QL_-mDeZ0EJAUNG2F4D3egdfH83b8CLz-KnD1fb5r128/s320/KIC118adjusted.png" width="320" /></a></div><span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">Compare to Justin's results: </span><br />
<span class="Apple-style-span" style="font-family: inherit;">At radial distances of <span class="Apple-style-span" style="background-color: white;">0.25", 0.5", 1", 2", 4" respectively:</span></span><br />
<span class="Apple-style-span" style="background-color: white;"><span class="Apple-style-span" style="font-family: inherit;">KIC109 3.7, 5.6, 7.8, 8.6, 8.6 </span></span><br />
<span class="Apple-style-span" style="font-family: inherit;"><span class="Apple-style-span" style="background-color: white;">KIC118 4.2, 5.7, 7.2, 7.6, 7.6</span></span><br />
<span class="Apple-style-span" style="font-family: inherit;"><span class="Apple-style-span" style="background-color: white;"><br />
</span></span><br />
<span class="Apple-style-span" style="font-family: inherit;"><span class="Apple-style-span" style="background-color: white;">Unfortunately, I can't usually go past 1" on my graphs yet due to the way my point source finder works (it'll crash my computer if I try). However you can see that this is generally sufficient distance to make the contrast curve flatten out by the end. </span></span><br />
<span class="Apple-style-span" style="font-family: inherit;"><span class="Apple-style-span" style="background-color: white;"><br />
</span></span><br />
<span class="Apple-style-span" style="font-family: inherit;"><span class="Apple-style-span" style="background-color: white;">You may also have noticed that my delta mags tend to be slightly lower than Justin's values. This could be due to the fact that Justin took a thin slice of the picture and calculated the delta mags based on distance in one direction, while I averaged the noise at a certain distance away in all directions. But overall, the graphs seem to agree with Justin's results pretty well (It seems accurate up to 1").</span></span><br />
<span class="Apple-style-span" style="font-family: inherit;"><span class="Apple-style-span" style="background-color: white;"><br />
</span></span><br />
<u>To-Do:</u><br />
-I will attempt to work out some kinks in my contrast curve calculator to make it run a bit more efficiently.<br />
-Will continue working on a way to find point sources, as fitting 2D-gaussians still doesn't seem to work.Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-85396266791715768772011-08-25T00:26:00.000-07:002011-08-25T00:26:12.337-07:00Accepting DirectoriesAlright, now that I've finally adjusted to moving from Caltech to home (and learnt how to deal with my dust allergies), IPhot now accepts directories as well as individual .FITS files in one directory. (I guess I have to change the <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">usage()</span> description of IPhot as well.) Here are the three different ways IPhot can process and find .FITS files in command line:<br />
<br />
<br />
<ol><li>By default, if no additional argument is written after 'IPhot', IPhot will assume the directory is the current directory. Any .FITS files in this directory will then be processed. Let's say you have a file called fitsimage.fits in this directory. Typing in IPhot will give you this:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\[Your path here]> IPhot<br />
fitsimage.fits</span><br />
<br />
The image will open up and you'll be able to click on it and such just as before.<br />
</li>
<li>You can specify a directory after IPhot. IPhot will go through this directory and process all the .FITS images in that directory.<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\[Your path here]> IPhot "C:\\Example\\Path\\To\\Your\\Images\\" -d 0.95 -t 4</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">ImageFromThisPath.fits</span><br />
<br />
ImageFromThisPath.fits and any other .fits images will then show up on the screen like before, and will create contrast curves in the way specified by the options following the path. You can still press 'q' to quite or any other key for the next image. Note the specific way you have to type the paths - it has to have quotes around it (since it's a string, and also because some path names have spaces inside them, like "Documents and Settings" that PC's use), and you should also write double \\'s to be safe.<br />
</li>
<li>This is the way I originally implemented this program to handle .FITS files.<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\[Your path here]> IPhot CK00012_snap_20110412.fits -d 0.97 -t 5</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">CK00012_snap_20110412.fits</span><br />
<br />
<span class="Apple-style-span" style="font-family: inherit;">The program will go through the .FITS files one by one and create contrast curves for them (if you make it do so) according to the options following the .FITS files. Note that you can still type in multiple individual .FITS file names. </span></li>
</ol>I gotta say, this was pretty fun to work on. But I'm still not done with my point sources finder -- it's rather reluctant to actually find some point sources (simulated or 'real' ones) -- so I still can't test this code very extensively to make sure that it works brilliantly. For now though, I'll say that it seems to work fine.Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-57181406531426352682011-08-18T18:17:00.000-07:002011-08-18T18:17:32.241-07:00Contrast Curve Function 2.0 III and Point Source Detector<br />
So it turns out that actually, because of various factors like dithering and such, my contrast curves are probably correct.<br />
...<br />
Yay! That's actually pretty exciting stuff.<br />
<br />
However, now my point source detector is far too <i>insensitive. </i>I am trying to search for regions that have point sources, and then use the fitgaussian(...) function to detect those point sources. However, the fitgaussian(...) runs very slowly over large arrays and doesn't seem to be all that effective at pinpointing the point sources. Even after I've put down an artificial point source, it still doesn't detect anything in any of the regions. Perhaps it's the way I've implemented it, and I just have to keep working towards a solution.<br />
<br />
<u>Learned:</u><br />
-What dithering means.<br />
<u>To-Do:</u><br />
-Find a way to make my point source detector work correctly, whether by using the fit gaussian function, or some other function.<br />
Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-82686732448450684372011-08-16T17:13:00.000-07:002011-08-16T17:20:54.061-07:00Contrast Curve Function v2.0 II<span class="Apple-style-span" style="font-family: inherit;">I finished the new contrastcurve(...) function today.</span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">def contrastcurve(self,ann_space=0,darkpix=0.95,thresh=5):</span><span class="Apple-style-span" style="font-family: inherit;"> Returns list of radii and corresponding noise (thresh*sigma+mean background noise) and point sources (if any). It detects point sources by fitting gaussians over regions that have, on average, greater intensity than the noise and searches for peaks in those regions.</span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">And it........... still doesn't work right. </span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">Here's an example though, of what the contrast curve looks like for KIC109:</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJU-I8218RF0JrJCooHVlYy6GhS3aqXThK8AmM5Km8D9mnJiqFunhiuikah3b0oId877P-akSeOA-upJS5RKYSwnkFcLmxSnwC5u2JW_rBUssph1tMhdRkBQPVHSW4xODjTQZo19rZYuI/s1600/log10results.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: inherit;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJU-I8218RF0JrJCooHVlYy6GhS3aqXThK8AmM5Km8D9mnJiqFunhiuikah3b0oId877P-akSeOA-upJS5RKYSwnkFcLmxSnwC5u2JW_rBUssph1tMhdRkBQPVHSW4xODjTQZo19rZYuI/s320/log10results.png" width="320" /></span></a></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: inherit;"><br />
</span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: inherit;">Interestingly, however, if I calculate magnitude using log instead of log base 10, I get this result:</span></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilJEHTUMGfgu983k6TXrGZsk4Fbmt1uFUeyQ8Ynexi2tkk93oVqN6p10O7zcmUQe-pEt0mD8_9UDI3pzbcdMcJLx53-A3OSaRO0E4qYLMKPSI5Tpyb56kj7lO5wCykyxiug0e6BBZ4RXs/s1600/logresults.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: inherit;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilJEHTUMGfgu983k6TXrGZsk4Fbmt1uFUeyQ8Ynexi2tkk93oVqN6p10O7zcmUQe-pEt0mD8_9UDI3pzbcdMcJLx53-A3OSaRO0E4qYLMKPSI5Tpyb56kj7lO5wCykyxiug0e6BBZ4RXs/s320/logresults.png" width="320" /></span></a></div><span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">This agrees much more closely with Justin's data. Weird! I still haven't figured out why. </span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">By the way, Justin's data is this:</span><br />
<span class="Apple-style-span" style="background-color: white;"><span class="Apple-style-span" style="font-family: inherit;">KIC109 3.7, 5.6, 7.8, 8.6, 8.6 at 0.25'', 0.5'', 1'', 2'', 4'' respectively.</span></span><br />
<span class="Apple-style-span" style="background-color: white;"><span class="Apple-style-span" style="font-family: inherit;">(This is for thresh=3; mine are produced with thresh=5, but I ran the code again and this barely makes any difference). </span></span><br />
<span class="Apple-style-span" style="background-color: white;"><span class="Apple-style-span" style="font-family: inherit;"><br />
</span></span><br />
<u>To-Do:</u><br />
-Start testing how my code behaves around images with bright point sources (yes I said I would do this today, but then the contrast curves looked funny...) while I try to figure out why my contrast curves are behaving this way.<br />
<u>Learned:</u><br />
-I actually learned something interesting today: If you have a function that returns multiple things in an array, it's much more efficient to do <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thing1, thing2, thing3=function() </span><br />
as opposed to <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thing1, thing2 = function()[0], function[1] </span>even if you only want to save <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thing1</span> and <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thing2</span>. This is probably because in the first case, Python will run the function once and save the corresponding variables, whereas in the second case, Python will run the function once, save the 0th element, and then run the function again and save the first. So I guess that ultimately what I learned is that if you have a function that takes a while to run, it's better to use the first case to save time, but if you have a function that's relatively fast for large amounts of data, but that returns a bunch of stuff, it's better to use the second case to save memory. If you have a slow function that returns lots of data.... well then good luck to you.Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-40881958844904439472011-08-15T18:01:00.000-07:002011-08-15T18:04:55.886-07:00Contrast Curve Function v2.0 IToday I finished most of the contrast curve function I talked about in my previous post. I haven't gotten it to return a list of detected point sources yet (it only returns radii and respective 5*sigma as of now), but it should integrate relatively well into all the other code I've written so far.<br />
<br />
I have also been given a rough timeline of what I'm supposed to do for the rest of the summer (yes, although officially ten weeks, my project will continue till the end of summer/beginning of the fall term). So here it is:<br />
<br />
Goals:<br />
1) Rewrite my code and try and get the same results that Justin did.<br />
2) Start using my code for all the fits files I have.<br />
3) Detect problems and check them.<br />
4) Repeat as necessary (This is not a fun step).<br />
5) Make my code more user-friendly.<br />
6) At some point start putting contrast curves up on a website.<br />
.<br />
.<br />
.<br />
n) Somehow help with the writing of a paper.<br />
<br />
<u>To-Do:</u><br />
-Tomorrow I'll have to figure out how this new contrast curve function will actually detect point sources. Since we're talking about regions now, I might have to also change the way the program points out detected sources to the user.<br />
-I also have to start writing code so that I can upload directories of .FITS files into the program. That way, the user won't have to spend a long time typing in the names of all the .FITS images.<br />
-At some point I'll have to see what I can do about adapting my program to various arcsecond/pixel ratio. That is, I want my program to be able to recognize a type of image by its file name and automatically assign the correct arcsecond/pixel ratio.<br />
-Finally, if possible/not too aesthetically ugly, I should try and make all the pictures axes display units in terms of arcseconds instead of pixels.Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-50739410953563118762011-08-12T17:09:00.000-07:002011-08-12T17:09:09.411-07:00New ImplementationI talked with Tim and Justin about my code. The problem seems to be that in my current program, I am overestimating the amount of background noise since I'm calculating noise by averaging the flux from individual pixels. What I should do instead was to average noise from little regions and calculate the noise from the average of those regions. It seems like I'm just working with slightly bigger pixels, but by first averaging the flux from each region, I am able to smooth out my background and ultimately decrease the noise in each image. <br />
<br />
So now, I have to code a different approach to finding point sources. It will still use much of what I have already written, but it's definitely the biggest change yet to my code.<br />
<br />
Here's a rough outline of what I'm about to do:<br />
I will partition each annulus into little circular regions of data. I will then average the flux in each region, and then find the standard deviation from the regions. This will be used to create <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">sigma</span>. The background mean will also be calculated from the regions. Detection of a point source apart from the main source will determined by if the a region has an average intensity greater than <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thresh*sigma</span><span class="Apple-style-span" style="font-family: inherit;">. My program might pinpoint the specific location of the point source less precisely, but at least it won't detect fake point sources that turned out to just be speckles. The contrast curve will still be created in much the same way. It's just the way I determine background noise that will change the most significantly. </span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">I'll start working on this next week. </span>Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-7940071690889407192011-08-11T14:43:00.000-07:002011-08-11T20:00:29.064-07:00Sanity CheckI've been debugging my program for the last few days without much success. I've sent some preliminary testing results to Tim, but the results are definitely not good.<br />
<br />
Here are two main problems I noticed:<br />
-The point source finder is too sensitive. It detects almost anything that is greater than <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thresh*sigma</span>. Unfortunately, there are many pixels in the picture that seem rather "grainy" and are registered as false point sources. I need to somehow eliminate these false point sources.<br />
-The range of delta mags (contrast) for the contrast curves are way too small. The delta mags themselves are also high values, often hovering just below 0. This indicates that my program is not finding too much contrast within the annuli of the star compared to the central flux of the star, which seems intuitively wrong. However, this is most likely caused by the small size of the cropped image. The small images size makes my program calculate the background noise as part of the annulus of the star, which is incorrect as there is light pollution from the star. The problem is somewhat fixed when I increase the size of the cropped image; however, compared to Justin's results the delta mags still seem too small. <br />
<br />
Professor Johnson suggested I do some sanity checks on my math yesterday, and I've been trying to figure out what really is going on with the math behind the contrast curves.<br />
<br />
I'll post some more if I find anything interesting, but for now, it is just alone time for me and a buggy program.Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-13448488594880604922011-08-09T17:57:00.000-07:002011-08-09T17:57:48.408-07:00Code TestingAnother colleague, Justin, sent Tim and I a MATLAB fitswriter file, which turns matlab .fig files into .fits files.<br />
<br />
I have been setting up Matlab and using it to convert images into .fits files. I am then able to test my code on these new files, and compare my results with those of Justin's. Unfortunately, they don't seem to match up. The images that Justin sent me also seem to focus on objects with large FWHM's, which ultimately means that I obtain less points for my contrast curve because of the way I've implemented my code.<br />
<br />
I am currently trying to compile a .pfd document containing the contrast curves I obtained using my code, and comparing my data to Justin's data. Hopefully this will give me a clearer indication of what the differences are between our results, and how I should change my code.Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-77036415869586335072011-08-05T18:10:00.000-07:002011-08-10T10:42:32.308-07:00Saving Text Files and FiguresToday I finished a function that will allow me to save text files of some important data associated with the contrast curve plots I made.<br />
<br />
When a user saves a figure, an associated text file will save the lists of data returned from <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">phot3.contrastcurve(...)</span>. 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.<br />
<br />
The text file will save to the name of <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">x-y_fitsfilename-results.txt</span>, where <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">x,y</span> are the center coordinates, and <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">fitsfilename</span> is the name of the fits file.<br />
<br />
Here's an example of the kind of text file it will save:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\[Your path here]>IPhot CK00012_snap_20110412.fits</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">CK00012_snap_20110412.fits</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7ZhTQludFNM3H_eax9bigzbdOnEyeeRgh1h_bshpn2WLAVO3ovjq7A1nvhyVOLwZGr-8rvjfsawCm-oEv3sTThRCxRA4dbEyaZDuxaTnvaeGcIFj20_jRgAOvKHXbctAer4Q5URk54zA/s1600/originalfits_wcompass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7ZhTQludFNM3H_eax9bigzbdOnEyeeRgh1h_bshpn2WLAVO3ovjq7A1nvhyVOLwZGr-8rvjfsawCm-oEv3sTThRCxRA4dbEyaZDuxaTnvaeGcIFj20_jRgAOvKHXbctAer4Q5URk54zA/s320/originalfits_wcompass.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Press Q/q to quit, or any other key to load next image.</span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span></div><span class="Apple-style-span" style="font-family: inherit;">Clicking on point (22,100) and pressing W will save this picture... </span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgugpPavaspxKkR6QcYRraswLoix1Hyvv2zZWYLaQUNAVq7UdUNH4k-Nmi0GAofS-TqK7J8ugCA2tZ20qNs2lkSF9Agb9VLwKqHQcnZhfpS67CWJv7F6Zz71ed7dv95-DoI_jCxFpDHoNM/s1600/CC22-100_CK00012_snap_20110412.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgugpPavaspxKkR6QcYRraswLoix1Hyvv2zZWYLaQUNAVq7UdUNH4k-Nmi0GAofS-TqK7J8ugCA2tZ20qNs2lkSF9Agb9VLwKqHQcnZhfpS67CWJv7F6Zz71ed7dv95-DoI_jCxFpDHoNM/s320/CC22-100_CK00012_snap_20110412.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: left;">...as well as a .txt file containing this information:</div><div class="separator" style="clear: both; text-align: left;"><br />
</div><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">Center Pts</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">(22, 100)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">Coordiates (Radius,Contrast)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">[(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)]</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">Additional Point Sources at Each Radius (if any)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">[[], [], [], [], [], [], [], [], [], [], [], [], []]</span><br />
<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Saved to C:\Documents and Settings\Administrator\Desktop\CC22-100_CK00012_snap_2</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">0110412.png</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Saved to C:\Documents and Settings\Administrator\Desktop\22-100_CK00012_snap_201</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">10412-results.txt</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">q</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Quitting program...</span><br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\[Your path here]></span><br />
<br />
-----<br />
Note that I also created a little compass on the lower right corner of each Image object. =]<br />
<br />
<u>To-Do:</u><br />
-Somehow scale the axis ticks of the subplot images to arcseconds as opposed to pixels.<br />
-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).<br />
<br />
-----<br />
EDIT:<br />
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.Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com1tag:blogger.com,1999:blog-7514066198006373646.post-91960633331566456162011-08-03T15:23:00.000-07:002011-08-03T15:28:01.469-07:00IPhot ChangesI successfully linked the two functions together in IPhot's <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">createfigure(...)</span> today after working on it for the past two days.<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">def createfigure(x,y):</span><span class="Apple-style-span" style="font-family: inherit;"> Creates a figure with a cropped image centering on the clicked point source by using </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">phot3.plotptsmarking(...)</span><span class="Apple-style-span" style="font-family: inherit;">. If there are no other point sources in the cropped image, this function will plot a contrast curve using </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">phot3.plotcontrastcurve(...)</span><span class="Apple-style-span" style="font-family: inherit;">, 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.</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> x,y </span><span class="Apple-style-span" style="font-family: inherit;">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. </span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
Example: (Using command line)<br />
<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\[Your path here]>IPhot CK00012_snap_20110412.fits -s 2</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">CK00012_snap_20110412.fits</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAAXdEdKFxYbhHfeX3D_gPkAbxytUs1InLNv_2LdzhTDuf2sZLcINP4darUllNcNu-MzYZF59g6tIm9a5czaiY9cT7zNHz6R2A5o0nfCTjQVcBlUEUwqApWqBVs0fZ6R0hwfGANCVTGHQ/s1600/originalfits.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAAXdEdKFxYbhHfeX3D_gPkAbxytUs1InLNv_2LdzhTDuf2sZLcINP4darUllNcNu-MzYZF59g6tIm9a5czaiY9cT7zNHz6R2A5o0nfCTjQVcBlUEUwqApWqBVs0fZ6R0hwfGANCVTGHQ/s320/originalfits.png" width="320" /></span></a></div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Press Q/q to quit, or any other key to load next image.</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">Clicking on the center point source at around (94,72), we get this:</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghJP2MpPXYe5JVEgP_Kj3UevNahL0ayKYbv97m6TkEKyB8V0zdT8VxBsZlGL2dLnm5lfYmRy9-6PJvtDUfVqQ7zbBQjHSKUfuIjuMKa7VtZhuUO4fd6s11xEuqXAbZF74NSZxOvabwIzM/s1600/subimwithmarkings.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghJP2MpPXYe5JVEgP_Kj3UevNahL0ayKYbv97m6TkEKyB8V0zdT8VxBsZlGL2dLnm5lfYmRy9-6PJvtDUfVqQ7zbBQjHSKUfuIjuMKa7VtZhuUO4fd6s11xEuqXAbZF74NSZxOvabwIzM/s320/subimwithmarkings.png" width="320" /></span></a></div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Detected point source: (94, 76)</span><br />
<br />
Clicking on the point source at around (22,100), we get this:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM29Wa__KEuFgR24bam1kabW_bIbRXRLjLx01nR_HbEpFZM2VkFXy_cG9gXOQs6Haf2KpMPJVTHvl-3UfNv90UA-MzdfM0ygJzhDD707nJYQiRma4HKL08NobRqP9H3LGuGyOOBdlVUlc/s1600/v3cc1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM29Wa__KEuFgR24bam1kabW_bIbRXRLjLx01nR_HbEpFZM2VkFXy_cG9gXOQs6Haf2KpMPJVTHvl-3UfNv90UA-MzdfM0ygJzhDD707nJYQiRma4HKL08NobRqP9H3LGuGyOOBdlVUlc/s320/v3cc1.png" width="320" /></a></div><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">q</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Quitting program...</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\[Your path here]></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">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. </span><br />
<br />
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.<br />
<br />
<u>Learned:</u><br />
-How to create inset graphs (in two ways actually!). I can either use the <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">axes(...)</span> function from <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">pylab </span>or the <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">inset_axes(...)</span> function from <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">mpl_toolkits</span><br />
<u>To-Do:</u><br />
-Test my program and debug i<span class="Apple-style-span" style="font-family: inherit;">t. There are probably still some minor problems or aesthetic issues I still need to fix. </span>Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-19406765792255176082011-08-02T00:34:00.000-07:002011-08-03T14:58:38.518-07:00Phot3.py - Two FunctionsToday I finished coding two plotting functions.<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">def plotcontrastcurve(self,ann_space=0,darkpix=0.95,adj=3,thresh=5,fig=1):</span> The original <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">plotcontrastcurve(...)</span> function wasn't nearly as fancy as this one. This function also allows the user to specify the number of adjacent pixels (<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">adj</span>) and the number of deviations from the mean background (<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thresh</span>) 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...<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqZ5857vALsEpn3I6Jzf0iO5z0v9-yoRpiBoOaFRfWaqWK4WHZZ3E_J0M4_IaO1gVD8rJvz6uwtJPRKTEWHHIHF7vwjBdxNVLsmZ4NXXTI4BDwHGcXG3BJ-g-Dk8OOSGNplQCF6e3JQ7M/s1600/contrastcurve3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqZ5857vALsEpn3I6Jzf0iO5z0v9-yoRpiBoOaFRfWaqWK4WHZZ3E_J0M4_IaO1gVD8rJvz6uwtJPRKTEWHHIHF7vwjBdxNVLsmZ4NXXTI4BDwHGcXG3BJ-g-Dk8OOSGNplQCF6e3JQ7M/s320/contrastcurve3.png" width="320" /></a></div><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">def plotptsmarking(self,cx,cy,filename="",ann_space=0,darkpix=0.95,adj=3,thresh=5):</span><span class="Apple-style-span" style="font-family: inherit;"> 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 </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thresh</span><span class="Apple-style-span" style="font-family: inherit;"> and </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">adj</span><span class="Apple-style-span" style="font-family: inherit;">. </span><br />
<br />
Tomorrow I will link these two methods together in IPhot.Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-14983114833967941662011-07-29T22:54:00.000-07:002011-08-01T11:50:53.035-07:00Phot3.py and Other Major ChangesDue to my recent major change to my <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">findptsources(...)</span><span class="Apple-style-span" style="font-family: inherit;"> function, I had to also implement major changes to my overall </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">phot2.py </span><span class="Apple-style-span" style="font-family: inherit;">module. The result was that I decided to just start over and make a new module called</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> phot3.py</span><span class="Apple-style-span" style="font-family: inherit;">. It is essentially the same module, but I've streamlined it a bit and deleted some functions that I now don't need because of my more efficient </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">findptsources(...)</span><span class="Apple-style-span" style="font-family: inherit;"> function. </span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">I've also been given suggestions to present my data in a more space-conserving and visually appealing way. </span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">I am working on creating a subplot image within a contrast curve plot. The subplot image will be like it is now - it will center on the point source and indicate where its aperture extends to and where its innermost annulus begins. </span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
I am also working on changing what happens when a user clicks a point source. When a click is registered, a cropped image centering around the point source will appear. If there are no point sources detected within the annuli of that cropped image, a contrast curve will appear as mentioned above. If there are point sources detected within the annuli, they will be marked with respective circles and the program will return a printed list of detected point source coordinates.<br />
<br />
I'll continue working on this next week.Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-57054712867872902832011-07-28T17:46:00.000-07:002011-07-29T22:30:29.731-07:00Editing More Code...This week has just been a major code-editing week.<br />
<br />
Today I made a major change to the way I find point sources.<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">def findptsources(self,datalist,darkpix=0.95,adj=4,thresh=5):</span> Finds a list of point sources (points brighter than their surrounding points where the number of adjacent pixels (<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">adj</span>) is brighter than <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thresh</span>*sigma).<br />
<br />
The new <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">findptsources(...) </span>function can be adjusted in sensitivity:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thresh</span> gives the user the ability to specify how many deviations from the mean background noise the flux of a point has to be to note it as a potential point source. Thus, instead of only having 5*sigma, we can also ask the program to search for all potential point sources in which a point source is defined by any point greater than 3*sigma.<br />
<br />
The new findptsources function can be adjusted in sensitivity by setting values for <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">adj </span>(0-4). It indicates how many of the neighboring points have to also be greater than <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">thresh</span>*sigma in order for the central point to be flagged as a point source.<br />
<br />
You may note that the new <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">findptsources(...)</span> requires an array input, which seems kind of silly at first glance. However, this function is also being used to find the point sources in each annulus around a main point source, which means that it needs to be able to take the annulus array as an input, even though the main FITS file array might be different.<br />
<br />
The new point source finder kind of already acts like a point source detector because it can look for point sources within annuli, which means that I don't need my old point source detector code I was working on earlier this week.<br />
<br />
I tested this new point source finder, and these are the results:<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>>im=phot3.Image(arr)</span><br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>> im.findptsources(im.data)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">[(116, 22), (83, 40), (25, 53), (94, 72), (94, 76), (22, 100), (52, 128)]</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">As you can see, this is exactly the same array as before. I haven't had time to extensively test this yet, but I believe I'm at least on the right track. </span><br />
<br />
<u>Learned:</u><br />
-Neat way to use booleans as integers (0 and 1's) to meet threshold requirements.<br />
<u>To-Do:</u><br />
-Debug more (I think you're seeing the trend by now...)Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-50800012856980659802011-07-27T17:54:00.000-07:002011-07-27T17:54:38.217-07:00Still editing that point source detector...Functions created: <div><br />
</div><div><div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">def addsource(self,cx,cy,peak_flux,FWHM=1):</span> Adds a point source to current Image object and returns a new Image object. <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">cx, cy</span> are the coordinates for the point source, <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">peak_flux</span> is the maximum flux at (<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">cx,cy</span>), and <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">FWHM</span> is... well, the full-width-half-max. </div></div><div><br />
</div><div>Other than that, today was mostly spent trying to correct tiny errors and figuring out how to correctly implement my Point Source Detector so that it looks for 3 points that are brighter than 5*sigma (the 5*sigma of the annulus it is positioned in). The current "filler" function I'm using for my Point Source Detector is the point source function I use to find my main point sources. However, this is technically incorrect, since the background noise affecting the main point sources is the background noise in the sky. The background noise for the non-main point sources (the faint point sources that might be polluting the light from the main point source) depends on the brightness of each annulus around each main point source. </div><div><br />
</div><div>So I guess I'll just continue to work on this tomorrow. </div>Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-76414159917729877492011-07-26T17:43:00.003-07:002011-07-26T17:50:06.730-07:00I feel like a happy frog......because I caught a major bug in my code today.<br />
Well, I suppose that means I did something horribly wrong in the past weeks, but it definitely feels good to at least know that I've fixed it. Anyways, I again edited my code for <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">findptsources(...)</span>. You may have noticed that in my previous posts dealing with point sources, the aperture rings were off-center. They're fine now. See the picture below:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuLvmCJlbi8wbCuiBqZffS9OIs6dDFaI_gFo9brTPKZa52FWRxo7y_3ceU_EYYvMX-bManj_UZYp0SWDMhuL6mzQmbLwNbWu99m2d-rpHyMgq-Js6f3N067fmxaFHkejhuMYLlBRCcl0Y/s1600/ptsdetector1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuLvmCJlbi8wbCuiBqZffS9OIs6dDFaI_gFo9brTPKZa52FWRxo7y_3ceU_EYYvMX-bManj_UZYp0SWDMhuL6mzQmbLwNbWu99m2d-rpHyMgq-Js6f3N067fmxaFHkejhuMYLlBRCcl0Y/s320/ptsdetector1.png" width="320" /></a></div>The aperture ring is very nicely centered on the brightest parts of the object. This is because the array of point sources changed. If I open up the Python interpreter and type:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>> from startup import*</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>> im=phot2.Image(arr)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>> im.findptsources(darkpix=0.95)</span><br />
<br />
I get this:<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">[(116, 22), (83, 40), (25, 53), (94, 72), (94, 76), (22, 100), (52, 128)]</span><br />
<br />
All the point sources are isolated, and there are very few of them, which is nice to start with. Also notice that (94,72) instead of (92,72) is the point source, which makes sense, since if we type in:<br />
<br />
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>> im.maxx</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">94</span></div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>> im.maxy</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">72</span><br />
<br />
we get the x and y coordinates of the pixel in the graphic with the maximum flux, and thus the point source (assuming of course it's not a cosmic ray).<br />
<br />
So, hopefully this will be the last time I edit the point source finder code. And hopefully tomorrow I can just focus on making my point source simulator.<br />
<br />
-----<br />
I also worked a little bit on the Point Source Simulator today and cleaned up some coding for my Point Source Detector. But then I got distracted by the bug mentioned above...<br />
-----<br />
<u>Learned (the hard way):</u><br />
-Array elements are organized <i>differently </i>than pixel coordinates! >.<<br />
<u>To-Do:</u><br />
-Finish the Point Source Simulator<br />
-Edit some more code for my Point Source Detector and make it more precise in detecting point sources (as in, not make it accidentally detect cosmic rays)Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-7512244075326326372011-07-25T17:27:00.000-07:002011-07-25T17:27:16.942-07:00Point Source DetectorHello!<br />
<br />
I finished the basic code for the Point Source Detector today. (Though I haven't quite had time to test it yet).<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">def ptsdetector(subim, aperture, darkpix=0.95): </span>Given a subplot of an Image object (cropped Image object basically), the aperture around the main point source, and an optional darkpix argument, we can detect whether there are any point sources near or within the aperture of the main star.<br />
<br />
Now, if we load the main FITS file and click on it, this figure will pop up:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifWyz_nKA6vlPjnFjn_dgu0YaLEtjLXXqASVEHCUmeHrVNACMCFClI-bIqkAZZFZpRtPb6nDte7PbjyoX7vL6q6V43zxVHLPsJVZWbm4nrBQAdA-1Vv1JMPz-TJfGm5KA97A2cSzmHocs/s1600/ptsdetector1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifWyz_nKA6vlPjnFjn_dgu0YaLEtjLXXqASVEHCUmeHrVNACMCFClI-bIqkAZZFZpRtPb6nDte7PbjyoX7vL6q6V43zxVHLPsJVZWbm4nrBQAdA-1Vv1JMPz-TJfGm5KA97A2cSzmHocs/s320/ptsdetector1.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: left;">If there are actual point sources within the aperture (significant addition to the light of the main point source), the program will print an additional message stating <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">"Detected point source within aperture: (x,y)"</span> and indicate the x and y coordinates where that point source was found. </div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">Note that there are two smaller circles. These denote where the point sources are in the picture. The concentric circles indicate that this is the main point source we are focusing on (the point source that was selected by the user). The other small circle indicate that there is another point source near the main point source. </div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;">In this case, however, it should be noted that the slit in the picture is messing around with the object's light, and so we are given another "point source" when in fact it is just the light from the main source on the other side of the slit. I'm eager to test this with some other images that hopefully do not have slits on the main point source. </div><div class="separator" style="clear: both; text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><u>Learned:</u></div><div class="separator" style="clear: both; text-align: left;">-Not much new stuff.... today was mainly coding</div><div class="separator" style="clear: both; text-align: left;"><u>To-Do:</u></div><div class="separator" style="clear: both; text-align: left;">-Clean the point source detector code a little</div><div class="separator" style="clear: both; text-align: left;">-Start on the point source simulator</div>Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-2019789109878300642011-07-22T16:57:00.000-07:002011-07-26T16:22:54.189-07:00Refined: findptsources(...)I finished the refined version of findptsources(...). Unfortunately, there are a lot of cases to take care of, and I'm not sure I accounted for all of them. I tested my code with the two FITS file images I had, and the code worked well for both of those images. Hopefully the code works well for all FITS files, though I'm currently not 100% sure. I'm trying to get some more FITS files to work with at the moment.<br />
<br />
Anyways, here's some examples:<br />
<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>> from startup import*</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>> im=phot2.Image(arr)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>> im.findptsources()</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">[(115, 22), (116, 22), (83, 40), (25, 53), (90, 72), (91, 72), (92, 72), (93, 72), (94, 72), (92, 76), (93, 76), (94, 76), (18, 100), (19, 100), (20, 100), (21, 100), (22, 100), (51, 128), (52, 128)]</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">[(115, 22), (83, 40), (25, 53), (92, 72), (93, 76), (20, 100), (52, 128)]</span><br />
<br />
As you can see, the second list of point sources is much shorter!<br />
In case I haven't explained what my edited code does clearly, here's another attempt.<br />
<br />
As you can see, the lists contain a bunch of tuples that represent coordinates of pixels in the FITS image. In the first list, many of these tuples have the same 'y-coordinate' (second number in each tuple), meaning that the pixels are aligned in a horizontal line (excuse my handwriting):<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWsuq21_bqe3CGmFWZHfAZtjgqMEun27agYSCepSyK60bIjVr8gk8hOQEPcgsb7PSS-V89ai6cfDgAPxIxGAd5XzhfWfudj2l4jMQwDYLbQLUIs5M1QVVo7eLQDMWiXIRoy0DWA2vhD24/s1600/labeled_originalim.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWsuq21_bqe3CGmFWZHfAZtjgqMEun27agYSCepSyK60bIjVr8gk8hOQEPcgsb7PSS-V89ai6cfDgAPxIxGAd5XzhfWfudj2l4jMQwDYLbQLUIs5M1QVVo7eLQDMWiXIRoy0DWA2vhD24/s320/labeled_originalim.png" width="320" /></a></div>It's easy to see now that the second list of tuples takes the 'midpoint' of a line of pixels. By midpoint I mean that for any line of odd pixel length, it takes the mid point, but for any line of even pixel length, it picks one of the two middle most points. For a single point, the program still includes it, even though it might just be a cosmic ray. You can check that this is true with the second FITS image as well:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>> im2=phot2.Image(arr2)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">>>> im2.findptsources()</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">[(42, 64), (43, 64), (91, 72), (92, 72), (93, 72), (94, 73), (95, 73), (94, 76), (95, 76), (91, 77), (92, 77), (93, 77), (37, 79), (52, 95), (98, 100)]</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">[(42, 64), (92, 72), (95, 73), (95, 76), (92, 77), (37, 79), (52, 95), (98, 100)]</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">Obviously a lot of these points could be cosmic rays or point sources we are not concerned with (as in they don't affect the total flux of the main point source we are looking at). But my program includes these points as well because I don't want to make it rule out anything potentially interesting. </span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
On Monday I'll start working on the point source detector code, and perhaps the point source simulator as well.<br />
<br />
<u>Learned:</u><br />
- How to write complicated if statements.<br />
- How to <i>follow</i> complicated if statements.<br />
<u>To-Do:</u><br />
- Write the point source detector code<br />
- Create the point source simulator to test my codeAerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-78975503088816820292011-07-21T17:29:00.000-07:002011-07-21T17:30:14.979-07:00Array SplicingI'm currently refining my code that finds point sources. However, I've been stuck on this same problem the whole day:<br />
<br />
I have here a list of point sources from one of the FITS images:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">[(42, 64), (43, 64), (91, 72), (92, 72), (93, 72), (94, 73), (95, 73), (94, 76), (95, 76), (91, 77), (92, 77), (93, 77), (37, 79), (52, 95), (98, 100)]</span><br />
<span class="Apple-style-span" style="font-family: inherit;">Each tuple is a coordinate (x,y). If you look carefully, you'll note that there seems to be many rows of "point sources". This is because at these points, the FITS array recorded the same amounts of photons. But a point source should be a single point that is brighter than all its surrounding points. It should be <i>the</i> point of the star (or whatever object you are looking at). So I need to somehow sum up all the x coordinates for each row and then return the average of the x coordinates to find the midpoint of each "row". For example, instead of returning </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">(91, 77), (92, 77), (93, 77), </span><span class="Apple-style-span" style="font-family: inherit;">the program should return only (92, 77) since it's the midpoint of the row at y coordinate 77. But to do this, I need to figure out a way to splice my array based solely on the row number (the y coordinate). This proves to be rather difficult - especially if I want to avoid as many for loops as I can. </span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">I'll think about this tomorrow. </span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;"><u>Learned:</u></span><br />
-A bunch of array manipulation functions<br />
<u>To-Do:</u><br />
-Finish this task<br />
-Create a point source simulatorAerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-64228345114270252842011-07-20T17:37:00.000-07:002011-07-20T17:37:00.547-07:00Save Function and Point Source DetectorI finished another save function today. It lets users save contrast curves by selecting the graph with the contrast curve and pressing "w" (w for 'write' since s is already taken).<br />
<br />
For example, <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">CK00012_snap_20110412.fits</span> saves as <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">CC94-72_CK00012_snap_20110412.png</span>. 'CC' indicates that it is a graph containing a Contrast Curve. 94-72 indicates that it was saved at the original FITS files coordinates of (94,72). This way, users can save multiple contrast curve images from the same fits file without accidentally writing files over.<br />
<br />
I addition, I have been outlining and planning out how to make a Point Source Detector that will detect if there is a point source close to the main point source in the picture. This, however, also requires me to fix up my existing code that finds point sources. "Close" is defined as probably within 1 FWHM of the main point source. That is, its light is merged with the main point source's light since it's within the main point source's aperture.<br />
<br />
<u>Learned:</u><br />
-How to save files<br />
-Key press functions<br />
<u>To-Do:</u><br />
-Create my point source detector function<br />
-Eventually create a point source simulator and test my detector functionAerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-62076024355879254382011-07-19T14:54:00.000-07:002011-07-19T17:22:47.156-07:00Save Function and ... some other things.Yesterday I was working/finishing up on a proposal for a competition that gives SURF students a chance to use the Hale Telescope at Palomar for a well-designed project. ...Yep.<br />
<div>-----</div><div><br />
</div><div>Today I attempted to learn a little bit about Python's (well...pylab's) <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">savefig(...)</span> function. It lets you save the current figure to a file. However, halfway through I realized that Python has its own save figure code. Simply by pressing '<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">s</span>', you can save the current figure that is selected!</div><div><br />
</div><div>The thing is, the save window will pop up and prompt you for a file name in this case. I'm hoping I can create a function that will allow me to save the figure with the press of a key, and automatically give it a filename without me having to specify one. Maybe something like figure_x, where x is the figure number. Unfortunately, this seems to be difficult to do since I also have to make sure I don't save <i>over</i> any previously saved data.<br />
-----<br />
<br />
Results from testing indicated that my code was, unfortunately, not mac compatible (so not much got tested). Apparently it had something to do with end-line characters. I wrote some more lines of code and sent my program back. This time, I'm hoping that it will work.<br />
------<br />
<br />
<u>Learned:</u><br />
-How to save things in Python<br />
-Certain compatibility issues</div>Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-79248890451998116102011-07-15T17:18:00.000-07:002011-07-16T23:55:13.408-07:00Beta Testing of IPhot?I sent my program to Tim, who will test it over the weekend. I hope there won't be any serious bugs...<br />
<br />
Anyways, IPhot now *ideally* comes with mac os compatability, the ability to upload multiple FITS files, and quick contrast curve plotting with a single click (or two)!<br />
<br />
Example:<br />
<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\>cd [your path here]</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\[your path here]>IPhot CK00012_snap_20110412.fits CK00350_snap_20110524.fits -d 0.95 -w 70 -h 40 -s 0</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">CK00012_snap_20110412.fits</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">CK00350_snap_20110524.fits</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Press Q/q to quit, or any other key to load next image.</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">The two lines starting with CK... indicate the FITS files that are loaded. At this point, this image pops up:</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEtrSPCb3XpR8ASwW4iBhq-X1Q0ecmHQIhJDD2pDgPBDZGhUiqts0gbAPtvEmHDaXOgDlGEfXiiK_Lyyy1p-akP3qJxGa9X9PIndHlfwrtcC7GLqXKmEZsz1fGJuxtACx8n-DTrd0A1c0/s1600/originalfits.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEtrSPCb3XpR8ASwW4iBhq-X1Q0ecmHQIhJDD2pDgPBDZGhUiqts0gbAPtvEmHDaXOgDlGEfXiiK_Lyyy1p-akP3qJxGa9X9PIndHlfwrtcC7GLqXKmEZsz1fGJuxtACx8n-DTrd0A1c0/s320/originalfits.png" width="320" /></a></div><span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<div class="separator" style="clear: both; text-align: left;">Clicking near point (93, 72) gives:</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKHBvyOCgkNAFNSA80FI7JC2sUZQrJzgaWIsCcljPtLm4mx5WipZexegCAz5FBnFRk7RxrrZhpt_-xJI3kZCD7vKt1I-pLLBEhy9iJNIp6YWuVGn7qIVHPUVUtybNAOB8lVidkc7VHdHE/s1600/v1cc1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKHBvyOCgkNAFNSA80FI7JC2sUZQrJzgaWIsCcljPtLm4mx5WipZexegCAz5FBnFRk7RxrrZhpt_-xJI3kZCD7vKt1I-pLLBEhy9iJNIp6YWuVGn7qIVHPUVUtybNAOB8lVidkc7VHdHE/s320/v1cc1.png" width="320" /></a></div><br />
To go to the next image and close the current figure, I just press any key:<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">n</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">...loading next image</span><br />
<span class="Apple-style-span" style="font-family: inherit;">This image loads:</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPAZWmyN34TNw0y-p7Z9Ky5xDc0q2CYwY4THxn7trOBHY5xh65Yi6f-ykssr6U4zHLRop4RCKI-SFfS5OYltmULyYg8XwX-TpjvZAIuwtVKT1ALQMd-yTERvwAubo-MDVjC3YWuqpB7Es/s1600/originalfits2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPAZWmyN34TNw0y-p7Z9Ky5xDc0q2CYwY4THxn7trOBHY5xh65Yi6f-ykssr6U4zHLRop4RCKI-SFfS5OYltmULyYg8XwX-TpjvZAIuwtVKT1ALQMd-yTERvwAubo-MDVjC3YWuqpB7Es/s320/originalfits2.png" width="320" /></a></div>Clicking near the center gives me this:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnZOQ-MjaTK9H9BR6kbQqiqF3n5O5GnPGvuE6HfPs_iScBtia5wmJrzG6JAtpv6zBfw_UBn6h1KVPg_G4dsLsYhjFHPAqXAfAgV5KUg8h22DcHOx7iOVeUCi-P0xmNbViCYKUmOeaux_U/s1600/v1cc2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnZOQ-MjaTK9H9BR6kbQqiqF3n5O5GnPGvuE6HfPs_iScBtia5wmJrzG6JAtpv6zBfw_UBn6h1KVPg_G4dsLsYhjFHPAqXAfAgV5KUg8h22DcHOx7iOVeUCi-P0xmNbViCYKUmOeaux_U/s320/v1cc2.png" width="320" /></a></div><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Press Q/q to quit, or any other key to load next image.</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">n</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">I pressed n again, but as it doesn't have another Image to load, it automatically quits the program:</span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">exiting...</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\[your path here]></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">-----</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">So there you have it! There are probably a few kinks I haven't worked out yet with the program, but hopefully nothing major. </span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">I haven't yet added a save function either as I couldn't easily figure out how to best add a save button without making the process of plotting contrast curves and loading images too slow. I'm trying to aim for a streamlined process of saving images, but at the same time, I don't want the user to feel rushed or confused while using my program. </span>Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-25150525493543780582011-07-14T16:09:00.000-07:002011-07-14T17:38:01.588-07:00Command Line Program - IPhot.py v 1.0!I finally finished coding <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">IPhot.py </span>(previously called <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">InteractivePhot.py</span>, but I got sick of typing it into command line every time). So here's the long-awaited example:<br />
<br />
Opening up my Windows command line... (not Python's command line)<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\>cd [my path here]</span><br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\[my path here]>IPhot CK00012_snap_20110412.fits -d 0.95 --width=74 -h 60 -s 3</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Press enter to exit.</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span><br />
The FITS image will pop up:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrHBsAHzOHs1I29Qc-yRhfHj1ooZlEMABTnlBRjW7qOeBGr6cBY8lhwAjkC_1qtnYktJaxkYzH3T8cv2gRSXjdyQenCAluq3IqI3pe6SR-uIiSt_QSDYI6zTbWInPa1ZxtSKpWNpJdKfM/s1600/originalfits.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrHBsAHzOHs1I29Qc-yRhfHj1ooZlEMABTnlBRjW7qOeBGr6cBY8lhwAjkC_1qtnYktJaxkYzH3T8cv2gRSXjdyQenCAluq3IqI3pe6SR-uIiSt_QSDYI6zTbWInPa1ZxtSKpWNpJdKfM/s320/originalfits.png" width="320" /></a></div><br />
Upon clicking, I'll get this:<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjI1PHgVsOzB_ywrTd40dB0i3FMi7OQB67S6f3XVYqQ47tPn7mnscPX0KI1zskKIm-CJCt_y6rHQKMEJOgkpYzIoHphbaVLoA4kmX5T3kS7AS62sQhLeTOuwSPSnUBNJkjlustpOecB_Uc/s1600/contrastcurve2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjI1PHgVsOzB_ywrTd40dB0i3FMi7OQB67S6f3XVYqQ47tPn7mnscPX0KI1zskKIm-CJCt_y6rHQKMEJOgkpYzIoHphbaVLoA4kmX5T3kS7AS62sQhLeTOuwSPSnUBNJkjlustpOecB_Uc/s320/contrastcurve2.png" width="320" /></a></div><br />
Notice that I actually have the name of the image on the second figure now =]<br />
<br />
Also, users can specify as many or as few of the options as they want in any order they want. So:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\[my path here]>IPhot CK00012_snap_20110412.fits -h 60 -s 3 -w 74</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Press enter to exit.</span><br />
<br />
will give the exact same thing as the image above. (Note that <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">-d</span> or <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">darkpix</span> has a default value of 0.95)<br />
<br />
To reiterate:<br />
<span class="Apple-style-span" style="color: #222222; font-family: 'Courier New', Courier, monospace; line-height: 18px;">-d, --darkpix </span><span class="Apple-style-span" style="font-family: inherit;">= </span><span class="Apple-style-span" style="font-family: inherit;">darkest x percentage of pixels</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">-w, --width </span><span class="Apple-style-span" style="font-family: inherit;">= width of sub image (</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">xsz</span><span class="Apple-style-span" style="font-family: inherit;"> variable in my python code)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">-h, --height </span><span class="Apple-style-span" style="font-family: inherit;">= height of sub image (</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">ysz</span><span class="Apple-style-span" style="font-family: inherit;"> variable)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">-s, --ann_space</span><span class="Apple-style-span" style="font-family: inherit;"> = annulus spacing, or the space between the aperture and innermost annulus radius (</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">ann_space</span><span class="Apple-style-span" style="font-family: inherit;"> variable)</span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
I also created a file called <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">IPhotParams.py</span> that is just a list of global variables with default values. A user can then edit the values in that file to quickly set the default values of <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">darkpix, ann_space</span>, etc without having to dig through the actual code.<br />
<br />
<u>Learned:</u><br />
-More about RE<br />
-A bit about setting paths<br />
<u>To-Do:</u><br />
-Make an option to save the contrast curves<br />
-Allow the program to sequentially load multiple FITS files; another will open once the user presses enter (or some other button)<br />
-Start thinking about making the program mc os compatible.Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com1tag:blogger.com,1999:blog-7514066198006373646.post-42564673717964254762011-07-13T18:01:00.000-07:002011-07-13T18:01:15.071-07:00Command Line Program IIMore command line coding!<br />
<br />
Today I learned about this function called <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">getopt()</span>, which will hopefully allow me to enter arguments (optional arguments) that will specify things such as the spacing between an annulus and aperture, the size of a cropped image, etc.<br />
<br />
I've received another challenge: To make my program accept an arbitrary number of fits files in the command line window. Basically, we're hoping the input will look something like this:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">C:\</span>[your directory to saved InteractivePhot file]<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">> InteractivePhot file1.fits file2.fits -d 0.95 -w 40 -h 40 -s 0</span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">Where:</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">-d</span><span class="Apple-style-span" style="font-family: inherit;"> = </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">darkpix </span><span class="Apple-style-span" style="font-family: inherit;">percentage</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">-w </span><span class="Apple-style-span" style="font-family: inherit;">= width of sub image (</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">xsz</span><span class="Apple-style-span" style="font-family: inherit;"> variable in my python code)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">-h </span><span class="Apple-style-span" style="font-family: inherit;">= height of sub image (</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">ysz</span><span class="Apple-style-span" style="font-family: inherit;"> variable)</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">-s</span><span class="Apple-style-span" style="font-family: inherit;"> = annulus spacing, or the space between the aperture and innermost annulus radius (</span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">ann_space</span><span class="Apple-style-span" style="font-family: inherit;"> variable)</span><br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
If these are not specified, the program will run them with default values and create graphs of all the fits files entered preceding these arguments.<br />
<span class="Apple-style-span" style="font-family: inherit;"><br />
</span><br />
I haven't quite completely finished coding yet, so I won't be putting an example here today; however, I hope to get it done by tomorrow and have something more interesting to blog about. =]<br />
<br />
I also learned about this neat thing called <a href="http://xkcd.com/208/">regular expressions</a>. Not the Perl kind, but the Python kind. Basically regular expressions is a pretty powerful tool used to search for strings. You can set all sorts of restrictions to make sure that you are searching for the string that you want. I'm hoping to use regular expressions to create a list of all the .fits files the user has entered in command line so that I can make those graphs one by one.<br />
<br />
<u>Learned:</u><br />
-Regular expressions<br />
-<span class="Apple-style-span" style="font-family: inherit;">How to use </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">getopt(...)</span><br />
<span class="Apple-style-span" style="font-family: inherit;"><u>To-Do:</u></span><br />
-Finish programAerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0tag:blogger.com,1999:blog-7514066198006373646.post-91604677680693901682011-07-12T17:03:00.000-07:002011-07-12T17:22:48.917-07:00Command Line ProgramI've been working on making the contrast curve program into a program that can be executed directly from the command line.<br />
<br />
Yesterday I attempted to at first to make a rectangle selector that allowed users to make a subplot and contrast curve by creating a rectangle on the FITS image. Unfortunately... the code was difficult for me to understand and since I couldn't find the source code, it ended up being easier to just abandon the whole idea.<br />
<br />
But today I'm definitely making much more progress! This morning I read up on some different command line functions and how to write Python files that required input from a command line. The current problem I have is that it's hard for me to load the actual FITS file onto command line, so I can't show you any examples just yet (since I can't actually make my code work on a file).<br />
<br />
Tim has been kind enough to teach me a bit about exception handling and the such. I'm assuming I'm doing something simple wrong and will continue to figure out why my fits file directories are "never found".<br />
<br />
**Edit:<br />
The fits file load now so that the programs will execute without error. However, I barely even have a chance to <i>see</i> anything load up before the program terminates again. Huh. I need to figure out how to make the program "pause".<br />
<br />
<u>Learned:</u><br />
-Loading Python scripts in command line<br />
-Using functions in Python that allows users to input info from command line<br />
-Exception Handling<br />
<u>Problems/To-Do:</u><br />
-Finish up the program.<br />
-Figure out how to "pause" it.<br />
-Test my contrast curve program against other contrast curves!Aerogelhttp://www.blogger.com/profile/04333912897557459188noreply@blogger.com0