########################
Specreduce Documentation
########################

The `specreduce <https://specreduce.readthedocs.io/en/latest/index.html>`_ package
aims to provide a data reduction toolkit for optical
and infrared spectroscopy, on which applications such as pipeline processes for
specific instruments can be built. The scope of its functionality is limited to
basic spectroscopic reduction, currently encompassing the following tasks:

#. Determining the trace of a spectrum dispersed in a 2D image, either by setting a flat
   trace, providing a custom trace array, or fitting a spline, polynomial, or other model
   to the positions of the dispersed spectrum.
#. Generating a background based on a region on one or both sides of this trace, and making
   available the background image, 1D spectrum of the background, and the
   background-subtracted image.
#. Performing either a Horne (a.k.a. "optimal") or boxcar extraction on either the original
   or background-subtracted 2D spectrum, using the trace generated by the first task to
   generate a 1D spectrum.
#. Calculating a 1D wavelength solution from arc spectra that can be used to resample the
   science spectra to produce wavelength-calibrated spectra, or stored to be used by other tools.

Further details about these capabilities are detailed in the sections linked below.
Beyond these tasks, basic *image* processing steps (such as bias subtraction) are covered by
`ccdproc <https://ccdproc.readthedocs.io/en/latest/>`_
and other packages, data analysis by `specutils <https://specutils.readthedocs.io/en/latest/>`_,
and visualization by `matplotlib <https://matplotlib.org/>`_. A few
examples will be provided that feature ``specreduce`` in conjunction with these
complementary packages.

.. note::

    Specreduce is currently an incomplete work-in-progress and is liable to
    change. Please feel free to contribute code and suggestions through github.


.. _spectral-extraction:

*******************
Spectral Extraction
*******************

.. toctree::
    :maxdepth: 2

    extraction_quickstart.rst

***********
Calibration
***********

.. toctree::
    :maxdepth: 1

    wavelength_calibration/wavelength_calibration.rst
    extinction.rst
    specphot_standards.rst
    mask_treatment/mask_treatment.rst


*****
Index
*****

.. toctree::
    :maxdepth: 1

    api.rst

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`


****************
Development Docs
****************

.. toctree::
    :maxdepth: 1

    process/index
    terms

