Skip to content

Commit 8950548

Browse files
authored
Merge pull request #374 from mkelley/fix-doc-indentation-202306
Fix indentation on documentation directives.
2 parents 7647830 + 94a8aa5 commit 8950548

File tree

4 files changed

+269
-269
lines changed

4 files changed

+269
-269
lines changed

docs/development/design-principles.rst

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Epochs must be Time objects
1919
---------------------------
2020

2121
* Any kind of epoch or point in time must be of type `~astropy.time.Time`; time scales must be properly set and propagated through all functions.
22-
22+
2323

2424
Use sbpy ``DataClass`` objects
2525
------------------------------
@@ -30,49 +30,49 @@ Use sbpy ``DataClass`` objects
3030

3131
* The classes enable easy parameter passing from online sources. Compare the following:
3232

33-
.. code-block:: python
34-
35-
eph = Ephem.from_horizons('2P')
36-
# rh, delta required, phase angle is optional:
37-
Afrho(wave, fluxd, aper, eph['rh'], eph['delta'], phase=eph['phase'])
38-
# more to the point:
39-
Afrho(wave, fluxd, aper, eph)
33+
.. code-block:: python
4034
41-
Carefully document which fields are used by your function or method.
35+
eph = Ephem.from_horizons('2P')
36+
# rh, delta required, phase angle is optional:
37+
Afrho(wave, fluxd, aper, eph['rh'], eph['delta'], phase=eph['phase'])
38+
# more to the point:
39+
Afrho(wave, fluxd, aper, eph)
40+
41+
Carefully document which fields are used by your function or method.
4242

4343
* Dictionary-like objects may be allowed for user input, but should be internally converted to a ``DataClass`` object with the `~sbpy.data.dataclass_input` decorator:
4444

45-
.. code-block:: python
46-
47-
@dataclass_input(eph=Ephem)
48-
def H11(eph):
49-
...
45+
.. code-block:: python
5046
51-
The same, but using function annotations:
52-
53-
.. code-block:: python
54-
55-
@dataclass_input
56-
def H11(eph: Ephem):
57-
...
47+
@dataclass_input(eph=Ephem)
48+
def H11(eph):
49+
...
50+
51+
The same, but using function annotations:
52+
53+
.. code-block:: python
54+
55+
@dataclass_input
56+
def H11(eph: Ephem):
57+
...
5858
5959
* Exceptions are allowed when only one parameter is needed, e.g., ``phase_func(phase)``. But instead consider using the relevant ``DataClass`` object, and decorating the function with `~sbpy.data.quantity_to_dataclass`:
6060

61-
.. code-block:: python
61+
.. code-block:: python
6262
63-
@quantity_to_dataclass(eph=(Ephem, 'phase'))
64-
def phase_func(eph):
65-
...
63+
@quantity_to_dataclass(eph=(Ephem, 'phase'))
64+
def phase_func(eph):
65+
...
6666
67-
The decorator may be stacked with ``dataclass_input`` for maximum
68-
flexibility:
67+
The decorator may be stacked with ``dataclass_input`` for maximum
68+
flexibility:
6969

70-
.. code-block:: python
70+
.. code-block:: python
7171
72-
@dataclass_input
73-
@quantity_to_dataclass(eph=(Ephem, 'phase'))
74-
def phase_func(eph):
75-
...
72+
@dataclass_input
73+
@quantity_to_dataclass(eph=(Ephem, 'phase'))
74+
def phase_func(eph):
75+
...
7676
7777
7878
Append fields to ``DataClass`` at the user's request
@@ -94,11 +94,11 @@ Cite relevant works
9494

9595
* Citations may be executed internally with :func:`sbpy.bib.register`, or via the `~sbpy.bib.cite` decorator:
9696

97-
.. code-block:: python
97+
.. code-block:: python
9898
99-
@cite({'method': '1687pnpm.book.....N'})
100-
def force(mass, acceleration):
101-
return mass * acceleration
99+
@cite({'method': '1687pnpm.book.....N'})
100+
def force(mass, acceleration):
101+
return mass * acceleration
102102
103103
* Labels describing references (``'method'`` in the above example) are
104104
required to start with the following strings: ``'method'`` (for

docs/sbpy/activity/dust.rst

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ Dust comae (`sbpy.activity.dust`)
88

99
The *Afρ* parameter of A'Hearn et al (1984) is based on observations of idealized cometary dust comae. It is proportional to the observed flux density within a circular aperture. The quantity is the product of dust albedo, dust filling factor, and the radius of the aperture at the distance of the comet. It carries the units of *ρ* (length), and under certain assumptions is proportional to the dust production rate of the comet:
1010

11-
.. math::
11+
.. math::
1212
13-
Afρ = \frac{4 Δ^2 r_h^2}{ρ}\frac{F_c}{F_⊙}
13+
Afρ = \frac{4 Δ^2 r_h^2}{ρ}\frac{F_c}{F_⊙}
1414
1515
where *Δ* and *ρ* have the same (linear) units, but :math:`r_h` is in units of au. :math:`F_c` * is the flux density of the comet in the aperture, and :math:`F_⊙` is that of the Sun at 1 au in the same units. See A'Hearn et al. (1984) and Fink & Rubin (2012) for more details.
1616

1717
The *εfρ* parameter is the thermal emission counterpart to *Afρ*, replacing albedo with IR emissivity, *ε*, and the solar spectrum with the Planck function, *B*:
1818

19-
.. math::
19+
.. math::
2020
21-
εfρ = \frac{F_c Δ^2}{π ρ B(T_c)}
21+
εfρ = \frac{F_c Δ^2}{π ρ B(T_c)}
2222
2323
where :math:`T_c` is the spectral temperature of the continuum (Kelley et al. 2013).
2424

@@ -27,21 +27,21 @@ where :math:`T_c` is the spectral temperature of the continuum (Kelley et al. 20
2727

2828
`Afrho` and `Efrho` are subclasses of `astropy`'s `~astropy.units.Quantity` and carry units of length.
2929

30-
>>> import numpy as np
31-
>>> import astropy.units as u
32-
>>> from sbpy.activity import Afrho, Efrho
33-
>>>
34-
>>> afrho = Afrho(100 * u.cm)
35-
>>> print(afrho) # doctest: +FLOAT_CMP
36-
100.0 cm
37-
>>> efrho = Efrho(afrho * 3.5)
38-
>>> print(efrho) # doctest: +FLOAT_CMP
39-
350.0 cm
30+
>>> import numpy as np
31+
>>> import astropy.units as u
32+
>>> from sbpy.activity import Afrho, Efrho
33+
>>>
34+
>>> afrho = Afrho(100 * u.cm)
35+
>>> print(afrho) # doctest: +FLOAT_CMP
36+
100.0 cm
37+
>>> efrho = Efrho(afrho * 3.5)
38+
>>> print(efrho) # doctest: +FLOAT_CMP
39+
350.0 cm
4040

4141
They may be converted to other units of length just like any `Quantity`:
4242

43-
>>> afrho.to('m') # doctest: +FLOAT_CMP
44-
<Afrho 1. m>
43+
>>> afrho.to('m') # doctest: +FLOAT_CMP
44+
<Afrho 1. m>
4545

4646
.. _afrho-to-from-flux-density:
4747

@@ -58,30 +58,30 @@ The quantities may be initialized from flux densities. Here, we reproduce one o
5858

5959
The solar flux density at 1 au is also needed. We use 1868 W/(m2 μm).
6060

61-
>>> from sbpy.data import Ephem
62-
>>> from sbpy.calib import solar_fluxd
63-
>>>
64-
>>> solar_fluxd.set({
65-
... 'λ5240': 1868 * u.W / u.m**2 / u.um,
66-
... 'λ5240(lambda pivot)': 5240 * u.AA
67-
... }) # doctest: +IGNORE_OUTPUT
68-
>>>
69-
>>> flam = 10**-13.99 * u.Unit('erg/(s cm2 AA)')
70-
>>> aper = 27200 * u.km
71-
>>>
72-
>>> eph = Ephem.from_dict({'rh': 4.785 * u.au, 'delta': 3.822 * u.au})
73-
>>>
74-
>>> afrho = Afrho.from_fluxd('λ5240', flam, aper, eph)
75-
>>> print(afrho) # doctest: +FLOAT_CMP
76-
6029.90248952895 cm
61+
>>> from sbpy.data import Ephem
62+
>>> from sbpy.calib import solar_fluxd
63+
>>>
64+
>>> solar_fluxd.set({
65+
... 'λ5240': 1868 * u.W / u.m**2 / u.um,
66+
... 'λ5240(lambda pivot)': 5240 * u.AA
67+
... }) # doctest: +IGNORE_OUTPUT
68+
>>>
69+
>>> flam = 10**-13.99 * u.Unit('erg/(s cm2 AA)')
70+
>>> aper = 27200 * u.km
71+
>>>
72+
>>> eph = Ephem.from_dict({'rh': 4.785 * u.au, 'delta': 3.822 * u.au})
73+
>>>
74+
>>> afrho = Afrho.from_fluxd('λ5240', flam, aper, eph)
75+
>>> print(afrho) # doctest: +FLOAT_CMP
76+
6029.90248952895 cm
7777

7878
Which is within a few percent of 6160 cm computed by A'Hearn et al.. The difference is likely due to the assumed solar flux density in the bandpass.
7979

8080
The `Afrho` class may be converted to a flux density, and the original value is recovered.
8181

82-
>>> f = afrho.to_fluxd('λ5240', aper, eph).to('erg/(s cm2 AA)')
83-
>>> print(np.log10(f.value)) # doctest: +FLOAT_CMP
84-
-13.99
82+
>>> f = afrho.to_fluxd('λ5240', aper, eph).to('erg/(s cm2 AA)')
83+
>>> print(np.log10(f.value)) # doctest: +FLOAT_CMP
84+
-13.99
8585

8686
`Afrho` works seamlessly with `sbpy`'s spectral calibration framework (:ref:`sbpy-calib`) when the `astropy` affiliated package `synphot` is installed. The solar flux density (via `~sbpy.calib.solar_fluxd`) is not required, but instead the spectral wavelengths or the system transmission of the instrument and filter:
8787

@@ -108,15 +108,15 @@ Reproduce the *εfρ* of 246P/NEAT from Kelley et al. (2013).
108108

109109
.. doctest-requires:: synphot
110110

111-
>>> wave = [15.8, 22.3] * u.um
112-
>>> fluxd = [25.75, 59.2] * u.mJy
113-
>>> aper = 11.1 * u.arcsec
114-
>>> eph = Ephem.from_dict({'rh': 4.28 * u.au, 'delta': 3.71 * u.au})
115-
>>> efrho = Efrho.from_fluxd(wave, fluxd, aper, eph)
116-
>>> for i in range(len(wave)):
117-
... print('{:5.1f} at {:.1f}'.format(efrho[i], wave[i])) # doctest: +FLOAT_CMP
118-
406.2 cm at 15.8 um
119-
427.9 cm at 22.3 um
111+
>>> wave = [15.8, 22.3] * u.um
112+
>>> fluxd = [25.75, 59.2] * u.mJy
113+
>>> aper = 11.1 * u.arcsec
114+
>>> eph = Ephem.from_dict({'rh': 4.28 * u.au, 'delta': 3.71 * u.au})
115+
>>> efrho = Efrho.from_fluxd(wave, fluxd, aper, eph)
116+
>>> for i in range(len(wave)):
117+
... print('{:5.1f} at {:.1f}'.format(efrho[i], wave[i])) # doctest: +FLOAT_CMP
118+
406.2 cm at 15.8 um
119+
427.9 cm at 22.3 um
120120

121121
Compare to 397.0 cm and 424.6 cm listed in Kelley et al. (2013).
122122

@@ -130,67 +130,67 @@ Estimate the *Afρ* of comet C/2012 S1 (ISON) based on Pan-STARRS 1 photometry i
130130

131131
.. doctest-requires:: synphot
132132

133-
>>> w = 0.617 * u.um
134-
>>> m = 16.02 * u.ABmag
135-
>>> aper = 5 * u.arcsec
136-
>>> eph = {'rh': 5.234 * u.au, 'delta': 4.275 * u.au, 'phase': 2.6 * u.deg}
137-
>>> afrho = Afrho.from_fluxd(w, m, aper, eph)
138-
>>> print(afrho) # doctest: +FLOAT_CMP
139-
1948.496075629444 cm
140-
>>> m2 = afrho.to_fluxd(w, aper, eph, unit=u.ABmag) # doctest: +FLOAT_CMP
141-
>>> print(m2)
142-
16.02 mag(AB)
133+
>>> w = 0.617 * u.um
134+
>>> m = 16.02 * u.ABmag
135+
>>> aper = 5 * u.arcsec
136+
>>> eph = {'rh': 5.234 * u.au, 'delta': 4.275 * u.au, 'phase': 2.6 * u.deg}
137+
>>> afrho = Afrho.from_fluxd(w, m, aper, eph)
138+
>>> print(afrho) # doctest: +FLOAT_CMP
139+
1948.496075629444 cm
140+
>>> m2 = afrho.to_fluxd(w, aper, eph, unit=u.ABmag) # doctest: +FLOAT_CMP
141+
>>> print(m2)
142+
16.02 mag(AB)
143143

144144

145145
Phase angles and functions
146146
^^^^^^^^^^^^^^^^^^^^^^^^^^
147147

148148
Phase angle was not used in the previous section. In the *Afρ* formalism, "albedo" includes the scattering phase function, and is more precisely written *A(θ)*, where *θ* is the phase angle. The default behavior for `Afrho` is to compute *A(θ)fρ* as opposed to *A(0°)fρ*. Returning to the A'Hearn et al. data, we scale *Afρ* to 0° from 3.3° phase using the :func:`~sbpy.activity.Afrho.to_phase` method:
149149

150-
>>> afrho = Afrho(6029.9 * u.cm)
151-
>>> print(afrho.to_phase(0 * u.deg, 3.3 * u.deg)) # doctest: +FLOAT_CMP
152-
6886.825981017757 cm
150+
>>> afrho = Afrho(6029.9 * u.cm)
151+
>>> print(afrho.to_phase(0 * u.deg, 3.3 * u.deg)) # doctest: +FLOAT_CMP
152+
6886.825981017757 cm
153153

154154
The default phase function is the Halley-Marcus composite phase function (:func:`~sbpy.activity.phase_HalleyMarcus`). Any function or callable object that accepts an angle as a `~astropy.units.Quantity` and returns a scalar value may be used:
155155

156-
>>> Phi = lambda phase: 10**(-0.016 / u.deg * phase.to('deg'))
157-
>>> print(afrho.to_phase(0 * u.deg, 3.3 * u.deg, Phi=Phi)) # doctest: +FLOAT_CMP
158-
6809.419810008357 cm
156+
>>> Phi = lambda phase: 10**(-0.016 / u.deg * phase.to('deg'))
157+
>>> print(afrho.to_phase(0 * u.deg, 3.3 * u.deg, Phi=Phi)) # doctest: +FLOAT_CMP
158+
6809.419810008357 cm
159159

160160
To correct an observed flux density for the phase function, use the ``phasecor`` option of :func:`~sbpy.activity.Afrho.to_fluxd` and :func:`~sbpy.activity.Afrho.from_fluxd` methods:
161161

162-
>>> flam = 10**-13.99 * u.Unit('erg/(s cm2 AA)')
163-
>>> aper = 27200 * u.km
164-
>>> eph = Ephem.from_dict({
165-
... 'rh': 4.785 * u.au,
166-
... 'delta': 3.822 * u.au,
167-
... 'phase': 3.3 * u.deg
168-
... })
169-
>>>
170-
>>> afrho = Afrho.from_fluxd('λ5240', flam, aper, eph, phasecor=True)
171-
>>> print(afrho) # doctest: +FLOAT_CMP
172-
6886.828824340642 cm
162+
>>> flam = 10**-13.99 * u.Unit('erg/(s cm2 AA)')
163+
>>> aper = 27200 * u.km
164+
>>> eph = Ephem.from_dict({
165+
... 'rh': 4.785 * u.au,
166+
... 'delta': 3.822 * u.au,
167+
... 'phase': 3.3 * u.deg
168+
... })
169+
>>>
170+
>>> afrho = Afrho.from_fluxd('λ5240', flam, aper, eph, phasecor=True)
171+
>>> print(afrho) # doctest: +FLOAT_CMP
172+
6886.828824340642 cm
173173

174174

175175
Apertures
176176
^^^^^^^^^
177177

178178
Other apertures may be used, as long as they can be converted into an equivalent radius, assuming a coma with a *1/ρ* surface brightness distribution. `~sbpy.activity` has a collection of useful geometries.
179179

180-
>>> from sbpy.activity import CircularAperture, AnnularAperture, RectangularAperture, GaussianAperture
181-
>>> apertures = (
182-
... ( '10" radius circle', CircularAperture(10 * u.arcsec)),
183-
... ( '5"–10" annulus', AnnularAperture([5, 10] * u.arcsec)),
184-
... ( '2"x10" slit', RectangularAperture([2, 10] * u.arcsec)),
185-
... ('σ=5" Gaussian beam', GaussianAperture(5 * u.arcsec))
186-
... )
187-
>>> for name, aper in apertures:
188-
... afrho = Afrho.from_fluxd('λ5240', flam, aper, eph)
189-
... print('{:18s} = {:5.0f}'.format(name, afrho)) # doctest: +FLOAT_CMP
180+
>>> from sbpy.activity import CircularAperture, AnnularAperture, RectangularAperture, GaussianAperture
181+
>>> apertures = (
182+
... ( '10" radius circle', CircularAperture(10 * u.arcsec)),
183+
... ( '5"–10" annulus', AnnularAperture([5, 10] * u.arcsec)),
184+
... ( '2"x10" slit', RectangularAperture([2, 10] * u.arcsec)),
185+
... ('σ=5" Gaussian beam', GaussianAperture(5 * u.arcsec))
186+
... )
187+
>>> for name, aper in apertures:
188+
... afrho = Afrho.from_fluxd('λ5240', flam, aper, eph)
189+
... print('{:18s} = {:5.0f}'.format(name, afrho)) # doctest: +FLOAT_CMP
190190
10" radius circle = 5917 cm
191191
5"–10" annulus = 11834 cm
192192
2"x10" slit = 28114 cm
193-
σ=5" Gaussian beam = 9442 cm
193+
σ=5" Gaussian beam = 9442 cm
194194

195195

196196
Reference/API

0 commit comments

Comments
 (0)