|
1 | | -=================== |
2 | | -Spectrum Fitting |
3 | | -=================== |
| 1 | +===================== |
| 2 | +Line/Spectrum Fitting |
| 3 | +===================== |
4 | 4 |
|
5 | | -Specutils has the ability to fit the flux of a `~specutils.Spectrum1D` object. |
6 | | -The fit routine takes the `~specutils.Spectrum1D` object and a list of |
7 | | -`~astropy.modeling.Model` that have initial guesses for each of the parameters. |
| 5 | +One of the primary tasks in spectroscopic analysis is fitting models of spectra. |
| 6 | +This concept is often applied mainly to line-fitting, but the same general |
| 7 | +approach applies to continuum fitting or even full-spectrum fitting. |
| 8 | +``specutils`` provides conveniences that aim to leverage the general fitting |
| 9 | +framework of `astropy.modeling` to spectral-specific tasks. |
8 | 10 |
|
9 | | -The internal functionality uses `~astropy.modeling.fitting` routines. The flux |
10 | | -is extracted from the `~specutils.Spectrum1D` and is passed along with a |
11 | | -compound model created from the model initial guesses. |
| 11 | +At a high level, this fitting takes the `~specutils.Spectrum1D` object and a |
| 12 | +list of `~astropy.modeling.Model` objects that have initial guesses for each of |
| 13 | +the parameters. these are used to create a compound model created from the model |
| 14 | +initial guesses. This model is then actually fit to the spectrum's ``flux``, |
| 15 | +yielding a single composite model result (which can be split back into its |
| 16 | +components if desired). |
12 | 17 |
|
13 | | -Model Fitting |
14 | | -------------- |
| 18 | +Model (Line) Fitting |
| 19 | +-------------------- |
15 | 20 |
|
16 | | -The first step is to create a set of models with initial guesses as the parameters. Even |
17 | | -better is to include a set of bounds for each parameter, but that is optional. (A method |
18 | | -will be provided in a future PR, but user defined initial guesses may be used with the |
19 | | -current code). |
| 21 | +The generic model fitting machinery is well-suited to fitting spectral lines. |
| 22 | +The first step is to create a set of models with initial guesses as the |
| 23 | +parameters. To acheive better fits it may be wise to include a set of bounds for |
| 24 | +each parameter, but that is optional. |
| 25 | + |
| 26 | +.. note:: |
| 27 | + A method to make plausible initial guesses will be provided in a future |
| 28 | + version, but user defined initial guesses are required at present. |
| 29 | + |
| 30 | +Below are a series of examples of this sort of fitting. |
20 | 31 |
|
21 | 32 |
|
22 | 33 | Simple Example |
23 | 34 | ^^^^^^^^^^^^^^ |
24 | 35 |
|
25 | | -Below is a simple example to demonstrate how to use the `~specutils.fitting.fit_lines` method |
26 | | -to fit a spectrum to an Astropy model initial guess. |
| 36 | +Below is a simple example to demonstrate how to use the |
| 37 | +`~specutils.fitting.fit_lines` method to fit a spectrum to an Astropy model |
| 38 | +initial guess. |
27 | 39 |
|
28 | 40 | .. plot:: |
29 | 41 | :include-source: |
@@ -429,6 +441,11 @@ all the data *except* between ``5.2*u.um`` and ``5.8*u.um``. |
429 | 441 | Continuum Fitting |
430 | 442 | ----------------- |
431 | 443 |
|
| 444 | +While the line-fitting machinery can be used to fit continuua at the same time |
| 445 | +as models, often it is convenient to subtract or normalize a spectrum by its |
| 446 | +continuum before other processing is done. ``specutils`` provides some |
| 447 | +convenience functions to perform exactly this task. An example is shown below. |
| 448 | + |
432 | 449 | .. plot:: |
433 | 450 | :include-source: |
434 | 451 | :align: center |
|
0 commit comments