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