Photometric Calibration of broad-band data for WYSH


July 9th, 2009

IDL Method
********************************************************************************
You will need to programs called 'make_calinfo.pro' and 'broadcalv2.pro' located 
at:
/d/users/davec/programs/
********************************************************************************
*make a directory and put all calibration images in this directory (I usually name
the directory 'MonthDayDayYear')
*get a file called landolts.dat from: /d/users/davec/clusters/data/calibration/landolt/
*put 'landolts.dat' in the directory above the 'MonthDayDayYear' directory you just created.

*make a text file (called notes.txt; make_calinfo.pro only recognizes this name) and 
put this file in the 'MonthDayDayYear' directory. This file will contain notes that you will write
about the photometry of each standard star image and the order of the stars that was photometred. 
It should look like this:

file ,field (landolt name), landolt star name:
**************************
a0009,92,259,342,339,335
**************************
for PG#### standard stars it should look like this:
**************************
a0055,PG0918+029,1,A,B,C,D
**************************

***Common Landolt fields are SA###_### or PG####+####  SA field name is the first numbers
before the underscore (2 or 3 digits) and the star names are the numbers after the underscore. 
PG field names are the first 7 numbers then the star names are the last letter (ex. PG1633+099A; 
field name = 1633+099, star number = A).

display the images and load the regions for the particular field you are 
calibrating regions can be found at /pawnee3/davec/clusters/data/calibration/regions).  Before 
doing any photometry make sure you check which stars are going to be useable for each pointing:
1)Make sure that you are not using stars with fewer observations than 3 (at the very least!!!) 
  I use n = 4. AKA get rid of any stars that have been observed only 3 times or less (see 
  landolt paper). 
2)Run IMEXAMINE on all images and hit 'r' on each star to make sure there is no plateau in the 
  radial profile; plateau=saturated=bad

***make sure that the "DATAPAR" keywords in the phot parameter file have the AIRMASS, FILTER, and EXPTIME are defined:
PACKAGE = apphot
   TASK = datapars

(scale  =                   1.) Image scale in units per pixel
(fwhmpsf=                  2.5) FWHM of the PSF in scale units
(emissio=                  yes) Features are positive ?
(sigma  =                INDEF) Standard deviation of background in counts
(datamin=                INDEF) Minimum good data value
(datamax=                INDEF) Maximum good data value
(noise  =              poisson) Noise model
(ccdread=                     ) CCD readout noise image header keyword
(gain   =                     ) CCD gain image header keyword
(readnoi=                   0.) CCD readout noise in electrons
(epadu  =                   1.) Gain in electrons per count
(exposur=              EXPTIME) Exposure time image header keyword
(airmass=              AIRMASS) Airmass image header keyword
(filter =               FILTER) Filter image header keyword
(obstime=                     ) Time of observation image header keyword
(itime  =                   1.) Exposure time
(xairmas=                INDEF) Airmass
(ifilter=                INDEF) Filter
(otime  =                INDEF) Time of observation
(mode   =                   ql)

***or whatever the header keyword is in your headers.
 
Run photometry (see "Real Live Photometry" section here) on each star while writing 
down the order of the stars you photometered in the 'notes.txt' file.  Make sure you run 
photometry on the same number of stars for each pointing.  This won't halt this process 
until running the calibration program, but doing this will make the process much less of 
a headache.  Also, run photometry on only the good images; headache reasoning. After photometry
you should have a *.mag.1 file for each image.

Now we need a file that lists all of the photometric variables for each star.  This file
has a format of:
night  file  objectname  filter  airmass  exptime  counts  mag  magerror

all of these things are contained in the *.mag.1 files except the name of the  
stars. The info in the *mag.1 files can be piped into a text file via:
********************************************************************************
     terminal> ls a*.mag.1 > mag1.list
iraf terminal> txdump @mag1.list image,ifilter,xairmass,itime,flux,mag,merr yes > phot_raw.txt
********************************************************************************

Next you will run an IDL code designed to add the names of the standards
stars and output each stars info in the correct format.  This program reads 
in the 'notes.txt' and the 'phot_raw.txt' files.  Run the program:

IDL> make_calinfo

This creates a "night"_full.txt file which contains all of the standard stars that you 
photometered. The program 'broadcalv2.pro' only handles two filter combinations (color pairs) 
at a time. So you will have to manually copy and paste the correct filters into the their own 
text file: "nightFILTERFILTER.txt". 'broadcalv2.pro' needs a specific column format to work, 
which make_calinfo has done for you.

***It is up to you to take all of the U and B filters (for example) and put them into a file 
called 'nightUB.txt' and put them in the format:

eg.
nov16172009	a0010	95_115	  U	  2.55	 15        5988.017      -6.503     0.078
nov16172009	a0010	95_43	  U	  2.55	 15        424116.1      -11.128    0.002

nov16172009	a0012	95_115	  B	  2.49	 10        28987.09      -8.656     0.019
nov16172009	a0012	95_43	  B	  2.49	 10        1532158.      -12.963    0.001

nov16172009	a0022	95_115	  U	  1.22	 15        9410.467      -6.994     0.047 
nov16172009	a0022	95_43	  U	  1.22	 15        768576.8      -11.774    0.001    

nov16172009	a0023	95_115	  B	  1.22   10        38217.91      -8.956     0.015
nov16172009	a0023	95_43	  B	  1.22   10        2096252.      -13.304    0.001

***MAKE SURE YOU HAVE THE SAME NUMBER OF STARS PER FILTER PAIR!!! (AKA IMAGES A0010 AND A0012 ARE
A PAIR AND NEED THE SAME NUMBER OF STARS IN THE SAME ORDER!!!

*Make a file like this one for each color combination.

Now you can run broadcalv2.pro.  
broadcalv2,'monthdaysCOLOR'.txt,/no_extinction

The /no_extinction allows the user to enter the coefficients yourself
I have been using set airmass coefficients:
    BOK   err    WIRO     err	 CTIO	err
U - 0.50  0.01   0.5      0.01	 0.450	0.01
B - 0.25  0.01   0.295    0.004	 0.232	0.01
V - 0.15  0.01   0.193    0.004	 0.144	0.01
R - 0.10  0.01   0.139    0.004	 0.083 	0.005
I - 0.07  0.01   0.061    0.011	 0.056	0.005

KPNO am coefficients have been extensively studied and can be found at:
http://www.noao.edu/kpno/manuals/dim/
in the color correction and extinction section near the bottom.

*'broadcalv2.pro' will output 'nightUB.cal' with:

night  color  filter  AirmassCoefficient  Error Co(Zeropoint) Error C1(color term) Error

*Your calibrated magnitude will be found using this equation:

M = m(instrumental) + C0 + C1*color + AMcoef*airmass

****Unless you have taken 5 pointings or more of standards in one night you should do your
calibrations on a overall run basis.  In other words, take the data from all the
nights in a run and run the calibration code on the entire run data set.  
Otherwise you may not have good enough statistics to eliminate bad standard star
data points.

#########################INCOMPLETE###################################################
Next the calibrations need to be put into the header. 

*****************************************************
***Make sure the stack.fit files are created!!!!!!!!!
*****************************************************

Next you have to put the calibration information into the header of each 
stack.fit image. You will need the program 'header_cal.pro' found at:
/d/users/davec/programs/

*make a text file called 'header_info.txt'. Add the path/stack name, the filter, 
the colors that you calibrated for this night, and the name of the night in the 
'MasterCalibration'file. Example:

directory (from stack.list)		filter	color	night		
-----------------------------------------------------------------
galaxies/ugc8201/bok/U/stack.fit	U	U-B     may2010
galaxies/ugc8201/bok/U/stack.fit	U	U-V     may2010
galaxies/ugc8201/bok/U/stack.fit	U	U-R     may2010
galaxies/ugc8201/bok/U/stack.fit	U	U-I     may2010

***Each image will need all of the color combinations in the header.

run header_cal.pro

This creates a text file called 'cal.cl' that can be used to add the 
calibration info to the appropriate galaxies headers, using IRAF.
It is better to pick out each individual galaxy and copy the appropriate lines
into IRAF rather than inputing the whole file ex- cl < header_cal.cl

Then move and rename the stack.fit to the correct galaxy directory and you are done.

update the webpage
#########################INCOMPLETE###################################################