Add Headers

Add_headers is a python script that adds a permanent record of the date and time of your observation to the FITS headers of images taken at MRO. It also adds which filter you used, what type of image this is, the name of the object, and if you have logs produced by the GTCC, add_headers will read them and save the pointing information.

A copy of add_headers.py is at the bottom of this page.

Using add_headers at MRO

We tried to make it useful and easy to run while you're observing. On Geezil, type:

[mro@geezil data/050513]$ add_headers.py 050513

Add_headers will continuously look for new image files in 'My Documents/050513/' on Popeye and save them into the current directory on Geezil.

To see all of the available options type:

add_headers.py --help

The '--no_comments' option means that it'll skip setting the imtype (one of object, flat, or bias) and the object's name. Usually you want this since it's a nice record and it makes using ccdproc in IRAF very quick (see A User's Guide to CCD Reductions with IRAF by Philip Massey).

How to Re-Run add_headers.py at MRO

(from Jim) Here is one way to re-run add_headers while at MRO if you have been using it all night to add the gtcc telemetry:

In your data directory on geezil, create new subdirectories for both the logs and a re-processing of the data:

[mro@geezil data/070515]$ mkdir logs [mro@geezil data/070515]$ mkdir 070515_logs

Then copy over the gtcc's logs:

[mro@geezil data/070514]$ scp chivens:/var/www/html/logfiles/2015* logs/.

Then from the new directory, re-run add_headers in a batch mode, pointing it to the logs and the source images, like so:

[mro@geezil data/050515_logs]$ add_headers.py -l ../logs --no_ds9 --no_comments -s ../

This will make a new copy of all your data. If it runs correctly, you can delete the old data version from geezil to save harddrive space.

Using add_headers in Seattle

Add_headers uses the version of python installed in the scisoft package on all of the astro linux machines. If you haven't added the setup script to your linux setup files you'll have to type the following:

source /scisoft/bin/Setup.csh

You'll also need to avoid import a couple of libraries that the astro machines don't have. Look for the list of import statements and remove the comment ('#') character from in front of pyfits, and add it to the beginning of the astropy and readline lines. It should look like this when you're done:

import pyfits # for dealing with fits files #import astropy.io.fits as pyfits #import readline

To add all of the headers when you're not at MRO you'll need a copy of GTCC's logs. Chris is trying to keep a copy in Seattle, but it won't include the latest logs, so make your own copy while you are at MRO:

chivens (gtcc)$ scp /var/www/html/logfiles/2014* astrolab10.astro.washington.edu:my_copy_of_the_logs/

Then once you're in Seattle you'll need to point add_headers to your copies of the logs and your raw images from Popeye. The following command will grab images from raw_images, logs from my_copy_of_the_logs, and proceed just like you were at MRO.

add_headers.py -s raw_images -l my_copy_of_the_logs 

You may also want to do it more quickly. This command does the same thing, but skips display the images in ds9, asking and writing the image type and comment for each one. and just runs once (instead of continuously looking for new files):

add_headers.py -s raw_images -l my_copy_of_the_logs --no_ds9 --no_comments --once

When Things Go Wrong

Why can't it find files it needs, either image files or logs?

First check that you're pointing it at the right directories. Running add_headers.py --help prints out the default directories. Trailing slashes on the directory names are don't matter. Add '--DEBUG --once' to the options you're using and rerun. It'll print out all the images and logfiles it finds, which may help you figure out what's wrong.

add_headers.py is an executable file, but it immediately fails with some stupid python garbage!

The program needs python with the non-standard libraries astropy (or pyfits) and pyraf, all of which are included in the science software bundle Scisoft . Many of the computers in the Astronomy Department have Scisoft already. Check if it's on your machine (look for /scisoft) and be sure to source the following (this is not necessary on Geezil): for c-shell users (most of us): source /scisoft/bin/Setup.csh for bash users: . /scisoft/bin/Setup.bash To run add_headers.py with a different python just type $ python add_headers.py. If your python doesn't have pyraf you won't be able to display the images automatically: add a pound sign before 'from pyraf import iraf' and use the '--no_ds9' option.

Why can't Geezil see the logs or images?

You're looking at logs and images on the GTCC and popeye (respectively). Look in ~/data/logs and ~/data/popeye. If you see messages that popeye or the gtcc aren't mounted, make sure both the GTCC and popeye are on and happy, and then reboot Geezil (this computer). You should see log in ~/data/logs/ and the contents of 'My Documents' in ~/data/popeye/.