Tuesday, October 7, 2014

SOUSA SCRIPTS

WARNING:  these instructions are a work in progress but posted here so I can get feedback from some people.  If you try them, please let me know if they work for you, where you need more instruction, etc.

As a part of the Swift Optical/Ultraviolet Supernova Archive (SOUSA) I am reducing and making public as many supernova light curves as I can.  In order to be open about my reduction methods and enable others to reduce Swift data on their own, I am posting the scripts that I use to produce light curves of SNe.  These scripts could be used to produce light curves of any other single object as well.  If you use these scripts in a publication, please cite the SOUSA paper which describes the basic method and put something in the acknowledgements.  I haven't extensively tested these scripts on other computers--I use a Macbook Pro 10.6.8 and a newer Macbook Pro.  If you have problems or questions, e-mail me or post it in the comments below.





You will need the HEASOFT package and the Swift CALDB (calibration database).
Here are my reduction scripts.  The reside in a folder with the alias $SNSCRIPTS.  The recipe using them is underneath, where I begin commenting out the comments to show which are the actual commands.  You should probably first understand how uvotimsum is used to combine images and uvotsource is used to do the photometry on an image.  These scripts use those and other commands to streamline the steps for doing the photometry on a whole bunch of images.

makecommands14.1.txt

SNgalsub14.1.maghist.txt

#  I have a SN data folder in which I have folders for each individual SN.

mkdir SN2006gy
cd SN2006gy

#Recent data (less than a week old) can be downloaded from the Quicklook site.
#If you can't find the target by name you can look up the Target ID on the Swift ToO page.
#For my scripts you will need to gzip the files before running the scripts.

#Older data can be downloaded from the Swift Archive.
#Search using the SN name, host galaxy name, or the position
#(with a search radius of 5 arcmin) to make sure you get all of the data
#for that source position.  Sometimes a SN is observed using multiple Target IDs
#or there are pre-SN images useful as galaxy templates.
#Clicking on the down arrow under "start time" will sort the observations.
#If there is a pre-explosion or late time observations that can be used as a template,
#write it down.  You can click on the boxes to select all the Target IDs.
#Scroll down to "Data Products" and choose to download the UVOT folder.
#For SN2006gy there was one SN observation.
#There are four later observations targeting the host galaxy of SN2008L. 
#Click on the "Create Download Script" button.  You will get the following wget commands:

wget -q -nH --cut-dirs=5 -r -l0 -c -N -np -R 'index*' -erobots=off --retr-symlinks http://heasarc.gsfc.nasa.gov/FTP/swift/data/obs/2013_07//00049990002/uvot/
wget -q -nH --cut-dirs=5 -r -l0 -c -N -np -R 'index*' -erobots=off --retr-symlinks http://heasarc.gsfc.nasa.gov/FTP/swift/data/obs/2013_07//00049990001/uvot/
wget -q -nH --cut-dirs=5 -r -l0 -c -N -np -R 'index*' -erobots=off --retr-symlinks http://heasarc.gsfc.nasa.gov/FTP/swift/data/obs/2013_09//00049990004/uvot/
wget -q -nH --cut-dirs=5 -r -l0 -c -N -np -R 'index*' -erobots=off --retr-symlinks http://heasarc.gsfc.nasa.gov/FTP/swift/data/obs/2013_07//00049990003/uvot/
wget -q -nH --cut-dirs=5 -r -l0 -c -N -np -R 'index*' -erobots=off --retr-symlinks http://heasarc.gsfc.nasa.gov/FTP/swift/data/obs/2007_02//00030817002/uvot/

# I would create a text file to keep these in for the possible redownload of the data

touch SN2006gy_downloadcommands.txt
edit SN2006gy_downloadcommands.txt

#paste the files here, save and close.
# if it has a pre-explosion galaxy image (name is a galaxy or something # and occurs before the SN year) or an observation a year or so
# after the SN observations stopped
# 000*45812*010   000*targetid*obsnumber
# write down the target id or obsid, unique number  0004581201
#
source SN2006gy_downloadcommands.txt
#
# switch shells

tcsh

# this command creates a script of commands to run
# you supply the SN name and the template target number
# or some unique number that the templates have that the SN images don't
# if there isn't such a number, for example, if the template images continued
# with the same target id as the SN observations, then put the full observation id
# of the first template observation and then you can manually
# edit the *_appendcommands.txt or *_allcommands.txt files to change
# where the later observations are being appended to.

source $SNSCRIPTS/makecommands14.1.txt SN2006gy 49990

#This creates a text file of commands which will sum up the individual epochs
#and then append them all to a single file.
#A separate file is made for each filter for the SN observations and the template.
#You can then execute this file.
#This file of commands is made instead of just executing the commands
#so that you can edit it as needed.
#For example, maybe certain exposure show star streaks from the spacecraft drifting.
#Frames where the coordinate system is off can be fixed or excluded.
#Those extensions can be excluded from the sums and then the
# appendcommands.txt files reexecuted.  That is why it is separate from the sumcommands.txt.
#To run them all you can just do:

source SN2006gy_allcommands.txt

exit
# you have to exit the tcsh shell to use ds9 and xmgrace on my machine

ds9 SN2006gy_vv_sum.img &

# you are now trying to identify the supernova
# and create a region file with a 3 arcsecond radius circle at its position
# click on analysis --> image server --> sao dss --> retrieve
#
# frame --> match --> frame --> wcs
# frame --> blink
#
# if you see the SN click on it to make a circle
#
# if you don't see an obvious new source, get coordinates from
# http://www.cbat.eps.harvard.edu/lists/Supernovae.html
#
# double click on circle
#
# degree --> arcsec
# set to 3 --> apply
# region --> save       filename SN2006gy_3.reg
# should be in ds9 format, fk5 coordinate system
# make two new regions
#
# one should be a little bigger with similar galaxy light
# save as SN2006gy_bkg.reg
#
# the other is in a blank sky near the galaxy, can be large
# save as SN2006gy_bkgclear.reg
#

tcsh

#Now to run the SN photometry you execute the following script
#which is a wrapper for the uvotsource/uvotmaghist photometry codes.
#The fits file of photometry outputs is manipulated to subtract the galaxy count rates.

source $SNSCRIPTS/SNgalsub14.1.maghist.txt SN2006gy
exit

# This should give you a SNZZZZ_uvotB14.1.dat file which contains all the photometry.

No comments:

Post a Comment