Pyspec - a python spectroscopy tool
This document lays out the basics of installing and using the Python tool pyspec (currently under testing and so is version 0, an example final plot can be found below). The installation steps are given for Ubuntu but all of the tools used here are standard python tools and can be install on a variety of different systems, given is the current webpage for each package.
Getting pyspec
The latest version of pyspec, along with some example data can be found [here] (it is a 1.4MB download).
To take this a bit further, I've not built this into the main package yet though I've put together another python script that allows you to perform flux calibrations - see [pyspec_flux] (it is a 10.7kB download). For this you need to have observed a standard star over the same wavelength range and to have the theoretical data (well the properly calibrated flux data and this can be found at [vizier] for most calibration stars. This tool works just like pyspec - you should run ./pyspec_flux.pyc and input your data tables (wavelength, flux).
Spectroscopy with pyspec a short manual
A short manual describing the functions of pyspec in more detail than on this page (though the below instructions gives you all you need to know) is available: pyspec_man.pdf.
Installing dependencies
Python (at least Python 2.5.2)
sudo apt-get install python
http://www.python.org/download/
You may also need to install Ipython:
http://ipython.scipy.org/moin/
Pyfits
sudo apt-get install python-pyfits
http://www.stsci.edu/resources/software_hardware/pyfits
AstroAsciiData
wget http://ecf.hq.eso.org/software/PYTHONtools/astroasciidata/source/asciidata-1.1.1.tar.gz
gunzip asciidata-1.1.1.tar.gz
tar -xvf asciidata-1.1.1.tar
cd asciidata-1.1.1
sudo python setup.py install
http://ecf.hq.eso.org/software/PYTHONtools/astroasciidata/
Scipy
sudo apt-get install python-scipy
http://www.scipy.org/Installing_SciPy/Linux
Matplotlib
http://matplotlib.sourceforge.net/
sudo apt-get install python-matplotlib
Python-tk
sudo apt-get install python-tk
http://wiki.python.org/moin/TkInter
DS9
DS9 is not required for running the software but is used for visualisation of the FITS file such that the correct calibration can be made.
http://hea-www.harvard.edu/RD/ds9/
wget http://hea-www.harvard.edu/saord/download/ds9/linux/ds9.linux.5.6.tar.gz
tar -zxf ds9.linux.5.6.tar.gz
sudo mv ds9 /usr/local/bin
sudo chmod +x /usr/local/bin/ds9
So you want a fit? Well there is a bit of preparation todo...
Firstly before you run the script you need to ensure that all of your files follow certain conventions:
Bias files should be named bias*.fit where the * represents any postive interger. The same is said for your dark*.fit files.
Your input reference lamp spectra/target observation can have any file name, but for consistancy it is suggested you have them named something.fit.
You should now open up your reference lamp fits file and using the calibration data (see: ) find the lines and record the results in a table ref.txt (you can use pico or any other text editor todo this). The table is just a table of pixel and wavelength values (see ref_example.txt for the structure). You also need to look at your dataset and find the correct row that you would like to extra and the number of rows over you wish to sum, for weakly exposed spectra you might want to make this large (however, for spectra with rotation structure, e.g. Saturn you will want todo this over a narrow range).
Running the program
Move to the directory you extracted pyspec to and simply type:
./pyspec.pyc
You will be asked if you want to apply a previous calibration. If you have already determined the calibration of a reference lamp and want to apply this to a secondary dataset, hit Y. This will then guide you through the steps to calibration a target (currently the software, if you hit N will only calibrate only target). If you choose N then you will go through the whole process of calibration, if is a fairly simple process.
Outputted data (if option N, and full calibration is undertaken):
cal_out.txt - a data table of pixel vs wavelenght for your final calibrated dataset, useful for reploting data / reading into fitting tools (you can read this data into IRAF or anything else really).
output.txt - a line of numbers, these represent the values determine of the median values of bias and the dark-bias, c and m from the linear regression. This is used if you choose not to repeat the whole process for another dataset.
fig_Ia.png - pixel / intensity plot for reference lamp.
fig_Ib.png - the wavlenght calibration regression, completed by python tool polyfit.
fig_Ic.png - the wavelength calibrated reference lamp.
fig_Id.png - the calibrated target dataset.
fig_out.png - the calibrated target dataset (if reapplying the calibrated dataset).
ALL OF THESE FILES WILL BE OVERWRITTEN BY REPEATING STAGES OF THE TASK - IF YOU WANT TO KEEP THEM COPY THEM TO A DIFFERENT NAME.
That's it really, its a pretty simple task...
Example Data
If you wish to test pyspec some example data taken with the University of Birmingham Observatory can be found in the tar file, the data is in the directory example_data - just move the data into the same directory as pyspec.pyc and you can use this data.
Source code: will be released once this is past basic debugging.
Comments are welcome, email me at: whoknowswhocares[at]krioma.net










