Variable Star Photometry Cookbook

for the AP6e CCD

In this cookbook, we will assume that you are performing differential photometry on a set of variable stars -- that is, comparing the brightness of each variable star to one or more non-variable comparison stars on the same frame. The photometry will be expressed as a magnitude difference between the variable and the comparison star.

General Procedure

1) Ensure that all the image processing has been done.

2) Load IRAF packages, copy required files into your working directory, and set PHOT parameters.

3) Run PHOT on each image to create an output data file with star magnitudes (shortcuts for experts).

4) Convert the nasty-format IRAF files to more compact format using TXDUMP.

5) Notify ACL <layden(at)baade(dot)bgsu(dot)edu> that new photometry is available.


At any point, if you have trouble, you may get a jumpstart from the troubleshooting page.

Updated 2001 June 08 - ACL

1) Ensure the Image Processing is Done.

Overview: At this stage, you should have completed image processing using the appropriate cookbook. This means the images should have been TZDF processed (Trimmed, Zero-subtracted, Dark-corrected, and Flat-field corrected), and certain image header keywords should have been included.

1) Go to your home directory and start up IRAF. Then CD to the directory where the images you wish to photometer live.

baade% cd
baade% cl
cl> cd /data/yourdirectorypath

2) Check the processing status using CCDLIST. The letters TZDF should appear within square brackets as shown in the example below. If any letters are missing, the processing is incomplete -- contact ACL.

cl> noao
no> imred
im> ccdred
cc> ccdlist *_*.imh
RU_Lup1v1.imh[1022,1019][real][none][][TZDF]: Are You Loopie?

3) Check to see whether EXPTIME and HJD have been written to the header. EXPTIME is the exposure time (length of time the CCD camera shutter was open), and HJD is the heliocentric Julian date. HJD is especially important, as it is the time-tag we will use when we study the variability in brightness over time. If values for either keyword are missing (see the example below), contact ACL.

cc> hselect *_*.imh $I,EXPTIME,HJD yes
RU_Lup1v1.imh 45. 2512347.9876
RU_Lup1i1.imh 30. 2512347.9971 [etc]

If you are satisfied, procede. If there are any questions or worries, contact ACL.

4) If you took pictures of a globular cluster, you must move them to a subdirectory, or they will mess up the running of autophot (Section 3). First, check to see if you have any images named NGC_*.imh. If so, create a subdirectory called GC and imrename the cluster images to there:

cc> imhead N*.imh [if no files appear, go to Section 2]   
cc> mkdir GC
cc> imrename N*.imh GC
cc> imhead N*.imh [they should not be in your current directory]  
cc> imhead GC/N*.imh [but they should be in the subdir GC]  

Updated 2000 April 03 - ACL

2) Prepare Directory

Overview: Here, we prepare the directory containing all your images by copying in some important files from the "Repository". Without them, subsequent steps will fail.

1) Load the appropriate IRAF packages (and unload a couple you won't need).

cc> bye
im> bye
no> digiphot
di> daophot

2) Copy the files from the Repository. The files include some files (named dpar.*) to set the parameters for the PHOT task and its sub-tasks (also called psets), and some scripts (named *.cl) that will perform complicated tasks quickly.

da> cp /data/layden/BGTEL/PHOTOM/* .

3) PHOT is the name of the IRAF task we will use to measure the magnitude of each star on a given frame. PHOT does a lot of things, and so it has several sub-tasks whose parameters we must set. Use "cl < filename" to dump the parameters in the file called 'filename' into the appropriate task parameter file (a quick and error-free alternative to EPAR). Page each of the dpar.* files to see what the parameters are you are setting (help PHOT will give you the ad-nauseum details of what happens when you run PHOT, and what the different parameters do).

da> cl < dpar.phot_1        (don't worry if some errors appear)  
da> cl < dpar.datapars
da> cl < dpar.centerpars
da> cl < dpar.fitskypars
da> cl < dpar.photpars

Updated 2006 Aug 08 -- ACL

3) Run the PHOT Task

Overview: This is where you measure the magnitude of each star on a given frame. You will repeat the steps on this page for each frame in the directory. Since that will quickly get tedious (and therefore prone to errors), we have a script that automates the worst of this process. When you feel confident you know what you are doing, you may use the automated script, but till then, gain practice with the manual approach described here.

PHOT will display the image in question on the ximtool display, and give you a cursor that you will use to select stars. By placing the cursor over a star and hitting the space bar, PHOT will do several things: (1) determine the XY coordinates of the center of the star image, (2) present you with a radial profile of the star -- a plot of pixel intensity as a function of distance from the star's center, (3) compute the typical number of counts in a sky pixel near the star, (4) sum up the total number of counts in a circle of a given radius around the star, and (5) compute the star's magnitude based on this number (minus the number of sky counts in that circle). The basic informaion gets written to the screen, and all the details get written to a text file.

The trick with PHOT is that for all the programs that we will run later to work properly, the order you click on the stars must always be the same: Var, Comp1, Comp2, ... CompN. This requires careful attention when you are idenitfying the stars on the finder chart, and constant vigilance when you are clicking the stars on the ximtool. Simple errors made at this stage can be difficult to track down later (maybe now is a good time to get some caffeine in your system!).

1) Display the image you are going to PHOT. Note: for the AP6 CCD, you will need to flip the image vertically for it to appear as it does in the finder charts (click the up/down arrow button along the upper right tool bar in ximtool). Now find the variable and comparison stars on the finder chart for this star. For example:

da> display RU_Lup1v1.imh 1

2) Run PHOT on this image. Omit the *.imh suffix in the image name (else it will appear in the output filename). Hit <return> in response to the two questions (i.e., accept the default values, which should be ' ' (blank) and default, respectively). The cursor will appear on the ximtool display.

da> phot RU_Lup1v1

3) Place the cursor over the variable star, which you should identify from the finder chart. Hit the space bar. PHOT will produce a radial profile plot, with vertical lines representing (from left to right) the radius of the aperture used to sum the star counts, the inner radius of the sky annulus, and the outer radius of the sky annulus. Check to be sure (a) the star core is not saturated (flat-topped, counts > 13,000), (b) there are no cosmic rays in the star aperture, and (c) that the median sky value (horizontal line) represents the level of the sky counts in the sky annulus. If any of these seem odd to you, check with ACL. A line of numbers will appear on the xterm window: X, Y, Sky, Mag, Error. X and Y are the coordinates of the star you just measured. Sky is the average counts per pixel in the sky. Mag is the magnitude of the star. Error is a note describing any errors that may have occured (ok means no error).

4) Place the cursor over the first comparison star ("1") listed on the finder chart, and hit the space bar. You will again get the radial profile and line of text. A glance at the radial profile is all that is needed here -- our analysis programs downstream should catch any errors of the type listed in Step 3.

5) Repeat for the remaining comparison stars, in order (2, 3, etc). If a given comparison star is off the frame or otherwise questionable, you should click on the sky nearby so that a value gets recorded. Even though the recorded value is incorrect, it will keep the order of the stars correct. The analysis programs will identify the discrepant value and omit it.

6) When you have finished all the comparison stars on this image, hit 'q' in the ximtool, and 'q' again in the xerm window to quit. PHOT has written a text file containing the photometry in the messy format. In our example, the file is called RU_Lup1v1.mag.1 . If you ran PHOT again on this image, the file produced would be called RU_Lup1v1.mag.2 (etc). If you had typed "phot RU_Lup1v1.imh", the file would be called RU_Lup1v1.imh.mag.1 . (If you are unfamiliar with the messy format, page one of the *.mag.1 files to see).

7) Do the next image, beginning at Step 1 (display). Continue image by image, until you have PHOTed each image taken on this night.

8) If you have run PHOT on a few nights of data, you probably know the ins and outs very well, and you are well into the stage of tedium (the stage where errors get made). Now is the time to learn how to run PHOT automatically!

Updated 2000 April 04 - ACL

4) Tidy up the PHOT output using TXDUMP.

Overview: The script run here calls the IRAF command TXDUMP, which dumps the information we care about out of the messy PHOT output file and into a nice format file. For example, if the PHOT output file was called RU_Lup1v1.mag.1, the new file will be called RU_Lup1v1.txd .

1) Run the script called to convert all the *.mag.1 files into *.txd files.

da> cl <

While the script was finishing, you may have noticed some lines flash by with the word "INDEF" in them. This means that one or more of the *.txd files you just created has this word in it, in place of a magnitude (and magnitude error) value -- these are the cases where the star in question was saturated, or PHOT could not compute a magnitude for some other reason. It messes up our other programs to have letters where numbers are expected, so you can run a quick script to fix them (it will set the magnitude to 99.999 and error to 88.888). While it was running, created a list of all the *.txd files that need fixing.

2) The following script will fix the files in this list, and write out a copy of the original into *.txd_old for safekeeping.

da> cl <

3) Just to be sure all got fixed correctly, run the UNIX command 'grep' again to search the new *.txd files for occurrences of "INDEF" (if all is well, you should get no output, just the da> prompt). You might also use the 'page' command to check a couple files to convince yourself the 99.999 and 88.888 values got handled correctly.

da> !grep "INDEF" *.txd

Updated 2001 June 08 - ACL

5) Troubleshooting

I'll add stuff as trouble crops up!

Updated 2000 April 05 - ACL

Running PHOT Automatically

Overview: Our CCD is fairly geometrically stable. That is, it doesn't seem to shrink or swell much, or rotate from night to night (we'd be a bit worried if it did!). That means that a given comparison star should always lie a fixed numbers of pixels X-ward and Y-ward of the variable star. We have created a file for each star containing list of Delta(X) and Delta(Y) values for each comparison star, where Delta(X) = Xcomp - Xvar, (and similarly for Y).

We also know that the standard telescope "dither" of 9 arcsec North and 9 arcsec East that you make between pairs of VI exposures corresponds to 7 pix in X and 7 pix in Y on the chip, so we can account for that too.

End result: You can know the coordinates of every star within an observing set (V-V-V or I-I-I) by knowing only the X and Y of the variable star in one of the images! That will save some wear and tear your mouse finger! Nick Pearson and ACL have written an IRAF script that will quickly allow you to determine the XYs of the variable stars on the required images, and automatically run PHOT on all the images. Slick!

Note: The following assumes you have collected data in the V filters only. If you only have data in I, use "", and if you have data in both V and I, use "", instead of "".


1) When you copied files from the Repository in Step 2 (Prepare Directory), you copied several key files:

2) You will need to have two windows open, running IRAF, and cd'ed to the directory with the images of the night in question. You will also need an ximtool running. Get that all set up now. Be sure both windows have the necessary IRAF packages open:

cl> digiphot
di> daophot

3) In one of the windows, start the script running. It will prompt you if you want to use the default shifts or not. If you did the standard telescope dither of 9N and 9E, answer '1'. If not, you will have to figure out the pixel equivalent of whatever telescope move you made (it is probably about 7/9*M(tel), where M(tel) is the telescope move you made in arcsec).

It will then ask you to display an image and start the IRAF task IMEXAM. You can easily do this by click-dragging the mouse over the lines "display..." and "imexam", and using cut/paste to drop them into the other IRAF window. The image in question will appear in the display with the IMEXAM cursor.

Put the cursor on the variable star and hit "a". IMEXAM will type the X and Y values of the star on the screen. Use cut/paste to transfer these values back to the "Get XY..." line of autophot_vi, and hit return to go to the next star. The use of cut/paste is faster and less error-prone than typing!

This process will repeat for each observing set of stars. When it is done, it will automatically run PHOT on all the images in your night of data. Sweet!

da> cl <
   Default set-to-set shift is 7.0 and 7.0 (1=accept, 0=enter new): 1
   display RU_Lup1v2.imh
Get XY of variable star (use "a") and cut/paste it here: 320.34 610.20

4) Make sure that it really did all your images. For each *.imh file, there should be a *.mag.1 file (and a *.coo file, but that is incidental). If any *.mag.1 files are missing, you should probably just do them by hand (for example, if you have any *1v4.imh or *1i4.imh, or higher, you will need to do them by hand).

da> ls 

5) Return to the regular processing path (minus a headache, eyesore, and with a couple extra hours to kill!).

Updated 2000 April 12 - ACL

Creating autophot_dxy Files

Overview: An autophot_dxy.* file contains the distance in X and Y between the variable and each of the comparison stars. That is, each comparison star has an offset Delta(X) = Xcomp - Xvar (and similarly for Y). The values for each comparison star occupy a different line in the file -- here is an example.

If one already exists, use it. If not, there are two ways you can create this file, (1) from an existing *.txd file for the variable star in question (i.e., you have already run PHOT manually on this star), or (2) directly from an image, using IMEXAM.

Method #1: Create autophot_dxy.* files from existing *.txd files. Run the indicated program, and it will prompt you for the name of the input *txd file. It creates a file called autophot_dxy.*, where the * is the first 6 letters of the filename you input. In the example below, the file is called "autophot_dxy.RU_Lup". Run it once for each autophot_dxy file you need to create.

da> !/data/layden/BGTEL/PROGS/autophot_prep.e
   Enter name of *.txd file from a good seeing image: RU_Lup2v3.txd


Method #2: Create autophot_dxy.* files from an image.

1) You will use two XTERM windows, and one should have IRAF running. First, display a good seeing image of the variable star in quesiton on the XIMTOOL and start the IRAF task IMEXAM running.

da> display U__Pic1v2.imh 1
da> imexam

2) In the other XTERM window, run the indicated program, and it will prompt you for the name of the input image (*.imh). Then it will ask you for the X,Y position of the variable star. Place the mouse on the variable star in the XIMTOOL and hit 'a'. The coordinates will appear in the IRAF XTERM window. Use the mouse to copy/paste the coordinates to answer the question posed by the progam. Then you will be prompted for the first comparison star's coordinates. Use IMEXAM to get those coords and copy/paste them over. Continue until you have entered the coords of all the comparison stars. The program will keep prompting you for more coords (it doesn't know how many comp stars there are), so answer "0 0" to stop it. It will write a file called "autophot_dxy.*", where * is the first 6 letters of the image name you input (in this example, U__Pic).

da> !/data/layden/BGTEL/PROGS/autophot_prep_imex.e
   Enter name of *.txd file from a good seeing image: U__Pic1v2.imh
   Enter the X and Y coords of the variable star: 345.2 372.5
   Enter the X and Y coords of comp star #1 (0 0 to end): 232.9 924.3
   ... etc ...
Enter the X and Y coords of comp star #11 (0 0 to end): 0 0

3) Repeat the procedure (go to Step 1) to create autophot_dxy.* files for any other variable stars you need.

4) Continue to run AUTOPHOT on your night of data.

Updated 2006 Aug 08 -- ACL