AstroPy - process.py - 9/3/07


Description

Performs all steps of image processing on a single file or a series of files in a directory. Currently these steps include:

  1. Rough alignment of the raw image,
  2. Flat-fielding,
  3. Filling masked areas and the slit,
  4. Shifting +-0.5 pixels in x and y and averaging the results to remove high-frequency (e.g. readout) noise,
  5. Shifting to center (255.0, 255.0) and performing 5 iterations of alignment and reshifting using the techinque in 'roughalign2.py'. The actual shift is only performed once on the final image, after the sum of all individual shifts has been accumulated.

If run on a series of files, also outputs the final circle coordinates, error, and number of points used, which can be redirected to a text file for further use. Writes the final image to a FITS file in the 'processed' directory of the selected day, and adds FITS headers describing the processing performed (see examples below).

Usage

process.py parent-directory [min-file-name] [max-file-name], or
process.py parent-directory fits-file [min] [max]

Examples

92: ~/Projects/Python/AstroPy > process.py 072407 072407/raw/im0215.a.fits 0 0
 0:      311.759364      251.072830      198.740857        3.548460   259
 1:      248.375814      255.990023      203.260340        2.057244    71
 2:      255.311012      254.976918      203.118648        2.013536    71
 3:      254.782418      255.071649      203.406920        2.103684    71
 4:      255.133298      255.111891      203.223770        2.108625    71
 5:      254.657494      255.084210      203.443551        1.989519    71
Total shift: dx = -50.019400, dy = 2.692479
 5:      255.249040      254.951704      203.313965        1.933188    71



93: ~/Projects/Python/AstroPy > process.py 072407 im0195.a.fits im0249.a.fits
072407/processed/im0195.a.fits 2007-07-24      05:18:47.828235      254.229680      256.013179      202.121694      2.356318        38   
072407/processed/im0196.a.fits 2007-07-24      05:18:56.368266      254.957269      255.265668      190.964092      4.843838        40   
072407/processed/im0197.a.fits 2007-07-24      05:19:04.888597      255.234336      254.972379      185.119235      4.170546        42   
072407/processed/im0198.a.fits 2007-07-24      05:19:13.462010      253.930009      255.401307      203.307513      2.113525        40   
072407/processed/im0199.a.fits 2007-07-24      05:19:21.991239      254.680357      255.247144      202.594452      2.091979        40   
072407/processed/im0200.a.fits 2007-07-24      05:19:30.534879      255.403673      254.707687      202.593521      1.577921        40   
072407/processed/im0201.a.fits 2007-07-24      05:19:39.811627      254.429349      255.245833      204.681828      1.784465        42   
072407/processed/im0202.a.fits 2007-07-24      05:19:48.336848      254.477021      255.342997      203.006764      2.425823        44   
072407/processed/im0203.a.fits 2007-07-24      05:19:56.853756      254.647836      254.986464      203.684079      2.369566        46   
072407/processed/im0204.a.fits 2007-07-24      05:20:05.403290      255.113239      254.935640      204.448178      2.239455        48   
...
072407/processed/im0240.a.fits 2007-07-24      05:25:12.832088      254.833921      254.881268      204.236557      1.340857        71   
072407/processed/im0241.a.fits 2007-07-24      05:25:21.152264      254.996051      255.255273      204.507777      1.482557        71   
072407/processed/im0242.a.fits 2007-07-24      05:25:29.473297      254.822342      255.131462      204.098085      1.470870        71   
072407/processed/im0243.a.fits 2007-07-24      05:25:38.055761      254.938663      255.194022      203.183470      1.491038        71   
072407/processed/im0244.a.fits 2007-07-24      05:25:46.369103      255.180292      255.020956      203.557401      1.533546        71   
072407/processed/im0245.a.fits 2007-07-24      05:25:54.780446      255.366070      254.819956      204.058057      1.314898        71   
072407/processed/im0246.a.fits 2007-07-24      05:26:03.336123      255.223394      254.650959      202.687006      1.612868        71   
072407/processed/im0247.a.fits 2007-07-24      05:26:11.817130      255.090087      254.940094      203.716341      1.564076        71   
072407/processed/im0248.a.fits 2007-07-24      05:26:20.140111      255.028546      255.227121      203.470856      1.371069        71   
072407/processed/im0249.a.fits 2007-07-24      05:26:28.452767      255.169728      255.050822      203.620347      1.530868        71   

Each processed file contains additional FITS headers describing the processing performed:

2: ~/Projects/Python/AstroPy > plotfits.py 072407/processed/im0215.a.fits 0 0 1
SIMPLE  =                    T / conforms to FITS standard                      
BITPIX  =                  -64 / array data type                                
NAXIS   =                    2 / number of array dimensions                     
NAXIS1  =                  512                                                  
NAXIS2  =                  512                                                  
...
AIRMASS =                3.154 / Air Mass                                       
EPOCH   =               2000.0 / Epoch                                          
ASTROPY =                    T / *** Image processed by AstroPy ***             
FLATTEND=                    T / Image has been flat-fielded                    
FILLED  =                    T / Masked values have been filled                 
SHFTAVGD=                    T / Image has been shifted to remove noise         
SHIFTDX =    -50.0193999259169 / Total shift amount                             
SHIFTDY =    2.692478694247256 / Total shift amount                             
CIRCX   =    255.2490398403469 / Final circumscription                          
CIRCY   =     254.951704115563 / Final circumscription                          
CIRCR   =    203.3139653664471 / Final circumscription                          

Note that when 'scancoords.py' is run on the coordinate output, it correctly identifies the 2 images that could not be properly aligned (196 and 197). These images can be deleted from the 'processed' directory:

94: ~/Projects/Python/AstroPy > scancoords.py 072407/intermediates/coords.processed.195-249.txt 
55 entries
 cx:  av =      255.043235, std =        0.381148, min =      253.930009, max =      255.841640
 cy:  av =      255.016337, std =        0.268066, min =      254.280379, max =      256.013179
rad:  av =      203.358676, std =        3.124337, min =      185.119235, max =      206.430188
err:  av =        1.816975, std =        0.655055, min =        1.134891, max =        4.843838
072407/processed/im0196.a.fits : radius out of 1.50 std band
072407/processed/im0196.a.fits : err out of 1.50 std band
072407/processed/im0197.a.fits : radius out of 1.50 std band
072407/processed/im0197.a.fits : err out of 1.50 std band
072407/processed/im0214.a.fits : err out of 1.50 std band


İSky Coyote 2007