예제 #1
0
파일: model.py 프로젝트: wkerzendorf/pyfica
    def fromPath(cls, basePath=".", machineName=None, param=None, origSpec=None, fitFunc=None, t=None, execTime=None):
        if param == None:
            dicaData = fileio.dicafile(os.path.join(basePath, "dica.dat")).read_data()
            compData = fileio.compfile(os.path.join(basePath, "comp.ind")).read_data()
            dica = paramMod.dica(dicaData, mode="fromPath", t=t)
            comp = paramMod.comp(compData, t=dica["t"])
            param = paramMod.param(initDica=dica, initComp=comp)

        aSpecPath = os.path.join(basePath, "spct.dat")
        try:
            aSpec = spectrum(aSpecPath, usecols=(0, 2))
            sbib = fileio.sbibfile(os.path.join(basePath, "sbib.dat")).read_data()
            llist = sbib["llist"]
            wParams = fileio.ststfile(os.path.join(basePath, "stst.dat")).getWParams()
            specFlag = 0
        except:
            print "Creating fake Spectrum @%s" % basePath
            aSpec = spectrum(zip(np.linspace(2000, 20000, 20), range(1, 21)))
            sbib = {"llist": []}
            llist = sbib["llist"]
            wParams = []
            specFlag = -1

        log = list(file(os.path.join(basePath, "fica.log")))
        # error=list(file(os.path.join(basePath,'error.log')))

        if wParams != []:
            w = wParams[-1][0][-1]
        else:
            w = -1

        return cls(
            aSpec,
            param,
            w,
            machineName=None,
            execTime=execTime,
            wParam=wParams,
            error=None,
            ficaLog=log,
            llist=llist,
            origSpec=origSpec,
            specFlag=specFlag,
            fitFunc=fitFunc,
        )
예제 #2
0
def printHist(dicaKeys=['log_lbol','v_ph'],compKeys=['Fe0','Fe','Ni0','Si','S','Cr','Ti','Mg'],max=10):
    #dica=fileio.dicafile('dica.dat').read_data()
    #comp=fileio.compfile('comp.ind').read_data()
    #print comp
    dicaStr=['%s=%s'%item for item in dica.items() if item[0] in dicaKeys]
    compStr=['%s=%s'%item for item in comp.items() if item[0] in compKeys]
    #print 'Current: '+' '.join(dicaStr+compStr)
    #print '------------------------------------'
    dicaFiles=glob('hist/dica.bak????')
    compFiles=glob('hist/comp.bak????')
    dicaFiles.sort()
    compFiles.sort()
    for dicaFile,compFile in zip(dicaFiles,compFiles)[::-1][:max]:
        id=int(dicaFile[-4:])
        dica=fileio.dicafile(dicaFile).read_data()
        comp=fileio.compfile(compFile).read_data()
        #print comp
        dicaStr=['%s=%s'%item for item in dica.items() if item[0] in dicaKeys]
        compStr=['%s=%s'%item for item in comp.items() if item[0] in compKeys]
        print 'id=%s |'%id+' '.join(dicaStr+compStr)
예제 #3
0
def getPrevDica():
    dicaFile=os.path.join(config.getLastMainDir(),'manual','dica.dat')
    dica=fileio.dicafile(dicaFile).read_data()
    print "Time=%s"%config.getTimeFromExplosion()
    dica['t']=config.getTimeFromExplosion()
    return dica
예제 #4
0
def getHistDica(id):
    dicaData=fileio.dicafile('hist/dica.bak%04d'%id).read_data()
    return param.dica(dicaData)
예제 #5
0
파일: param.py 프로젝트: wkerzendorf/pyfica
 def write2file(self,fileName='dica.dat'):
     fileio.dicafile(fileName,'w').write_data(self.data)
예제 #6
0
def getVanillaDica():
    dicaConf = os.path.join(getMainConfigDir(), "dica.dat")
    return fileio.dicafile(dicaConf).read_data()