tardis-sn/carsus

Cannot reproduce results of 'Creating a TARDIS atomic data file'

Closed this issue · 5 comments

My code

from carsus.io.nist import NISTWeightsComp,  NISTIonizationEnergies
from carsus.io.kurucz import GFALLReader
from carsus.io.zeta import KnoxLongZeta
from carsus.io.output import TARDISAtomData

output_file = "kurucz_As-U_ALL.h5"

atomic_weights = NISTWeightsComp('As-U') # weights from NIST
ionization_energies = NISTIonizationEnergies('As-U') # ionization energies from NIST
atomic_weights.to_hdf(output_file)
ionization_energies.to_hdf(output_file)

zeta = KnoxLongZeta('data_for_carsus/knox_long_recombination_zeta.dat') # zeta from Knox Long
zeta.to_hdf(output_file)

gfall_reader = GFALLReader('data_for_carsus/gfall.dat') ## Kurucz gfall data

atom_data = TARDISAtomData(gfall_reader, ionization_energies, ions='As-U')
atom_data.to_hdf(output_file)

Problem description

Hello,

I am following the tutorial given here to create a TARDIS atomic data file. Everything works until the line atom_data = ..., at which point, I get the following:

Downloading data from the NIST Atomic Weights and Isotopic Compositions database.
Downloading ionization energies from the NIST Atomic Spectra Database
[carsus.io.kurucz.gfall][WARNING]  A specific combination to identify unique levels from the gfall data has not been given. Defaulting to ["energy", "j"]. (gfall.py:68)
Traceback (most recent call last):
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/series.py", line 987, in setitem
    self._set_with_engine(key, value)
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/series.py", line 1046, in _set_with_engine
    self.index._engine.set_value(values, key, value)
  File "pandas/_libs/index.pyx", line 95, in pandas._libs.index.IndexEngine.set_value
  File "pandas/_libs/index.pyx", line 106, in pandas._libs.index.IndexEngine.set_value
ValueError: setting an array element with a sequence.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nvieira/Documents/rprocess_2020/make_TARDISAtomData.py", line 112, in <module>
    ions='As-U')
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/carsus-0.1.dev623-py3.6.egg/carsus/io/output/base.py", line 50, in __init__
    self.ground_levels = ionization_energies.get_ground_levels()
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/carsus-0.1.dev623-py3.6.egg/carsus/io/nist/ionization.py", line 333, in get_ground_levels
    levels = self.parser.prepare_ground_levels()
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/carsus-0.1.dev623-py3.6.egg/carsus/io/nist/ionization.py", line 174, in prepare_ground_levels
    "L", "parity", "J"]] = ground_levels.apply(parse_ground_level, axis=1)
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/frame.py", line 6487, in apply
    return op.get_result()
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/apply.py", line 151, in get_result
    return self.apply_standard()
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/apply.py", line 257, in apply_standard
    self.apply_series_generator()
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/apply.py", line 286, in apply_series_generator
    results[i] = self.f(v)
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/carsus-0.1.dev623-py3.6.egg/carsus/io/nist/ionization.py", line 153, in parse_ground_level
    lvl["J"] = lvl_tokens["J"]
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/series.py", line 1039, in __setitem__
    setitem(key, value)
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/series.py", line 1015, in setitem
    self.loc[key] = value
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/indexing.py", line 190, in __setitem__
    self._setitem_with_indexer(indexer, value)
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/indexing.py", line 656, in _setitem_with_indexer
    value=value)
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/internals/managers.py", line 510, in setitem
    return self.apply('setitem', **kwargs)
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/internals/managers.py", line 395, in apply
    applied = getattr(b, f)(**kwargs)
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/internals/blocks.py", line 827, in setitem
    values, value = self._try_coerce_args(values, value)
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/internals/blocks.py", line 712, in _try_coerce_args
    if np.any(notna(other)) and not self._can_hold_element(other):
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/dtypes/missing.py", line 333, in notna
    res = isna(obj)
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/dtypes/missing.py", line 99, in isna
    return _isna(obj)
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/dtypes/missing.py", line 114, in _isna_new
    return _isna_ndarraylike(obj)
  File "/home/nvieira/anaconda3/envs/tardis/lib/python3.6/site-packages/pandas/core/dtypes/missing.py", line 193, in _isna_ndarraylike
    dtype = values.dtype
AttributeError: ("'function' object has no attribute 'dtype'", 'occurred at index 0')

I am working within an environment specifically for tardis, as suggested in the tardis installation guide. My install of tardis was cloned directly from the github and has successfully produced the spectra from the quickstart guide. I have verified that the version of pandas in this environment is 0.24.2, as is requested in the tardis environment definition file. The version of carsus I am using has also been cloned directly from the github.

I have tried taking the other route of using the carsus quickstart guide, but have had no success there either. I'm at a bit of a loss.

Any help would be much appreciated! (Additionally, if anyone happens to have an usable .h5 file with all the elements from As-U in the meantime, that would also be very helpful.)

Hi @nvieira-mcgill! Thank you for your detailed report.

Currently NIST doesn't have ground state configurations for every ions (starting from atomic number 59). For example, look for Neodymium (z=60) at:

https://physics.nist.gov/PhysRefData/ASD/ionEnergy.html.

From Nd VI to XI have missing configurations (we need to parse total angular momentum J from that column).

This situation makes impossible (for now) to build atomic files containing ions with Z > 58.

Maybe with discuss more about this in the next days.

Ah, that makes sense, thank you very much!

I was able to get around the issue by instead doing the following:

  1. Working within an environment specifically made for carsus using the environment definition file carsus_env3.yml
  2. Explicitly passing a string of ions for which the Kurucz line list contains lines, i.e., ions='As 0; Se 0; Rb 0; Sr 0; Sr 1; U 0; U 1' (not showing all elements for brevity)

But, of course, I can't carry out the simulation with TARDIS because the atomic data is incomplete, as you mentioned. I will look into obtaining/producing more complete atomic data elsewhere.

However, I tried my first code with H-Zn, and I had the same error when running in the environment produced by tardis_env3.yml. The only way to get the code to work was by running the code in the environment produced by carsus_env3.yml. I think it might be more logical for the environments produced by each of these files to be consistent. Otherwise, it seems like one has to make their atomic data file in one conda environment and then run their TARDIS simulation in another environment.

In any case, thank you very much for your help. I am happy to discuss this any time!

Yes, Carsus should be installed in a separated environment. The new Carsus documentation is ready and should be available tomorrow, it's way more clear.

Hi @nvieira-mcgill we patched Carsus to make possible to work with heavy elements. The documentation is still not updated, some things have changed (and will continue changing in the next weeks).

@epassaro Excellent, I'm happy to hear this!