Skip to content

Commit 14cc083

Browse files
authored
Photolysis rates update (#425)
* Add new photolysis rates; reformat photo_timescale exception; light code reformatting. * Restore behavior when species is None (no exception). * Make photo_lengthscale behavior consistent with photo_timescale * Reformat * photo_lengthscale/timescale now require source. * Reformat code. * Add lengthscale source to test. * Fix quotes in f-string
1 parent dac9a95 commit 14cc083

File tree

9 files changed

+956
-730
lines changed

9 files changed

+956
-730
lines changed

CHANGES.rst

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,54 @@ Update supported versions [#419]:
1010
New Features
1111
------------
1212

13+
sbpy.activity.gas
14+
^^^^^^^^^^^^^^^^^
15+
16+
- Added active and quiet sun photolysis rates for H2O and CO2 from Huebner &
17+
Mukherjee 2015 to `sbpy.activity.gas.photo_timescale`. [#425]
18+
19+
1320
sbpy.names
1421
^^^^^^^^^^
22+
1523
- Added functionality to `sbpy.Names.from_packed()` and
1624
`sbpy.Names.to_packed()` to handle new extended provisional designations
1725
to be implemented by the MPC in anticipation of higher asteroid discovery
18-
rates in the LSST survey era [#406]
26+
rates in the LSST survey era. [#406]
27+
1928

2029
API Changes
2130
-----------
31+
32+
sbpy.activity.gas
33+
^^^^^^^^^^^^^^^^^
34+
35+
- Data source is now a required parameter for
36+
`sbpy.activity.gas.photo_lengthscale` and `sbpy.activity.gas.photo_timescale`.
37+
If the data source is ``None``, then a table of sources will be printed.
38+
[#425]
39+
40+
41+
sbpy.activity.gas.productionrate
42+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43+
44+
- Data source is now a required parameter for
45+
`sbpy.activity.gas.productionrate.beta_factor`. [#425]
46+
47+
48+
sbpy.ginga_plugins
49+
^^^^^^^^^^^^^^^^^^
50+
2251
- Deprecated `sbpy.ginga_plugins` in favor of using `sbpy-ginga` at
2352
https://github.com/NASA-Planetary-Science/sbpy-ginga [#413]
2453

54+
2555
sbpy.data.ephem
2656
^^^^^^^^^^^^^^^
2757

2858
- New command-line script: ``sbpy-ephem``. [#396]
2959

60+
3061
Other Changes and Additions
3162
---------------------------
3263

@@ -35,6 +66,7 @@ sbpy.activity.gas
3566
- Replaced calls to the deprecated function `scipy.integrate.romberg` with
3667
`scipy.integrate.quad`. [#412]
3768

69+
3870
sbpy.names
3971
^^^^^^^^^^
4072
- Fixed `sbpy.Names.to_packed()' to raise an error in cases of invalid
@@ -53,6 +85,7 @@ sbpy.names
5385
"P2015XN77"), which was previously being interpreted as a packed
5486
asteroid designation, but now raises a TargetNameParseError [#422]
5587

88+
5689
0.5.0 (2024-08-28)
5790
==================
5891

docs/sbpy/activity/gas.rst

Lines changed: 62 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Gas Comae (`sbpy.activity.gas`)
66
.. toctree::
77
:maxdepth: 2
88

9+
910
Photolysis
1011
----------
1112

@@ -14,35 +15,37 @@ Two functions provide reference data for the photolysis of gas molecules in opti
1415
:func:`~sbpy.activity.gas.photo_lengthscale` provides empirical comae lengthscales (defaults to Cochran and Schleicher 1993)):
1516

1617
>>> from sbpy.activity import gas
17-
>>> gas.photo_lengthscale(None)
18-
Traceback (most recent call last):
19-
...
20-
ValueError: Invalid species None. Choose from:
21-
H2O [CS93]
22-
OH [CS93]
23-
>>> gas.photo_lengthscale('H2O') # doctest: +FLOAT_CMP
18+
>>> gas.photo_lengthscale()
19+
species source gamma bibcode
20+
km
21+
------- ------ -------- -------------------
22+
H2O CS93 24000.0 1993Icar..105..235C
23+
OH CS93 160000.0 1993Icar..105..235C
24+
>>> gas.photo_lengthscale("H2O", "CS93") # doctest: +FLOAT_CMP
2425
<Quantity 24000. km>
2526

2627
Use :func:`~sbpy.activity.gas.photo_timescale` to retrieve photolysis timescales:
2728

28-
>>> gas.photo_timescale(None)
29-
Traceback (most recent call last):
30-
...
31-
ValueError: Invalid species None. Choose from:
32-
CH3OH [C94]
33-
CN [H92]
34-
CO [CE83]
35-
CO2 [CE83]
36-
H2CO [C94]
37-
H2O [CS93]
38-
HCN [C94]
39-
OH [CS93]
40-
>>> gas.photo_timescale('H2O') # doctest: +FLOAT_CMP
29+
>>> gas.photo_timescale()
30+
species source tau bibcode
31+
------- ------ ------------------- -------------------
32+
H2O CS93 52000.0 s 1993Icar..105..235C
33+
H2O HM15 [82940. 49390.] s 2015P&SS..106...11H
34+
OH CS93 160000.0 s 1993Icar..105..235C
35+
HCN C94 67000.0 s 1994JGR....99.3777C
36+
CH3OH C94 77000.0 s 1994JGR....99.3777C
37+
H2CO C94 5000.0 s 1994JGR....99.3777C
38+
CO CE83 1500000.0 s 1983A&A...126..170C
39+
CO2 CE83 500000.0 s 1983A&A...126..170C
40+
CO2 HM15 [494800. 210100.] s 2015P&SS..106...11H
41+
CN H92 [315000. 135000.] s 1992Ap&SS.195....1H
42+
>>> gas.photo_timescale("H2O", "CS93") # doctest: +FLOAT_CMP
4143
<Quantity 52000. s>
4244

43-
Some sources provide values for the quiet and active Sun (Huebner et al. 1992):
45+
Some sources provide values for the quiet and active Sun (e.g., Huebner et al.
46+
1992):
4447

45-
>>> gas.photo_timescale('CN', source='H92') # doctest: +FLOAT_CMP
48+
>>> gas.photo_timescale("CN", "H92") # doctest: +FLOAT_CMP
4649
<Quantity [315000., 135000.] s>
4750

4851

@@ -53,7 +56,7 @@ With the :doc:`../bib`, the citation may be discovered:
5356
>>> from sbpy import bib
5457
>>> bib.reset() # clear any old citations
5558
>>> with bib.Tracking():
56-
... tau = gas.photo_timescale('H2O')
59+
... tau = gas.photo_timescale("H2O", "CS93")
5760
>>> print(bib.to_text()) # doctest: +REMOTE_DATA
5861
sbpy:
5962
software: sbpy:
@@ -62,8 +65,10 @@ With the :doc:`../bib`, the citation may be discovered:
6265
H2O photodissociation timescale:
6366
Cochran & Schleicher 1993, Icarus, Vol 105, 1, 235
6467

68+
6569
Fluorescence
6670
------------
71+
6772
Reference data for fluorescence band emission is available via :func:`~sbpy.activity.gas.fluorescence_band_strength`. Compute the fluorescence band strength (luminosity per molecule) of the OH 0-0 band at 1 au from the Sun, moving towards the Sun at 1 km/s (defaults to Schleicher and A'Hearn 1988):
6873

6974
>>> import astropy.units as u
@@ -89,8 +94,8 @@ column density and total number of molecules within an aperture:
8994

9095
>>> Q = 1e28 / u.s # production rate
9196
>>> v = 0.8 * u.km / u.s # expansion speed
92-
>>> parent = gas.photo_lengthscale('H2O')
93-
>>> daughter = gas.photo_lengthscale('OH')
97+
>>> parent = gas.photo_lengthscale("H2O", "CS93")
98+
>>> daughter = gas.photo_lengthscale("OH", "CS93")
9499
>>> coma = gas.Haser(Q, v, parent, daughter)
95100
>>> print(coma.column_density(10 * u.km)) # doctest: +FLOAT_CMP
96101
7.099280153851781e+17 1 / m2
@@ -106,6 +111,7 @@ The gas coma models work with sbpy's apertures:
106111
>>> print(coma.total_number(ap)) # doctest: +FLOAT_CMP
107112
3.8133654170856037e+31
108113

114+
109115
Vectorial Model
110116
^^^^^^^^^^^^^^^
111117

@@ -136,14 +142,14 @@ number of molecules in an aperture. Parent and daughter data is provided via
136142

137143
>>> from sbpy.data import Phys
138144
>>> water = Phys.from_dict({
139-
... 'tau_T': gas.photo_timescale('H2O') * 0.8, # approximate
140-
... 'tau_d': gas.photo_timescale('H2O'),
141-
... 'v_outflow': 0.85 * u.km / u.s,
142-
... 'sigma': 3e-16 * u.cm**2
145+
... "tau_T": gas.photo_timescale("H2O", "CS93") * 0.8, # approximate
146+
... "tau_d": gas.photo_timescale("H2O", "CS93"),
147+
... "v_outflow": 0.85 * u.km / u.s,
148+
... "sigma": 3e-16 * u.cm**2
143149
... })
144150
>>> hydroxyl = Phys.from_dict({
145-
... 'tau_T': gas.photo_timescale('OH') * 0.8, # approximate
146-
... 'v_photo': 1.05 * u.km / u.s
151+
... "tau_T": gas.photo_timescale("OH", "CS93") * 0.8, # approximate
152+
... "v_photo": 1.05 * u.km / u.s
147153
... })
148154
>>> Q = 1e28 / u.s # water production rate
149155
>>> coma = gas.VectorialModel(Q, water, hydroxyl)
@@ -152,6 +158,7 @@ number of molecules in an aperture. Parent and daughter data is provided via
152158
>>> print(coma.total_number(1000 * u.km)) # doctest: +FLOAT_CMP
153159
6.995084479934798e+29
154160

161+
155162
Production Rate calculations
156163
----------------------------
157164

@@ -173,7 +180,7 @@ using JPLSpec:
173180
>>> temp_estimate = 47. * u.K
174181
>>> transition_freq = (230.53799 * u.GHz).to('MHz')
175182
>>> integrated_flux = 0.26 * u.K * u.km / u.s
176-
>>> mol_tag = '^CO$'
183+
>>> mol_tag = "^CO$"
177184
>>> mol_data = Phys.from_jplspec(temp_estimate, transition_freq, mol_tag)
178185
>>> mol_data
179186
<QTable length=1>
@@ -188,6 +195,7 @@ Having this information, we can move forward towards the calculation of
188195
production rate. The functions that sbpy currently provides to calculate
189196
production rates are listed below.
190197

198+
191199
Integrated Line Intensity Conversion
192200
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
193201

@@ -203,7 +211,7 @@ For more information on the needed parameters for this function see
203211

204212
>>> from sbpy.activity import intensity_conversion
205213
>>> intl = intensity_conversion(mol_data)
206-
>>> mol_data.apply([intl.value] * intl.unit, name='intl')
214+
>>> mol_data.apply([intl.value] * intl.unit, name="intl")
207215
11
208216
>>> intl
209217
<Quantity 0.00280051 MHz nm2>
@@ -231,7 +239,7 @@ for this function see `~sbpy.activity.einstein_coeff`.
231239

232240
>>> from sbpy.activity import einstein_coeff
233241
>>> au = einstein_coeff(mol_data)
234-
>>> mol_data.apply([au.value] * au.unit, name = 'Einstein Coefficient')
242+
>>> mol_data.apply([au.value] * au.unit, name = "Einstein Coefficient")
235243
12
236244
>>> au
237245
<Quantity 7.03946054e-07 1 / s>
@@ -241,27 +249,27 @@ Beta Factor Calculation
241249
^^^^^^^^^^^^^^^^^^^^^^^
242250

243251
Returns beta factor based on timescales from `~sbpy.activity.gas` and distance
244-
from the Sun using an `~sbpy.data.Ephem` object. The calculation is
245-
parent photodissociation timescale * (distance from comet to Sun)**2
246-
and it accounts for certain photodissociation and geometric factors needed
247-
in the calculation of total number of molecules `~sbpy.activity.total_number`
248-
If you wish to provide your own beta factor, you can calculate the equation
249-
expressed in units of AU**2 * s , all that is needed is the timescale
250-
of the molecule and the distance of the comet from the Sun. Once you
251-
have the beta factor you can append it to your `mol_data` phys object
252-
with the name 'beta' or any of its alternative names. For more information on
253-
the needed parameters for this function see `~sbpy.activity.beta_factor`.
252+
from the Sun using an `~sbpy.data.Ephem` object. The calculation is parent
253+
photodissociation timescale * (distance from comet to Sun)**2 and it accounts
254+
for certain photodissociation and geometric factors needed in the calculation of
255+
total number of molecules `~sbpy.activity.total_number` If you wish to provide
256+
your own beta factor, you can calculate the equation expressed in units of AU**2
257+
* s , all that is needed is the timescale of the molecule and the distance of
258+
the comet from the Sun. Once you have the beta factor you can append it to your
259+
`mol_data` phys object with the name 'beta' or any of its alternative names. For
260+
more information on the needed parameters for this function see
261+
`~sbpy.activity.gas.productionrate.beta_factor`.
254262

255263
.. doctest-skip::
256264

257265
>>> from astropy.time import Time
258266
>>> from sbpy.data import Ephem
259267
>>> from sbpy.activity import beta_factor
260268
>>> target = 'C/2016 R2'
261-
>>> time = Time('2017-12-22 05:24:20', format = 'iso')
262-
>>> ephemobj = Ephem.from_horizons(target, epochs=time.jd)
263-
>>> beta = beta_factor(mol_data, ephemobj)
264-
>>> mol_data.apply([beta.value] * beta.unit, name='beta')
269+
>>> time = Time('2017-12-22 05:24:20', format="iso")
270+
>>> eph = Ephem.from_horizons(target, epochs=time.jd)
271+
>>> beta = beta_factor(mol_data, "CE83", eph)
272+
>>> mol_data.apply([beta.value] * beta.unit, name="beta")
265273
13
266274
>>> beta
267275
<Quantity [13333365.25745597] AU2 s>
@@ -307,7 +315,7 @@ for column density explained in the next section.
307315
.. doctest-skip::
308316

309317
>>> cdensity = lte.cdensity_Bockelee(integrated_flux, mol_data)
310-
>>> mol_data.apply([cdensity.value] * cdensity.unit, name='cdensity')
318+
>>> mol_data.apply([cdensity.value] * cdensity.unit, name="cdensity")
311319

312320

313321
Non-LTE Column Density Calculation
@@ -329,7 +337,7 @@ input parameters, please see `~sbpy.activity.NonLTE.from_pyradex`.
329337
>>> from sbpy.activity import NonLTE
330338
>>> nonlte = NonLTE()
331339
>>> cdensity = nonlte.from_pyradex(integrated_flux, mol_data, iter=500)
332-
>>> mol_data.apply([cdensity.value] * cdensity.unit, name='cdensity')
340+
>>> mol_data.apply([cdensity.value] * cdensity.unit, name="cdensity")
333341

334342
Note that for this calculation the installation of `pyradex` is needed. Pyradex
335343
is a python wrapper for the RADEX fortran code. See `pyradex installation
@@ -340,6 +348,7 @@ works and what common errors might arise. You need to make sure you have a
340348
fortran compiler installed in order for pyradex to work (gfortran works and can
341349
be installed with homebrew for easier management).
342350

351+
343352
Total Number
344353
^^^^^^^^^^^^
345354

@@ -362,7 +371,7 @@ for this function see `~sbpy.activity.total_number`.
362371
>>> b = 0.74
363372
>>> aper = 10 * u.m
364373
>>> tnum = total_number(integrated_flux, mol_data, aper, b)
365-
>>> mol_data.apply([tnum], name='total_number')
374+
>>> mol_data.apply([tnum], name="total_number")
366375
14
367376
>>> tnum
368377
<Quantity [2.93988826e+26]>
@@ -390,7 +399,7 @@ on the parameters that are needed for the function see
390399

391400
>>> from sbpy.activity import Haser, photo_timescale, from_Haser
392401
>>> Q_estimate = 3.5939*10**(28) / u.s
393-
>>> parent = photo_timescale('CO') * vgas
402+
>>> parent = photo_timescale("CO", "H92") * vgas
394403
>>> coma = Haser(Q_estimate, vgas, parent)
395404
>>> Q = from_Haser(coma, mol_data, aper=aper)
396405
>>> Q
@@ -399,6 +408,7 @@ on the parameters that are needed for the function see
399408
For more involved examples and literature comparison for any of the production
400409
rate modules, please see notebook examples.
401410

411+
402412
Reference/API
403413
-------------
404414
.. automodapi:: sbpy.activity.gas.core

0 commit comments

Comments
 (0)