Skip to content

Commit

Permalink
Merge pull request #14 from Morisset/devel
Browse files Browse the repository at this point in the history
1.1.15
  • Loading branch information
Morisset authored May 11, 2021
2 parents 23cff40 + 71c6d8d commit 49b39a8
Show file tree
Hide file tree
Showing 28 changed files with 1,998 additions and 1,599 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ This project is partly supported by grants DGAPA/PAPIIT-107215 and CONACyT-CB201
PyNeb uses part of Chiantipy:

* Utility functions, many for reading the CHIANTI database files:

Copyright 2009, 2010 Kenneth P. Dere
This software is distributed under the terms of the GNU General Public License that is found in the LICENSE file

Expand Down
Binary file modified docs/Notebooks/OIII_diag.pdf
Binary file not shown.
47 changes: 38 additions & 9 deletions docs/Notebooks/PyNeb_manual_7.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Notebooks/PyNeb_manual_7b.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.7.9"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/Notebooks/PyNeb_manual_8.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.7.9"
}
},
"nbformat": 4,
Expand Down
171 changes: 68 additions & 103 deletions docs/Notebooks/PyNeb_manual_9.ipynb

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyneb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
from .utils.manage_atomic_data import _ManageAtomicData
atomicData = _ManageAtomicData()

atomicData.defaultDict = 'PYNEB_20_01'
atomicData.defaultDict = 'PYNEB_21_01'
atomicData.resetDataFileDict()

from .core.pynebcore import Atom, RecAtom, getAtomDict, getRecEmissivity, EmissionLine, Observation, \
parseLineLabel, isValid
#from .core.pipeline import PipeLine
from .core.icf import ICF
from .core.diags import Diagnostics, diags_dict
from .core.emisGrid import EmisGrid, getEmisGridDict
Expand Down
2 changes: 1 addition & 1 deletion pyneb/atomic_data/deprecated/fe_iii_coll_Q96.dat
Original file line number Diff line number Diff line change
Expand Up @@ -567,5 +567,5 @@
*** SPECTRUM 3
*** N_LEVELS 34
*** GSCONFIG d6
*** SOURCE Was wrogly refered to Quinet 1996. Data are actually a subset of Z96
*** SOURCE Was wrongly referred to Quinet 1996. Data are actually a subset of Z96
*** NOTE Collision strengths
16 changes: 8 additions & 8 deletions pyneb/atomic_data/he_i_rec_P91.func
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
PEQ1991
SOURCE Pequignot, Petitjean & Boisson, 1991, AandA, 251, 680
4471 447.1 A 0.429 -0.530 1.505 0.779 0.790 A 0.135
4713 471.3 A 0.019 -0.518 -0.045 0.951 0.626 A 0.013
5876 587.6 A 1.323 -0.696 1.683 0.667 1.000 A 0.493
3889 388.9 A 0.511 -0.489 0.719 0.530 0.898 A 0.267
7065 706.5 A 0.070 -0.509 -0.010 -0.263 1.000 A 0.071
10830 1083.0 A 0.796 -0.525 0.148 0.719 1.000 A 0.693
4922 492.2 A 0.135 -0.540 1.505 0.779 0.740 A 0.040
7281 728.1 A 0.036 -0.503 0.165 0.614 1.000 A 0.031
4471. 447.1 A 0.429 -0.530 1.505 0.779 0.790 A 0.135
4713. 471.3 A 0.019 -0.518 -0.045 0.951 0.626 A 0.013
5876. 587.6 A 1.323 -0.696 1.683 0.667 1.000 A 0.493
3889. 388.9 A 0.511 -0.489 0.719 0.530 0.898 A 0.267
7065. 706.5 A 0.070 -0.509 -0.010 -0.263 1.000 A 0.071
10830. 1083.0 A 0.796 -0.525 0.148 0.719 1.000 A 0.693
4922. 492.2 A 0.135 -0.540 1.505 0.779 0.740 A 0.040
7281. 728.1 A 0.036 -0.503 0.165 0.614 1.000 A 0.031
7 changes: 6 additions & 1 deletion pyneb/atomic_data/o_ii_rec_P91.func
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ SOURCE Pequignot, Petitjean & Boisson, 1991, AandA, 251, 680
4341+ 434.1 A 0.633 -0.609 1.683 0.667 1.000 C 1.766
4341+ 434.1 B 0.792 -0.620 1.683 0.667 1.000 C 2.244
3736+ 373.6 A 0.047 -0.506 0.624 0.681 1.000 C 0.153
3736+ 373.6 B 0.255 -0.565 1.683 0.667 1.000 C 0.669
3736+ 373.6 B 0.255 -0.565 1.683 0.667 1.000 C 0.669
3727+ 372.7 A 1.175 -0.6182 0.0097 -0.2717 1.000 B 0.000
3727+ 372.7 B 1.175 -0.6182 0.0097 -0.2717 1.000 B 0.000
7325+ 732.5 A 0.657 -0.6166 0.00 1.000 0.80 B 0.000
7325+ 732.5 B 0.657 -0.6166 0.00 1.000 0.80 B 0.000

8 changes: 4 additions & 4 deletions pyneb/core/continuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ def make_cont_Ercolano(self, tem, case, wl):
4.6, 4.7, 4.8, 4.9, 5. ])
D = np.loadtxt(ROOT_DIR + '/' + 'atomic_data/coeff_ercolano_He2.txt')
else:
print('Invalid case {0}'.format(case))
return None
self.log_.warn('Invalid case {0}'.format(case), calling='Continuum.make_cont_Ercolano')
return np.nan
if (tem < np.min(tab_T)).any() or (tem > np.max(tab_T)).any():
print('Invalid temperature {0}'.format(tem))
return None
self.log_.warn('Invalid temperature {0}'.format(tem), calling='Continuum.make_cont_Ercolano')
return np.nan

BE_E_Ry = D[:,1]
BE_E_erg = BE_E_Ry * CST.RYD_erg
Expand Down
49 changes: 43 additions & 6 deletions pyneb/core/diags.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
diags_dict['[OI] 5577/6300'] = ('O1', 'L(5577)/L(6300)', 'RMS([E(6300), E(5577)])')
diags_dict['[OI] 5577/6300+'] = ('O1', 'L(5577)/(L(6300)+L(6364))', 'RMS([E(6300)*L(6300)/(L(6300)+L(6364)), E(6364)*L(6364)/(L(6300)+L(6364)), E(5577)])')
diags_dict['[OII] 3726/3729'] = ('O2', 'L(3726)/L(3729)', 'RMS([E(3729), E(3726)])')
diags_dict['[OII] 3727+/7325+c'] = ('O2', '(B("3727A+"))/(B("7319A+")+B("7330A+"))',
'RMS([BE("7319A+")*B("7319A+")/(B("7319A+")+B("7330A+")), BE("7330A+")*B("7330A+")/(B("7319A+")+B("7330A+")), BE("3727A+")])')
#diags_dict['[OII] 3727+/7325+c'] = ('O2', '(B("3727A+"))/(B("7319A+")+B("7330A+"))',
# 'RMS([BE("7319A+")*B("7319A+")/(B("7319A+")+B("7330A+")), BE("7330A+")*B("7330A+")/(B("7319A+")+B("7330A+")), BE("3727A+")])')
diags_dict['[OII] 3727+/7325+'] = ('O2', '(L(3726)+L(3729))/(B("7319A+")+B("7330A+"))',
'RMS([E(3726)*L(3726)/(L(3726)+L(3729)), E(3729)*L(3729)/(L(3726)+L(3729)),BE("7319A+")*B("7319A+")/(B("7319A+")+B("7330A+")),BE("7330A+")*B("7330A+")/(B("7319A+")+B("7330A+"))])')
#diags_dict['[OII] 3727+/7325+'] = ('O2', '(L(3726)+L(3729))/(B("7325A+"))', 'RMS([E(3726)*L(3726)/(L(3726)+L(3729)), E(3729)*L(3729)/(L(3726)+L(3729)),BE("7325A+")])')
Expand Down Expand Up @@ -788,17 +788,20 @@ def B(label, I=I, L=L):
else:
self.ANN = ANN
# set the test values to the one we are looking for
self.ANN.set_test(np.array((value_tem, value_den)).T)
shape = value_tem.shape
self.ANN.set_test(np.array((value_tem.ravel(), value_den.ravel())).T)
# predict the result and denormalize them
self.ANN.predict()
if self.ANN.isfin is None:
tem = self.ANN.pred[:,0]*1e4
den = 10**self.ANN.pred[:,1]
else:
tem = np.zeros_like(value_tem) * -10
tem = np.zeros_like(value_tem.ravel()) * -10
tem[self.ANN.isfin] = self.ANN.pred[:,0]*1e4
den = np.zeros_like(value_tem) * -10
den = np.zeros_like(value_tem.ravel()) * -10
den[self.ANN.isfin] = 10**self.ANN.pred[:,1]
tem = np.reshape(tem, shape)
den = np.reshape(den, shape)
if limit_res:
mask = (tem<tem_min) | (tem>tem_max)
tem[mask] = np.nan
Expand Down Expand Up @@ -862,4 +865,38 @@ def getDiagLimits(self, diag):
LDR = atom.getLowDensRatio(to_eval = to_eval)
return(np.sort((LDR, HDR)))


def eval_diag(self, label):
"""
Parameters
----------
label : diagnostic label(e.g. '[OIII] 4363/5007')
A string of a key included in the self.diags dictionnary.
Returns
-------
np.array
The evaluation of the diagnostic corresponding to the label.
"""
if label not in self.diags:
self.log_.error('Unknown diagnostic: {}'.format(label), calling='eval_diag')
atom, diag_expression, error = self.diags[label]
sym, spec, rec = parseAtom2(atom)
def I(i, j):
wave = atom.wave_Ang[i - 1, j - 1]
corrIntens = obs.getLine(sym, spec, wave).corrIntens
return corrIntens
def L(wave):
corrIntens = obs.getLine(sym, spec, wave).corrIntens
return corrIntens
def B(label):
full_label = atom + '_' + label
corrIntens = obs.getLine(label=full_label).corrIntens
return corrIntens
def S(label):
full_label = atom + '_' + label + 'A'
corrIntens = obs.getLine(label=full_label).corrIntens
return corrIntens
diag_value = eval(diag_expression)
return diag_value
Loading

0 comments on commit 49b39a8

Please sign in to comment.