mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-12-26 14:23:42 +01:00
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
from ..formatHandlerBase import formatHandlerBase
|
|
from ..formatName import formatName
|
|
from ...data import dataFileBase,DataType,method,excitationValue,datafileSelector
|
|
from ...utils import getValFromCell
|
|
import numpy as np
|
|
@formatName("line")
|
|
class lineHandler(formatHandlerBase):
|
|
def readFromTable(self,table):
|
|
datalist=list()
|
|
for col in range(1,np.size(table,1)):
|
|
col=table[:,col]
|
|
mymolecule=str(col[0])
|
|
mymethod=method(str(col[2]),str(col[1]))
|
|
initialState=self.TexOps.initialStates[mymolecule]
|
|
finsts=dataFileBase.convertState(table[3:,0],initialState,default=self.TexOps.defaultType,commands=self.Commands)
|
|
datacls=dict()
|
|
for index,cell in enumerate(col[3:]):
|
|
if str(cell)!="":
|
|
val,unsafe=getValFromCell(cell)
|
|
finst=finsts[index]
|
|
dt=finst[1]
|
|
if dt in datacls:
|
|
data=datacls[dt]
|
|
else:
|
|
cl=datafileSelector(dt)
|
|
data=cl()
|
|
datacls[dt]=data
|
|
data.molecule=mymolecule
|
|
data.method=mymethod
|
|
data.excitations.append(excitationValue(initialState,finst[0],val,type=finst[2],isUnsafe=unsafe))
|
|
for value in datacls.values():
|
|
datalist.append(value)
|
|
return datalist |