diff --git a/docs/example-tbe.tex b/docs/example-tbe.tex index a4426b9f..19e2a8a1 100644 --- a/docs/example-tbe.tex +++ b/docs/example-tbe.tex @@ -24,7 +24,7 @@ \newcommand{\DAVPZ}{d-\emph{aug}-cc-pV5Z} \newcommand{\PopleDZ}{6-31+G(d)} -\begin{table}{llcccccc} +\begin{tabular}{llcccccc} & & & & TBE(FC)& \multicolumn{3}{c}{Corrected TBE} \\ & State & $f$ & \%$T_1$ & AVTZ & Method & Corr. & Value \\ Acetaldehyde &$^1A''(\mathrm{V};n \rightarrow \pis)$ & 0.000 &91.3& 4.31 & {\exCI}/AVTZ & AVQZ &4.31 \\ @@ -99,7 +99,7 @@ &$^1A' (\Ryd;n \rightarrow 3s)$ &0.001 &88.6 &6.77$^a$ & & &6.81 \\ &$^1A' (\mathrm{V};\pi \rightarrow \pis)$ &0.251 &89.3 &7.63 &{\exCI}/AVTZ & AVQZ &7.64 \\ &$^1A' (\Ryd;n \rightarrow 3p)$ &0.111 &89.6 &7.38$^b$ &{\CCSDT}/AVTZ& AVQZ &7.41 \\ - &$^3A'' (\mathrm{V};n \rightarrow \pis)$ & &97.7 &5.38$^c$ &{\exCI}/AVDZ& AVQZ &5.37 \\%X-EX + &$^3A'' (\mathrm{V};n \rightarrow \pis)$ & &97.7 &5.38$^c$ &{\exCI}/AVDZ& AVQZ &5.37 \\ &$^3A' (\mathrm{V};\pi \rightarrow \pis)$ & &98.2 &5.81$^c$ & & &5.81 \\ Hydrogen chloride & $^1\Pi (\mathrm{CT})$ &0.056 &94.3 &7.84 & {\exCI}/AVQZ &dAV5Z &7.86 \\ Hydrogen sulfide &$^1A_2 (\Ryd;n \rightarrow 4p)$ & &94.6 &6.18 & {\exCI}/AVQZ &dAV5Z &6.10 \\ @@ -120,7 +120,7 @@ &$^1A' (\mathrm{V};n,n \rightarrow \pis,\pis)$ &0.000 &2.5 &4.72 & {\exCI}/AVTZ & AVQZ & 4.69 \\ &$^1A' (\Ryd;n \rightarrow 3s/3p)$ &0.006 &90.8 &6.40$^a$ &{\exCI}/AVDZ & AVQZ &6.42 \\ &$^3A'' (\mathrm{V};n \rightarrow \pis)$ & &98.4 &1.16 & & &1.16 \\ - &$^3A' (\mathrm{V};\pi \rightarrow \pis)$ & &98.9 &5.60 & & &5.61 �\\ + &$^3A' (\mathrm{V};\pi \rightarrow \pis)$ & &98.9 &5.60 & & &5.61 \\ &$^1A'' [\mathrm{F}] (\mathrm{V};n \rightarrow \pis)$ & &92.7&1.67$^a$ &{\exCI}/AVDZ & AVQZ &1.66 \\ Streptocyanine-C1&$^1B_2 (\mathrm{V};\pi \rightarrow \pis)$ & 0.347 &88.7&7.13$^a$ & {\exCI}/AVDZ & AVQZ &7.12 \\ & $^3B_2 (\mathrm{V};\pi \rightarrow \pis)$ & &98.3 &5.52 & {\exCI}/AVTZ & AVQZ &5.52 \\ @@ -137,4 +137,4 @@ & $^3B_1 (\Ryd; n \rightarrow 3s)$ & &98.1 &7.25 & & &7.33 \\ & $^3A_2 (\Ryd; n \rightarrow 3p)$ & &98.0 &9.24 & & &9.30 \\ & $^3A_1 (\Ryd; n \rightarrow 3s)$ & &98.2 &9.54 & & &9.59 \\ - \end{tabular} \ No newline at end of file +\end{tabular} \ No newline at end of file diff --git a/static/js/data.js b/static/js/data.js index 32d4f5aa..aed68cc2 100644 --- a/static/js/data.js +++ b/static/js/data.js @@ -78,7 +78,7 @@ class DOI { } class excitationBase { - constructor(initial, final, type, T1=null) { + constructor(initial, final, type=null, T1=null) { this.initial = initial; this.final = final if (type !== null) { diff --git a/tools/datafileBuilder.py b/tools/datafileBuilder.py index 232b0538..a5a588f8 100755 --- a/tools/datafileBuilder.py +++ b/tools/datafileBuilder.py @@ -5,15 +5,15 @@ from enum import IntEnum,auto,unique import numpy as np from pathlib import Path from lib import LaTeX -from lib.Orientation import Orientation +from lib.Format import Format from TexSoup import TexSoup from lib.data import dataFileBase,dataType import argparse -DEBUG=False +DEBUG=True parser = argparse.ArgumentParser() parser.add_argument('--file', type=argparse.FileType('r')) parser.add_argument('--defaultType', type=str, choices=[t.name for t in list(dataType)]) -parser.add_argument('--MoleculeOrentation',type=str, choices=[t.name for t in list(Orientation)],default=Orientation.LINE.name) +parser.add_argument('--format',type=str, choices=[t.name for t in list(Format)],default=Format.LINE.name) args = parser.parse_args() print(args) lines=args.file.readlines() @@ -26,6 +26,6 @@ if DEBUG: datapath=datapath/"test" if not datapath.exists(): datapath.mkdir() -datalst=dataFileBase.readFromTable(dat,orientation=Orientation[args.MoleculeOrentation],default=dataType[args.defaultType]) +datalst=dataFileBase.readFromTable(dat,format=Format[args.format],default=dataType[args.defaultType]) for data in datalst: data.toFile(datapath) \ No newline at end of file diff --git a/tools/lib/Orientation.py b/tools/lib/Format.py similarity index 53% rename from tools/lib/Orientation.py rename to tools/lib/Format.py index 43a97308..e76c1bb4 100644 --- a/tools/lib/Orientation.py +++ b/tools/lib/Format.py @@ -1,5 +1,6 @@ from enum import IntEnum,auto,unique @unique -class Orientation(IntEnum): +class Format(IntEnum): LINE=auto() - COLUMN=auto() \ No newline at end of file + COLUMN=auto() + TBE=auto() \ No newline at end of file diff --git a/tools/lib/data.py b/tools/lib/data.py index d25f05b7..6fd42ae6 100644 --- a/tools/lib/data.py +++ b/tools/lib/data.py @@ -1,6 +1,6 @@ from collections import OrderedDict from enum import IntEnum,auto,unique,IntFlag -from .Orientation import Orientation +from .Format import Format import re import numpy as np @@ -53,18 +53,18 @@ class dataFileBase(object): for index,item in enumerate(tmplst): unformfirststate=(str(firstState.multiplicity),firstState.symetry) count=([unformfirststate]+tmplst[:index+1]).count(item) - lst.append((state(count,int(item[0]),item[1]),item[2])) + lst.append((state(count,int(item[0]),item[1]),item[2],item[3])) return lst @staticmethod - def readFromTable(table,orientation=Orientation.LINE,default=dataType.ABS ,firstState=state(1,1,"A_1")): + def readFromTable(table,format=Format.LINE,default=dataType.ABS ,firstState=state(1,1,"A_1")): datalist=list() switcher={ dataType.ABS:AbsDataFile, dataType.FLUO:FluoDataFile, dataType.ZPE:ZPEDataFile } - if orientation==Orientation.LINE: + if format==Format.LINE: for col in range(1,np.size(table,1)): col=table[:,col] mymolecule=str(col[0]) @@ -84,11 +84,11 @@ class dataFileBase(object): data=cl() data.molecule=mymolecule data.method=mymethod - data.excitations.append(excitationValue(firstState,finst[0],val)) + data.excitations.append(excitationValue(firstState,finst[0],val,type=finst[2])) for value in datacls.values(): datalist.append(value) return datalist - else: + elif format==Format.COLUMN: subtablesindex=list() firstindex=2 for i in range(3,np.size(table,0)): @@ -96,11 +96,6 @@ class dataFileBase(object): subtablesindex.append((firstindex,i-1)) firstindex=i for first, last in subtablesindex: - for col in range(2,np.size(table,1)): - col=table[:,col] - mymolecule=str(table[first,0]) - mymethod=method(str(col[1]),str(col[0])) - finsts=dataFileBase.convertState(table[first:last+1,1],default=default,firstState=firstState) for col in range(2,np.size(table,1)): datacls=dict() col=table[:,col] @@ -121,10 +116,41 @@ class dataFileBase(object): data.molecule=mymolecule data.method=mymethod datacls[dt]=data - data.excitations.append(excitationValue(firstState,finst[0],val)) + data.excitations.append(excitationValue(firstState,finst[0],val,type=finst[2])) for value in datacls.values(): datalist.append(value) return datalist + elif format==Format.TBE: + subtablesindex=list() + firstindex=2 + for i in range(2,np.size(table,0)): + if str(table[i,0])!="": + subtablesindex.append((firstindex,i-1)) + firstindex=i + for first, last in subtablesindex: + mymolecule=str(table[first,0]) + mymethod="TBE" + finsts=dataFileBase.convertState(table[first:last+1,1],default=default,firstState=firstState) + for row in table[first,last+1]: + OscilatorForces=float(str(cell.contents)[2]) + T1 = float(str(list(cell.contents)[3])) + val = float(str(list(cell.contents)[4])) + corr = float(str(list(cell.contents[7]))) + finst=finsts[index] + dt=finst[1] + if dt in datacls: + data = datacls[dt] + else: + cl=switcher[dt] + data=cl() + data.molecule=mymolecule + data.method=mymethod + datacls[dt]=data + data.excitations.append(excitationValue(firstState,finst[0],val,type=finst[2],T1=T1,corrected=corr)) + for value in datacls.values(): + datalist.append(value) + return datalist + def getMetadata(self): dic=OrderedDict() dic["Molecule"]=self.molecule @@ -145,11 +171,11 @@ class dataFileBase(object): if value is not None: f.write("# {:9s}: {}\n".format(key,value)) f.write(""" -# Initial state Final state Energies (eV) Oscilator forces -####################### ####################### ################# ################### -# Number Spin Symm Number Spin Symm E_{:5s} Corr \n""".format(self.GetFileType().name.lower())) +# Initial state Final state Transition Energies (eV) %T1 Oscilator forces +####################### ####################### ################ ################# ####### ################### +# Number Spin Symm Number Spin Symm type E_{:5s} Corr %T1 f \n""".format(self.GetFileType().name.lower())) for ex in self.excitations: - mystr=" {:8s}{:7s}{:10s}{:8s}{:6s}{:13s}{:8s}{:8s}{}\n".format(str(ex.initial.number),str(ex.initial.multiplicity),ex.initial.symetry,str(ex.final.number),str(ex.final.multiplicity),ex.final.symetry,str(ex.value) if ex.value is not None else "_",str(ex.corrected) if ex.corrected is not None else "_",str(ex.OscilatorForces) if ex.OscilatorForces is not None else "_") + mystr=" {:8s}{:7s}{:10s}{:8s}{:6s}{:13s}{:16s}{:8s}{:10s}{:15s}{}\n".format(str(ex.initial.number),str(ex.initial.multiplicity),ex.initial.symetry,str(ex.final.number),str(ex.final.multiplicity),ex.final.symetry,str(ex.type) if ex.type is not None else "_",str(ex.value) if ex.value is not None else "_",str(ex.corrected) if ex.corrected is not None else "_",str(ex.T1) if ex.T1 is not None else "_", str(ex.oscilatorForces) if ex.oscilatorForces is not None else "_") f.write(mystr) class method: def __init__(self,name, *args): @@ -233,13 +259,19 @@ class ZPEDataFile(twoStateDataFileBase): return dataType.ZPE class excitationBase: - def __init__(self,initial, final): + def __init__(self,initial, final, **kwargs): self.initial = initial self.final = final + self.type = kwargs["type"] if "type" in kwargs else None + self.T1 = kwargs["T1"] if "T1" in kwargs else None class excitationValue(excitationBase): - def __init__(self,initial, final, value,*args): - super(excitationValue,self).__init__(initial, final) + def __init__(self,initial, final, value,**kwarg): + supkwarg=kwarg.copy() + for item in ["forces","corrected"]: + if item in supkwarg: + supkwarg.pop(item) + super(excitationValue,self).__init__(initial, final,**supkwarg) self.value = value - self.Corrcorrectedection=args[0] if len(args)>0 else None - self.OscilatorForces=args[1] if len(args)>1 else None + self.corrected=kwarg["corrected"] if "corrected" in kwarg else None + self.oscilatorForces=kwarg["forces"] if "forces" in kwarg else None