Skip to content

Commit

Permalink
Mark required packages for new doctests blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mkelley committed Nov 12, 2024
1 parent aa896f1 commit adccab5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/sbpy/surfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ The model `~sbpy.surfaces.scattered.LambertianSurfaceScatteredSunlight` is used
Create an instance of the ``LambertianSurfaceScatteredSunlight`` model, and calculate the absorptance, emittance, and reflectance for :math:`(i, e, \phi) = (30^\circ, 60^\circ, 90^\circ)`::

>>> import astropy.units as u
>>> import matplotlib.pyplot as plt
>>> from sbpy.surfaces import LambertianSurfaceScatteredSunlight
>>>
>>> surface = LambertianSurfaceScatteredSunlight({"albedo": 0.1})
Expand Down Expand Up @@ -50,6 +49,8 @@ Radiance of scattered sunlight

``LambertianSurfaceScatteredSunlight`` is derived from the ``ScatteredSunlight`` class, which provides convenience methods for calculating the radiance of sunlight scattered off the surface::

.. doctest-requires:: synphot

>>> wave = 0.55 * u.um
>>> rh = 1 * u.au # heliocentric distance of the surface
>>> surface.scattered_sunlight(wave, rh, i, e, phi) # doctest: +FLOAT_CMP
Expand All @@ -63,6 +64,8 @@ Radiance from vectors

As an alternative to using :math:`(i, e, \phi)`, radiance may be calculated using vectors that define the normal direction, radial vector of the light source, and radial vector of the observer::

.. doctest-requires:: synphot

>>> # the following vectors are equivalent to (i, e, phi) = (30, 60, 90) deg
>>> n = [1, 0, 0]
>>> rs = [0.866, 0.5, 0] * u.au
Expand All @@ -83,6 +86,8 @@ Defining your own surface model is typically done by creating a new class based

Here, we define a new surface model with surface scattering proportional to :math:`\cos^2` based on the `~sbpy.surfaces.scattered.ScatteredSunlight` class::

.. doctest-requires:: synphot

>>> import numpy as np
>>> from sbpy.surfaces import Surface, ScatteredSunlight
>>>
Expand All @@ -106,6 +111,11 @@ Here, we define a new surface model with surface scattering proportional to :mat
>>> surface.scattered_sunlight(wave, rh, i, e, phi) # doctest: +FLOAT_CMP
<Quantity [35.22159375] W / (sr um m2)>

.. for test runs without synphot
.. testsetup::

>>> from sbpy.surfaces import Surface, ScatteredSunlight

However, if a scattering model will be re-used with other classes, e.g., for scattered light and thermal emission modeling, then the most flexible approach is to base the model on ``Surface`` and have derived classes combine the model with scattering or thermal emission classes::

>>> class Cos2Surface(Surface):
Expand Down

0 comments on commit adccab5

Please sign in to comment.