Skip to content

Commit d7590b3

Browse files
committed
Transferred latest version from IDL to Python
1 parent 480208e commit d7590b3

23 files changed

+7439
-59
lines changed

.coveragerc

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
[report]
33
omit =
44
*/__init__.py
5-
*/orl.py

.coveralls.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11

2+

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ before_install:
66

77
python:
88
- 2.7
9-
- 3.4
10-
- 3.5
9+
- 3.8
1110

1211
install:
1312
- pip install --quiet coveralls
1413
- pip install --quiet nose
1514
- pip install --quiet coverage
15+
- pip install --quiet numpy
1616
- pip install --quiet scipy
17+
- pip install --quiet astropy
1718
- python setup.py install
1819

1920
script:

AUTHORS.rst

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Author:
2+
3+
* Ashkbiz Danehkar (`@danehkar <https://github.com/danehkar>`_)

CONTRIBUTING.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contributing to pyEQUIB
2+
3+
The following guidelines are designed for contributors to the pyEQUIB Python package, which is
4+
hosted in the [pyEQUIB repository](https://github.com/equib/pyEQUIB) on GitHub.
5+
6+
## Reporting Issues
7+
8+
The [issue tracker](https://github.com/equib/pyEQUIB/issues) is used to report bugs, request new functionality, and discuss improvements.
9+
For reporting a bug or a failed function or requesting a new feature, you can simply open an issue
10+
in the [issue tracker](https://github.com/equib/pyEQUIB/issues) of the
11+
[pyEQUIB repository](https://github.com/equib/pyEQUIB). If you are reporting a bug, please also include a minimal code
12+
example that reproduces the problem, and Python version you are using.
13+
14+
## Contributing Code
15+
16+
Fo contributing code to pyEQUIB, you need to set up your [GitHub](https://github.com)
17+
account if you do not have and sign in, and request your change(s) or contribution via
18+
opening a pull request against the ``master``
19+
branch in your fork of the [pyEQUIB repository](https://github.com/equib/pyEQUIB).
20+
21+
To contribute to this package, you need to follow these steps:
22+
23+
- Open a new issue for new feature or failed function in the [Issue tracker](https://github.com/equib/pyEQUIB/issues).
24+
- Fork the [pyEQUIB repository](https://github.com/equib/pyEQUIB) to your GitHub account.
25+
- Clone your fork of the [pyEQUIB repository](https://github.com/equib/pyEQUIB):
26+
27+
$ git clone [email protected]:your-username/pyEQUIB.git
28+
29+
- Make your change(s) in the `master` branch of your cloned fork.
30+
- Make sure that it passes all tests and there is no error.
31+
- Push yout change(s) to your fork in your GitHub account.
32+
- [Submit a pull request][pr], mentioning what issue has been addressed.
33+
34+
[pr]: https://github.com/equib/pyEQUIB/compare/
35+
36+
Then, you are waiting, until your contribution is checked and merged into the original repository.
37+
We will contact you if there is a problem in your code.
38+
39+
While you are opening a pull request for your contribution, be sure that you have included:
40+
41+
* **Code** which you are contributing to this package.
42+
43+
* **Documentation** of this code if it provides new functionality. This should be a
44+
description of new functionality added to the API documentation (in ``docs/``).
45+
46+
- **Tests** of this code to make sure that the previously failed function or the new functionality now works properly.
47+
48+
- **Revision history** if you fixed a bug in the previously failed function or add a code for new functionality, you should
49+
well document your change(s) or addition in the *Revision History* entry of the changed or added function in your code.

README.rst

+850-18
Large diffs are not rendered by default.

appveyor.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ environment:
22
matrix:
33
- PYTHON_VERSION: 2.7
44
MINICONDA: C:\Miniconda
5-
- PYTHON_VERSION: 3.6
5+
- PYTHON_VERSION: 3.8
66
MINICONDA: C:\Miniconda3
77

88
matrix:
@@ -19,8 +19,8 @@ install:
1919
- conda config --set always_yes yes --set changeps1 no
2020
- conda update -q conda
2121
- conda info -a
22-
- pip install numpy scipy nose
23-
- "conda create -q -n test-environment python=%PYTHON_VERSION% numpy scipy nose"
22+
- pip install numpy scipy astropy nose
23+
- "conda create -q -n test-environment python=%PYTHON_VERSION% numpy scipy astropy nose"
2424
- activate test-environment
2525
- pip install coverage
2626

examples/cel_abundance_example.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Example: calc_abundance()
2+
# determine ionic abundance from observed
3+
# flux intensity for gievn electron density
4+
# and temperature using calc_abundance function
5+
# from proEQUIB
6+
#
7+
# --- Begin MAIN program. ---------------
8+
#
9+
#
10+
import pyequib
11+
import atomneb
12+
import os
13+
import numpy as np
14+
15+
# Locate datasets
16+
base_dir = '/home/danehkar/github/AtomNeb-py/'
17+
data_dir = os.path.join('atomic-data', 'chianti70')
18+
data_rc_dir = os.path.join('atomic-data-rc')
19+
atom_elj_file = os.path.join(base_dir,data_dir, 'AtomElj.fits')
20+
atom_omij_file = os.path.join(base_dir,data_dir, 'AtomOmij.fits')
21+
atom_aij_file = os.path.join(base_dir,data_dir, 'AtomAij.fits')
22+
atom_rc_sh95_file = os.path.join(base_dir,data_rc_dir, 'rc_SH95.fits')
23+
24+
atom = 'h'
25+
ion = 'ii' # H I Rec
26+
hi_rc_data = atomneb.read_aeff_sh95(atom_rc_sh95_file, atom, ion)
27+
28+
atom = 'o'
29+
ion = 'iii' # [O III]
30+
o_iii_elj = atomneb.read_elj(atom_elj_file, atom, ion, level_num=5) # read Energy Levels (Ej)
31+
o_iii_omij = atomneb.read_omij(atom_omij_file, atom, ion) # read Collision Strengths (Omegaij)
32+
o_iii_aij = atomneb.read_aij(atom_aij_file, atom, ion) # read Transition Probabilities (Aij)
33+
34+
levels5007 = '3,4/'
35+
temperature = np.float64(10000.0,)
36+
density = np.float64(5000.0)
37+
iobs5007 = np.float64(1200.0)
38+
abb5007 = np.float64(0.0)
39+
40+
emis = pyequib.calc_emissivity(temperature=temperature, density=density, atomic_levels=levels5007, elj_data=o_iii_elj, omij_data=o_iii_omij, aij_data=o_iii_aij)
41+
print('Emissivity(O III 5007):', emis)
42+
43+
abb5007 = pyequib.calc_abundance(temperature=temperature, density=density, line_flux=iobs5007, atomic_levels=levels5007,
44+
elj_data=o_iii_elj, omij_data=o_iii_omij, aij_data=o_iii_aij, h_i_aeff_data=hi_rc_data.aeff)
45+
print('N(O^2+)/N(H+):', abb5007)
46+
47+
nlj = pyequib.calc_populations(temperature=temperature, density=density, elj_data=o_iii_elj, omij_data=o_iii_omij, aij_data=o_iii_aij)
48+
print('Atomic Level Populations:', nlj)
49+
50+
51+
n_crit = pyequib.calc_crit_density(temperature=temperature, elj_data=o_iii_elj, omij_data=o_iii_omij, aij_data=o_iii_aij)
52+
print('Critical Densities:', n_crit)
53+
54+
temperature = np.float64(10000.0)
55+
omij_t = pyequib.get_omij_temp(temperature=temperature, omij_data=o_iii_omij, level_num=8)
56+
print('Effective Collision Strengths: ')
57+
print(omij_t)
58+
59+
pyequib.print_ionic(temperature=temperature, density=density,
60+
elj_data=o_iii_elj, omij_data=o_iii_omij, aij_data=o_iii_aij,
61+
h_i_aeff_data=hi_rc_data.aeff)
62+
#
63+
# --- End MAIN program. ---------------
64+

examples/cel_diagnostics_example.py

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Example: calc_temperature() and calc_density()
2+
# determine electron density or temperature from given
3+
# flux intensity ratio for a fixed electron density
4+
# or temperature using calc_temperature function
5+
# calc_density function from proEQUIB
6+
#
7+
# --- Begin MAIN program. ---------------
8+
#
9+
#
10+
import pyequib
11+
import atomneb
12+
import os
13+
import numpy as np
14+
15+
# Locate datasets
16+
base_dir = '/home/danehkar/github/AtomNeb-py/'
17+
data_dir = os.path.join('atomic-data', 'chianti70')
18+
data_rc_dir = os.path.join('atomic-data-rc')
19+
atom_elj_file = os.path.join(base_dir,data_dir, 'AtomElj.fits')
20+
atom_omij_file = os.path.join(base_dir,data_dir, 'AtomOmij.fits')
21+
atom_aij_file = os.path.join(base_dir,data_dir, 'AtomAij.fits')
22+
atom_rc_sh95_file = os.path.join(base_dir,data_rc_dir, 'rc_SH95.fits')
23+
24+
25+
atom = 'h'
26+
ion = 'ii' # H I Rec
27+
hi_rc_data = atomneb.read_aeff_sh95(atom_rc_sh95_file, atom, ion)
28+
29+
atom = 's'
30+
ion = 'ii'
31+
s_ii_elj = atomneb.read_elj(atom_elj_file, atom, ion, level_num=5) # read Energy Levels (Ej)
32+
s_ii_omij = atomneb.read_omij(atom_omij_file, atom, ion) # read Collision Strengths (Omegaij)
33+
s_ii_aij = atomneb.read_aij(atom_aij_file, atom, ion) # read Transition Probabilities (Aij)\
34+
35+
upper_levels = '1,2,1,3/'
36+
lower_levels = '1,5/'
37+
density = np.float64(2550)
38+
line_flux_ratio = np.float64(10.753)
39+
temperature = pyequib.calc_temperature(line_flux_ratio=line_flux_ratio, density=density, upper_levels=upper_levels, lower_levels=lower_levels, elj_data=s_ii_elj, omij_data=s_ii_omij, aij_data=s_ii_aij)
40+
print("Electron Temperature:", temperature)
41+
42+
upper_levels = '1,2/'
43+
lower_levels = '1,3/'
44+
temperature = np.float64(7000.0)
45+
line_flux_ratio = np.float64(1.506)
46+
density = pyequib.calc_density(line_flux_ratio=line_flux_ratio, temperature=temperature, upper_levels=upper_levels, lower_levels=lower_levels, elj_data=s_ii_elj, omij_data=s_ii_omij, aij_data=s_ii_aij)
47+
print("Electron Density:", density)
48+
49+
density = np.float64(1000)
50+
temperature = np.float64(10000.0)
51+
nlj = pyequib.calc_populations(temperature=temperature, density=density, elj_data=s_ii_elj, omij_data=s_ii_omij, aij_data=s_ii_aij)
52+
print('Atomic Level Populations:', nlj)
53+
54+
temperature = np.float64(10000.0)
55+
n_crit = pyequib.calc_crit_density(temperature=temperature, elj_data=s_ii_elj, omij_data=s_ii_omij, aij_data=s_ii_aij)
56+
print('Critical Densities:', n_crit)
57+
58+
temperature = np.float64(10000.0)
59+
omij_t = pyequib.get_omij_temp(temperature=temperature, omij_data=s_ii_omij)
60+
print('Effective Collision Strengths: ')
61+
print(omij_t)
62+
63+
pyequib.print_ionic(temperature=temperature, density=density,
64+
elj_data=s_ii_elj, omij_data=s_ii_omij, aij_data=s_ii_aij,
65+
h_i_aeff_data=hi_rc_data.aeff)
66+
67+
# --- End MAIN program. ---------------

0 commit comments

Comments
 (0)