AstroPy - roughalign.py


Description

Roughly circumscribes the planet by estimating points on the bright limb and then fitting a circle. The limb estimation uses the technique from 'findlimb.py'. A circle is then fit to these points using the technique from 'fitcircle.py'. The resulting coordinates (cx, cy, radius), fit error (RMSD in radius), and number of points used are printed.

Usage

roughalign.py fits-file [thresh dir interval0 interval1 min_count], or
roughalign.py folder [min-fits-file max-fits-file thresh dir interval0 interval1 min_count]

This program can operate on a single file or on a sequence of files. On a single file, it estimates a set of points on the bright limb, and then fits a circle to those points, printing the resulting coordinates and error, and plotting the points and circle over the input image. On a sequence of files, it outputs a list of coordinates that can be redirected to a text file. Since the limb estimation relies on negative row values in the image (in the saturated crescent), this program is best used on raw images.

'roughalign.py' attempts to find the limb in every 8th row of the image. Using more rows doesn't improve the result, but runs slower. 100 iterations of the circle fitting algorithm are used, whereas the error converges in about 60 iterations. All of these settings can be changed in the code.

The program contains a function which can be called from other programs:

roughAlign(im, thresh=0.75, dir=0, interval=(50, 5), minCount=5, printout=False, returnPts=False)
   'thresh' is the fraction (0.0 to 1.0) of the row max that a peak must be.
   'dir' is the orientation of the bright limb. 0 = sun to the right, 1 = sun to the left.
   'interval0' is the number of pixels to the left of each peak.
   'interval1' is the number of pixels to the right of each peak.
   'min_count' is the minimum number of negative values which must be in the crescent side of the peak.
   'returnPts' is a flag which returns the limb points as well as the resulting circle.
   
   See the 'findlimb.py' page for details.

Examples

This program works reasonably well on most raw images:

> roughalign.py 072407/raw/im0215.a.fits
Circle: cx=296.959917      cy=253.505009      rad=210.532756      err=1.921364        npts=38   

It can even accomodate some images where the bright limb is partially offscreen:

> roughalign.py 090807/raw/im1850.a.fits 0.75 1 5 50 5
Circle: cx=155.056316      cy=267.498732      rad=214.335478      err=0.371155        npts=9    

> roughalign.py 090807/raw/im1979.a.fits 0.75 1 5 50 5
Circle: cx=385.863713      cy=233.859617      rad=212.945557      err=0.889931        npts=44   

For sun on the right, the default parameters should suffice (thresh=0.75, dir=0, interval0=50, interval1=5, min_count=5). For sun on the left, set dir=1 and reverse interval0 and interval1 (e.g. args='0.75 1 5 50 5'). This program should work on both cont-K and br-gm data. Play with it to see how far the bright limb can be out of the frame before there are not enough limb points for a good circle.

Multiple files:

> roughalign.py 090807/raw im1970.a.fits im1979.a.fits 0.75 1 5 50 5
090807/raw/im1970.a.fits            378.608389      233.739025      214.544781      1.808101        43   
090807/raw/im1971.a.fits            377.506105      236.038080      212.303412      1.854545        45   
090807/raw/im1972.a.fits            375.062214      233.379800      211.627523      1.903415        46   
090807/raw/im1973.a.fits            380.392327      233.873925      214.502585      1.012246        40   
090807/raw/im1974.a.fits            374.509289      234.231681      210.227520      0.933074        41   
090807/raw/im1975.a.fits            380.821674      234.526641      215.306581      1.193662        45   
090807/raw/im1976.a.fits            382.243533      233.505755      211.512986      1.072806        36   
090807/raw/im1977.a.fits            381.191627      235.110605      212.602575      1.459239        43   
090807/raw/im1978.a.fits            385.618460      231.851314      213.044879      1.183417        42   
090807/raw/im1979.a.fits            385.863713      233.859617      212.945557      0.889931        44   

> roughalign.py 072407/raw
072407/raw/im0001.a.fits            225.237488      282.057854      199.038452      0.480574        40   
072407/raw/im0002.a.fits            224.735053      281.393230      198.938637      0.662971        44   
072407/raw/im0003.a.fits            226.727053      281.324609      198.203339      0.569237        38   
072407/raw/im0004.a.fits            227.656998      280.704849      198.443130      0.657364        41   
072407/raw/im0005.a.fits            226.821066      281.268604      198.693074      0.499104        37   
072407/raw/im0006.a.fits            226.667954      280.817715      198.395979      0.348853        36   
072407/raw/im0007.a.fits            225.496243      281.141945      198.837367      0.450066        39   
072407/raw/im0008.a.fits            223.831192      280.181402      199.399277      0.538154        41   
072407/raw/im0009.a.fits            224.425934      281.170340      200.107891      0.428056        32   
072407/raw/im0010.a.fits            227.008706      280.204848      198.405911      0.549547        42   
072407/raw/im0011.a.fits            228.420511      281.106945      198.177213      0.575066        39   
072407/raw/im0012.a.fits            229.346603      281.179160      197.424958      0.571816        36   
etc...

Note the increase in planet radius from 7/07 to 9/07. Output is only printed for files where >=3 non-colinear points can be found. By looking at the radius field, you can tell when the program is getting a good limb:

> roughalign.py 090807/raw im0001.a.fits im0351.a.fits 0.75 1 5 50 5

090807/raw/im0092.a.fits            -23.125000      512.312500      84.052244       1.942289        4    
090807/raw/im0095.a.fits            60.283854       396.039062      68.203261       0.076719        3    
090807/raw/im0097.a.fits            54.614583       385.687500      79.391036       0.396454        3    
090807/raw/im0101.a.fits            48.927083       401.828125      55.817203       0.178176        3    
090807/raw/im0103.a.fits            67.843750       361.906250      96.130753       0.614768        3  
...
090807/raw/im0139.a.fits            127.541667      294.767361      145.502579      1.196338        9    
090807/raw/im0140.a.fits            171.681822      244.654761      215.063554      0.708980        9    
090807/raw/im0141.a.fits            168.556152      247.537109      217.595490      0.920200        8    
090807/raw/im0142.a.fits            107.102679      326.312500      119.383888      1.066484        7    
090807/raw/im0143.a.fits            119.919643      308.343750      136.477122      0.658026        7    
090807/raw/im0144.a.fits            139.687500      285.937500      165.706108      1.298860        8    
090807/raw/im0145.a.fits            164.512817      246.350586      213.786221      0.393891        8    
090807/raw/im0146.a.fits            168.696289      248.621094      218.414932      0.494656        8    
090807/raw/im0147.a.fits            173.728223      245.920215      212.351439      2.045703        10   
090807/raw/im0148.a.fits            179.991721      242.614839      215.202593      0.774199        11   
090807/raw/im0149.a.fits            189.277464      249.379311      219.034582      1.190396        11
...


©Sky Coyote 2007