Coverage for /builds/kinetik161/ase/ase/calculators/demon/demon_io.py: 21.74%
23 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
1import os.path as op
3import numpy as np
5from ase.calculators.calculator import ReadError
6from ase.units import Hartree
9def parse_xray(filename):
10 # filename = self.label + '/deMon.xry'
11 if op.isfile(filename):
12 with open(filename) as fd:
13 lines = fd.readlines()
15 mode = lines[0].split()[0]
16 ntrans = int(lines[0].split()[1])
18 E_trans = []
19 osc_strength = []
20 trans_dip = []
21 for i in range(1, ntrans + 1):
22 tokens = lines[i].split()
24 E_trans.append(float(tokens[0]))
25 osc_strength.append(
26 float(tokens[1].replace('D', 'e')))
28 dip1 = float(tokens[3].replace('D', 'e'))
29 dip2 = float(tokens[4].replace('D', 'e'))
30 dip3 = float(tokens[5].replace('D', 'e'))
31 trans_dip.append([dip1, dip2, dip3])
33 return mode, ntrans, np.array(
34 E_trans) * Hartree, np.array(osc_strength), np.array(trans_dip)
36 else:
37 raise ReadError('The file {} does not exist'
38 .format(filename))