| 1 |
Design notes for specman, the spectrum manipulation package |
| 2 |
----------------------------------------------------------- |
| 3 |
|
| 4 |
The fundamental object here is the SPECTRUM. A spectrum is a mapping |
| 5 |
between SPECTRAL COORDINATES (typically wavelengths, frequencies, energies, |
| 6 |
or similar) and the corresponding SPECTRAL INTENSITY. The spectral |
| 7 |
intensity gives a measure of how much energy is emitted or detected |
| 8 |
per unit spectral coordinate interval per unit area. |
| 9 |
|
| 10 |
Spectra come in two (or more) flavors: Analytic functions (such as black body |
| 11 |
functions, Gaussians, Lorentzians, power laws, etc) and Tables. Typically, |
| 12 |
the former are used to model spectra, and the latter are the result of an |
| 13 |
observation. The former type is continuous, and provides a method for |
| 14 |
calculating the spectral intensity for any value of the spectral coordinate |
| 15 |
using analytic functions, while the latter type is discrete, and so the |
| 16 |
spectral intensity is only available for a limited set of spectral coordinates. |
| 17 |
Converting from an analytic function to a table involves loss of information |
| 18 |
(since the capability for calculating the spectral intensity for spectral |
| 19 |
coordinates other than those in the table set is lost), while converting |
| 20 |
from a table to an analytic function (for example, by interpolating) involves |
| 21 |
guessing what the spectral intensity is at spectral coordinates other than |
| 22 |
those provided. This loss or distortion of information means that conversion |
| 23 |
of spectra from one form to another should be done only when absolutely |
| 24 |
necessary. |
| 25 |
|
| 26 |
A spectrum has the following properties: |
| 27 |
|
| 28 |
1) It knows how to supply an array of spectral coordinates that is |
| 29 |
appropriate for itself. For example, a tabular spectrum knows how to |
| 30 |
return the spectral coordinates it is specified at, and a Gaussian knows |
| 31 |
that it needs to supply a wavelength set centered around its center and |
| 32 |
with enough resolution to adequately represent its shape. |
| 33 |
2) It knows how to calculate the spectral intensity given an input array |
| 34 |
of spectral coordinates that is unrelated to the array from 1) |
| 35 |
3) Its spectral coordinates and spectral intensity both have units that |
| 36 |
default to the units that the spectrum was originally supplied with |
| 37 |
4) It has an internal representation that is calculated when the spectrum |
| 38 |
object is instantiated. This representation is (angstroms, photlam). |
| 39 |
5) It can convert its internal representation to any other set of units |
| 40 |
|
| 41 |
A related object is the SPECTRAL ELEMENT. This is used to represent |
| 42 |
elements of an optical system, such as mirrors, lenses, filters and |
| 43 |
detectors. SpectralElements represent a mapping between spectral coordinates |
| 44 |
and a dimensionless ratio of output to input intensity. They share some of |
| 45 |
the characteristics of Spectrum objects, and can be discrete (like most of |
| 46 |
the throughput tables in the synphot system) or analytic (e.g. constant |
| 47 |
transmission, gaussian, tophat,...). |
| 48 |
|
| 49 |
SpectralElements have the following properties: |
| 50 |
|
| 51 |
1) They know how to supply a set of spectral coordinates that describe the |
| 52 |
domain over which they can be calculated |
| 53 |
2) They can calculate the dimensionless transmission given an array of |
| 54 |
spectral coordinates that is unrelated to the set from 1) |
| 55 |
3) They remember the units of the spectral coordinates they were instantiated |
| 56 |
with |
| 57 |
4) They have an internal representation that is the same for all |
| 58 |
SpectralElements - (angstroms, unitless) |
| 59 |
5) They can convert from the internal representation to their initial |
| 60 |
representation |
| 61 |
|
| 62 |
So SpectralElements and Spectrum objects have very similar properties, |
| 63 |
which allows much of the same machinery to be used without caring whether |
| 64 |
the object is a Spectrum or a SpectralElement. |
| 65 |
|
| 66 |
It is in combining SpectralElements and Spectrum objects that the differences |
| 67 |
emerge. Combining such objects produces a Composite object subject to the |
| 68 |
following rules: |
| 69 |
|
| 70 |
1) A Spectrum may be added to another Spectrum returning a CompositeSpectrum |
| 71 |
object |
| 72 |
2) A SpectralElement may be multiplied by another SpectralElement resulting |
| 73 |
in a CompositeSpectralElement object |
| 74 |
3) A Spectrum may be multiplied by SpectralElement object resulting in a |
| 75 |
CompositeSpectrum object |
| 76 |
|
| 77 |
In each case, the Spectrum or SpectralElement that is combined may be |
| 78 |
Composite or simple. |
| 79 |
|
| 80 |
The Composite objects are references to the objects that it is composed of. |
| 81 |
The actual calculation of the sum or product is not performed until the |
| 82 |
__call__ method of the Composite object is called. The __call__ method takes |
| 83 |
as input the array of wavelengths at which the spectral intensity of the |
| 84 |
Composite object is to be calculated. Since this wavelength array is |
| 85 |
specified, the Composite object returns a TabularSpectrum (or |
| 86 |
TabularSpectralElement), i.e. specified at a fixed number of wavelength |
| 87 |
points. The wavelength set is calculated by forming the union of wavelengths |
| 88 |
from each of the component Spectrum or SpectralElement objects. |
| 89 |
|
| 90 |
So processes involved in using the spectrum package are: |
| 91 |
|
| 92 |
1) Instantiation |
| 93 |
|
| 94 |
- A Spectrum or SpectralElement object is instantiated either from an input |
| 95 |
FITS table or an analytic function |
| 96 |
|
| 97 |
- The original units of the object are kept as attributes. In the case of |
| 98 |
a FITS table, the original units are read from the TUNIT1 (spectral coordinate) |
| 99 |
and TUNIT2 (spectral intensity/throughput) FITS header parameters |
| 100 |
|
| 101 |
- The units of an analytic function are specified as parameters in the |
| 102 |
constructor. Technically, most analytic functions change their analytic |
| 103 |
form when converted from one representation to another. For example, a |
| 104 |
Gaussian in (frequency, F-nu) space is not a Gaussian in (wavelength, |
| 105 |
F-lambda) space. We will deal with this by just calculating the equivalent |
| 106 |
parameters in (angstroms, photlam) space and treating the analytic function |
| 107 |
as a Gaussian in (angstroms, photlam) space. |
| 108 |
|
| 109 |
- If the Spectrum or SpectralElement is instantiated from a FITS table, |
| 110 |
it is converted to the internal representation of (angstroms, photlam). |
| 111 |
|
| 112 |
- If the Spectrum or SpectralElement is instantiated from an analytic |
| 113 |
function, the corresponding parameters of the analytic function are calculated |
| 114 |
in (angstroms, photlam) space. |
| 115 |
|
| 116 |
|
| 117 |
2) Doing stuff |
| 118 |
|
| 119 |
- Spectrum and/or SpectralElement objects are combined using the rules for |
| 120 |
composition described above. |
| 121 |
|
| 122 |
- Methods are defined for performing common tasks on the |
| 123 |
Spectrum/SpectralElement objects, for example, integrating over the wavelength |
| 124 |
set of interest. |
| 125 |
|
| 126 |
3) Getting at the answers |
| 127 |
|
| 128 |
- A Composite object is just a reference to the tree of component objects. No |
| 129 |
actual calculations have been done |
| 130 |
|
| 131 |
- The object is calculated at an array of wavelengths by giving the wavelength |
| 132 |
array as an argument to the object (using the internal __call__ method). A |
| 133 |
Tabular object is returned, in the internal representation and with the |
| 134 |
units of the dominant component. |
| 135 |
|
| 136 |
- The arrays of (spectral coordinate, spectral intensity) are retrieved by |
| 137 |
calling methods to convert from the internal representation to the units of |
| 138 |
the object. 1-d numarrays are returned. |