Skip to content

Commit f6a834f

Browse files
authored
Merge pull request #142 from kecnry/docs-quickstart
basic quickstart examples for spectral extraction
2 parents 78e68b7 + 478c99c commit f6a834f

File tree

3 files changed

+138
-26
lines changed

3 files changed

+138
-26
lines changed

docs/api.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.. _api_index:
2+
3+
API Index
4+
=========
5+
6+
.. automodapi:: specreduce
7+
:no-inheritance-diagram:
8+
9+
.. automodapi:: specreduce.core
10+
:no-inheritance-diagram:
11+
12+
.. automodapi:: specreduce.tracing
13+
:no-inheritance-diagram:
14+
15+
.. automodapi:: specreduce.background
16+
:no-inheritance-diagram:
17+
18+
.. automodapi:: specreduce.extract
19+
:no-inheritance-diagram:
20+
21+
.. automodapi:: specreduce.calibration_data
22+
:no-inheritance-diagram:
23+
:include-all-objects:

docs/extraction_quickstart.rst

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
.. _extraction_quickstart:
2+
3+
Spectral Extraction Quick Start
4+
===============================
5+
6+
Specreduce provides flexible functionality for extracting a 1D spectrum from a 2D spectral image,
7+
including steps for determining the trace of a spectrum, background subtraction, and extraction.
8+
9+
10+
Tracing
11+
-------
12+
13+
The `specreduce.tracing` module defines the trace of a spectrum on the 2D image. These
14+
traces can either be determined semi-automatically or manually, and are provided as the inputs for
15+
the remaining steps of the extraction process. Supported trace types include:
16+
17+
* `~specreduce.tracing.ArrayTrace`
18+
* `~specreduce.tracing.FlatTrace`
19+
* `~specreduce.tracing.KosmosTrace`
20+
21+
22+
Each of these trace classes takes the 2D spectral image as input, as well as additional information
23+
needed to define or determine the trace (see the API docs above for required parameters for each
24+
of the available trace classes)::
25+
26+
trace = specreduce.tracing.FlatTrace(image, 15)
27+
28+
29+
Background
30+
----------
31+
32+
The `specreduce.background` module generates and subtracts a background image from
33+
the input 2D spectral image. The `~specreduce.background.Background` object is defined by one
34+
or more windows, and can be generated with:
35+
36+
* `~specreduce.background.Background`
37+
* `Background.one_sided <specreduce.background.Background.one_sided>`
38+
* `Background.two_sided <specreduce.background.Background.two_sided>`
39+
40+
The center of the window can either be passed as a float/integer or as a trace::
41+
42+
bg = specreduce.tracing.Background.one_sided(image, trace, separation=5, width=2)
43+
44+
45+
or, equivalently::
46+
47+
bg = specreduce.tracing.Background.one_sided(image, 15, separation=5, width=2)
48+
49+
50+
The background image can be accessed via `~specreduce.background.Background.bkg_image` and the
51+
background-subtracted image via `~specreduce.background.Background.sub_image` (or ``image - bg``).
52+
53+
The background and trace steps can be done iteratively, to refine an automated trace using the
54+
background-subtracted image as input.
55+
56+
Extraction
57+
----------
58+
59+
The `specreduce.extract` module extracts a 1D spectrum from an input 2D spectrum (likely a
60+
background-extracted spectrum from the previous step) and a defined window, using one of the
61+
implemented methods:
62+
63+
* `~specreduce.extract.BoxcarExtract`
64+
* `~specreduce.extract.HorneExtract`
65+
66+
Each of these takes the input image and trace as inputs (see the API above for other required
67+
and optional parameters)::
68+
69+
extract = specreduce.extract.BoxcarExtract(image-bg, trace, width=3)
70+
spectrum = extract.spectrum
71+
72+
The returned ``extract`` object contains all the set options. The extracted 1D spectrum can be
73+
accessed via the ``spectrum`` property or by calling the ``extract`` object (which also allows
74+
temporarily overriding any values)::
75+
76+
spectrum2 = extract(width=6)
77+
78+
Example Workflow
79+
----------------
80+
81+
This will produce a 1D spectrum, with flux in units of the 2D spectrum. The wavelength units will
82+
be pixels. Wavelength and flux calibration steps are not included here.
83+
84+
Putting all these steps together, a simple extraction process might look something like::
85+
86+
from specreduce.trace import FlatTrace
87+
from specreduce.background import Background
88+
from specreduce.extract import BoxcarExtract
89+
90+
trace = FlatTrace(image, 15)
91+
bg = Background.two_sided(image, trace, separation=5, width=2)
92+
extract = BoxcarExtract(image-bg, trace, width=3)
93+
spectrum = extract.spectrum

docs/index.rst

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
########################
2-
Specreduce documentation
2+
Specreduce Documentation
33
########################
44

55
The `specreduce <https://specreduce.readthedocs.io/en/latest/index.html>`_ package aims to provide a data reduction toolkit for optical
@@ -17,16 +17,16 @@ complementary packages.
1717
change. Please feel free to contribute code and suggestions through github.
1818

1919

20-
.. _DR-process:
20+
.. _spectral-extraction:
2121

22-
**********************
23-
Data reduction process
24-
**********************
22+
*******************
23+
Spectral Extraction
24+
*******************
2525

2626
.. toctree::
27-
:maxdepth: 1
27+
:maxdepth: 2
2828

29-
process/index
29+
extraction_quickstart.rst
3030

3131
***********
3232
Calibration
@@ -38,30 +38,26 @@ Calibration
3838
extinction.rst
3939
specphot_standards.rst
4040

41-
*************
42-
Reference/API
43-
*************
44-
45-
.. automodapi:: specreduce.core
46-
:no-inheritance-diagram:
47-
48-
.. automodapi:: specreduce.tracing
49-
:no-inheritance-diagram:
50-
51-
.. automodapi:: specreduce.background
52-
:no-inheritance-diagram:
53-
54-
.. automodapi:: specreduce.extract
55-
:no-inheritance-diagram:
56-
57-
.. automodapi:: specreduce.calibration_data
58-
:no-inheritance-diagram:
59-
:include-all-objects:
6041

6142
*****
6243
Index
6344
*****
6445

46+
.. toctree::
47+
:maxdepth: 1
48+
49+
api.rst
50+
6551
* :ref:`genindex`
6652
* :ref:`modindex`
6753
* :ref:`search`
54+
55+
56+
****************
57+
Development Docs
58+
****************
59+
60+
.. toctree::
61+
:maxdepth: 1
62+
63+
process/index

0 commit comments

Comments
 (0)