Ccd mosaic

From MediaWiki

Jump to: navigation, search


Download at:

Simple script called

  mkdir rawdirFILTER projdirFILTER diffdirFILTER corrdirFILTER finalFILTER
 cd rawdirFILTER/
 ln -s ../IMAGES .
 cd ..
 mImgtbl rawdirFILTER imagesFILTER.tbl
 mMakeHdr imagesFILTER.tbl templateFILTER.hdr
 mProjExec -p rawdirFILTER imagesFILTER.tbl templateFILTER.hdr projdirFILTER statsFILTER.tbl
 mImgtbl projdirFILTER imagesFILTER.tbl
 mAdd -p projdirFILTER imagesFILTER.tbl templateFILTER.hdr finalFILTER/uncorrectedFILTER.fits
 mViewer -ct 1 -gray finalFILTER/uncorrectedFILTER.fits -1s max gaussian-log -out finalFILTER/uncorrectedFILTER.png
 mOverlaps imagesFILTER.tbl diffsFILTER.tbl
 mDiffExec -p projdirFILTER diffsFILTER.tbl templateFILTER.hdr diffdirFILTER
 mFitExec diffsFILTER.tbl fitsFILTER.tbl diffdirFILTER
 mBgModel imagesFILTER.tbl fitsFILTER.tbl correctionsFILTER.tbl
 mBgExec -p projdirFILTER imagesFILTER.tbl correctionsFILTER.tbl corrdirFILTER
 mAdd -p corrdirFILTER imagesFILTER.tbl templateFILTER.hdr finalFILTER/mosaicFILTER.fits
 mViewer -ct 1 -gray finalFILTER/mosaicFILTER.fits -1s max gaussian-log -out finalFILTER.png

Then simply if images are called images* and FILTER is B:

  sed -e 's/FILTER/B/g' -e 's/IMAGES/images*.fit/g' >

And start the script with:


It will take a while ...


Great tutorial at:

The steps are the following:

  • Create object list
  ls images*.fit > img.list
  • Create BPM
    • Create COLD bad pixel map:
   imstat master_flat field=midpt
   imexpr " (a < lower) ? 1 : 0" a=master_flat
    • Create HOT pixel map:
  imstat dark_current_ofthesameexposure.fits
  # upper = 0.75*mean + 3*stdev
  imexpr "(a > upper) ? 1 : 0" a=dark_current_ofthesameexposure.fits
    • Final BPM mask = HOT and COLD
  imexpr "max(a,b)"
    • Add BPM to the header of each image:
  hedit @image.list BPM add+ ver-
  • Create satellite-trail masks:
  Display the image (img01) and with imexam find min,ymin,xmax,ymax and save it to a file img01.satin
  #In terminal:
  sat-b-gone -g 2 img01.satin > img01.satout # terminal program you can find at
  #In iraf
  text2mask img01.satout 2048 2048 # where 2048 x 2048 are image dimensions
  imexpr "max(a,b)"
  hedit BPM add+ ver-
  • Create object masks:
  set masktype = pl
  !sed -e 's/^/mask_/g' -e 's/.fit/.pl/g' img.list > mask.list
  objmask @img.list @mask.list masks="!BPM" hsigma=10 lsigma=5 minpix=40 ngrow=5
  # Check if all objects are found in mask_images*.fit images, if not change hsigma and lsigma and eventually minpix.
  • Find the background in the part of the images (the same part-it's easiest) - replace [xmin:xmax,ymin:ymax] with coordinates of some rectangular region without objects:
 ## In terminal
 awk '{print "iterstat",$1"[xmin:xmax,ymin:ymax] print+ ver-"}' img.list  > 
 ## In IRAF
 cl < > iterout.txt
 !sed 's/=/ /g' iterout.txt | awk '{print $9}' > foo
 ## In terminal 
 paste b.list fooB > boundariesB
 echo "mscred" >
 # Change below the to your reference image: should be the same for all observations on every night in all filters used
 awk '{print "mscimage",$1,"mos_"$1," wcssour=\"image\" reference=\"\" interpo=\"sinc17\" boundary=\"constant\" constant="$2}' boundaries >>
 # In IRAF
# Before we run the script, we must set parameters of the mscimage task correctly:

epar mscimage 
 PACKAGE = mscred
 TASK = mscimage    
 input   =                       List of input mosaic exposures
 output  =                       List of output images
 (format =                image) Output format (image|mef)
 (pixmask=                  yes) Create pixel mask?
 (verbose=                  yes) Verbose output?
                               # Output WCS parameters
 (wcssour=                image) Output WCS source (image|parameters)
 (referen= Reference image
 (ra     =		 INDEF) RA of tangent point (hours)
 (dec    =		 INDEF) DEC of tangent point (degrees)
 (scale  =                INDEF) Scale (arcsec/pixel)
 (rotatio=                INDEF) Rotation of DEC from N to E (degrees)
                               # Resampling parmeters
 (blank  =                   0.) Blank value
 (interpo=               sinc17) Interpolant for data
 (minterp=               linear) Interpolant for mask
 (boundar=             constant) Boundary extension
 (constan=                   0.) Constant boundary extension value
 (fluxcon=                   no) Preserve flux per unit area?
 (ntrim  =                    7) Edge trim in each extension
 (nxblock=                 2100) X dimension of working block size in pixels
 (nyblock=                 4200) Y dimension of working block size in pixels
                               # Geometric mapping parameters
 (interac=                   no) Fit mapping interactively?
 (nx     =                   10) Number of x grid points
 (ny     =                   20) Number of y grid points
 (fitgeom=              general) Fitting geometry
 (xxorder=                    4) Order of x fit in x
 (xyorder=                    4) Order of x fit in y
 (xxterms=                 half) X fit cross terms type
 (yxorder=                    4) Order of y fit in x
 (yyorder=                    4) Order of y fit in y
 (yxterms=                 half) Y fit cross terms type
 (fd_in  =                     )
 (fd_ext =                     )
 (fd_coor=                     )
 (mode   =                   ql)
# The reference image must be the same for all observations on diff nights, from diff filters!
# Now, we can run the script:
 cl <
  • Fit 2D surfaces to the images and correct them for these gradients:
  ## In terminal
  ls mos_images*.fit > skysubin.list
  sed s/.fit/ skysubin.list > skysubout.list
  ## In IRAF
  mscskysub @skysubin.list @skysubout.list 2 2 xmed=300 ymed=300 median_per=50 lower=3 upper=3 regions="mask" mask="BPM"
  • Finally, stack the images:
  ## In IRAF
  !ls mos_images* > bpm.list
  mscstack @skysubout.list bpmask=@bpm.list comb=ave reject=avsigclip masktype=goodvalue maskvalue=0 scale=exposure  \
  zero=median statsec=[xmin:xmax,ymin:ymax] lthresh=100 hthresh=60000 rdnoise=12.5 gain=1.25
  # These images may be of different exposure time, thus the scale keyword is set to exposure.
Personal tools