10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-24 13:23:40 +01:00

Treat commands in excitation

This commit is contained in:
Mickaël Véril 2019-12-12 15:20:56 +01:00
parent c661067e49
commit 4900ad296a
2 changed files with 14 additions and 8 deletions

View File

@ -26,6 +26,6 @@ if DEBUG:
datapath=datapath/"test" datapath=datapath/"test"
if not datapath.exists(): if not datapath.exists():
datapath.mkdir() datapath.mkdir()
datalst=dataFileBase.readFromTable(dat,format=Format[args.format],default=dataType[args.defaultType]) datalst=dataFileBase.readFromTable(dat,format=Format[args.format],default=dataType[args.defaultType],commands=commands)
for data in datalst: for data in datalst:
data.toFile(datapath) data.toFile(datapath)

View File

@ -1,4 +1,6 @@
from collections import OrderedDict from collections import OrderedDict
from TexSoup import TexSoup
from .LaTeX import newCommand
from enum import IntEnum,auto,unique,IntFlag from enum import IntEnum,auto,unique,IntFlag
from .Format import Format from .Format import Format
import re import re
@ -34,11 +36,15 @@ class dataFileBase(object):
pass pass
@staticmethod @staticmethod
def convertState(StateTablelist,default=dataType.ABS,firstState=state(1,1,"A_1")): def convertState(StateTablelist,default=dataType.ABS,firstState=state(1,1,"A_1"),commands=[]):
tmplst=[] tmplst=[]
for TexState in StateTablelist: for TexState in StateTablelist:
lst=list(TexState.find("$").contents) math=TexState.find("$")
st=str(lst[0]) dec=math.contents
lst=list(math.contents)
mathsoup=TexSoup(str(lst[0]))
newCommand.runAll(mathsoup,commands)
st=str(mathsoup)
m=re.match(r"^\^(?P<multiplicity>\d)(?P<symm>[^\s\[(]*)\s*(?:\[(?:\\mathrm{)?(?P<special>\w)(?:})\])?\s*\((?P<type>[^\)]*)\)",st) m=re.match(r"^\^(?P<multiplicity>\d)(?P<symm>[^\s\[(]*)\s*(?:\[(?:\\mathrm{)?(?P<special>\w)(?:})\])?\s*\((?P<type>[^\)]*)\)",st)
seq=m.group("multiplicity","symm") seq=m.group("multiplicity","symm")
spgrp=m.group("special") spgrp=m.group("special")
@ -56,7 +62,7 @@ class dataFileBase(object):
return lst return lst
@staticmethod @staticmethod
def readFromTable(table,format=Format.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"),commands=[]):
datalist=list() datalist=list()
switcher={ switcher={
dataType.ABS:AbsDataFile, dataType.ABS:AbsDataFile,
@ -68,7 +74,7 @@ class dataFileBase(object):
col=table[:,col] col=table[:,col]
mymolecule=str(col[0]) mymolecule=str(col[0])
mymethod=method(str(col[2]),str(col[1])) mymethod=method(str(col[2]),str(col[1]))
finsts=dataFileBase.convertState(table[3:,0],firstState) finsts=dataFileBase.convertState(table[3:,0],firstState,commands=commands)
datacls=dict() datacls=dict()
for index,cell in enumerate(col[3:]): for index,cell in enumerate(col[3:]):
if str(cell)!="": if str(cell)!="":
@ -100,7 +106,7 @@ class dataFileBase(object):
col=table[:,col] col=table[:,col]
mymolecule=str(table[first,0]) mymolecule=str(table[first,0])
mymethod=method(str(col[1]),str(col[0])) mymethod=method(str(col[1]),str(col[0]))
finsts=dataFileBase.convertState(table[first:last+1,1],default=default,firstState=firstState) finsts=dataFileBase.convertState(table[first:last+1,1],default=default,firstState=firstState,commands=commands)
for index,cell in enumerate(col[first:last+1]): for index,cell in enumerate(col[first:last+1]):
if str(cell)!="": if str(cell)!="":
val= list(cell.contents)[0] val= list(cell.contents)[0]
@ -130,7 +136,7 @@ class dataFileBase(object):
datacls=dict() datacls=dict()
mymolecule=str(table[first,0]) mymolecule=str(table[first,0])
mymethod=(method("TBE"),method("TBE-corr")) mymethod=(method("TBE"),method("TBE-corr"))
finsts=dataFileBase.convertState(table[first:last+1,1],default=default,firstState=firstState) finsts=dataFileBase.convertState(table[first:last+1,1],default=default,firstState=firstState,commands=commands)
for index,row in enumerate(table[first:last+1,]): for index,row in enumerate(table[first:last+1,]):
def toFloat(x): def toFloat(x):
try: try: