Python Spectroscopy Preface

2. Python Spectroscopy Preface#

This is a short note, originally written in 2016-2018. As of late 2023, the situation did not change much, unfortunately.

However, importantly, PypeIt appeared after this lecture note. If a professional spectroscopic data reduction is requited (for research), you may consult with PypeIt for your work, and/or make a whole new pipeline for your specific instrument.

In later notes, I will demonstrate how to do the spectroscopic data reduction using python. Since the concepts of the tasks, i.e., the procedures of what you should do, are clear, you must be able to do them in any language you can use.

2.1. General References#

Some useful materials to understand spectroscopic data reduction:

  • Wagner’s writing in 1992

    • As far as I know, this is the most comprehensive article about spectroscopic data reduction, including theoretical background and practical usage (using IRAF).

  • FOCAS cookbook

    • This is written specifically for FOCAS and is one of the available English manuals for that specific instrument. It gives you an idea of how to reduce data using IRAF.

    • Even though you are not using FOCAS, Sections 5, 6, and Appendix B will generally be useful. Especially Sections 5.5 (and 5.7) are very valuable.

  • Among the IRAF archive, the writing by Massey et al. in 1992 is THE official manual for doing spectroscopic data reduction in IRAF.

2.2. Available Packages#

As you can see, all the important materials are made for IRAF, not Python. I could only find a few informative packages, including PyDIS by Dr. James Davenport. There is currently an ongoing discussion about making a spectroscopy package in astropy called specutils.

But currently, there are no useful packages as of 2021 (situation is similar as of 2023 Fall). One of the most recent discussions about this issue among the Python users in Astronomy group was this, with no hope.

  • In our lecture note’s references/, you can find some materials related to spectroscopy.

  • The astropy-affiliated package specutils is under development now. It will be released in a “usable” form only in 2019. It’s useful only after you’ve obtained the 1-D spectrum from your data.

  • You may benchmark PypeIt

2.3. Remarks#

In short, there are currently no perfect python tools or packages to satisfactorily do the spectroscopic data reduction in python (to replace IRAF). Among them, PypeIt has the biggest potential, but still not in a satisfactory stage. So my basic philosophy in producing this material is:

  1. Make explicit codes step by step so that every process is visible.

    • This means I intentionally do not make packages for all the processes. Only simple code snippets will be shown here.

    • As I am not an expert in programming (and I believe a scientist sometimes should not think too much about these technical issues), the codes are never carefully optimized. But they work, at least.

  2. Make the code similar to IRAF.

    • This is basically because IRAF is still the de facto standard for spectroscopic data reduction. If I try to take some different approach than IRAF, it may require significant effort from my side (which is impossible due to my lack of ability), and I do believe that IRAF is very carefully designed.

In the following notes, I show my own code, which can be extremely slow and inefficient compared to optimized codes. I didn’t care much about technical details (faster calculation, etc.), basically due to my lack of ability plus time limits.