Skip to content

Commit

Permalink
Remove re library
Browse files Browse the repository at this point in the history
  • Loading branch information
danehkar committed Sep 12, 2020
1 parent 53119ac commit 40e8639
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 30 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ install:
- pip install --quiet coverage
- pip install --quiet numpy
- pip install --quiet pandas
- pip install --quiet regex
- pip install --quiet astropy
- python setup.py install

Expand Down
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ Dependent Python Packages
- `NumPy <https://numpy.org/>`_
- `pandas <https://pandas.pydata.org/>`_
- `Astropy <https://www.astropy.org/>`_
- `regex <https://pypi.org/project/regex/>`_

* To get this package with all the FITS file, you can simply use ``git`` command as follows::

Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ install:
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
- pip install numpy pandas regex astropy nose
- "conda create -q -n test-environment python=%PYTHON_VERSION% numpy pandas regex astropy nose"
- pip install numpy pandas astropy nose
- "conda create -q -n test-environment python=%PYTHON_VERSION% numpy pandas astropy nose"
- activate test-environment
- pip install coverage

Expand Down
70 changes: 45 additions & 25 deletions atomneb/atomneb.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import numpy as np
import pandas as pd

try:
import regex as re
except ImportError:
import re
#try:
# import regex as re
#except ImportError:
# import re

__all__ = ["read_aij","read_aij_list","search_aij","read_aij_references","list_aij_references",
"get_aij_reference_citation",
Expand All @@ -43,7 +43,6 @@
"read_aeff_o_ii_ssb17_references","list_aeff_o_ii_ssb17_references",
"get_aeff_o_ii_ssb17_reference_citation"]


def read_aij(atom_aij_file, atom, ion, reference=None, level_num=None):
"""
This function returns the transition probabilities (Aij) from the table extensions
Expand Down Expand Up @@ -120,7 +119,8 @@ def read_aij(atom_aij_file, atom, ion, reference=None, level_num=None):
else:
atom_ion_name = atom.lower() + '_' + ion.lower() + '_aij'
aij_list=np.asarray(element_data_list.aij_data)
aij_res = [x for x in aij_list if re.search(atom_ion_name, x)]
#aij_res = [x for x in aij_list if re.search(atom_ion_name, x)]
aij_res = [x for x in aij_list if atom_ion_name in x]
iii = np.where(aij_list == aij_res[0])[0] #
if len(iii) == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -248,7 +248,8 @@ def search_aij(atom_aij_file, atom, ion):
element_data_list = read_aij_list(atom_aij_file)
atom_ion_name = atom.lower() + '_' + ion.lower() + '_aij_'
aij_list = np.asarray(element_data_list.aij_data)
aij_res = [x for x in aij_list if re.search(atom_ion_name, x)]
#aij_res = [x for x in aij_list if re.search(atom_ion_name, x)]
aij_res = [x for x in aij_list if atom_ion_name in x]
if len(aij_res) == 0:
print('could not find the given element or ion')
return 0
Expand Down Expand Up @@ -362,7 +363,8 @@ def list_aij_references(atom_aij_file, atom, ion):

atom_ion_name = atom.lower() + '_' + ion.lower() + '_aij_'
aij_list = np.asarray(element_data_list.aij_data)
aij_res = [x for x in aij_list if re.search(atom_ion_name, x)]
#aij_res = [x for x in aij_list if re.search(atom_ion_name, x)]
aij_res = [x for x in aij_list if atom_ion_name in x]
ii_length = len(aij_res)
if ii_length == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -782,7 +784,8 @@ def read_omij(atom_omij_file, atom, ion, reference=None, level_num=None):
else:
atom_ion_name = atom.lower() + '_' + ion.lower() + '_omij'
omij_list=np.asarray(element_data_list.omij_data)
omij_res = [x for x in omij_list if re.search(atom_ion_name, x)]
#omij_res = [x for x in omij_list if re.search(atom_ion_name, x)]
omij_res = [x for x in omij_list if atom_ion_name in x]
iii = np.where(omij_list == omij_res[0])[0] #
if len(iii) == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -929,7 +932,8 @@ def search_omij(atom_omij_file, atom, ion):
element_data_list = read_omij_list(atom_omij_file)
atom_ion_name = atom.lower() + '_' + ion.lower() + '_omij_'
omij_list = np.asarray(element_data_list.omij_data)
omij_res = [x for x in omij_list if re.search(atom_ion_name, x)]
#omij_res = [x for x in omij_list if re.search(atom_ion_name, x)]
omij_res = [x for x in omij_list if atom_ion_name in x]
if len(omij_res) == 0:
print('could not find the given element or ion')
return 0
Expand Down Expand Up @@ -1042,7 +1046,8 @@ def list_omij_references(atom_omij_file, atom, ion):
element_data_list = read_omij_list(atom_omij_file)
atom_ion_name = atom.lower() + '_' + ion.lower() + '_omij_'
omij_list = np.asarray(element_data_list.omij_data)
omij_res = [x for x in omij_list if re.search(atom_ion_name, x)]
#omij_res = [x for x in omij_list if re.search(atom_ion_name, x)]
omij_res = [x for x in omij_list if atom_ion_name in x]
ii_length = len(omij_res)
if ii_length == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -1252,7 +1257,8 @@ def read_aeff_collection(atom_rc_file, atom, ion, br=None, reference=None):
else:
atom_ion_name = atom.lower() + '_' + ion.lower() + prefix
aeff_list=np.asarray(element_data_list.aeff_data)
aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
#aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
aeff_res = [x for x in aeff_list if atom_ion_name in x]
iii = np.where(aeff_list == aeff_res[0])[0] #
if len(iii) == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -1505,7 +1511,8 @@ def search_aeff_collection(atom_rc_file, atom, ion, br=None):
element_data_list = read_aeff_collection_list(atom_rc_file)
atom_ion_name = atom.lower() + '_' + ion.lower() + prefix
aeff_list = np.asarray(element_data_list.aeff_data)
aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
#aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
aeff_res = [x for x in aeff_list if atom_ion_name in x]
if len(aeff_res) == 0:
print('could not find the given element or ion')
return 0
Expand Down Expand Up @@ -1626,7 +1633,8 @@ def list_aeff_collection_references(atom_rc_file, atom, ion, br=None):
prefix = '_aeff'
atom_ion_name = atom.lower() + '_' + ion.lower() + prefix
aeff_list = np.asarray(element_data_list.aeff_data)
aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
#aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
aeff_res = [x for x in aeff_list if atom_ion_name in x]
ii_length = len(aeff_res)
if ii_length == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -1797,7 +1805,8 @@ def read_aeff_sh95(atom_rc_file, atom, ion, reference=None, case1=None):
else:
atom_ion_name = atom_ion_name + '_b'
aeff_list = np.asarray(element_data_list.aeff_data)
aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
#aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
aeff_res = [x for x in aeff_list if atom_ion_name in x]
iii = np.where(aeff_list == aeff_res[0])[0] #
if len(iii) == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -1920,7 +1929,8 @@ def search_aeff_sh95(atom_rc_file, atom, ion):
element_data_list = read_aeff_sh95_list(atom_rc_file)
atom_ion_name = atom.lower() + '_' + ion.lower() + '_aeff'
aeff_list = np.asarray(element_data_list.aeff_data)
aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
#aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
aeff_res = [x for x in aeff_list if atom_ion_name in x]
if len(aeff_res) == 0:
print('could not find the given element or ion')
return 0
Expand Down Expand Up @@ -2032,7 +2042,8 @@ def list_aeff_sh95_references(atom_rc_file, atom, ion):
element_data_list = read_aeff_sh95_list(atom_rc_file)
atom_ion_name = atom.lower() + '_' + ion.lower() + '_aeff'
aeff_list = np.asarray(element_data_list.aeff_data)
aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
#aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
aeff_res = [x for x in aeff_list if atom_ion_name in x]
ii_length = len(aeff_res)
if ii_length == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -2205,7 +2216,8 @@ def read_aeff_ppb91(atom_rc_file, atom, ion, reference=None):
else:
atom_ion_name = atom.lower() + '_' + ion.lower() + '_aeff'
aeff_list = np.asarray(element_data_list.aeff_data)
aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
#aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
aeff_res = [x for x in aeff_list if atom_ion_name in x]
iii = np.where(aeff_list == aeff_res[0])[0] #
if len(iii) == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -2347,7 +2359,8 @@ def search_aeff_ppb91(atom_rc_file, atom, ion):
element_data_list = read_aeff_ppb91_list(atom_rc_file)
atom_ion_name = atom.lower() + '_' + ion.lower() + '_aeff'
aeff_list = np.asarray(element_data_list.aeff_data)
aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
#aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
aeff_res = [x for x in aeff_list if atom_ion_name in x]
if len(aeff_res) == 0:
print('could not find the given element or ion')
return 0
Expand Down Expand Up @@ -2459,7 +2472,8 @@ def list_aeff_ppb91_references(atom_rc_file, atom, ion):
element_data_list = read_aeff_ppb91_list(atom_rc_file)
atom_ion_name = atom.lower() + '_' + ion.lower() + '_aeff'
aeff_list = np.asarray(element_data_list.aeff_data)
aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
#aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
aeff_res = [x for x in aeff_list if atom_ion_name in x]
ii_length = len(aeff_res)
if ii_length == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -2632,7 +2646,8 @@ def read_aeff_he_i_pfsd12(atom_rc_file, atom, ion, wavelength=None, reference=No
else:
atom_ion_name = atom.lower() + '_' + ion.lower() + prefix + '_' + reference.upper()
aeff_list=np.asarray(element_data_list.aeff_data)
aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
#aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
aeff_res = [x for x in aeff_list if atom_ion_name in x]
iii = np.where(aeff_list == aeff_res[0])[0] #
if len(iii) == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -2771,7 +2786,8 @@ def search_aeff_he_i_pfsd12(atom_rc_file, atom, ion):
element_data_list = read_aeff_he_i_pfsd12_list(atom_rc_file)
atom_ion_name = atom.lower() + '_' + ion.lower() + '_aeff'
aeff_list = np.asarray(element_data_list.aeff_data)
aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
#aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
aeff_res = [x for x in aeff_list if atom_ion_name in x]
if len(aeff_res) == 0:
print('could not find the given element or ion')
return 0
Expand Down Expand Up @@ -2883,7 +2899,8 @@ def list_aeff_he_i_pfsd12_references(atom_rc_file, atom, ion):
element_data_list = read_aeff_he_i_pfsd12_list(atom_rc_file)
atom_ion_name = atom.lower() + '_' + ion.lower()+ '_aeff'
aeff_list = np.asarray(element_data_list.aeff_data)
aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
#aeff_res = [x for x in aeff_list if re.search(atom_ion_name, x)]
aeff_res = [x for x in aeff_list if atom_ion_name in x]
ii_length = len(aeff_res)
if ii_length == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -3330,7 +3347,8 @@ def list_aeff_n_ii_fsl13_references(atom_rc_file, atom, ion):

atom_ion_name = atom.lower() + '_' + ion.lower() + '_aeff'
rc_list = np.asarray(rc_reference_data.reference)
rc_res = [x for x in rc_list if re.search(atom_ion_name, x)]
#rc_res = [x for x in rc_list if re.search(atom_ion_name, x)]
rc_res = [x for x in rc_list if atom_ion_name in x]
ii_length = len(rc_res)
if ii_length == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -3777,7 +3795,8 @@ def list_aeff_o_ii_ssb17_references(atom_rc_file, atom, ion):

atom_ion_name = atom.lower() + '_' + ion.lower() + '_aeff'
rc_list = np.asarray(rc_reference_data.reference)
rc_res = [x for x in rc_list if re.search(atom_ion_name, x)]
#rc_res = [x for x in rc_list if re.search(atom_ion_name, x)]
rc_res = [x for x in rc_list if atom_ion_name in x]
ii_length = len(rc_res)
if ii_length == 0:
print('could not find the given element or ion')
Expand Down Expand Up @@ -3863,3 +3882,4 @@ def get_aeff_o_ii_ssb17_reference_citation(atom_rc_file, atom, ion, reference=No
citation = np.asarray(element_data_reference.citation[ii])

return citation

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
platforms=['any'],
packages=['atomneb'],
package_data={'atomneb': ['*.txt', 'text/*.readme']},
install_requires=['numpy','pandas','astropy','regex'],
install_requires=['numpy','pandas','astropy'],
)

0 comments on commit 40e8639

Please sign in to comment.