Skip to content

Commit df41612

Browse files
authored
Merge pull request #134 from jianyangli/photometry_rebased
Photometry rebased
2 parents c481c69 + ce3d26d commit df41612

File tree

3 files changed

+1091
-161
lines changed

3 files changed

+1091
-161
lines changed

docs/sbpy/photometry.rst

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,142 @@ Renormalize to 1.0 μm:
4343
>>> S = SpectralGradient(10 * u.percent / hundred_nm, wave0=550 * u.nm)
4444
>>> S.renormalize(1 * u.um) # doctest: +FLOAT_CMP
4545
<SpectralGradient 6.89655172 % / 100 nm>
46-
46+
47+
48+
Disk-integrated Phase Function Models
49+
-------------------------------------
50+
51+
Disk-integrated phase function referrs to the brightness or reflectance of
52+
an asteroid, often measured in magnitude, with respect to phase angle. The IAU
53+
adopted a number of models to describe the phase function of asteroids,
54+
including the two-parameter H, G system (Bowell et al. 1989), the
55+
three-parameter H, G1, G2, and the two-parameter H, G12 system derived from
56+
the three-parameter system (Muinonen et al. 2010). The H, G12 system was
57+
further revised by Penttilä et al. (2016). `~sbpy.photometry` provides all
58+
four models classes `~sbpy.photometry.HG`, `~sbpy.photometry.HG1G2`,
59+
`~sbpy.photometry.HG12`, and `~sbpy.photometry.HG12_Pen16`, respectively.
60+
61+
The photometric model class can be initialized with the default parameters,
62+
by supplying the model parameters as either dimensionless numbers or the
63+
`~astropy.units.Quantity`:
64+
65+
>>> import astropy.units as u
66+
>>> from sbpy.photometry import HG, HG1G2, HG12, HG12_Pen16
67+
>>> m = HG()
68+
>>> print(m)
69+
Model: HG
70+
Inputs: ('x',)
71+
Outputs: ('y',)
72+
Model set size: 1
73+
Parameters:
74+
H G
75+
--- ---
76+
8.0 0.4
77+
>>> m = HG(H=3.34*u.mag, G=0.12*u.dimensionless_unscaled, radius=460*u.km)
78+
>>> print(m)
79+
Model: HG
80+
Inputs: ('x',)
81+
Outputs: ('y',)
82+
Model set size: 1
83+
Parameters:
84+
H G
85+
mag
86+
---- ----
87+
3.34 0.12
88+
89+
Calculate geometric albedo, Bond albedo, and phase integral:
90+
91+
>>> print(m.geoalb) # doctest: +FLOAT_CMP
92+
0.09825058857735823
93+
>>> print(m.bondalb) # doctest: +FLOAT_CMP
94+
0.035797658494252343
95+
>>> print(m.phaseint) # doctest: +FLOAT_CMP
96+
0.36435057552929395
97+
98+
Users can supply a solar magnitude corresponding to the magnitude system of
99+
the H-parameter. The default is the apparent V-magnitude of the Sun,
100+
M_sun = -26.74 mag.
101+
102+
The model class can also be initialized by a subclass of ``sbpy``'s
103+
`~sbpy.data.DataClass`, such as `~sbpy.data.Phys`, as long as it contains the
104+
model parameters:
105+
106+
>>> from sbpy.data import Phys
107+
>>> phys = Phys.from_sbdb('Ceres')
108+
>>> m = HG(data=phys)
109+
INFO: Model initialized for 1 Ceres. [sbpy.photometry.core]
110+
>>> print(m)
111+
Model: HG
112+
Inputs: ('x',)
113+
Outputs: ('y',)
114+
Model set size: 1
115+
Parameters:
116+
H G
117+
---- ----
118+
3.34 0.12
119+
120+
Note that model set is not supported. Only one model can be initialized with
121+
the first set of valid parameters in the input `~sbpy.data.DataClass`.
122+
123+
To fit a photometric model, one may follow the standard procedure defined in
124+
``astropy.modeling`` submodule, first initializing a model, then using one of
125+
the fitter classes defined in ``astropy``'s `~astropy.modeling.fitting`
126+
submodule, such as `~astropy.modeling.fitting.LevMarLSQFitter`.
127+
128+
>>> import numpy as np
129+
>>> from astropy.modeling.fitting import LevMarLSQFitter
130+
>>> # generate data to be fitted
131+
>>> model1 = HG(3.34, 0.12)
132+
>>> alpha = np.linspace(0, 40, 20) * u.deg
133+
>>> mag = model1(alpha) + np.random.rand(20)*0.2-0.1
134+
>>> # fit new model
135+
>>> fitter = LevMarLSQFitter()
136+
>>> model2 = HG()
137+
>>> model2 = fitter(model2, alpha, mag)
138+
>>> print(model2) # doctest: +SKIP
139+
Model: HG
140+
Inputs: ('x',)
141+
Outputs: ('y',)
142+
Model set size: 1
143+
Parameters:
144+
H G
145+
146+
----------------- -------------------
147+
3.305001580933622 0.08532754955207918
148+
149+
Alternatively, one may use the wrapper method
150+
`~sbpy.photometry.DiskIntegratedPhaseFunc.fit` pre-defined in the photometric
151+
model classes to fit magnitude data and return a model class object, or use
152+
class method `~sbpy.photometry.DiskIntegratedPhaseFunc.from_data` to
153+
initialize a model directly from data by fitting.
154+
155+
>>> # use .fit method
156+
>>> model3 = HG1G2().fit(alpha, mag)
157+
>>> print(model3) # doctest: +SKIP
158+
Model: HG1G2
159+
Inputs: ('x',)
160+
Outputs: ('y',)
161+
Model set size: 1
162+
Parameters:
163+
H G1 G2
164+
165+
------------------ ------------------ -------------------
166+
3.3391210178858013 0.6551118013498317 0.09728839079940735
167+
168+
>>> # use class method .from_data
169+
>>> model4 = HG12.from_data(alpha, mag)
170+
>>> print(model4) # doctest: +SKIP
171+
Model: HG12
172+
Inputs: ('x',)
173+
Outputs: ('y',)
174+
Model set size: 1
175+
Parameters:
176+
H G12
177+
178+
----------------- ------------------
179+
3.424576008941485 0.8052670564595159
180+
181+
47182
Reference/API
48183
-------------
49184
.. automodapi:: sbpy.photometry

0 commit comments

Comments
 (0)