Example #1
0
 def parse_atom(self):
     """
     Parse the :class:`~exatomic.atom.Atom` object from the cube file in place.
     """
     df = pd.read_csv(StringIO('\n'.join(self._lines[6:self._volume_data_start])), delim_whitespace=True,
                      header=None, names=('Z', 'nelectron', 'x', 'y', 'z'))
     del df['nelectron']
     mapper = z_to_symbol()
     df['symbol'] = df['Z'].map(mapper).astype('category')
     del df['Z']
     df['frame'] = pd.Series([0] * len(df), dtype='category')
     df['label'] = pd.Series(range(self._nat), dtype='category')
     self._atom = Atom(df)
Example #2
0
#########################
Editor classes for various types of Gaussian output files
"""

import re
import numpy as np
import pandas as pd
from io import StringIO

from exatomic import Length
from .editor import Editor
from exa.relational.isotope import z_to_symbol
from exatomic.frame import compute_frame_from_atom
from exatomic.algorithms.basis import lmap, spher_lml_count, cart_lml_count

z_to_symbol = z_to_symbol()


class Fchk(Editor):
    def parse_atom(self):
        nat = int(self[2].split()[-1])
        found = self.find(_reznum, _reposition, keys_only=True)
        start = found[_reznum][0] + 1
        col = min(len(self[start].split()), nat)
        stop = np.ceil(start + nat / col).astype(np.int64)
        znums = self.pandas_dataframe(start, stop, col).stack()
        symbols = znums.map(z_to_symbol).values
        start = found[_reposition][0] + 1
        col = min(len(self[start].split()), nat * 3)
        stop = np.ceil(start + nat * 3 / col).astype(np.int64)
        pos = self.pandas_dataframe(start, stop, col).stack().values.reshape(nat, 3)