Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from ase.calculators.calculator import ReadError 

2import os.path as op 

3import numpy as np 

4from ase.units import Hartree 

5 

6 

7def parse_xray(filename): 

8 # filename = self.label + '/deMon.xry' 

9 if op.isfile(filename): 

10 with open(filename, 'r') as fd: 

11 lines = fd.readlines() 

12 

13 mode = lines[0].split()[0] 

14 ntrans = int(lines[0].split()[1]) 

15 

16 E_trans = [] 

17 osc_strength = [] 

18 trans_dip = [] 

19 for i in range(1, ntrans + 1): 

20 tokens = lines[i].split() 

21 

22 E_trans.append(float(tokens[0])) 

23 osc_strength.append( 

24 float(tokens[1].replace('D', 'e'))) 

25 

26 dip1 = float(tokens[3].replace('D', 'e')) 

27 dip2 = float(tokens[4].replace('D', 'e')) 

28 dip3 = float(tokens[5].replace('D', 'e')) 

29 trans_dip.append([dip1, dip2, dip3]) 

30 

31 return mode, ntrans, np.array( 

32 E_trans) * Hartree, np.array(osc_strength), np.array(trans_dip) 

33 

34 else: 

35 raise ReadError('The file {0} does not exist' 

36 .format(filename))