Skip to content

Commit 8461d79

Browse files
committed
Partial updates for new method names.
1 parent 15ef081 commit 8461d79

File tree

4 files changed

+65
-76
lines changed

4 files changed

+65
-76
lines changed

docs/sbpy/surfaces.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Surfaces Module (`sbpy.surfaces`)
22
=================================
33

4+
.. admonition:: warning
5+
6+
The surface module is being made available on a preview basis. The API is
7+
subject to change. Feedback on the approach used is welcome.
8+
49
The ``surfaces`` module describes the interaction of electromagnetic radiation with surfaces. Sbpy uses the :math:`(i, e, \phi)` model (angle of incidence, angle of emittance, and phase angle) to describe how light scatters and emits light. It has a flexible system that can incorporate any surface scattering model that can be described with these three angles. A few built-in surface models are provided.
510

611
.. figure:: ../static/scattering-vectors.svg

sbpy/surfaces/lambertian.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,45 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22

3+
import numpy as np
34
import astropy.units as u
45

56
from .surface import Surface
7+
from ..units.typing import SpectralFluxDensityQuantity
68

79

810
class LambertianSurface(Surface):
911
"""Abstract base class for Lambertian surfaces."""
1012

1113
@u.quantity_input
12-
def absorptance(self, i: u.physical.angle) -> u.Quantity:
13-
# use self._min_zero_cos(i) which ensures cos(>= 90 deg) = 0
14+
def absorption(
15+
self,
16+
F_i: SpectralFluxDensityQuantity,
17+
i: u.physical.angle,
18+
) -> u.Quantity:
19+
# use self._min_zero_cos(i) to ensure cos(>= 90 deg) = 0
1420
cos_i = self._min_zero_cos(i)
15-
return (1 - self.phys["albedo"]) * cos_i
21+
return F_i * (1 - self.phys["albedo"]) * cos_i
1622

1723
@u.quantity_input
18-
def emittance(self, e: u.physical.angle, phi: u.physical.angle) -> u.Quantity:
19-
# use self._min_zero_cos(e) which ensures cos(>= 90 deg) = 0
20-
return self._min_zero_cos(e)
24+
def emission(
25+
self,
26+
X_e: SpectralFluxDensityQuantity,
27+
e: u.physical.angle,
28+
phi: u.physical.angle,
29+
) -> u.Quantity:
30+
# use self._min_zero_cos(e) to ensure cos(>= 90 deg) = 0
31+
cos_e = self._min_zero_cos(e)
32+
return X_e * cos_e / np.pi / u.sr
2133

2234
@u.quantity_input
2335
def reflectance(
24-
self, i: u.physical.angle, e: u.physical.angle, phi: u.physical.angle
36+
self,
37+
F_i: SpectralFluxDensityQuantity,
38+
i: u.physical.angle,
39+
e: u.physical.angle,
40+
phi: u.physical.angle,
2541
) -> u.Quantity:
26-
# use self._min_zero_cos(e) which ensures cos(>= 90 deg) = 0
42+
# use self._min_zero_cos(theta) to ensure cos(>= 90 deg) = 0
2743
cos_i = self._min_zero_cos(i)
28-
return self.phys["albedo"] * cos_i * self.emittance(e, phi)
44+
cos_e = self._min_zero_cos(e)
45+
return F_i * self.phys["albedo"] * cos_i * cos_e / np.pi

sbpy/surfaces/scattered.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,7 @@
1010
from ..units.typing import SpectralQuantity, SpectralFluxDensityQuantity, UnitLike
1111

1212

13-
class ScatteredLight(Surface):
14-
"""Abstract base class to observe light scattered by a surface."""
15-
16-
@u.quantity_input
17-
def radiance(
18-
self,
19-
F_i: SpectralFluxDensityQuantity,
20-
i: u.physical.angle,
21-
e: u.physical.angle,
22-
phi: u.physical.angle,
23-
) -> u.Quantity:
24-
"""Observed light reflected from a surface."""
25-
return F_i * self.reflectance(i, e, phi) / u.sr
26-
27-
radiance.__doc__ += Surface.radiance.__doc__[
28-
Surface.radiance.__doc__.index("\n") : # noqa: E203
29-
]
30-
31-
32-
class ScatteredSunlight(ScatteredLight):
13+
class ScatteredSunlight(Surface):
3314
"""Abstract base class to observe sunlight scattered by a surface."""
3415

3516
@u.quantity_input
@@ -82,7 +63,7 @@ def scattered_sunlight(
8263
F_i = sun.observe(wave_freq, unit=flux_density_unit)
8364

8465
F_i /= rh.to_value("au") ** 2
85-
return self.radiance(F_i, i, e, phi).to(unit)
66+
return self.reflectance(F_i, i, e, phi).to(unit)
8667

8768
@u.quantity_input
8869
def scattered_sunlight_from_vectors(

sbpy/surfaces/surface.py

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -39,47 +39,63 @@ def _min_zero_cos(a: u.physical.angle) -> u.Quantity:
3939
return np.maximum(x, 0)
4040

4141
@abstractmethod
42-
def absorptance(self, i: u.physical.angle) -> u.Quantity:
43-
r"""Absorption of incident light.
42+
def absorption(
43+
self,
44+
F_i: SpectralFluxDensityQuantity,
45+
i: u.physical.angle,
46+
) -> u.Quantity:
47+
r"""Absorption of directional, incident light.
4448
4549
The surface is illuminated by incident flux density, :math:`F_i`, at an
4650
angle of :math:`i`, measured from the surface normal direction.
4751
4852
4953
Parameters
5054
----------
55+
F_i : `astropy.units.Quantity`
56+
Incident light (spectral flux density / spectral irradiance).
57+
5158
i : `~astropy.units.Quantity`
5259
Angle from normal of incident light.
5360
5461
5562
Returns
5663
-------
57-
a : `~astropy.units.Quantity`
58-
Surface absorptance.
64+
F_a : `~astropy.units.Quantity`
65+
Absorbed spectral flux density.
5966
6067
"""
6168

6269
@abstractmethod
63-
def emittance(self, e: u.physical.angle, phi: u.physical.angle) -> u.Quantity:
64-
r"""Emission of light.
70+
def emission(
71+
self,
72+
X_e: SpectralFluxDensityQuantity,
73+
e: u.physical.angle,
74+
phi: u.physical.angle,
75+
) -> u.Quantity:
76+
r"""Emission of light from a surface, as seen by a distant observer.
6577
6678
The surface is observed at an angle of :math:`e`, measured from the
6779
surface normal direction, and at a solar phase angle of :math:`phi`.
6880
6981
7082
Parameters
7183
----------
84+
X_e : `astropy.units.Quantity`
85+
Emitted spectral radiance.
86+
7287
e : `~astropy.units.Quantity`
73-
Angle from normal of emitted light.
88+
Observed angle from normal.
7489
7590
phi : `~astropy.units.Quantity`
7691
Source-target-observer (phase) angle.
7792
7893
7994
Returns
8095
-------
81-
e : `~astropy.units.Quantity`
82-
Surface emittance.
96+
F_e : `~astropy.units.Quantity`
97+
Spectral flux density / spectral irradiance received by the
98+
observer.
8399
84100
"""
85101

@@ -96,36 +112,6 @@ def reflectance(
96112
emitted light are assumed to be collimated.
97113
98114
99-
Parameters
100-
----------
101-
i : `~astropy.units.Quantity`
102-
Angle from normal of incident light.
103-
104-
e : `~astropy.units.Quantity`
105-
Angle from normal of emitted light.
106-
107-
phi : `~astropy.units.Quantity`
108-
Source-target-observer (phase) angle.
109-
110-
111-
Returns
112-
-------
113-
r : `~astropy.units.Quantity`
114-
Surface reflectance.
115-
116-
"""
117-
118-
@abstractmethod
119-
def radiance(
120-
self,
121-
F_i: SpectralFluxDensityQuantity,
122-
i: u.physical.angle,
123-
e: u.physical.angle,
124-
phi: u.physical.angle,
125-
) -> u.Quantity:
126-
"""Observed radiance from a surface.
127-
128-
129115
Parameters
130116
----------
131117
F_i : `astropy.units.Quantity`
@@ -143,8 +129,8 @@ def radiance(
143129
144130
Returns
145131
-------
146-
radiance : `~astropy.units.Quantity`
147-
Observed radiance.
132+
F_r : `~astropy.units.Quantity`
133+
Spectral flux density / spectral irradiance received by the observer.
148134
149135
"""
150136

@@ -165,14 +151,14 @@ def _vectors_to_angles(
165151
return i, e, phi
166152

167153
@u.quantity_input
168-
def radiance_from_vectors(
154+
def reflectance_from_vectors(
169155
self,
170156
F_i: SpectralFluxDensityQuantity,
171157
n: np.ndarray,
172158
rs: u.physical.length,
173159
ro: np.ndarray,
174160
) -> u.Quantity:
175-
"""Observed radiance from a surface with geometry defined by vectors.
161+
"""Vector based alternative to reflectance().
176162
177163
Input vectors do not need to be normalized.
178164
@@ -194,9 +180,9 @@ def radiance_from_vectors(
194180
195181
Returns
196182
-------
197-
radiance : `~astropy.units.Quantity`
198-
Observed radiance.
183+
reflectance : `~astropy.units.Quantity`
184+
Reflectance.
199185
200186
"""
201187

202-
return self.radiance(F_i, *self._vectors_to_angles(n, rs, ro))
188+
return self.reflectance(F_i, *self._vectors_to_angles(n, rs, ro))

0 commit comments

Comments
 (0)