This package assumes you, the user, have some apVisit spectra from APOGEE and would like to turn them into text files that are continuum normalized and free of "spikey" telluric artifacts.
- Jo Bovy's apogee python module
- The PyAstronomy python module
- numpy
- matplotlib
- astropy
First, clone (or download and unzip) this package.
At present, the best way to run the two main scripts in this package are from the command line, as described below.
You may also navigate to the apVisitproc directory and run
python setup.py install
. This should allow you toimport apvisitproc
within python, but this is not particularly useful at present.
apVisit2input.py takes a data directory datadir
and a KIC (targetID).
It looks for a text file named datadir/KIC/KICVisitinfo.txt
which you must
create for your target.
To create this file, use the interface at https://dr13.sdss.org/infrared/spectrum/view/visits to retrieve a list of apVisit spectra. Save the CSV as the KICVisitinfo.txt file described above.
For example, if your target's KIC is 9246715 and APOGEE ID is 2M20034832+4536148:
- Search for the APOGEE ID = 2M20034832+4536148 using the web form
- Scroll down and select the "Visits" tab
- Click the button to download the Table (csv) of the visit metadata
- Rename/move this file to
datadir/9246715/9246715Visitinfo.txt
- Then, run apVisit2input like this
$ python apVisit2input.py -d datadir -k 9246715
The output will show the result of the continuum normalization for each visit spectrum. Once this is complete, you will have a new set of text file spectra. The full path to each one is printed to the screen, along with each visit's time of observation in days (HJD) and barycentric velocity in km/s (BCV).
despike.py takes either the text files generated by apVisit2input (preferred) or a set
of regular apVisit FITS files (in case you downloaded them individually yourself
and did not use apVisit2input). You must tell the program which files to despike
by creating a text file referred to as infilelist
that lives at datapath
.
(Note that following the example convention above, datapath
= datadir/KIC/
.)
For example, if you have just two spectra in datapath
, create a text file
called infilelist.txt
in the same directory which contains two lines
nameofspectrum1.txt
nameofspectrum2.txt
Do not include the full paths to the spectra in infilelist.txt
, just their filenames.
Note: if you are using apVisit FITS files that have not been retrieved via apVisit2input, the visit spectra may have names like, e.g.,
nameofspectrum1.fits
. This approach is not recommended because apVisit2input does continuum normalization and despike may not work well on un-normalized spectra.
Then, run despike like this
$ python despike.py -d datapath -i infilelist.txt
The output is a series of plots showing what the despike routine is doing.
Close each plot to let the program proceed. When it is finished, you will have
a new set of text file spectra in datapath
that end in _despiked.txt
.