Skip to content

Commit 2a63e7d

Browse files
authored
Merge pull request #128 from ojustino/poly-trace
Introducing polynomial tracing
2 parents 67b6b8b + 02231cf commit 2a63e7d

File tree

12 files changed

+537
-432
lines changed

12 files changed

+537
-432
lines changed

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44
New Features
55
^^^^^^^^^^^^
66

7+
- The new FitTrace class (see "API Changes" below) introduces the ability to
8+
take a polynomial trace of an image [#128]
9+
710
API Changes
811
^^^^^^^^^^^
912

13+
- Renamed KosmosTrace as FitTrace, a conglomerate class for traces that are fit
14+
to images instead of predetermined [#128]
15+
- The default number of bins for FitTrace is now its associated image's number
16+
of dispersion pixels instead of 20. Its default peak_method is now 'max'. [#128]
17+
1018
Bug Fixes
1119
^^^^^^^^^
1220

docs/extraction_quickstart.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ the remaining steps of the extraction process. Supported trace types include:
1616

1717
* `~specreduce.tracing.ArrayTrace`
1818
* `~specreduce.tracing.FlatTrace`
19-
* `~specreduce.tracing.KosmosTrace`
19+
* `~specreduce.tracing.FitTrace`
2020

2121

2222
Each of these trace classes takes the 2D spectral image as input, as well as additional information
@@ -47,17 +47,17 @@ or, equivalently::
4747
bg = specreduce.tracing.Background.one_sided(image, 15, separation=5, width=2)
4848

4949

50-
The background image can be accessed via `~specreduce.background.Background.bkg_image` and the
50+
The background image can be accessed via `~specreduce.background.Background.bkg_image` and the
5151
background-subtracted image via `~specreduce.background.Background.sub_image` (or ``image - bg``).
5252

53-
The background and trace steps can be done iteratively, to refine an automated trace using the
53+
The background and trace steps can be done iteratively, to refine an automated trace using the
5454
background-subtracted image as input.
5555

5656
Extraction
5757
----------
5858

5959
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
60+
background-extracted spectrum from the previous step) and a defined window, using one of the
6161
implemented methods:
6262

6363
* `~specreduce.extract.BoxcarExtract`

licenses/KOSMOS_LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# NOTE: This license applies only to code used in the KosmosTrace class.
1+
# NOTE: This license applies only to code used in part of the FitTrace class.
22

33
MIT License
44

notebook_sandbox/compare_extractions.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
{
2424
"cell_type": "code",
25-
"execution_count": 1,
25+
"execution_count": null,
2626
"id": "fc741345-720e-4189-9748-b3bb98d2d693",
2727
"metadata": {},
2828
"outputs": [],
@@ -94,8 +94,8 @@
9494
"metadata": {},
9595
"outputs": [],
9696
"source": [
97-
"index_arr = np.tile(np.arange(nrows), (ncols, 1))\n",
98-
"index_arr.T"
97+
"index_arr = np.broadcast_to(np.arange(nrows)[:, np.newaxis], (nrows, ncols))\n",
98+
"index_arr"
9999
]
100100
},
101101
{
@@ -105,7 +105,7 @@
105105
"metadata": {},
106106
"outputs": [],
107107
"source": [
108-
"img = col_model(index_arr.T) + noise"
108+
"img = col_model(index_arr) + noise"
109109
]
110110
},
111111
{
@@ -214,7 +214,7 @@
214214
"img_obj = CCDData(img, uncertainty=var_obj, mask=mask, unit=u.DN)\n",
215215
"\n",
216216
"hrn2 = HorneExtract(img_obj, trace)\n",
217-
"hrn2_result1d_whole = hrn()"
217+
"hrn2_result1d_whole = hrn2()"
218218
]
219219
},
220220
{
@@ -244,7 +244,7 @@
244244
"metadata": {},
245245
"source": [
246246
"## Compare results\n",
247-
"The whole-image extractions come out as expected, with the Horne-extracted 1D spectrum showing a noticeably better signal-to-noise ratio than its boxcar equivalent."
247+
"The whole-image extractions come out as expected, with the Horne-extracted 1D spectrum showing a noticeably better signal-to-noise ratio than its windowless boxcar equivalent."
248248
]
249249
},
250250
{

notebook_sandbox/horne_extract/optimal_extract_VLT.ipynb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
"# Optimal/Horne extraction exploration"
99
]
1010
},
11+
{
12+
"cell_type": "markdown",
13+
"id": "5b9dc060-5262-463c-ab9b-5790dcf3e9e7",
14+
"metadata": {},
15+
"source": [
16+
"<p style=\"font-size:125%; background-color:#ce1141;\"><b><i>Note:</i> This is an experimental notebook created for an older version of <tt>specreduce</tt>. To learn the package's current best practices, please visit our other notebooks.</b></p>"
17+
]
18+
},
1119
{
1220
"cell_type": "markdown",
1321
"id": "fc5ad51c-fc94-4dfc-8750-3e58b6224278",

notebook_sandbox/jwst_boxcar/boxcar_extraction.ipynb

Lines changed: 16 additions & 26 deletions
Large diffs are not rendered by default.

notebook_sandbox/jwst_boxcar/jwst_boxcar_algorithm.ipynb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
"# Spectral extraction tests (JDAT-1855)"
88
]
99
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"<p style=\"font-size:125%; background-color:#ce1141;\"><b><i>Note:</i> This is an experimental notebook created for an older version of <tt>specreduce</tt>. To learn the package's current best practices, please visit our other notebooks.</b></p>"
15+
]
16+
},
1017
{
1118
"cell_type": "markdown",
1219
"metadata": {},

notebook_sandbox/jwst_boxcar/tracing_options.ipynb

Lines changed: 0 additions & 334 deletions
This file was deleted.

notebook_sandbox/tracing_options.ipynb

Lines changed: 381 additions & 0 deletions
Large diffs are not rendered by default.

specreduce/background.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def two_sided(cls, image, trace_object, separation, **kwargs):
145145
146146
Example: ::
147147
148-
trace = KosmosTrace(image, guess=trace_pos)
148+
trace = FitTrace(image, guess=trace_pos)
149149
bg = Background.two_sided(image, trace, bkg_sep, width=bkg_width)
150150
151151
Parameters
@@ -178,7 +178,7 @@ def one_sided(cls, image, trace_object, separation, **kwargs):
178178
179179
Example: ::
180180
181-
trace = KosmosTrace(image, guess=trace_pos)
181+
trace = FitTrace(image, guess=trace_pos)
182182
bg = Background.one_sided(image, trace, bkg_sep, width=bkg_width)
183183
184184
Parameters

0 commit comments

Comments
 (0)