GETTING STARTED To get started, move into directory where PyNeb resides and enter python


In [1]:
%matplotlib inline
# import code and modules
import pyneb as pn
import numpy as np
import matplotlib.pyplot as plt

In [2]:
#######################################################################
# DEFINING ATOMS

# define an OII atom
O2 = pn.Atom("O", 2)

# alternate syntax to define an atom (spec is a string)
N2 = pn.Atom("N", "2")

In [3]:
# check atom definition
print O2.elem
print O2.spec
print O2.atom
print O2.name


O
2
O2
oxygen

In [4]:
# explore the atom: builtin data
print O2.gs # ground-state configuration


p3

In [5]:
# array of stat weights
print O2.getStatWeight()


[ 4.  6.  4.  4.  2.  6.  4.  2.]

In [6]:
# stat weight of a given level
lev_i = 2
print O2.getStatWeight(lev_i)


6.0

In [7]:
# explore the atom: adopted atomic data
pn.atomicData.getPredefinedDataFileDict() # we suggest using the tab for this command...
pn.atomicData.getDirForFile('o_ii_atom_WFD96.fits') # wanna know where the file lies?
O2.printSources() # print bibliographic references of data used to build O2


O2: Energy levels : NIST 2014
O2: A-values from level 6 : Wiese, Fuhr & Deters, 1996, JPCRD, Monograph 7, 369
O2: A-values from levels up to 5 : Zeippen 1982, MNRAS, 198, 111
O2: CS up to level 5 : Pradhan et al 2006, MNRAS 366, L6
O2: CS for levels from 6, interpolated to adapt to Pal07 Tem grid : Tayal 2007, ApJS, 171, 331

In [8]:
print O2.NLevels # number of levels in the selected data
print O2.getEnergy(2) # energy of first excited level (ground = 1) in Angstrom^-1
print O2.getA(2,1) # transition probability of 2->1


8
0.0002681055
3.82e-05

In [9]:
N2.plotGrotrian()



In [10]:
# set temperature and density
tem = 15000.
den = 1000.
print O2.getPopulations(tem, den) # compute populations


[  9.73452672e-01   2.06878141e-02   5.85819178e-03   8.23867455e-07
   4.97864417e-07   2.92747483e-19   1.86769357e-19   9.15097829e-20]

In [11]:
print O2.getCritDensity(tem, level=2) # critical density of level 2 at tem


1241.56280771

In [12]:
print O2.getOmega(tem, 2, 1) # effective collision strength of transition 2->1 at T=10000K


0.884

In [13]:
print O2.getOmegaArray(2, 1) # array of effective collision strengths for 2->1 as a function of T


[ 0.864  0.885  0.883  0.884  0.885  0.888]

In [14]:
print O2.getTemArray() # print array of temperatures of tabulated Omegas


[ 0.1  0.5  1.   1.5  2.   2.5]

In [15]:
print O2.getCollRates(tem) # print collisional Rates at T=tem


[[  0.00000000e+00   1.18979040e-09   7.85850784e-10   1.15483097e-10
    5.59151024e-11   2.43623651e-13   1.58597662e-13   7.86743224e-14]
 [  1.03806015e-08   0.00000000e+00   1.59981194e-08   3.07654017e-09
    1.31147738e-09   6.66778113e-13   2.23121317e-13   4.58627385e-14]
 [  1.03042735e-08   2.40433049e-08   0.00000000e+00   2.97134567e-09
    1.94719300e-09   1.88185845e-13   4.35367075e-13   3.07870982e-13]
 [  5.60129741e-09   1.71033327e-08   1.09912251e-08   0.00000000e+00
    5.28323429e-09   5.74293400e-13   8.41205580e-13   5.60919861e-13]
 [  5.42515598e-09   1.45845102e-08   1.44083688e-08   1.05684857e-08
    0.00000000e+00   4.83020730e-12   2.26192125e-12   8.50040815e-13]
 [  1.59466706e-08   5.00241655e-09   9.39420949e-10   7.75022283e-10
    3.25861642e-09   0.00000000e+00   9.44365074e-09   3.75619863e-09]
 [  1.58175002e-08   2.55052788e-09   3.31145885e-09   1.72970882e-09
    2.32506685e-09   1.43889932e-08   0.00000000e+00   6.26493974e-09]
 [  1.58175002e-08   1.05684857e-09   4.72059027e-09   2.32506685e-09
    1.76141428e-09   1.15372635e-08   1.26293404e-08   0.00000000e+00]]

In [16]:
pn.atomicData.getAllAvailableFiles('O3')


Out[16]:
['o_iii_atom.chianti',
 'o_iii_atom_FFT04.dat',
 'o_iii_atom_GMZ97-WFD96.dat',
 'o_iii_atom_SZ00-WFD96.dat',
 'o_iii_coll.chianti',
 'o_iii_coll_AK99.dat',
 'o_iii_coll_LB94.dat',
 'o_iii_coll_Pal12-AK99.dat',
 'o_iii_coll_SSB13.dat']

In [17]:
# This bit calls the script DataPlot.py to plot atomic data. 
dataplot = pn.DataPlot('O', 3)
dataplot.plotAllA(figsize=(14, 10)) # transition probabilities plot


warng _ManageAtomicData: rec data not available for O3

In [18]:
pn.config.setNlevels(6, 'O3', 'coll')
dataplot.plotOmega() # collision strength plot



In [19]:
# customize atomic data 
# First step: check which directories are searched for atomic data files
pn.atomicData.getAllDataFilePaths()


Out[19]:
['/home/morisset/Ureka/variants/common/lib/python2.7/site-packages/pyneb/utils/../atomic_data_fits/',
 '/home/morisset/Ureka/variants/common/lib/python2.7/site-packages/pyneb/utils/../atomic_data/',
 '/home/morisset/pyneb/trunk/pyneb/sample_scripts']

In [20]:
# Add your selected directory to the list
pn.atomicData.addDataFilePath('/tmp')

In [21]:
# Check if it's been added
pn.atomicData.getAllDataFilePaths()


Out[21]:
['/home/morisset/Ureka/variants/common/lib/python2.7/site-packages/pyneb/utils/../atomic_data_fits/',
 '/home/morisset/Ureka/variants/common/lib/python2.7/site-packages/pyneb/utils/../atomic_data/',
 '/home/morisset/pyneb/trunk/pyneb/sample_scripts',
 '/tmp']

In [22]:
# Remove it if you gave the wrong dir
pn.atomicData.removeDataFilePath('/tmp')


warng _ManageAtomicData: {0} could not be removed from the path list

In [23]:
# Set 'o_iii_.fits' to be the OIII atom file
pn.atomicData.setDataFile('o_iii_coll_Pal12-AK99.dat')

In [24]:
# define an atom with the new data
O2test = pn.Atom("O", 2)

In [25]:
# define all atoms at once and put them in a dictionary
# (all of them defined with the latest dataset selected)
atoms = pn.getAtomDict() #this generates a lot of warnings as not all element-spectrum combination exist

In [26]:
# see what atoms have been built
atoms


Out[26]:
{'Al2': Atom Al2 from al_ii_atom_JSP86-HK87-VVF96-KS86.dat and al_ii_coll_KHAF92-TBK85-TBK84.dat,
 'Ar2': Atom Ar2 from ar_ii_atom_Bal06.dat and ar_ii_coll_PB95.dat,
 'Ar3': Atom Ar3 from ar_iii_atom_M83-KS86.dat and ar_iii_coll_GMZ95.dat,
 'Ar4': Atom Ar4 from ar_iv_atom_MZ82.dat and ar_iv_coll_RB97.dat,
 'Ar5': Atom Ar5 from ar_v_atom_LL93-MZ82-KS86.dat and ar_v_coll_GMZ95.dat,
 'Ba2': Atom Ba2 from ba_ii_atom_C04.dat and ba_ii_coll_SB98.dat,
 'Ba4': Atom Ba4 from ba_iv_atom_BHQZ95.dat and ba_iv_coll_SB98.dat,
 'Br3': Atom Br3 from br_iii_atom_BH86.dat and br_iii_coll_S97.dat,
 'Br4': Atom Br4 from br_iv_atom_BH86.dat and br_iv_coll_S97.dat,
 'C1': Atom C1 from c_i_atom_FFS85.dat and c_i_coll_JBK87-PA76.dat,
 'C2': Atom C2 from c_ii_atom_GMZ98.dat and c_ii_coll_BP92.dat,
 'C3': Atom C3 from c_iii_atom_G83-NS78-WFD96.dat and c_iii_coll_Bal85.dat,
 'C4': Atom C4 from c_iv_atom_WFD96.dat and c_iv_coll_AK04.dat,
 'Ca5': Atom Ca5 from ca_v_atom_M83-KS86.dat and ca_v_coll_GMZ95.dat,
 'Cl2': Atom Cl2 from cl_ii_atom_MZ83.dat and cl_ii_coll_T04.dat,
 'Cl3': Atom Cl3 from cl_iii_atom_M83-KS86.dat and cl_iii_coll_BZ89.dat,
 'Cl4': Atom Cl4 from cl_iv_atom_KS86-MZ82-EM84.dat and cl_iv_coll_GMZ95.dat,
 'Fe3': Atom Fe3 from fe_iii_atom_Q96_J00.dat and fe_iii_coll_Z96.dat,
 'K4': Atom K4 from k_iv_atom_M83-KS86.dat and k_iv_coll_GMZ95.dat,
 'K5': Atom K5 from k_v_atom_M83-KS86.dat and k_v_coll_BZL88.dat,
 'Kr3': Atom Kr3 from kr_iii_atom_BH86.dat and kr_iii_coll_S97.dat,
 'Kr4': Atom Kr4 from kr_iv_atom_BH86.dat and kr_iv_coll_S97.dat,
 'Kr5': Atom Kr5 from kr_v_atom_BH86.dat and kr_v_coll_S97.dat,
 'Mg5': Atom Mg5 from mg_v_atom_GMZ97.dat and mg_v_coll_BZ94.dat,
 'Mg7': Atom Mg7 from mg_vii_atom_GMZ97.dat and mg_vii_coll_LB94-U.dat,
 'N1': Atom N1 from n_i_atom_KS86-WFD96.dat and n_i_coll_PA76-DMR76.dat,
 'N2': Atom N2 from n_ii_atom_GMZ97-WFD96.dat and n_ii_coll_T11.dat,
 'N3': Atom N3 from n_iii_atom_GMZ98.dat and n_iii_coll_BP92.dat,
 'N4': Atom N4 from n_iv_atom_WFD96.dat and n_iv_coll_RBHB94.dat,
 'Na4': Atom Na4 from na_iv_atom_GMZ97.dat and na_iv_coll_BZ94.dat,
 'Na6': Atom Na6 from na_vi_atom_GMZ97.dat and na_vi_coll_LB94.dat,
 'Ne2': Atom Ne2 from ne_ii_atom_Bal06.dat and ne_ii_coll_GMB01.dat,
 'Ne3': Atom Ne3 from ne_iii_atom_GMZ97.dat and ne_iii_coll_McLB00.dat,
 'Ne4': Atom Ne4 from ne_iv_atom_BBZ89-BK88.dat and ne_iv_coll_G81.dat,
 'Ne5': Atom Ne5 from ne_v_atom_GMZ97-U-BD93.dat and ne_v_coll_LB94.dat,
 'Ne6': Atom Ne6 from ne_vi_atom_GMZ98.dat and ne_vi_coll_ZGP94.dat,
 'Ni3': Atom Ni3 from ni_iii_atom_B01.dat and ni_iii_coll_B01.dat,
 'O1': Atom O1 from o_i_atom_WFD96.dat and o_i_coll_BK95.dat,
 'O2': Atom O2 from o_ii_atom_Z82-WFD96.dat and o_ii_coll_P06-T07.dat,
 'O3': Atom O3 from o_iii_atom_SZ00-WFD96.dat and o_iii_coll_Pal12-AK99.dat,
 'O4': Atom O4 from o_iv_atom_GMZ98.dat and o_iv_coll_BP92.dat,
 'O5': Atom O5 from o_v_atom_H80-NS79.dat and o_v_coll_BBDK85.dat,
 'Rb4': Atom Rb4 from rb_iv_atom_BH86.dat and rb_iv_coll_S97.dat,
 'Rb5': Atom Rb5 from rb_v_atom_BH86.dat and rb_v_coll_S97.dat,
 'Rb6': Atom Rb6 from rb_vi_atom_BH86.dat and rb_vi_coll_S97.dat,
 'S2': Atom S2 from s_ii_atom_PKW09.dat and s_ii_coll_TZ10.dat,
 'S3': Atom S3 from s_iii_atom_PKW09.dat and s_iii_coll_GMZ95.dat,
 'S4': Atom S4 from s_iv_atom_JKD86-DHKD82.dat and s_iv_coll_DHKD82.dat,
 'Se3': Atom Se3 from se_iii_atom_BH86.dat and se_iii_coll_S97.dat,
 'Se4': Atom Se4 from se_iv_atom_B05.dat and se_iv_coll_B05.dat,
 'Si2': Atom Si2 from si_ii_atom_BL93-CSB93-N77.dat and si_ii_coll_DK91.dat,
 'Si3': Atom Si3 from si_iii_atom_M83-OKH88-FW90-KS86.dat and si_iii_coll_DK94.dat,
 'Xe3': Atom Xe3 from xe_iii_atom_BHQZ95.dat and xe_iii_coll_SB98.dat,
 'Xe4': Atom Xe4 from xe_iv_atom_BHQZ95.dat and xe_iv_coll_SB98.dat,
 'Xe6': Atom Xe6 from xe_vi_atom_BHQZ95.dat and xe_vi_coll_SB98.dat}

In [27]:
# build only some atoms                       
atoms = pn.getAtomDict(atom_list=['O1', 'O2', 'O3', 'N2', 'N3'])

In [28]:
# explore some specific atom in the atoms collection
atoms['N2'].elem


Out[28]:
'N'

In [29]:
# if you want to be able to access them directly rather than through a dictionary:
for key in atoms.keys():
    vars()[key]=atoms[key]

In [30]:
# for example
O2.elem


Out[30]:
'O'

In [31]:
# list all atom features
dir(O2)


Out[31]:
['AtomData',
 'AtomHeader',
 'CollData',
 'EnergyNLevels',
 'NIST',
 'NLevels',
 '_A',
 '_Energy',
 '_StatWeight',
 '_Transition',
 '__class__',
 '__delattr__',
 '__dict__',
 '__doc__',
 '__format__',
 '__getattribute__',
 '__hash__',
 '__init__',
 '__module__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_getTemDen_1',
 '_getTemDen_MP',
 '_test_lev',
 'atom',
 'atomFile',
 'atomFileType',
 'atomFitsFile',
 'atomFitsPath',
 'atomNLevels',
 'atomPath',
 'calling',
 'collFile',
 'collFileType',
 'collFitsFile',
 'collFitsPath',
 'collNLevels',
 'collPath',
 'elem',
 'energy_Ryd',
 'energy_eV',
 'getA',
 'getCollRates',
 'getCritDensity',
 'getDensityRange',
 'getEmissivity',
 'getEnergy',
 'getHighDensRatio',
 'getIonAbundance',
 'getLowDensRatio',
 'getOmega',
 'getOmegaArray',
 'getPopulations',
 'getSources',
 'getStatWeight',
 'getTemArray',
 'getTemDen',
 'getTransition',
 'gs',
 'lineList',
 'log_',
 'name',
 'plotEmiss',
 'plotGrotrian',
 'plotGrotrian_bkp',
 'printIonic',
 'printSources',
 'printTemDen',
 'printTransition',
 'spec',
 'tem_units',
 'wave_Ang']

In [32]:
#######################################################################
# MAKING CALCULATIONS

# set temperature and density
tem = 15000.
den = 1000.

# compute populations
O2.getPopulations(tem, den)


Out[32]:
array([  9.73452672e-01,   2.06878141e-02,   5.85819178e-03,
         8.23867455e-07,   4.97864417e-07,   2.92747483e-19,
         1.86769357e-19,   9.15097829e-20])

In [33]:
# compute emissivity of transition (lev_i, lev_j)
O2.getEmissivity(tem, den, 3, 2)


Out[33]:
array(2.79566801999487e-27)

In [34]:
# also works if tem is an array
tem = np.array([10000, 20000, 30000])
print O2.getOmega(tem, 2, 1)
print O2.getCollRates(tem)
print O2.getPopulations(tem, den)


[ 0.883  0.885  0.888]
[[[  0.00000000e+00   0.00000000e+00   0.00000000e+00]
  [  4.02348947e-10   1.96201773e-09   3.05729835e-09]
  [  2.65795165e-10   1.29506046e-09   2.02248448e-09]
  [  1.99892345e-11   2.67251627e-10   5.84802421e-10]
  [  9.70445312e-12   1.29457409e-10   2.82538118e-10]
  [  8.96839926e-16   3.94650511e-12   5.52112835e-11]
  [  5.78080057e-16   2.57945263e-12   3.36414737e-11]
  [  2.85632308e-16   1.28345197e-12   1.97988347e-11]]

 [[  1.26992065e-08   9.00003412e-09   7.37340725e-09]
  [  0.00000000e+00   0.00000000e+00   0.00000000e+00]
  [  2.04495828e-08   1.34450801e-08   1.09499517e-08]
  [  1.90685065e-09   3.80720020e-09   4.44251634e-09]
  [  8.10078768e-10   1.62924843e-09   1.90190557e-09]
  [  9.42817655e-15   5.37417243e-12   4.08381064e-11]
  [  3.13031340e-15   1.80539043e-12   1.37728857e-11]
  [  6.40899379e-16   3.71833485e-13   2.84224001e-12]]

 [[  1.26201062e-08   8.92376265e-09   7.32358693e-09]
  [  3.07628571e-08   2.01966867e-08   1.64407054e-08]
  [  0.00000000e+00   0.00000000e+00   0.00000000e+00]
  [  1.83452287e-09   3.68305597e-09   4.29999680e-09]
  [  1.20346626e-09   2.41880382e-09   2.82969770e-09]
  [  2.66348533e-15   1.51603323e-12   1.15147424e-11]
  [  6.11391395e-15   3.52109027e-12   2.68486513e-11]
  [  4.30641232e-15   2.49487492e-12   1.90613009e-11]]

 [[  6.75229612e-09   4.91188303e-09   4.07281110e-09]
  [  2.04078982e-08   1.52542951e-08   1.28287322e-08]
  [  1.30515628e-08   9.82376606e-09   8.27017300e-09]
  [  0.00000000e+00   0.00000000e+00   0.00000000e+00]
  [  6.27589668e-09   4.72815457e-09   3.99769907e-09]
  [  1.56330473e-14   3.33604855e-12   1.82706770e-11]
  [  2.27202103e-14   4.90569440e-12   2.69725853e-11]
  [  1.50901700e-14   3.27761250e-12   1.80566897e-11]]

 [[  6.55814064e-09   4.75934008e-09   3.93580522e-09]
  [  1.73445562e-08   1.30576766e-08   1.09853804e-08]
  [  1.71288279e-08   1.29051337e-08   1.08857398e-08]
  [  1.25553877e-08   9.45766298e-09   7.99616124e-09]
  [  0.00000000e+00   0.00000000e+00   0.00000000e+00]
  [  1.31497361e-13   2.80571519e-11   1.53654447e-10]
  [  6.10983006e-14   1.31903130e-11   7.25197774e-11]
  [  2.28704412e-14   4.96679053e-12   2.73612320e-11]]

 [[  1.83944339e-08   1.45932757e-08   1.15334039e-08]
  [  6.12668402e-09   4.33221982e-09   3.53724267e-09]
  [  1.15055099e-09   8.13562407e-10   6.64270923e-10]
  [  9.49204566e-10   6.71188985e-10   5.48023512e-10]
  [  3.99097374e-09   2.82204460e-09   2.30418977e-09]
  [  0.00000000e+00   0.00000000e+00   0.00000000e+00]
  [  1.14758782e-08   8.21051421e-09   6.73014677e-09]
  [  4.54650503e-09   3.27218187e-09   2.68750980e-09]]

 [[  1.82074694e-08   1.44763261e-08   1.06241831e-08]
  [  3.12374594e-09   2.20882193e-09   1.80349556e-09]
  [  4.05569224e-09   2.86780748e-09   2.34155500e-09]
  [  2.11845201e-09   1.49797178e-09   1.22308884e-09]
  [  2.84761370e-09   2.01356696e-09   1.64407054e-09]
  [  1.76228457e-08   1.24612337e-08   1.01745547e-08]
  [  0.00000000e+00   0.00000000e+00   0.00000000e+00]
  [  7.64267936e-09   5.43633202e-09   4.44752899e-09]]

 [[  1.82074694e-08   1.44915804e-08   1.25547205e-08]
  [  1.29436986e-09   9.15257707e-10   7.47304789e-10]
  [  5.78151872e-09   4.08815109e-09   3.33796139e-09]
  [  2.84761370e-09   2.01356696e-09   1.64407054e-09]
  [  2.15728310e-09   1.52542951e-09   1.24550798e-09]
  [  1.41302043e-08   9.99156331e-09   8.15807728e-09]
  [  1.54677199e-08   1.09373296e-08   8.93029223e-09]
  [  0.00000000e+00   0.00000000e+00   0.00000000e+00]]]
[[  9.91510528e-01   9.54771880e-01   9.26853031e-01]
 [  6.52382507e-03   3.55526924e-02   5.80300307e-02]
 [  1.96540209e-03   9.67251526e-03   1.51110326e-02]
 [  1.52722031e-07   1.81470325e-06   3.68276302e-06]
 [  9.24915727e-08   1.09741196e-06   2.22248330e-06]
 [  1.11031751e-21   4.61530674e-18   6.23890714e-17]
 [  7.00138150e-22   2.96075896e-18   3.74403632e-17]
 [  3.41241993e-22   1.45647826e-18   2.16882451e-17]]

In [35]:
# tem and den can be arrays as well as single numbers
tem = np.array([10000, 12000, 13000]) 
den = np.array([100, 200, 300])
print O2.getPopulations(tem, den) # returns the n_tem x n_den x n_levels array of populations
print O2.getPopulations(tem, den, product=False) #  element-by-element multiplication of tem and den (no scalar product: returns [pop(tem_1, den_1), pop(tem_2, den_2), ... pop(tem_n, den_n)]


[[[  9.98814476e-01   9.97747175e-01   9.96772963e-01]
  [  9.97907387e-01   9.96013650e-01   9.94278945e-01]
  [  9.97405907e-01   9.95053836e-01   9.92896515e-01]]

 [[  1.01008493e-03   1.88979798e-03   2.66876864e-03]
  [  1.78472117e-03   3.35104230e-03   4.74572152e-03]
  [  2.21330225e-03   4.16149208e-03   5.89989095e-03]]

 [[  1.75423488e-04   3.62994400e-04   5.58214848e-04]
  [  3.07855374e-04   6.35228166e-04   9.75206697e-04]
  [  3.80739831e-04   7.84561820e-04   1.20341751e-03]]

 [[  9.46042099e-09   2.06242624e-08   3.32663143e-08]
  [  2.27603334e-08   4.93538457e-08   7.92928392e-08]
  [  3.17567799e-08   6.87002228e-08   1.10179853e-07]]

 [[  5.74293754e-09   1.24796872e-08   2.00952981e-08]
  [  1.38088802e-08   2.98524440e-08   4.78814254e-08]
  [  1.92610165e-08   4.15448885e-08   6.65188695e-08]]

 [[  1.05199547e-22   2.12219662e-22   3.20765635e-22]
  [  1.73857483e-21   3.50148439e-21   5.28486107e-21]
  [  5.10054414e-21   1.02642145e-20   1.54809732e-20]]

 [[  6.72404280e-23   1.35240220e-22   2.03924919e-22]
  [  1.11693946e-21   2.24328436e-21   3.37820409e-21]
  [  3.28358334e-21   6.59011724e-21   9.91772235e-21]]

 [[  3.30676779e-23   6.63814992e-23   9.99397367e-23]
  [  5.50498227e-22   1.10367440e-21   1.65962590e-21]
  [  1.61973590e-21   3.24523850e-21   4.87698469e-21]]]
[[  9.98814476e-01   9.96013650e-01   9.92896515e-01]
 [  1.01008493e-03   3.35104230e-03   5.89989095e-03]
 [  1.75423488e-04   6.35228166e-04   1.20341751e-03]
 [  9.46042099e-09   4.93538457e-08   1.10179853e-07]
 [  5.74293754e-09   2.98524440e-08   6.65188695e-08]
 [  1.05199547e-22   3.50148439e-21   1.54809732e-20]
 [  6.72404280e-23   2.24328436e-21   9.91772235e-21]
 [  3.30676779e-23   1.10367440e-21   4.87698469e-21]]

In [36]:
# find transition corresponding to given wavelength
N2.printTransition(6584)


Input wave: 6584.0
Closest wave found: 6583.5
Relative error: 8E-05 
Transition: 4 -> 3

In [37]:
# temperature determination from an intensity ratio
N2.getTemDen(0.01, den=1000., wave1=5755, wave2=6584)


Out[37]:
8588.005788908411

In [38]:
# same as above, by specifying the levels involved
N2.getTemDen(0.01, den=1000., lev_i1=5, lev_j1=4, lev_i2=4, lev_j2=3)


Out[38]:
8588.005788908411

In [39]:
# same as above, by specifying the levels involved
N2.getTemDen(0.01, den=1000., to_eval = 'L(5755) / L(6584)')


Out[39]:
8588.005788908411

In [40]:
# no formal difference between temperature and density diagnostics, so beware of what you do
print N2.getTemDen(0.01, tem=8782., wave1=5755, wave2=6584)
print N2.getTemDen(0.01, tem=8882., wave1=5755, wave2=6584)


nan
nan

In [41]:
# ionic abundance (intensity, temperature, density, transition)
O2.getIonAbundance(100, 1.5e4, 100., wave=3727)


Out[41]:
1.8390892170722003e-05

In [42]:
# printout as in old nebular
O2.printIonic() # only prints transitions and corresponding wavelengths. Useful for a quick glance at the atom.


elem = O
spec = 2

warng Atom O2: Cannot print populations as tem or den is missing
warng Atom O2: Cannot print critical densities as tem is missing
   3728.81A  
    (2-->1)  


   3726.03A      499.36m  
    (3-->1)      (3-->2)  


   2470.34A     7319.98A     7330.73A  
    (4-->1)      (4-->2)      (4-->3)  


   2470.22A     7318.92A     7329.66A     5023.75m  
    (5-->1)      (5-->2)      (5-->3)      (5-->4)  


    834.47A     1074.96A     1075.19A     1259.93A     1259.97A  
    (6-->1)      (6-->2)      (6-->3)      (6-->4)      (6-->5)  


    833.33A     1073.08A     1073.31A     1257.35A     1257.38A       61.25m  
    (7-->1)      (7-->2)      (7-->3)      (7-->4)      (7-->5)      (7-->6)  


    832.76A     1072.13A     1072.36A     1256.05A     1256.08A       40.70m      121.28m  
    (8-->1)      (8-->2)      (8-->3)      (8-->4)      (8-->5)      (8-->6)      (8-->7)  



In [43]:
O2.printIonic(tem=10000, den=100) # also prints line emissivities


elem = O
spec = 2
temperature = 10000.0 K
density =  100.0 cm-3

Level   Populations  Critical densities
Level 1:  9.988E-01  0.000E+00
Level 2:  1.010E-03  1.065E+03
Level 3:  1.754E-04  3.557E+03
Level 4:  9.460E-09  5.051E+06
Level 5:  5.743E-09  3.484E+06
Level 6:  1.052E-22  1.846E+16
Level 7:  6.724E-23  1.555E+16
Level 8:  3.307E-23  1.448E+16

   3728.81A  
    (2-->1)  
  2.055E-21  

   3726.03A      499.36m  
    (3-->1)      (3-->2)  
  1.543E-21    8.372E-28  

   2470.34A     7319.98A     7330.73A  
    (4-->1)      (4-->2)      (4-->3)  
  4.289E-23    3.003E-23    1.574E-23  

   2470.22A     7318.92A     7329.66A     5023.75m  
    (5-->1)      (5-->2)      (5-->3)      (5-->4)  
  1.071E-23    9.583E-24    1.587E-23    4.722E-37  

    834.47A     1074.96A     1075.19A     1259.93A     1259.97A  
    (6-->1)      (6-->2)      (6-->3)      (6-->4)      (6-->5)  
  2.156E-26    0.000E+00    0.000E+00    0.000E+00    0.000E+00  

    833.33A     1073.08A     1073.31A     1257.35A     1257.38A       61.25m  
    (7-->1)      (7-->2)      (7-->3)      (7-->4)      (7-->5)      (7-->6)  
  1.386E-26    0.000E+00    0.000E+00    0.000E+00    0.000E+00    0.000E+00  

    832.76A     1072.13A     1072.36A     1256.05A     1256.08A       40.70m      121.28m  
    (8-->1)      (8-->2)      (8-->3)      (8-->4)      (8-->5)      (8-->6)      (8-->7)  
  6.839E-27    0.000E+00    0.000E+00    0.000E+00    0.000E+00    0.000E+00    0.000E+00  

# H-beta volume emissivity:
1.235E-25 N(H+) * N(e-)  (erg/s)

In [44]:
O2.printIonic(tem=10000, den=100, printA=True, printPop=True, printCrit=True) # also prints populations and critical densities


elem = O
spec = 2
temperature = 10000.0 K
density =  100.0 cm-3

Level   Populations  Critical densities
Level 1:  9.988E-01  0.000E+00
Level 2:  1.010E-03  1.065E+03
Level 3:  1.754E-04  3.557E+03
Level 4:  9.460E-09  5.051E+06
Level 5:  5.743E-09  3.484E+06
Level 6:  1.052E-22  1.846E+16
Level 7:  6.724E-23  1.555E+16
Level 8:  3.307E-23  1.448E+16

3.820E-05    
   3728.81A  
    (2-->1)  
  2.055E-21  

1.650E-04    1.200E-07    
   3726.03A      499.36m  
    (3-->1)      (3-->2)  
  1.543E-21    8.372E-28  

5.640E-02    1.170E-01    6.140E-02    
   2470.34A     7319.98A     7330.73A  
    (4-->1)      (4-->2)      (4-->3)  
  4.289E-23    3.003E-23    1.574E-23  

2.320E-02    6.150E-02    1.020E-01    2.080E-11    
   2470.22A     7318.92A     7329.66A     5023.75m  
    (5-->1)      (5-->2)      (5-->3)      (5-->4)  
  1.071E-23    9.583E-24    1.587E-23    4.722E-37  

8.610E+08    0.000E+00    0.000E+00    0.000E+00    0.000E+00    
    834.47A     1074.96A     1075.19A     1259.93A     1259.97A  
    (6-->1)      (6-->2)      (6-->3)      (6-->4)      (6-->5)  
  2.156E-26    0.000E+00    0.000E+00    0.000E+00    0.000E+00  

8.650E+08    0.000E+00    0.000E+00    0.000E+00    0.000E+00    0.000E+00    
    833.33A     1073.08A     1073.31A     1257.35A     1257.38A       61.25m  
    (7-->1)      (7-->2)      (7-->3)      (7-->4)      (7-->5)      (7-->6)  
  1.386E-26    0.000E+00    0.000E+00    0.000E+00    0.000E+00    0.000E+00  

8.670E+08    0.000E+00    0.000E+00    0.000E+00    0.000E+00    0.000E+00    0.000E+00    
    832.76A     1072.13A     1072.36A     1256.05A     1256.08A       40.70m      121.28m  
    (8-->1)      (8-->2)      (8-->3)      (8-->4)      (8-->5)      (8-->6)      (8-->7)  
  6.839E-27    0.000E+00    0.000E+00    0.000E+00    0.000E+00    0.000E+00    0.000E+00  

# H-beta volume emissivity:
1.235E-25 N(H+) * N(e-)  (erg/s)

In [45]:
# Compute Hb emissivity at T=10000K
H1 = pn.RecAtom('H', 1)
H1.getEmissivity(10000, 1e2, 4, 2)


Out[45]:
array(1.235e-25)

In [46]:
# simultaneously compute temperature and density from pairs of line ratios
# First of all, a Diagnostics object must be created and initialized with the relevant diagnostics.
diags = pn.Diagnostics()   # this creates the object
diags.getAllDiags()  # see what Diagnostics exist
tem, den = diags.getCrossTemDen('[NII] 5755/6548', '[SII] 6731/6716', 0.050, 1.0)

In [47]:
#TO BE CONTINUED FROM HERE
print tem, den


10526.7510913 507.170474716

In [47]: