Skip to content

Commit e720e46

Browse files
authored
Merge pull request #446 from NASA-Planetary-Science/445-docs-add-example-color-of-reddened-source
Example in documentation showing color computation for a reddened source
2 parents 63627d1 + 46cecae commit e720e46

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

docs/sbpy/spectroscopy/index.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,41 @@ The following example reddens a solar spectrum:
140140
ylabel='Flux density ({})'.format(fluxd_unit))
141141
plt.tight_layout()
142142

143+
Conversion to Photometry
144+
------------------------
145+
146+
Magnitudes using specified filters of a reddened object, which can then be
147+
used to compute equivalent broadband colors for an object with the specified
148+
spectral gradient, can be computed using the ``bandpass`` function from the
149+
`~sbpy.photometry` module. The following example computes the LSST g-r
150+
color of an object with a spectral gradient of 18%/100 nm (normalized to 550 nm).
151+
152+
First, create a reddened source (e.g., a comet). Then, specify the bandpasses
153+
to be used for the desired color calculation (in this example, LSST g and r),
154+
and calculate the specified color of the comet, where the list of available
155+
bandpasses and their sources may be found in the `~sbpy.photometry.bandpass`
156+
documentation. Alternatively, any other filter bandpass can also be provided
157+
as a `~synphot.spectrum.SpectralElement` object and used instead:
158+
159+
.. doctest-requires:: synphot
160+
.. doctest-remote-data::
161+
162+
>>> import astropy.units as u
163+
>>> from sbpy.calib import Sun
164+
>>> from sbpy.spectroscopy import SpectralGradient
165+
>>> from sbpy.photometry import bandpass
166+
>>> import sbpy.units as sbu
167+
>>>
168+
>>> S = SpectralGradient(18 * u.percent / sbu.hundred_nm, wave0=550 * u.nm)
169+
>>> sun = Sun.from_builtin("calspec")
170+
>>> comet = sun.redden(S)
171+
>>>
172+
>>> bp_g = bandpass("LSST g")
173+
>>> bp_r = bandpass("LSST r")
174+
>>> _, r = comet.observe_bandpass(bp_r, unit=u.ABmag)
175+
>>> _, g = comet.observe_bandpass(bp_g, unit=u.ABmag)
176+
>>> print("g-r =", g - r)
177+
g-r = 0.7007308548908533 mag
143178

144179
Reference/API
145180
-------------

0 commit comments

Comments
 (0)