Terapix Star Formation Region IC 1396, © 2001 CFHT
Step by step procedure to reduce WIRCam data
Article
How to reduce WIRCam data from CFHT pre-reduction
by CMA - Updated December 28th, 2007

-  Building the directory tree

% mkdir <principal>

% cd <principal>

% mkdir images

% mkdir calib

% cp <subsky_dir>/config/flat.reg calib/

-  Downloading *p.fits and *s.fits images

% cd images

% wget ...

-  Decompressing images

% ls *.fits.fz > zlist

% <subsky_dir>/imcopy.pl zlist

-  Slicing *p.fits data-cubes.

Note that it seems to be a better idea to use listfiles with missfits when dealing with large numbers of images. i.e.

ls -1 *p.fits > list_p.dat

% missfits -c <subsky_dir>/subsky/config/missfits.conf -OUTFILE_TYPE SLICE -SLICE_SUFFIX _%02d.fits -SAVE_TYPE BACKUP -DISPLAY_KEYWORD OBJECT,FILTER,MJDATE,EXPTIME,FOTC,ABSOR,PI_NAME,RA_DEG,DEC_DEG @list_p.dat -XML_NAME <thenameyouprefer>_missfits.xml

-  Build night lists and .ahead

% <subsky_dir>/subsky/c_scripts/listfile missfits.xml

-  Quality assessment

% ls *p_??.fits > list

% <subsky_dir>/subsky/qfits.pl list --mail teraop@iap.fr --calib-dir ../calib --conf-dir <subsky_dir>/subsky/config

It is also possible to run qfits.pl distributing jobs with condor on lists of images. To optimize the job distribution, lists will have almost the same number of elements. A script example to run qfits.pl with condor is available in the subsky SVN distribution. Copy it in your working directory and run

% ./qfits1.x *.list | condor_submit

Bad images are then rejected from directory and from lists created by listfile.

-  Astrometric and photometric calibration

% cd ../

% mkdir scamp

% cd scamp

% ln -s ../images/*p_??/qualityFITS/*p_??.ldac .

% mv ../images/*p_??.ahead .

% scamp *p_??.ldac -c <subsky_dir>/subsky/config/scamp.conf -MATCH Y -SOLVE_ASTROM Y -MOSAIC_TYPE SAME_CRVAL -SOLVE_PHOTOM Y -CHECKPLOT_DEV PNG -CHECKPLOT_ANTIALIAS Y -MAGZERO_KEY FOTC -AHEADER_GLOBAL <subsky_dir>/subsky/config/wircam.ahead -AHEADER_SUFFIX .ahead -VERBOSE_TYPE NORMAL -DISTORT_DEGREES 4

-  Coaddition

% cd ..

% mkdir swarp

% cd swarp

% ln -s ../scamp/*p_??.head .

% ln -s ../images/*p_??/qualityFITS/*p_??_weight.fits .

% ln -s ../images/*p_??.fits .

% swarp *p_??.fits -c <subsky_dir>/subsky/config/swarp.conf -IMAGEOUT_NAME coadd.fits -WEIGHTOUT_NAME coadd.weight.fits -RESAMPLING_TYPE LANCZOS2 -BACK_SIZE 128 -WEIGHT_SUFFIX _weight.fits -WEIGHT_IMAGE "" -COMBINE_TYPE MEDIAN -COPY_KEYWORDS OBJECT,FILTER,MAGZEROP -WEIGHT_TYPE MAP_WEIGHT

-  Slicing no-sky-subtracted data-cubes

% cd ../images

% missfits -c <subsky_dir>/subsky/config/missfits.conf -OUTFILE_TYPE SLICE -SLICE_SUFFIX _%02d.fits -SAVE_TYPE BACKUP -DISPLAY_KEYWORD OBJECT,FILTER,MJDATE,EXPTIME,FOTC,ABSOR,PI_NAME *s.fits

Images identified as bad in first quality assessment are rejected. It is sufficient to modify the lists prepared by listfile.

% <subsky_dir>/subsky/slistbuild.x *.list

At the same type lists of sky-subtracted images are builded.

-  Double pass subtraction

preparing subtraction: producing input weights to discard zeroes as in the *p.fits images and linking weights and headers

% ls *p.fits > plist

% <subsky_dir>/subsky/preparesub.pl plist

At the same time the *p_??.ahead files are linked as *s_??_sub.ahead in the scamp directory.

subtraction

% <subsky_dir>/subsky/subsky.pl list -N 4 -n 23 -I ../swarp/coadd.fits -W ../swarp/coadd.weight.fits --pass2 -T 3 --inweight-suffix _sub_zeroes.fits --outweight-suffix _outw2.fits -M ../calib/<mask>.fits --mail teraop@iap.fr --conf-path <subsky_dir>/subsky/config --script-path <subsky_dir>/subsky/c_scripts

It is also possible to run subsky.pl distributing jobs with condor. A script example to run subsky.pl with condor is available in the subsky SVN distribution. Copy it in your working directory and run

% ./subsky.x *.list | condor_submit

-  Redoing quality assessment and calibration

% ls *s_??_sub.fits >sublist

% <subsky_dir>/subsky/qfits.pl sublist --pass2 --inweight-suff _zeroes.fits --mail teraop@iap.fr --calib-dir ../calib --conf-dir <subsky_dir>/subsky/config

It is also possible to run qfits.pl distributing jobs with condor on lists of images. A script example to run qfits.pl on sky-subtracted images with condor is available in the subsky SVN distribution. Copy it in your working directory and run

% ./qfits2.x *.list | condor_submit

% cd ../scamp

% ln -s ../images/*s_??_sub/qualityFITS/*s_??_sub.ldac .

% scamp *s_??_sub.ldac -c <subsky_dir>/subsky/config/scamp.conf -MATCH Y -SOLVE_ASTROM Y -MOSAIC_TYPE SAME_CRVAL -SOLVE_PHOTOM Y -CHECKPLOT_DEV PNG -CHECKPLOT_ANTIALIAS Y -MAGZERO_KEY FOTC -AHEADER_GLOBAL <subsky_dir>/subsky/config/wircam.ahead -AHEADER_SUFFIX .ahead -VERBOSE_TYPE NORMAL -DISTORT_DEGREES 4

-  Coaddition

% cd ../swarp

% ln -s ../scamp/*s_??_sub.head .

% ln -s ../images/*s_??_sub.fits .

% ln -s ../images/*s_??_sub/qualityFITS/*s_??_sub_weight.fits .

% swarp *s_??_sub.fits -c <subsky_dir>/subsky/config/swarp.conf -IMAGEOUT_NAME final.fits -WEIGHTOUT_NAME final.weight.fits -RESAMPLING_TYPE LANCZOS2 -SUBTRACT_BACK N -WEIGHT_SUFFIX _weight.fits -WEIGHT_IMAGE "" -COMBINE_TYPE MEDIAN -COPY_KEYWORDS OBJECT,FILTER,MAGZEROP -WEIGHT_TYPE MAP_WEIGHT -SATLEV_KEYWORD PIPPO -SATLEV_DEFAULT 30000

-  Background correction for negative crosstalk remanences (temporarily)

% sex -FILTER N -DETECT_THRESH 100000000000 -CHECKIMAGE_TYPE -BACKGROUND -BACK_SIZE 10,1000 -BACK_FILTERSIZE 1 final.fits -WEIGHT_TYPE MAP_WEIGHT -WEIGHT_IMAGE final.weight.fits -CATALOG_TYPE NONE -INTERP_TYPE NONE; sex -FILTER N -DETECT_THRESH 100000000000 -CHECKIMAGE_TYPE -BACKGROUND -BACK_SIZE 1000,10 -BACK_FILTERSIZE 1 check.fits -WEIGHT_TYPE MAP_WEIGHT -WEIGHT_IMAGE final.weight.fits -CATALOG_TYPE NONE -CHECKIMAGE_NAME final_new.fits -INTERP_TYPE NONE

-  Quality Evaluation

% /usr/local/bin/qualityFITS final.fits -W final.weight.fits [--ref-image other_final.fits --ref-weight other_final.weight.fits] -2 -vv -c <subsky_dir>/subsky/config/Wircam2pass.rc -P final.reg --back2

Build a 'scratch' directory for catalogs manipulation

% mkdir scratch

% cd scratch

Comparison with 2MASS (only for 2MASS filters)

1) Extract the center of the field and its radius, for example

% exvovalue ../scamp/scamp.xml FGroups Field_Coordinates,Max_Radius

The output is something like

Max_Radius      Field_Coordinates
42.2932 333.9024839 -17.76217271

2) Retrieve 2MASS catalog from CDS

% /usr/local/bin/aclient cocat1.u-strasbg.fr 1660 find2m -c <alpha> <delta> -r <Max_Radius> -m 1000000 | sed 's/|/ /g' > 2mass.cat

3) Convert your catalog from LDAC to ASCII format. Use, for example, ldactoasc available in the last SVN distribution of SExtractor.

% <YOUR_PATH>/ldactoasc final/qualityFITS/final.ldac > final.cat

4) Cross-identifie your catalog with 2MASS one

% <subsky_dir>/subsky/c_scripts/cross2mass 2mass.cat final.cat <magmin> <magmax> <filter> 1.

% mv cross.dat finalcross.dat

5) Use <subsky_dir>/subsky/smmacro/cross.sm to produce the plot.

Galaxy counts

1) Extract galaxies from your catalog

% awk '{if ($37==0 && $38<4) print $2, $3, $32, $34, $1}' final.cat > r2_scratch.dat

<subsky_dir>/subsky/sgsep.pl

One of the outputs of sgsep.pl is, for example, a file named <filter>

awk '{if ($6==0) print $0}' <filter> > <thenameyouwant>.cat

2) Compute the effective area in degrees as

(NAXIS1 * NAXIS2) * (abs(CD1_1*CD2_2 - CD1_2*CD2_1)) * EFF_AREA

strings ../final/qualityFITS/final_flag.fits | fold | egrep -h "NAXIS.|CD._.|EFF_AREA"

3) Use <subsky_dir>/subsky/smmacro/<filter>counts.sm to produce the plot.


Site Map  -   -  Contact
© Terapix 2003-2011