mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-12-25 22:03:49 +01:00
Fix DOUBLECOLUMN format
This commit is contained in:
parent
7fb707ec85
commit
782677f88b
@ -75,10 +75,14 @@ class dataFileBase(object):
|
|||||||
def readFromTable(table,format=Format.LINE,default=dataType.ABS ,firstState=state(1,1,"A_1"),commands=[]):
|
def readFromTable(table,format=Format.LINE,default=dataType.ABS ,firstState=state(1,1,"A_1"),commands=[]):
|
||||||
def getSubtableIndex(table,firstindex=2,column=0,count=1):
|
def getSubtableIndex(table,firstindex=2,column=0,count=1):
|
||||||
subtablesindex=list()
|
subtablesindex=list()
|
||||||
for i in range(firstindex+count,np.size(table,0)):
|
i=firstindex+count
|
||||||
|
while i<np.size(table,0):
|
||||||
if str(table[i,column])!="":
|
if str(table[i,column])!="":
|
||||||
subtablesindex.append((firstindex,i-1))
|
subtablesindex.append((firstindex,i-1))
|
||||||
firstindex=i
|
firstindex=i
|
||||||
|
i+=count
|
||||||
|
else:
|
||||||
|
i+=1
|
||||||
subtablesindex.append((firstindex,np.size(table,0)))
|
subtablesindex.append((firstindex,np.size(table,0)))
|
||||||
return subtablesindex
|
return subtablesindex
|
||||||
|
|
||||||
@ -138,55 +142,59 @@ class dataFileBase(object):
|
|||||||
datalist.append(value)
|
datalist.append(value)
|
||||||
return datalist
|
return datalist
|
||||||
elif format==Format.DOUBLECOLUMN:
|
elif format==Format.DOUBLECOLUMN:
|
||||||
subtablesindex=getSubtableIndex(table)
|
datacls=dict()
|
||||||
for first, last in subtablesindex:
|
subtablesMol=getSubtableIndex(table)
|
||||||
mymolecule=table[first,0]
|
for firstMol, lastMol in subtablesMol:
|
||||||
mytrans=table[first:first+1,1]
|
mymolecule=str(table[firstMol,0])
|
||||||
for i,mystr in enumerate(mytrans):
|
subtablestrans=getSubtableIndex(table[firstMol:lastMol+1,:],firstindex=0,column=1,count=2)
|
||||||
mystr=mytrans[i]
|
for firstTrans,lastTrans in subtablestrans:
|
||||||
|
mytrans=table[firstMol+firstTrans:firstMol+lastTrans+1,:]
|
||||||
|
mytransdesc=mytrans[0:2,1]
|
||||||
|
for i in range(2):
|
||||||
try:
|
try:
|
||||||
mathsoup=TexSoup(mystr)
|
mathsoup=TexSoup(mytransdesc[i])
|
||||||
except:
|
except:
|
||||||
print(f"Error when parsing latex state: {mystr}")
|
print(f"Error when parsing latex state: {str(mytransdesc[i])}")
|
||||||
exit(-1)
|
exit(-1)
|
||||||
newCommand.runAll(mathsoup,commands)
|
newCommand.runAll(mathsoup,commands)
|
||||||
mytrans[i]=str(mathsoup)
|
mytransdesc[i]=str(mathsoup)
|
||||||
for col in range(3,np.size(table,1)):
|
for col in range(3,np.size(table,1)):
|
||||||
col=table[:,col]
|
col=table[:,col]
|
||||||
mybasis=col[1]
|
mybasis=str(col[1])
|
||||||
for index,cell in enumerate(col[first:last+1]):
|
for index,cell in enumerate(col[firstMol+firstTrans:firstMol+lastTrans+1]):
|
||||||
methodnameAT1=str(table[first+index,2])
|
methodnameAT1=str(table[firstMol+firstTrans+index,2])
|
||||||
PTString="($\%T_1$)"
|
PTString=r"($\%T_1$)"
|
||||||
HasT1=methodnameAT1.endswith(PTString)
|
HasT1=methodnameAT1.endswith(PTString)
|
||||||
if HasT1:
|
if HasT1:
|
||||||
methodname=methodnameAT1[:-len(PTString)]
|
methodname=methodnameAT1[:-len(PTString)]
|
||||||
else:
|
else:
|
||||||
methodname=methodnameAT1
|
methodname=str(methodnameAT1)
|
||||||
mymethod=method(methodname,mybasis)
|
mymethod=method(methodname,mybasis)
|
||||||
strcell=str(cell)
|
strcell=str(cell)
|
||||||
if strcell!="":
|
if strcell!="":
|
||||||
if HasT1:
|
if HasT1:
|
||||||
m=re.match(r"^(?P<value>[-+]?\d+\.?\d*)\s*\((?P<T1>\d*\.?\d+)\%\)$",strcell)
|
m=re.match(r"^(?P<value>[-+]?\d+\.?\d*)\s*(?:\((?P<T1>\d+\.?\d*)\\\%\))?",strcell)
|
||||||
val,unsafe=getValFromCell(TexSoup(m.group("value")))
|
val,unsafe=getValFromCell(TexSoup(m.group("value")))
|
||||||
T1=m.group("T1")
|
T1=m.group("T1")
|
||||||
else:
|
else:
|
||||||
m=re.match(r"^[-+]?\d+\.?\d*",strcell)
|
m=re.match(r"^[-+]?\d+\.?\d*",strcell)
|
||||||
val,unsafe=getValFromCell(TexSoup(m.group(0)))
|
val,unsafe=getValFromCell(TexSoup(m.group(0)))
|
||||||
T1=None
|
T1=None
|
||||||
finst=finsts[index]
|
if (mymolecule,mymethod.name,mymethod.basis) in datacls:
|
||||||
if (mymolecule,mymethod) in datacls:
|
data=datacls[(mymolecule,mymethod.name,mymethod.basis)]
|
||||||
data=datacls[(mymolecule,mymethod)]
|
|
||||||
else:
|
else:
|
||||||
data=AbsDataFile()
|
data=AbsDataFile()
|
||||||
data.molecule=mymolecule
|
data.molecule=mymolecule
|
||||||
data.method=mymethod
|
data.method=mymethod
|
||||||
infin=mytrans.split("\rightarrow")
|
datacls[(mymolecule,mymethod.name,mymethod.basis)]=data
|
||||||
|
infin=mytransdesc[0].split(r"\rightarrow")
|
||||||
for i,item in enumerate(infin):
|
for i,item in enumerate(infin):
|
||||||
m=re.match(r"^(?P<number>\d)\\[,:;\s]\s*\^(?P<multiplicity>\d)(?P<sym>\S*)",item)
|
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"))
|
infin[i]=state(m.group("number"),m.group("multiplicity"),m.group("sym"))
|
||||||
data.excitations.append(excitationValue(infin[0],infin[1],val,type=mytrans[1],isUnsafe=unsafe,T1=T1))
|
data.excitations.append(excitationValue(infin[0],infin[1],val,type=mytransdesc[1],isUnsafe=unsafe,T1=T1))
|
||||||
for value in datacls.values():
|
for value in datacls.values():
|
||||||
datalist.append(value)
|
datalist.append(value)
|
||||||
|
return datalist
|
||||||
elif format==Format.TBE:
|
elif format==Format.TBE:
|
||||||
subtablesindex=getSubtableIndex(table)
|
subtablesindex=getSubtableIndex(table)
|
||||||
for first, last in subtablesindex:
|
for first, last in subtablesindex:
|
||||||
|
Loading…
Reference in New Issue
Block a user