13
13
from astroquery .jplspec import JPLSpec
14
14
from astroquery .jplhorizons import Horizons , conf
15
15
from ..bib import register
16
+ from ..data import Phys
16
17
17
18
conf .horizons_server = 'https://ssd.jpl.nasa.gov/horizons_batch.cgi'
18
19
@@ -26,20 +27,20 @@ def molecular_data(temp_estimate, transition_freq, mol_tag):
26
27
27
28
Parameters
28
29
----------
29
- transition_freq : `~astropy.units.Quantity`
30
- Transition frequency in MHz
31
-
32
30
temp_estimate : `~astropy.units.Quantity`
33
31
Estimated temperature in Kelvins
34
32
33
+ transition_freq : `~astropy.units.Quantity`
34
+ Transition frequency in MHz
35
+
35
36
mol_tag : int or str
36
37
Molecule identifier. Make sure it is an exclusive identifier.
37
38
38
39
Returns
39
40
-------
40
- Molecular data : list
41
- List of constants in the following order:
42
- | Transtion frequency
41
+ Molecular data : `~sbpy.data.Phys` instance
42
+ Quantities in the following order:
43
+ | Transition frequency
43
44
| Temperature
44
45
| Integrated line intensity at 300 K
45
46
| Partition function at 300 K
@@ -95,12 +96,17 @@ def molecular_data(temp_estimate, transition_freq, mol_tag):
95
96
energy_J = energy .to (u .J , equivalencies = u .spectral ())
96
97
elo_J = elo .to (u .J , equivalencies = u .spectral ())
97
98
98
- result = []
99
-
100
- result .append (t_freq )
101
-
102
- result .extend ((temp , lgint , part300 , partition , gu , energy_J ,
103
- elo_J , df ))
99
+ quantities = [t_freq , temp , lgint , part300 , partition , gu , energy_J , elo_J , df ]
100
+ names = ('Transition frequency' ,
101
+ 'Temperature' ,
102
+ 'Integrated line intensity at 300 K' ,
103
+ 'Partition function at 300 K' ,
104
+ 'Partition function at designated temperature' ,
105
+ 'Upper state degeneracy' ,
106
+ 'Upper level energy in Joules' ,
107
+ 'Lower level energy in Joules' ,
108
+ 'Degrees of freedom' )
109
+ result = Phys .from_array (quantities , names )
104
110
105
111
return result
106
112
@@ -129,15 +135,15 @@ def intensity_conversion(temp_estimate, transition_freq, mol_tag):
129
135
130
136
mol_data = molecular_data (temp_estimate , transition_freq , mol_tag )
131
137
132
- temp = mol_data [1 ]
133
- lgint = mol_data [2 ]
134
- part300 = mol_data [3 ]
135
- partition = mol_data [4 ]
136
- energy_J = mol_data [6 ]
137
- elo_J = mol_data [7 ]
138
- df = mol_data [8 ]
138
+ temp = mol_data [0 ][ 1 ]
139
+ lgint = mol_data [0 ][ 2 ]
140
+ part300 = mol_data [0 ][ 3 ]
141
+ partition = mol_data [0 ][ 4 ]
142
+ energy_J = mol_data [0 ][ 6 ]
143
+ elo_J = mol_data [0 ][ 7 ]
144
+ df = mol_data [0 ][ 8 ]
139
145
140
- k = con .k_B .to ('J/K' ) # boltzman constant
146
+ k = con .k_B .to ('J/K' ) # Boltzmann constant
141
147
142
148
if (((energy_J - elo_J ).value / (k * temp ).value ) and
143
149
((energy_J - elo_J ).value / (k * 300 * u .K ).value ) < 1 ):
@@ -185,18 +191,18 @@ def einstein_coeff(temp_estimate, transition_freq, mol_tag):
185
191
186
192
mol_data = molecular_data (temp_estimate , transition_freq , mol_tag )
187
193
188
- t_freq = mol_data [0 ]
189
- temp = mol_data [1 ]
190
- lgint = mol_data [2 ]
191
- part300 = mol_data [3 ]
192
- partition = mol_data [4 ]
193
- gu = mol_data [5 ]
194
- energy_J = mol_data [6 ]
195
- elo_J = mol_data [7 ]
194
+ t_freq = mol_data [0 ][ 0 ]
195
+ temp = mol_data [0 ][ 1 ]
196
+ lgint = mol_data [0 ][ 2 ]
197
+ part300 = mol_data [0 ][ 3 ]
198
+ partition = mol_data [0 ][ 4 ]
199
+ gu = mol_data [0 ][ 5 ]
200
+ energy_J = mol_data [0 ][ 6 ]
201
+ elo_J = mol_data [0 ][ 7 ]
196
202
197
- h = con .h .to ('J*s' ) # planck constant
203
+ h = con .h .to ('J*s' ) # Planck constant
198
204
199
- k = con .k_B .to ('J/K' ) # boltzman constant
205
+ k = con .k_B .to ('J/K' ) # Boltzmann constant
200
206
201
207
intl = intensity_conversion (temp_estimate , transition_freq , mol_tag )
202
208
@@ -246,7 +252,9 @@ def photod_rate(time, time_scale, target, id_type, observatory, time_format,
246
252
247
253
beta = (timescale ) * r ** 2
248
254
249
- return beta , delta
255
+ result = Phys .from_array ((beta , delta ), ('beta' , 'delta' ))
256
+
257
+ return result
250
258
251
259
252
260
def total_number (integrated_line , temp_estimate , transition_freq , mol_tag ,
@@ -277,10 +285,11 @@ def total_number(integrated_line, temp_estimate, transition_freq, mol_tag,
277
285
transition_freq ,
278
286
mol_tag ))).decompose ()
279
287
280
- delta , beta = photod_rate (time , time_scale , target , id_type , observatory ,
281
- time_format , mol_tag )
288
+ photod = photod_rate (time , time_scale , target , id_type , observatory ,
289
+ time_format , mol_tag )
290
+ beta = photod ["beta" ]
282
291
283
- sigma = (1. / 2. * delta * b * con .c / (transition_freq * aper )).value
292
+ sigma = (1. / 2. * beta * b * con .c / (transition_freq * aper )).value
284
293
285
294
total_number = cdensity .decompose () * sigma * u .m * u .m / np .sqrt (np .log (2 ))
286
295
@@ -517,7 +526,7 @@ def prodrate_np(self, spectra, temp_estimate, transition_freq,
517
526
518
527
Returns
519
528
-------
520
- q : list
529
+ q : `~astropy.units.Quantity`
521
530
Production rate, not including photodissociation
522
531
523
532
Examples
@@ -588,8 +597,8 @@ def prodrate_np(self, spectra, temp_estimate, transition_freq,
588
597
gu_list = []
589
598
energy_J_list = []
590
599
au_list = []
591
- h = con .h .to ('J*s' ) # planck constant
592
- k = con .k_B .to ('J/K' ) # boltzman constant
600
+ h = con .h .to ('J*s' ) # Planck constant
601
+ k = con .k_B .to ('J/K' ) # Boltzmann constant
593
602
c = con .c .to ('m/s' ) # speed of light
594
603
vgas = vgas .to ('m/s' )
595
604
@@ -600,11 +609,11 @@ def prodrate_np(self, spectra, temp_estimate, transition_freq,
600
609
mol_data = molecular_data (temp_estimate , transition_freq [i ],
601
610
mol_tag )
602
611
603
- t_freq = mol_data [0 ]
604
- temp = mol_data [1 ]
605
- partition = mol_data [4 ]
606
- gu = mol_data [5 ]
607
- energy_J = mol_data [6 ]
612
+ t_freq = mol_data [0 ][ 0 ]
613
+ temp = mol_data [0 ][ 1 ]
614
+ partition = mol_data [0 ][ 4 ]
615
+ gu = mol_data [0 ][ 5 ]
616
+ energy_J = mol_data [0 ][ 6 ]
608
617
609
618
au = einstein_coeff (temp_estimate , transition_freq [i ], mol_tag )
610
619
@@ -622,8 +631,9 @@ def prodrate_np(self, spectra, temp_estimate, transition_freq,
622
631
gu = sum (gu_list ) / float (len (gu_list ))
623
632
energy_J = sum (energy_J_list ) / float (len (energy_J_list ))
624
633
625
- beta , delta = photod_rate (time , time_scale , target , id_type ,
626
- observatory , time_format , mol_tag )
634
+ photod = photod_rate (time , time_scale , target , id_type , observatory ,
635
+ time_format , mol_tag )
636
+ delta = photod ["delta" ]
627
637
628
638
calc = ((16 * np .pi * k * t_freq .decompose () *
629
639
partition * vgas ) / (np .sqrt (np .pi * np .log (2 ))
@@ -640,20 +650,21 @@ def prodrate_np(self, spectra, temp_estimate, transition_freq,
640
650
641
651
mol_data = molecular_data (temp_estimate , transition_freq , mol_tag )
642
652
643
- t_freq = mol_data [0 ]
644
- temp = mol_data [1 ]
645
- partition = mol_data [4 ]
646
- gu = mol_data [5 ]
647
- energy_J = mol_data [6 ]
648
- h = con .h .to ('J*s' ) # planck constant
649
- k = con .k_B .to ('J/K' ) # boltzman constant
653
+ t_freq = mol_data [0 ][ 0 ]
654
+ temp = mol_data [0 ][ 1 ]
655
+ partition = mol_data [0 ][ 4 ]
656
+ gu = mol_data [0 ][ 5 ]
657
+ energy_J = mol_data [0 ][ 6 ]
658
+ h = con .h .to ('J*s' ) # Planck constant
659
+ k = con .k_B .to ('J/K' ) # Boltzmann constant
650
660
c = con .c .to ('m/s' ) # speed of light
651
661
vgas = vgas .to ('m/s' )
652
662
653
663
au = einstein_coeff (temp_estimate , transition_freq , mol_tag )
654
664
655
- beta , delta = photod_rate (time , time_scale , target , id_type ,
656
- observatory , time_format , mol_tag )
665
+ photod = photod_rate (time , time_scale , target , id_type , observatory ,
666
+ time_format , mol_tag )
667
+ delta = photod ["delta" ]
657
668
658
669
calc = ((16 * np .pi * k * t_freq .decompose () *
659
670
partition * vgas ) / (np .sqrt (np .pi * np .log (2 ))
0 commit comments