AstroPy - brightalign.py


Description

Better circumscribes the planet by estimating points on the bright limb and then fitting a circle. The limb estimation uses a technique which looks for maxima on individual radii near the perimeter of an already estimated circle at equally spaced angles. A new circle is then fit to these points using the technique described in 'fitcircle.py'. The resulting coordinates (cx, cy, radius), fit error (RMSD in radius), and number of points used are printed. This techinque can be used repeatedly to often get better estimates of the circle fitting the bright limb. In addition, image interpolation using either the nearest 4 pixels (linear), or a neighborhood of +-5 pixels in X and Y (sinc superposition) can be used to get better fractional image values. For some images, the rough alignment using row limbs is pretty good. However, for many other images the new technique (especially with multiple iterations) can significantly improve the circumscription.

Usage

To use this program you must first:

  1. Get the rough circle coordinates from the raw image using 'roughalign.py' or another method.
  2. Flatten and fill the image using 'flatten.py' and 'fill.py'.

You can run 'brightalign.py' in either single file or batch folder mode. You must provide initial circle coordinates either from a file or on the command line. The syntax is:

brightalign.py -f fits-file [-c coord-file] [-a 'a0 an da'] [-t thresh] [-r res] [-i iters] [-b blend] [cx cy rad], or
brightalign.py -d folder [-c coord-file] [-a 'a0 an da'] [-t thresh] [-r res] [-i iters] [-b blend] [min-file] [max-file]

   'fits-file' is a file to use in single-file mode,
   'folder' is a folder to use in multi-file mode (only one of -f or -d should be set),
   'coord-file' is a text file of coordinates in the format produced by 'roughalign.py', 
   'a0 an da' are 2 angles (in degrees) and a delta angle used to orient the points around the limb (defaults -110, 60, 5), 
   'thresh' is the limb threshold value (default 1000.0),
   'res' is the resolution in pixels (default 1.0),
   'iters' is the number of iterations (default 1),
   'blend' is the pixel blending method = {1: nearest (default), 2: linear of 4 closest, 3: sinc superposition of +-5 in X and Y},
   'cx, cy, rad' are the initial circle coordinates which override those in the coordinate file,
   'min-file', 'max-file' are file names used in batch mode.

This program can operate on a single file or on a sequence of files. On a single file, it uses the input circle coordinates as a guide to further estimate a set of points on the bright limb and then fits a circle to those points. It then prints the resulting coordinates and error, and plots the original circle and final 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 maxima on a per-radial basis, it should be performed on processed images, and can be used repeatedly to get better circle estimates.

Examples

> brightalign.py -c 072407/intermediates/coords.171-276.raw.txt -f 072407/filled/im0215.a.fits -b 2 -r 0.1 -i 3
Old: cx=296.959917      cy=253.505009      rad=210.532756      err=1.921364        npts=38   
New: cx=306.408986      cy=252.084069      rad=202.773780      err=2.119477        npts=34   
New: cx=305.505028      cy=252.544997      rad=203.650724      err=1.660518        npts=32   
New: cx=305.429288      cy=252.348162      rad=203.308285      err=1.607127        npts=32   

> brightalign.py -c 072407/intermediates/coords.171-276.raw.txt -d 072407/filled im0171.a.fits im0276.a.fits
072407/filled/im0188.a.fits         475.506939      99.227062       29.679471       2.011445        29   
072407/filled/im0189.a.fits         477.403097      100.877858      27.411034       1.569618        29   
072407/filled/im0190.a.fits         482.573370      100.412489      22.101177       1.841216        30   
072407/filled/im0191.a.fits         441.454081      140.253343      74.184136       2.230917        21   
072407/filled/im0192.a.fits         449.763755      127.372574      58.685330       1.883183        24   
072407/filled/im0193.a.fits         365.956267      250.537877      203.915964      2.022145        15   
072407/filled/im0194.a.fits         351.490585      252.256244      208.626454      2.457132        17   
072407/filled/im0195.a.fits         417.111846      165.989911      102.187812      1.887082        17   
072407/filled/im0196.a.fits         362.863057      251.343798      202.048397      1.028670        18   
072407/filled/im0197.a.fits         363.077644      251.278702      201.422309      1.080783        18   
...

> brightalign.py -c 072407/intermediates/coords.171-276.raw.txt -d 072407/filled -i 25 -r 0.25 -b 2 im0171.a.fits im0276.a.fits
072407/filled/im0188.a.fits         385.117388      247.701152      202.441504      0.680466        14   
072407/filled/im0189.a.fits         378.252185      249.203951      202.278048      2.040256        15   
072407/filled/im0190.a.fits         377.983045      249.415566      201.680636      1.609686        15   
072407/filled/im0191.a.fits         370.851447      235.731296      188.895651      3.620695        18   
072407/filled/im0192.a.fits         381.531125      190.686352      144.205580      6.977277        24   
072407/filled/im0193.a.fits         371.541229      248.988594      201.966219      1.356143        16   
072407/filled/im0194.a.fits         364.198224      251.771358      202.561424      1.734825        17   
072407/filled/im0195.a.fits         363.488501      251.795934      202.025659      1.367454        17   
072407/filled/im0196.a.fits         360.338893      251.879939      202.694216      1.089841        18   
072407/filled/im0197.a.fits         361.274958      251.728418      202.114698      1.027579        18   
...

Note how multiple iterations, subpixel resolution, and pixel blending improve almost all the radial estimates in the previous run.

Initial coordinates can also be entered on the command line:

> brightalign.py -f 072407/filled/im0276.a.fits 125.334772 272.398795 200.727358
Old: cx=125.334772      cy=272.398795      rad=200.727358      err=-1.000000       npts=-1   
New: cx=120.866434      cy=270.397674      rad=204.510632      err=1.600417        npts=35   

To use on images with the sun at left, enter a new set of angles:

> brightalign.py -c 090807/intermediates2/coords.1756-1979.raw.txt -f 090807/filled/im1847.a.fits -a '95 250 5'
Old: cx=137.555804      cy=269.470424      rad=206.494144      err=0.812697        npts=7    
New: cx=151.153251      cy=267.095697      rad=214.797093      err=1.114426        npts=13   

Angles are in degrees CCW from the +X axis, and should be enclosed in quotes.

You can perform multiple iterations, and use sub-pixel coordinates, with the -i and -r options. Often this will consideraby improve the circle estimate:

> brightalign.py -c 072407/intermediates/coords.171-276.raw.txt -f 072407/filled/im0193.a.fits -i 10 -r 0.25
Old: cx=386.150000      cy=248.600000      rad=191.529344      err=2.719268        npts=5    
New: cx=366.902120      cy=250.359207      rad=202.948798      err=2.170681        npts=15   
New: cx=371.406033      cy=248.094387      rad=200.927137      err=1.078970        npts=16   
New: cx=372.981450      cy=248.174631      rad=200.835638      err=1.337027        npts=16   
New: cx=370.432388      cy=248.862928      rad=201.551614      err=1.279210        npts=16   
New: cx=373.221190      cy=248.424684      rad=200.802524      err=1.574870        npts=16   
New: cx=370.695820      cy=248.671434      rad=201.526637      err=1.425269        npts=16   
New: cx=371.984677      cy=248.765568      rad=201.510867      err=1.525461        npts=16   
New: cx=371.007888      cy=249.014412      rad=201.648754      err=1.182801        npts=16   
New: cx=373.579727      cy=248.544977      rad=200.758791      err=1.477198        npts=16   
New: cx=373.191230      cy=247.992047      rad=200.627735      err=0.887509        npts=16   

> brightalign.py -c 072407/intermediates/coords.171-276.raw.txt -f 072407/filled/im0209.a.fits -r 0.25 -b 2 -i 11
Old: cx=304.677589      cy=256.368623      rad=219.826168      err=2.404159        npts=21   
New: cx=318.892259      cy=254.567141      rad=207.945751      err=2.680420        npts=25   
New: cx=324.262687      cy=254.421710      rad=204.153877      err=1.908926        npts=25   
New: cx=326.288637      cy=253.478328      rad=203.401327      err=1.389994        npts=24   
New: cx=325.824447      cy=254.404703      rad=203.576849      err=1.356377        npts=24   
New: cx=325.646571      cy=254.293337      rad=203.711554      err=1.332034        npts=24   
New: cx=325.459426      cy=254.263746      rad=203.810248      err=1.260315        npts=24   
New: cx=325.704978      cy=253.938663      rad=203.783574      err=1.182006        npts=24   
New: cx=325.426674      cy=254.071720      rad=203.799083      err=1.125457        npts=24   
New: cx=325.258336      cy=254.312177      rad=203.915416      err=1.251797        npts=24   
New: cx=325.604550      cy=254.015935      rad=203.701544      err=1.239800        npts=24   
New: cx=325.343207      cy=253.970037      rad=203.887666      err=1.113565        npts=24   

> brightalign.py -c 090807/intermediates2/coords.1756-1979.raw.txt -f 090807/filled/im1822.a.fits -a '95 250 5' -r 0.25 -b 2 -i 13
Old: cx=62.145833       cy=378.093750      rad=102.794713      err=0.495846        npts=3    
New: cx=77.346624       cy=366.214675      rad=119.143670      err=3.878372        npts=11   
New: cx=79.027930       cy=358.432847      rad=126.767321      err=6.193828        npts=13   
New: cx=86.670535       cy=345.607851      rad=141.222078      err=3.264148        npts=11   
New: cx=95.015229       cy=334.037326      rad=155.100979      err=3.549777        npts=11   
New: cx=97.711272       cy=325.780852      rad=163.525571      err=6.500879        npts=11   
New: cx=101.387395      cy=314.167827      rad=174.920979      err=4.587352        npts=11   
New: cx=87.147177       cy=311.319856      rad=173.775777      err=6.047864        npts=11   
New: cx=113.568619      cy=299.906668      rad=193.523710      err=6.116633        npts=9    
New: cx=112.033106      cy=289.271434      rad=201.433948      err=5.334823        npts=11   
New: cx=105.330870      cy=285.961217      rad=202.797502      err=3.178170        npts=9    
New: cx=119.661271      cy=278.884694      rad=214.015076      err=7.738273        npts=9    
New: cx=96.675093       cy=278.459516      rad=207.463276      err=2.637648        npts=8    
New: cx=102.065403      cy=275.595647      rad=212.340646      err=0.358380        npts=7    

> brightalign.py -c 072407/intermediates/coords.171-276.raw.txt -f 072407/filled/im0188.a.fits -i 20 -r 0.25 -b 2
Old: cx=485.880534      cy=90.234375       rad=18.256319       err=0.000882        npts=3    
New: cx=478.495602      cy=96.899503       rad=26.353740       err=1.756228        npts=29   
New: cx=464.577083      cy=105.915025      rad=41.331815       err=2.128827        npts=26   
New: cx=438.591439      cy=136.796333      rad=80.539970       err=1.498212        npts=20   
New: cx=422.232401      cy=143.182781      rad=93.651694       err=6.581373        npts=20   
New: cx=412.013357      cy=150.365261      rad=104.462842      err=8.479587        npts=24   
New: cx=402.286821      cy=162.248406      rad=118.178283      err=7.133187        npts=24   
New: cx=393.635843      cy=174.393539      rad=131.415680      err=6.839916        npts=24   
New: cx=392.112187      cy=185.046017      rad=142.149455      err=6.162206        npts=23   
New: cx=389.201877      cy=195.497343      rad=152.080008      err=6.123190        npts=21   
New: cx=391.150198      cy=203.151322      rad=159.466468      err=5.948705        npts=19   
New: cx=387.244408      cy=213.735190      rad=169.760155      err=4.329276        npts=18   
New: cx=382.957692      cy=223.301583      rad=179.233850      err=6.048678        npts=18   
New: cx=383.137194      cy=229.552281      rad=184.901250      err=6.280105        npts=17   
New: cx=386.234027      cy=233.095245      rad=188.529638      err=2.446290        npts=16   
New: cx=382.631037      cy=238.281860      rad=192.948015      err=5.941841        npts=16   
New: cx=381.286536      cy=243.250574      rad=197.947459      err=5.690559        npts=16   
New: cx=382.512362      cy=247.622656      rad=201.710674      err=2.667881        npts=14   
New: cx=385.347727      cy=247.540287      rad=201.989907      err=1.098188        npts=14   
New: cx=386.040566      cy=247.468141      rad=202.063883      err=0.875550        npts=14   
New: cx=385.040811      cy=247.801350      rad=202.533488      err=0.689608        npts=14   


©Sky Coyote 2007