keflavich / pyradex

Python interface to RADEX
BSD 3-Clause "New" or "Revised" License
18 stars 12 forks source link

Add Fujun Du's myRadex #4

Closed keflavich closed 9 years ago

keflavich commented 9 years ago

This PR adds Fujun Du's myRadex as a submodule and adds an object-oriented wrapper with identical call signatures to RADEX. It includes some comparison scripts too. The two are now nearly identical, with only subtle differences. Example:

In [1]: import pyradex.fjdu, pyradex

In [2]: FF = pyradex.fjdu.Fjdu(species='co', column=1e15, density=1e3, temperature=30)

In [3]: RR = pyradex.Radex(species='co', column=1e15, density=1e3, temperature=30)

In [4]: FF(species='ph2co-h2', deltav=5, density={'oH2':1e5, 'pH2':1e5,}, column=1e14, temperature=30)[np.array((2,9,12))].pprint()
!  1.0000E+05 =     pH2
!  1.0000E+05 =     oH2
     Tex           tau         frequency   upperstateenergy upperlevel lowerlevel  upperlevelpop   lowerlevelpop       brightness          T_B
      K                           GHz             K                                                               erg / (cm2 Hz s sr)       K
------------- -------------- ------------- ---------------- ---------- ---------- --------------- --------------- ------------------- --------------
10.9850266643  1.32179129864 218.221928103    20.9564811133        3.0        2.0  0.151766825553  0.281254720835   6.79892676587e-14  4.64698536225
8.05053084523  0.15678636984 218.476751692    68.0940679574        8.0        6.0  0.019292274524 0.0506864308309   7.83989913836e-15 0.534598497514
8.03698214519 0.154534224046 218.761554527    68.1111893831        9.0        7.0 0.0189155655708 0.0498907178498   7.72394242942e-15 0.525320979097

In [5]: RR(species='ph2co-h2', deltav=5, density={'oH2':1e5, 'pH2':1e5,}, column=1e14, temperature=30)[np.array((2,9,12))].pprint()
pyradex/core.py:806: RuntimeWarning: invalid value encountered in divide
  frac_level_diff = level_diff/self.level_population
     Tex           tau       frequency  upperstateenergy upperlevel lowerlevel  upperlevelpop   lowerlevelpop       brightness          T_B
      K                         GHz            K                                                               erg / (cm2 Hz s sr)       K
------------- -------------- ---------- ---------------- ---------- ---------- --------------- --------------- ------------------- --------------
10.8725461875    1.333141597 218.222192             21.0      3_0_3      2_0_2  0.150645903772  0.281945353464   6.86054393918e-14  4.68909371872
7.80402367318 0.161072242648 218.475632             68.1      3_2_2      2_2_1 0.0187394568895 0.0513020999616   8.07559238671e-15 0.550676535796
7.79197678094 0.158774743839 218.760066             68.1      3_2_1      2_2_0  0.018378137173 0.0505058504318   7.95918249474e-15 0.541328087558

cc @fjdu, @ZhiyuZhang, @jrka