diff --git a/pyneb/core/diags.py b/pyneb/core/diags.py index 8222ad3..30c7a3b 100644 --- a/pyneb/core/diags.py +++ b/pyneb/core/diags.py @@ -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 = {} @@ -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) diff --git a/pyneb/core/icf.py b/pyneb/core/icf.py index 9508380..226ec04 100644 --- a/pyneb/core/icf.py +++ b/pyneb/core/icf.py @@ -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', diff --git a/pyneb/core/pynebcore.py b/pyneb/core/pynebcore.py index 383c1d9..df846c2 100755 --- a/pyneb/core/pynebcore.py +++ b/pyneb/core/pynebcore.py @@ -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): @@ -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)) @@ -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. diff --git a/pyneb/utils/Config.py b/pyneb/utils/Config.py index 2f7dcdf..5407840 100644 --- a/pyneb/utils/Config.py +++ b/pyneb/utils/Config.py @@ -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() @@ -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) diff --git a/pyneb/utils/misc.py b/pyneb/utils/misc.py index 3aecd9e..8defe5c 100644 --- a/pyneb/utils/misc.py +++ b/pyneb/utils/misc.py @@ -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: diff --git a/pyneb/version.py b/pyneb/version.py index 8b857ab..fcebaee 100644 --- a/pyneb/version.py +++ b/pyneb/version.py @@ -1,2 +1,2 @@ # PyNeb version -__version__ = '1.1.17' +__version__ = '1.1.18'