2020-07-03 14:51:12 +02:00
|
|
|
from ..formatHandlerBase import formatHandlerBase
|
|
|
|
from ..formatName import formatName
|
2020-07-08 13:21:40 +02:00
|
|
|
from ...data import dataFileBase,DataType,method,excitationValue,datafileSelector,getSubtablesRange,AbsDataFile,state
|
2020-07-03 14:51:12 +02:00
|
|
|
from ...utils import getValFromCell, checkFloat
|
2020-08-03 17:08:20 +02:00
|
|
|
from ...LaTeX import newCommand,extractMath
|
2020-07-03 14:51:12 +02:00
|
|
|
from TexSoup import TexSoup
|
|
|
|
import re
|
|
|
|
@formatName("doubleTBE")
|
|
|
|
class doubleTBEHandler(formatHandlerBase):
|
|
|
|
def readFromTable(self,table):
|
|
|
|
datalist=list()
|
2020-07-08 13:21:40 +02:00
|
|
|
subtablesMol=getSubtablesRange(table)
|
|
|
|
for rangeMol in subtablesMol:
|
2020-07-03 14:51:12 +02:00
|
|
|
data=AbsDataFile()
|
2020-08-03 16:01:34 +02:00
|
|
|
data.molecule=str(table[rangeMol[0],0])
|
2020-07-03 14:51:12 +02:00
|
|
|
data.method=method("TBE","CBS")
|
2020-07-08 13:21:40 +02:00
|
|
|
for mytrans in table[rangeMol]:
|
2020-08-03 17:08:20 +02:00
|
|
|
mathsoup=extractMath(mytrans[1],Soup=True,commands=self.commands)
|
2020-07-03 14:51:12 +02:00
|
|
|
mytransdesc=str(mathsoup)
|
|
|
|
infin=mytransdesc.split(r"\rightarrow")
|
|
|
|
for i,item in enumerate(infin):
|
|
|
|
m=re.match(r"^(?P<number>\d)\\[,:;\s]\s*\^(?P<multiplicity>\d)(?P<sym>\S*)",item.strip())
|
|
|
|
infin[i]=state(m.group("number"),m.group("multiplicity"),m.group("sym"))
|
|
|
|
cell=mytrans[6]
|
|
|
|
val,unsafe=getValFromCell(cell)
|
|
|
|
data.excitations.append(excitationValue(infin[0],infin[1],val,isUnsafe=unsafe))
|
|
|
|
datalist.append(data)
|
|
|
|
return datalist
|