Morisset / PyNeb_devel

PyNeb development repository
Other
41 stars 10 forks source link

'_CollDataNone' object has no attribute 'getOmega' #17

Closed moustakas closed 3 years ago

moustakas commented 3 years ago

Using the pip-installed version of PyNeb, I get a crash when I try to compute the emissivity of HeII:

import pyneb as pn
atm = pn.Atom('He', 2)
emis = atm.getEmissivity(1e4, 1e2)

~/anaconda3/envs/py39/lib/python3.9/site-packages/pyneb/core/pynebcore.py in getEmissivity(self, tem, den, lev_i, lev_j, wave, product)
   1898             n_den = den.size
   1899             tem_ones = np.ones(n_tem)
-> 1900             populations = self.getPopulations(tem, den, product=True)
   1901             if ((lev_i == -1) and (lev_j == -1)):
   1902                 resultArray = np.zeros((NLevels, NLevels, n_tem, n_den))

~/anaconda3/envs/py39/lib/python3.9/site-packages/pyneb/core/pynebcore.py in getPopulations(self, tem, den, product, NLevels)
   1680             den_ones = np.ones(n_den)
   1681             # q is vector-indexed (q(0, 1) = rate between levels 1 and 2)
-> 1682             q = self.getCollRates(tem, n_level)
   1683             Atem = np.outer(self._A[:n_level, :n_level], tem_ones).reshape(n_level, n_level, n_tem)
   1684             pop_result = np.zeros((n_level, n_tem, n_den))

~/anaconda3/envs/py39/lib/python3.9/site-packages/pyneb/core/pynebcore.py in getCollRates(self, tem, NLevels)
   1479             res_shape.append(sh)
   1480         resultArray = np.zeros(res_shape)
-> 1481         Omegas = self.getOmega(tem)
   1482         for i in range(NLevels - 1):
   1483             lev_i = i + 1

~/anaconda3/envs/py39/lib/python3.9/site-packages/pyneb/core/pynebcore.py in getOmega(self, tem, lev_i, lev_j, wave)
   1416         kappa = config.kappa
   1417         if kappa is None:
-> 1418             to_return = self.CollData.getOmega(tem, lev_i, lev_j)
   1419         else:
   1420             #ToDo The Kappa correction should come AFTER the transformation into CS unit

AttributeError: '_CollDataNone' object has no attribute 'getOmega'
Morisset commented 3 years ago

Hi Moustakas, You may want to use the RecAtom class for the HeII lines:

import pyneb as pn
atm = pn.RecAtom('He', 2)
emis = atm.getEmissivity(1e4, 1e2)

Christophe

moustakas commented 3 years ago

Thanks @Morisset!

In addition to HeII, I'm also interested in HeI, but the wave_Ang attribute appears to be missing, e.g.,

atm = pn.RecAtom('He', 1)
print(atm.wave_Ang)
  None

Any suggestions?

Morisset commented 3 years ago

In the case of HeI, the labels are in the form of strings:

print(atm.labels)
('2945.0', '3188.0', '3614.0', '3889.0', '3965.0', '4026.0', '4121.0', '4388.0', '4438.0', '4471.0', '4713.0', '4922.0', '5016.0', '5048.0', '5876.0', '6678.0', '7065.0', '7281.0', '9464.0', '10830.0', '11013.0', '11969.0', '12527.0', '12756.0', '12785.0', '12790.0', '12846.0', '12968.0', '12985.0', '13412.0', '15084.0', '17003.0', '18556.0', '18685.0', '18697.0', '19089.0', '19543.0', '20427.0', '20581.0', '20602.0', '21118.0', '21130.0', '21608.0', '21617.0')

Hope it helps, Christophe

moustakas commented 3 years ago

Thanks, I did see these labels but I need 3-4 decimals of precision. Is this possible?

On Sat, Jul 31, 2021, 2:01 PM Christophe Morisset @.***> wrote:

In the case of HeI, the labels are in the form of strings:

print(atm.labels) ('2945.0', '3188.0', '3614.0', '3889.0', '3965.0', '4026.0', '4121.0', '4388.0', '4438.0', '4471.0', '4713.0', '4922.0', '5016.0', '5048.0', '5876.0', '6678.0', '7065.0', '7281.0', '9464.0', '10830.0', '11013.0', '11969.0', '12527.0', '12756.0', '12785.0', '12790.0', '12846.0', '12968.0', '12985.0', '13412.0', '15084.0', '17003.0', '18556.0', '18685.0', '18697.0', '19089.0', '19543.0', '20427.0', '20581.0', '20602.0', '21118.0', '21130.0', '21608.0', '21617.0')

Hope it helps, Christophe

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Morisset/PyNeb_devel/issues/17#issuecomment-890383607, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK5SDBQMKIAF462JA3DCX3T2Q3ARANCNFSM5BJ75U2A .

Morisset commented 3 years ago

These are labels, as strings. There is no precision, they are hard-coded as they appear with this command.