Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GFALL data and/or parser #328

Open
isaacgsmith opened this issue Mar 1, 2023 · 1 comment
Open

Update GFALL data and/or parser #328

isaacgsmith opened this issue Mar 1, 2023 · 1 comment

Comments

@isaacgsmith
Copy link
Member

isaacgsmith commented Mar 1, 2023

There is new GFALL data that has been released since 2016 (see http://kurucz.harvard.edu/linelists.html under GFNEW). I tried parsing it with carsus but it did not work, so I am assuming that the parser either needs to be updated, or something needs to be done with the .dat file to make it readable by carsus. I am not sure which one of these is the case, since I am not too familiar with carsus.

I am including my error message when parsing gfnew/gfall08oct17.dat in case it is helpful:

TypeError                                 Traceback (most recent call last)
~/mambaforge-pypy3/envs/carsus/lib/python3.7/site-packages/pandas/core/ops/array_ops.py in na_arithmetic_op(left, right, op, str_rep)
    148     try:
--> 149         result = expressions.evaluate(op, str_rep, left, right)
    150     except TypeError:

~/mambaforge-pypy3/envs/carsus/lib/python3.7/site-packages/pandas/core/computation/expressions.py in evaluate(op, op_str, a, b, use_numexpr)
    207     if use_numexpr:
--> 208         return _evaluate(op, op_str, a, b)
    209     return _evaluate_standard(op, op_str, a, b)

~/mambaforge-pypy3/envs/carsus/lib/python3.7/site-packages/pandas/core/computation/expressions.py in _evaluate_numexpr(op, op_str, a, b)
    120     if result is None:
--> 121         result = _evaluate_standard(op, op_str, a, b)
    122 

~/mambaforge-pypy3/envs/carsus/lib/python3.7/site-packages/pandas/core/computation/expressions.py in _evaluate_standard(op, op_str, a, b)
     69     with np.errstate(all="ignore"):
---> 70         return op(a, b)
     71 

~/mambaforge-pypy3/envs/carsus/lib/python3.7/site-packages/pandas/core/ops/roperator.py in rpow(left, right)
     47 def rpow(left, right):
---> 48     return right ** left
     49 

TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'str'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_3668324/4130594254.py in <module>
      4                            ionization_energies,
      5                            gfall_reader,
----> 6                            zeta_data)

~/carsus/carsus/io/output/base.py in __init__(self, atomic_weights, ionization_energies, gfall_reader, zeta_data, chianti_reader, cmfgen_reader, levels_lines_param, collisions_param)
     70 
     71         self.levels_all = self._get_all_levels_data()
---> 72         self.lines_all = self._get_all_lines_data()
     73         self.levels, self.lines = self.create_levels_lines(**levels_lines_param)
     74         self.create_macro_atom()

~/carsus/carsus/io/output/base.py in _get_all_lines_data(self)
    422 
    423         logger.info('Ingesting transition lines.')
--> 424         gf_lines = self.gfall_reader.lines
    425         gf_lines['ds_id'] = 2
    426 

~/carsus/carsus/io/kurucz/gfall.py in lines(self)
    119     def lines(self):
    120         if self._lines is None:
--> 121             self._lines = self.extract_lines()
    122         return self._lines
    123 

~/carsus/carsus/io/kurucz/gfall.py in extract_lines(self, gfall, levels, selected_columns)
    346 
    347         lines = gfall[selected_columns].copy()
--> 348         lines["gf"] = np.power(10, lines["loggf"])
    349         lines = lines.drop(["loggf"], 1)
    350 

~/mambaforge-pypy3/envs/carsus/lib/python3.7/site-packages/pandas/core/series.py in __array_ufunc__(self, ufunc, method, *inputs, **kwargs)
    634         # for binary ops, use our custom dunder methods
    635         result = ops.maybe_dispatch_ufunc_to_dunder_op(
--> 636             self, ufunc, method, *inputs, **kwargs
    637         )
    638         if result is not NotImplemented:

pandas/_libs/ops_dispatch.pyx in pandas._libs.ops_dispatch.maybe_dispatch_ufunc_to_dunder_op()

~/mambaforge-pypy3/envs/carsus/lib/python3.7/site-packages/pandas/core/ops/common.py in new_method(self, other)
     62         other = item_from_zerodim(other)
     63 
---> 64         return method(self, other)
     65 
     66     return new_method

~/mambaforge-pypy3/envs/carsus/lib/python3.7/site-packages/pandas/core/ops/__init__.py in wrapper(left, right)
    501         lvalues = extract_array(left, extract_numpy=True)
    502         rvalues = extract_array(right, extract_numpy=True)
--> 503         result = arithmetic_op(lvalues, rvalues, op, str_rep)
    504 
    505         return _construct_result(left, result, index=left.index, name=res_name)

~/mambaforge-pypy3/envs/carsus/lib/python3.7/site-packages/pandas/core/ops/array_ops.py in arithmetic_op(left, right, op, str_rep)
    195     else:
    196         with np.errstate(all="ignore"):
--> 197             res_values = na_arithmetic_op(lvalues, rvalues, op, str_rep)
    198 
    199     return res_values

~/mambaforge-pypy3/envs/carsus/lib/python3.7/site-packages/pandas/core/ops/array_ops.py in na_arithmetic_op(left, right, op, str_rep)
    149         result = expressions.evaluate(op, str_rep, left, right)
    150     except TypeError:
--> 151         result = masked_arith_op(left, right, op)
    152 
    153     return missing.dispatch_fill_zeros(op, left, right, result)

~/mambaforge-pypy3/envs/carsus/lib/python3.7/site-packages/pandas/core/ops/array_ops.py in masked_arith_op(x, y, op)
    110         if mask.any():
    111             with np.errstate(all="ignore"):
--> 112                 result[mask] = op(xrav[mask], y)
    113 
    114     result, _ = maybe_upcast_putmask(result, ~mask, np.nan)

~/mambaforge-pypy3/envs/carsus/lib/python3.7/site-packages/pandas/core/ops/roperator.py in rpow(left, right)
     46 
     47 def rpow(left, right):
---> 48     return right ** left
     49 
     50 

TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'str'
@epassaro
Copy link
Member

Or maybe we need to write a new parser, I don't know how similar the file is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants