From 4033f559fcc22900a0e417ffc7cad87b9b1cc0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Fri, 21 Feb 2020 12:04:26 +0100 Subject: [PATCH 1/2] Try support quest#2 format --- tools/lib/Format.py | 4 +++- tools/lib/data.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/tools/lib/Format.py b/tools/lib/Format.py index e76c1bb4..4763e8e5 100644 --- a/tools/lib/Format.py +++ b/tools/lib/Format.py @@ -3,4 +3,6 @@ from enum import IntEnum,auto,unique class Format(IntEnum): LINE=auto() COLUMN=auto() - TBE=auto() \ No newline at end of file + DOUBLECOLUMN=auto() + TBE=auto() + DOUBLETBE=auto() \ No newline at end of file diff --git a/tools/lib/data.py b/tools/lib/data.py index eb1a17f9..7151d6fc 100644 --- a/tools/lib/data.py +++ b/tools/lib/data.py @@ -136,6 +136,43 @@ class dataFileBase(object): for value in datacls.values(): datalist.append(value) return datalist + elif format==Format.DOUBLECOLUMN: + subtablesindex=getSubtableIndex(table) + for first, last in subtablesindex: + mymolecule=table[first,0] + mytrans=table[first:first+1,1] + for i,mystr in enumerate(mytrans)): + mystr=mytrans[i] + try: + mathsoup=TexSoup(mystr) + except: + print(f"Error when parsing latex state: {mystr}") + exit(-1) + newCommand.runAll(mathsoup,commands) + mytrans[i]=str(mathsoup) + for col in range(3,np.size(table,1)): + col=table[:,col] + mybasis=col[2] + for index,cell in enumerate(col[first:last+1]): + mymethod=method(str(table[index,2],mybasis)) + if str(cell)!="": + m=re.match(r"(?P[-+]?\d*\.?\d+)\s*\((?:(?P\d*\.?\d+)\%)|(?P\d*\.?\d+)\)") + val,unsafe=getValFromCell(m.group("value")) + T1=m.group("T1") + finst=finsts[index] + if (mymolecule,mymethod) in datacls: + data=datacls[(mymolecule,mymethod)] + else: + data=AbsDataFile() + data.molecule=mymolecule + data.method=mymethod + infin=mytrans.split("\rightarrow") + for i,item in enumerate(infin): + m=re.match(r"^(?P\d)\\[,:;\s]\s*\^(?P\d)(?P\S*)",item) + infin[i]=state(m.group("number"),m.group("multiplicity"),m.group("sym")) + data.excitations.append(excitationValue(infin[0],infin[0],val,type=mytrans[1],isUnsafe=unsafe,T1=T1)) + for value in datacls.values(): + datalist.append(value) elif format==Format.TBE: subtablesindex=getSubtableIndex(table) for first, last in subtablesindex: From b663aa9a3bd16ebc5e96469db351a2cf3088c4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Fri, 28 Feb 2020 10:00:42 +0100 Subject: [PATCH 2/2] Fix typo --- tools/lib/data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/data.py b/tools/lib/data.py index 7151d6fc..39ff4c4a 100644 --- a/tools/lib/data.py +++ b/tools/lib/data.py @@ -141,7 +141,7 @@ class dataFileBase(object): for first, last in subtablesindex: mymolecule=table[first,0] mytrans=table[first:first+1,1] - for i,mystr in enumerate(mytrans)): + for i,mystr in enumerate(mytrans): mystr=mytrans[i] try: mathsoup=TexSoup(mystr) @@ -170,7 +170,7 @@ class dataFileBase(object): for i,item in enumerate(infin): m=re.match(r"^(?P\d)\\[,:;\s]\s*\^(?P\d)(?P\S*)",item) infin[i]=state(m.group("number"),m.group("multiplicity"),m.group("sym")) - data.excitations.append(excitationValue(infin[0],infin[0],val,type=mytrans[1],isUnsafe=unsafe,T1=T1)) + data.excitations.append(excitationValue(infin[0],infin[1],val,type=mytrans[1],isUnsafe=unsafe,T1=T1)) for value in datacls.values(): datalist.append(value) elif format==Format.TBE: