Debian Codegraph @

doc/source/bandpass.rst

raw
1 .. _pysynphot-bandpass:
2
3 ********
4 Bandpass
5 ********
6
7 A bandpass can be constructed by one of the following methods:
8
9 * Specifying a valid string of HST instrument mode keywords
10 (:ref:`pysynphot-obsmode-bandpass`)
11 * Using a pre-defined function (:ref:`pysynphot-box-bandpass`)
12 * :ref:`Loading from a FITS or ASCII table <pysynphot-bandpass-from-file>`
13 * :ref:`Using your own wavelength and throughput arrays <pysynphot-bandpass-arrays>`
14
15 It has various :ref:`photometric properties <pysynphot-properties>` and these
16 main components:
17
18 * ``name`` (Description of the bandpass; Also accessible via
19 :py:meth:`~object.__str__`)
20 * ``throughput``
21 * ``wave`` (a.k.a. ``waveset``)
22 * ``waveunits`` (see :ref:`pysynphot-wave-units`)
23
24 To evaluate its transmission at a given wavelength, use its
25 :meth:`~pysynphot.spectrum.SpectralElement.sample` or
26 :py:meth:`~object.__call__` method, as given in the following example.
27 Internally, evaluation uses :func:`numpy.interp`.
28
29 >>> bp = S.ObsBandpass('acs,wfc1,f555w')
30 >>> bp.sample(5000)
31 0.34331630723608403
32 >>> bp(5000)
33 0.34331630723608403
34
35
36 .. _pysynphot-obsmode-bandpass:
37
38 Observation Mode
39 ================
40
41 The observation mode (``obsmode``) parameter defines the passband, i.e., the
42 wavelength-dependent sensitivity curve of the photometer or
43 spectrophotometer. It is controlled by :ref:`pysynphot-refdata`.
44 It can also be used to specify
45 :ref:`color index <pysynphot-tutorial-color-index>`.
46
47 The ``obsmode`` is usually given as a string of keyword arguments
48 to the `~pysynphot.obsbandpass.ObsBandpass` class.
49 The list of keywords identify the light path through the telescope and the
50 instrument, or through a non-HST filter system.
51 For example, ``"wfc3,uvis1,f555w"`` creates a bandpass that is calculated by
52 taking the product of the individual throughputs of the Wide Field
53 Camera 3 (WFC3) UVIS Channel 1, the F555W filter, the detector
54 sensitivity, and the HST Optical Telescope Assembly (OTA). There are special
55 considerations for :ref:`pysynphot-ota` and :ref:`pysynphot-costar`.
56 Another example, ``"johnson,v"`` creates a Johnson *V* bandpass that does not
57 account for HST optics. A complete list of ``obsmode`` keywords can be found in
58 :ref:`Appendix B <pysynphot-appendixb>`.
59
60
61 Quick Example
62 -------------
63
64 Create a bandpass for HST/ACS instrument with its WFC1 detector and F555W
65 filter:
66
67 >>> bp_acs = S.ObsBandpass('acs,wfc1,f555w')
68
69 To see which throughput tables are being used, as set by
70 :ref:`pysynphot-refdata`:
71
72 >>> bp_acs.showfiles()
73 /my/local/dir/trds/comp/ota/hst_ota_007_syn.fits
74 /my/local/dir/trds/comp/acs/acs_wfc_im123_004_syn.fits
75 /my/local/dir/trds/comp/acs/acs_f555w_wfc_005_syn.fits
76 /my/local/dir/trds/comp/acs/acs_wfc_ebe_win12f_005_syn.fits
77 /my/local/dir/trds/comp/acs/acs_wfc_ccd1_mjd_021_syn.fits
78
79 Create a bandpass for Johnson *V*:
80
81 >>> bp_v = S.ObsBandpass('johnson,v')
82
83 Compare them in a plot:
84
85 >>> plt.plot(bp_acs.binset, bp_acs(bp_acs.binset), 'b',
86 ... bp_v.wave, bp_v.throughput, 'g--')
87 >>> plt.xlim(4000, 7000)
88 >>> plt.xlabel(bp_acs.waveunits)
89 >>> plt.ylabel('throughput')
90 >>> plt.legend([bp_acs.name, 'Johnson V'], loc='best')
91
92 .. image:: _static/acs_johnson_bandpass.png
93 :width: 600px
94 :alt: Bandpasses for ACS WFC1 F555W and Johnson V.
95
96
97 .. _pysynphot-command-range:
98
99 Pixel and Wavelength Ranges
100 ---------------------------
101
102 The :meth:`~pysynphot.obsbandpass.ObsModeBandpass.pixel_range` and
103 :meth:`~pysynphot.obsbandpass.ObsModeBandpass.wave_range` methods can be used to
104 calculate the pixel and wavelength ranges, respectively, spanned by the
105 observation mode given its ``binset``, if available. For example:
106
107 >>> bp = S.ObsBandpass('wfc3,ir,f105w')
108
109 To calculate the number of pixels covered from 8600.5 to 12400.5 Angstroms:
110
111 >>> bp.pixel_range([8600.5, 12400.5])
112 3800
113
114 To calculate starting and ending wavelengths in Angstroms covered by 3800 pixels
115 centered at 10500 Angstroms:
116
117 >>> bp.wave_range(10500.0, 3800)
118 (8600.5, 12400.5)
119
120
121 .. _pysynphot-command-therm:
122
123 Thermal Background
124 ------------------
125
126 For IR detectors (e.g., NICMOS and WFC3), thermal background can be calculated
127 using the :meth:`~pysynphot.obsbandpass.ObsModeBandpass.thermback` method.
128 The thermal component is defined by ``thermtable`` in :ref:`pysynphot-refdata`.
129 For non-IR detectors, calling this method would raise ``NotImplementedError``.
130 For example:
131
132 >>> bp = S.ObsBandpass('wfc3,ir,f105w')
133 >>> bp.thermback()
134 0.050852529496148512
135 >>> bp = S.ObsBandpass('acs,wfc1,f555w')
136 >>> bp.thermback()
137 NotImplementedError: No thermal support provided for acs,wfc1,f555w
138
139
140 .. _pysynphot-box-bandpass:
141
142 Box
143 ===
144
145 A box-shaped bandpass is a rectangular window centered on a given wavelength
146 with a given width, both in Angstroms. It is defined as:
147
148 .. math::
149
150 \mathrm{throughput} = \left \{
151 \begin{array}{ll}
152 1 & : x_0 - w/2 \geq x \geq x_0 + w/2 \\
153 0 & : \mathrm{else}
154 \end{array}
155 \right.
156
157 where
158
159 * :math:`x_{0}` is the central wavelength
160 * :math:`x` is the wavelength array
161 * :math:`w` is the width of the box
162
163 The example below creates and plots a box-shaped bandpass centered at
164 6000 Angstroms with a width of 100 Angstroms:
165
166 >>> bp = S.Box(6000, 100)
167 >>> plt.plot(bp.wave, bp.throughput)
168 >>> plt.ylim(0, 1.1)
169 >>> plt.axvline(6000, ls='--', color='k')
170 >>> plt.xlabel(bp.waveunits)
171 >>> plt.ylabel('throughput')
172 >>> plt.title(bp.name)
173
174 .. image:: _static/box_bandpass.png
175 :width: 600px
176 :alt: Box bandpass.
177
178
179 .. _pysynphot-bandpass-uniform:
180
181 Flat
182 ====
183
184 `~pysynphot.spectrum.UniformTransmission` generates a uniform (flat) bandpass
185 that has a constant throughput at any wavelength value.
186
187 The example below creates and samples a bandpass with a uniform transmission
188 value of 0.8:
189
190 >>> bp = S.UniformTransmission(0.8)
191 >>> bp.sample(5000)
192 0.8
193 >>> bp.sample(np.arange(1000, 10000))
194 array([ 0.8, 0.8, 0.8, ..., 0.8, 0.8, 0.8])
195
196
197 .. _pysynphot-bandpass-from-file:
198
199 From File
200 =========
201
202 A bandpass can also be defined using a FITS or ASCII table containing columns
203 of wavelength and throughput. See :ref:`pysynphot-io` for details on how to
204 create such tables.
205
206 The example below loads a bandpass from FITS table:
207
208 >>> filename = os.path.join(
209 ... os.environ['PYSYN_CDBS'], 'comp', 'acs', 'acs_wfc_ccd2_019_syn.fits')
210 >>> bp = S.FileBandpass(filename)
211 >>> bp.throughput
212 array([ 0.00000000e+00, 0.00000000e+00, 1.87380003e-27, ...,
213 4.14354995e-09, 0.00000000e+00, 0.00000000e+00])
214 >>> bp.sample(5100)
215 0.80144459009170532
216 >>> bp.sample(2100)
217 0.0
218
219 :ref:`pysynphot_tutorial_10` offers hints on how to load a bandpass from an ASCII table
220 of any format.
221
222
223 .. _pysynphot-bandpass-arrays:
224
225 From Arrays
226 ===========
227
228 To create a bandpass from arrays, use `~pysynphot.spectrum.ArraySpectralElement`
229 (also callable as ``pysynphot.ArrayBandpass``). Note in the example below that
230 the bandpass is explicitly tapered at both ends to avoid extrapolation;
231 Also, unlike source spectrum, its negative throughput value is not automatically
232 set to zero:
233
234 >>> w = np.array([999, 1000, 2000, 3000, 3001]) # Angstroms
235 >>> t = np.array([0, 0.1, -0.2, 0.3, 0])
236 >>> bp = S.ArrayBandpass(w, t, name='MyBandpass')
237 >>> bp.throughput
238 array([ 0. , 0.1, -0.2, 0.3, 0. ])
239 >>> bp.sample(2500)
240 0.049999999999999989
241 >>> bp.sample(4000)
242 0.0
243
244
245 .. _pysynphot-command-checko:
246
247 Overlap Checks
248 ==============
249
250 To check whether the wavelength range of other bandpass or spectra is defined
251 everywhere within the main bandpass, you can use the
252 :meth:`~pysynphot.spectrum.SpectralElement.check_overlap` method, which returns
253 ``"full"``, ``"partial"``, or ``"none"``. The example below checks whether
254 the main bandpass overlap with another bandpass of the same detector but with a
255 different filter, and with a box-shaped one:
256
257 >>> bp = S.ObsBandpass('wfc3,ir,f105w')
258 >>> other_bp = S.ObsBandpass('wfc3,ir,f110w')
259 >>> bp.check_overlap(other_bp)
260 'full'
261 >>> box_bp = S.Box(10000, 10000)
262 >>> bp.check_overlap(box_bp)
263 'partial'
264
265 To check if the lack of overlap is insignificant, you can use the
266 :meth:`~pysynphot.spectrum.SpectralElement.check_sig` method. The example
267 below shows that the partial overlap above is not a concern:
268
269 >>> bp.check_sig(box_bp)
270 True