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
|
2020-07-03 14:51:12 +02:00
|
|
|
from ...utils import getValFromCell
|
2020-07-04 15:41:24 +02:00
|
|
|
import numpy as np
|
2020-07-03 14:51:12 +02:00
|
|
|
@formatName("column")
|
|
|
|
class columnHandler(formatHandlerBase):
|
|
|
|
def readFromTable(self,table):
|
|
|
|
datalist=list()
|
2020-07-08 13:21:40 +02:00
|
|
|
subtablesRange=getSubtablesRange(table)
|
|
|
|
for myrange in subtablesRange:
|
2020-07-03 14:51:12 +02:00
|
|
|
for col in range(2,np.size(table,1)):
|
|
|
|
datacls=dict()
|
|
|
|
col=table[:,col]
|
2020-07-08 13:21:40 +02:00
|
|
|
mymolecule=str(table[myrange[0],0])
|
2020-07-04 15:41:24 +02:00
|
|
|
initialState=self.TexOps.initialStates[mymolecule]
|
2020-07-03 14:51:12 +02:00
|
|
|
mymethod=method(str(col[1]),str(col[0]))
|
2020-07-08 13:21:40 +02:00
|
|
|
finsts=dataFileBase.convertState(table[myrange,1],initialState,default=self.TexOps.defaultType,commands=self.commands)
|
|
|
|
for index,cell in enumerate(col[myrange]):
|
2020-07-03 14:51:12 +02:00
|
|
|
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()
|
|
|
|
data.molecule=mymolecule
|
|
|
|
data.method=mymethod
|
|
|
|
datacls[dt]=data
|
|
|
|
data.excitations.append(excitationValue(initialState,finst[0],val,type=finst[2]))
|
|
|
|
for value in datacls.values():
|
|
|
|
datalist.append(value)
|
|
|
|
return datalist
|