Skip to content

Commit

Permalink
Merge pull request #31 from Morisset/devel
Browse files Browse the repository at this point in the history
1.1.18
  • Loading branch information
Morisset authored Aug 8, 2023
2 parents 26b62ee + 9f6fe24 commit 550a5f0
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 32 deletions.
6 changes: 4 additions & 2 deletions pyneb/core/diags.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from pyneb.utils.misc import int_to_roman, parseAtom, parseAtom2
from pyneb.utils.init import BLEND_LIST
from pyneb import config
if config.INSTALLED['ai4neb']:
from ai4neb import manage_RM

diags_dict = {}

Expand Down Expand Up @@ -778,6 +776,10 @@ def B(label, I=I, L=L):
else:
if type(value_den) == type([]): value_den = np.asarray(value_den)
if use_ANN:

if config.INSTALLED['ai4neb']:
from ai4neb import manage_RM

if not config.INSTALLED['ai4neb']:
self.log_.error('_getPopulations_ANN cannot be used in absence of ai4neb package',
calling=self.calling)
Expand Down
33 changes: 16 additions & 17 deletions pyneb/core/icf.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,26 +402,25 @@ def _init_all_icfs(self):
# Wrong comment. Corrected 26 Dec 2014
# 'comment': 'Based on a grid of photoionization models. To be used if both O4 and N5 detected'},
'comment': 'Based on a grid of photoionization models. Valid if both S2 and S3 detected. He2 detected, He3 not.'},
# Added 26 Dec 2014
# 26 Dec 2014 These icfs are temporarily commented out because they must be still be checked.
# 'KB94_A38.6':{'elem': 'S',
# 'atom': 'abun["S2"]',
# 'icf': '((1 - (1 - abun["O2"]/elem_abun["KB94_A6"])**3)**(-1./3.)*(5.677 + (abun["O3"]/abun["O2"])**(0.433))',
# 'type': 'PNe',
# 'comment': 'Based on a grid of photoionization models and the S3/S2 ratio of a sample of PNe. Valid if S2 is detected but S3 is not detected'},
# June 2023, after talking with L. Stanghellini, it appears there is a typo in KB94_A38, 4.677 + instead of 4.677 *
'KB94_A38.6':{'elem': 'S',
'atom': 'abun["S2"]',
'icf': '((1 - (1 - abun["O2"]/elem_abun["KB94_A6"])**3)**(-1./3.)) * (4.677 * (abun["O3"]/abun["O2"])**(0.433))',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models and the S3/S2 ratio of a sample of PNe. Valid if S2 is detected but S3 is not detected'},
# Added 26 Dec 2014
# 'KB94_A38.8':{'elem': 'S',
# 'atom': 'abun["S2"]',
# 'icf': '((1 - (1 - abun["O2"]/elem_abun["KB94_A8"])**3)**(-1./3.)*(5.677 + (abun["O3"]/abun["O2"])**(0.433))',
# 'type': 'PNe',
# 'comment': 'BBased on a grid of photoionization models and the S3/S2 ratio of a sample of PNe. Valid if S2 is detected but S3 is not detected'},
'KB94_A38.8':{'elem': 'S',
'atom': 'abun["S2"]',
'icf': '((1 - (1 - abun["O2"]/elem_abun["KB94_A8"])**3)**(-1./3.)) * (4.677 * (abun["O3"]/abun["O2"])**(0.433))',
'type': 'PNe',
'comment': 'BBased on a grid of photoionization models and the S3/S2 ratio of a sample of PNe. Valid if S2 is detected but S3 is not detected'},
# Added 26 Dec 2014
# 'KB94_A38.10':{'elem': 'S',
# 'atom': 'abun["S2"]',
# 'icf': '((1 - (1 - abun["O2"]/elem_abun["KB94_A10"])**3)**(-1./3.)*(5.677 + (abun["O3"]/abun["O2"])**(0.433))',
# 'type': 'PNe',
# 'comment': 'Based on a grid of photoionization models and the S3/S2 ratio of a sample of PNe. Valid if S2 is detected but S3 is not detected'},
# end commented block
'KB94_A38.10':{'elem': 'S',
'atom': 'abun["S2"]',
'icf': '((1 - (1 - abun["O2"]/elem_abun["KB94_A10"])**3)**(-1./3.)) * (4.677 * (abun["O3"]/abun["O2"])**(0.433))',
'type': 'PNe',
'comment': 'Based on a grid of photoionization models and the S3/S2 ratio of a sample of PNe. Valid if S2 is detected but S3 is not detected'},
'KH01_4a': {'elem': 'He',
'atom': 'abun["He2"] + abun["He3"]',
'icf': '1',
Expand Down
8 changes: 4 additions & 4 deletions pyneb/core/pynebcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2581,7 +2581,7 @@ def printIonic(self, tem=None, den=None, printA=False, printPop=True, printCrit=
for i in range(1, self.NLevels):
if printA:
for j in range(i):
to_print = "{0:.3E} ".format(np.float(self.getA(i + 1, j + 1)))
to_print = "{0:.3E} ".format(np.float64(self.getA(i + 1, j + 1)))
print(to_print, end="")
print("")
for j in range(i):
Expand Down Expand Up @@ -3417,8 +3417,8 @@ def _loadTotRecombination(self):
f = open(self.TotRecFile)
data = f.readlines()
f.close()
den_points = [np.float(d) for d in data[0].split()]
tem_points = [np.float(d) for d in data[1].split()]
den_points = [np.float64(d) for d in data[0].split()]
tem_points = [np.float64(d) for d in data[1].split()]
self.alpha_grid = np.array([d.split() for d in data if d[0:3]!='***'][2::], dtype='float')
self.lg_den_grid, self.lg_tem_grid = np.meshgrid(np.log10(den_points), np.log10(tem_points))

Expand Down Expand Up @@ -4933,7 +4933,7 @@ def __normalize(self, label='H1_4861A'):
"""
if "=" in label:
line_label, factor = label.split('=')
factor = np.float(factor)
factor = np.float64(factor)
else:
line_label = label
factor = 1.
Expand Down
15 changes: 9 additions & 6 deletions pyneb/utils/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,8 @@ def __init__(self):
self.INSTALLED['cvxopt'] = True
except:
self.INSTALLED['cvxopt'] = False
try:
from ai4neb import manage_RM
self.INSTALLED['ai4neb'] = True
except:
self.INSTALLED['ai4neb'] = False


self.INSTALLED['ai4neb'] = False
self.DataFiles = {}

self.unuse_multiprocs()
Expand All @@ -118,6 +114,13 @@ def __init__(self):
self.vactoair_low_wl = 2000. # UV in vacuum
self.vactoair_high_wl = 1e30 # no upper limit, IR in air!!!

def import_ai4neb(self):
try:
from ai4neb import manage_RM
self.INSTALLED['ai4neb'] = True
except:
self.INSTALLED['ai4neb'] = False

def set_noExtrapol(self, value):
self._noExtrapol = bool(value)

Expand Down
4 changes: 2 additions & 2 deletions pyneb/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,10 @@ def get_reduced(N_rand, a, value_method = 'original', error_method='std'):
# error = (quants[1]-quants[0])/2)
elif error_method == 'upper':
mask = (a - value) >= 0
error = ((((a[mask] - value)**2).sum())/np.float(mask.sum()))**0.5
error = ((((a[mask] - value)**2).sum())/np.float64(mask.sum()))**0.5
elif error_method == 'lower':
mask = (a - value) <= 0
error = -((((a[mask] - value)**2).sum())/np.float(mask.sum()))**0.5
error = -((((a[mask] - value)**2).sum())/np.float64(mask.sum()))**0.5
elif error_method == 'std':
error = a.std()
else:
Expand Down
2 changes: 1 addition & 1 deletion pyneb/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# PyNeb version
__version__ = '1.1.17'
__version__ = '1.1.18'

0 comments on commit 550a5f0

Please sign in to comment.