def runAnalysis(self): print "RFpost_local::runAnalysis()" assert not self.lockdown #Generate the setup file self.lockdown = True origResultDir = self.localSolver.metaSetup['RFField']['children']['ResultDir']['value'] #Subdirectory whith the data dataPath = os.path.join(self.folder, self.instName, "data") #Path to symlink to data folder dataPath2 = os.path.join(dataPath, origResultDir) #Path to O3P etc. results thorough symlink self.localSolver.metaSetup['RFField']['children']['ResultDir'].setValSingle("value", os.path.join("data", origResultDir)) self.localSolver.generateSetup() self.localSolver.lockdown = True #Create a symlink to avoid long folder names (ACDtool doesn't like that) if os.path.islink(dataPath): os.unlink(dataPath) os.symlink(self.runConfig.finishedFolder, dataPath) #UNIX only! #Modify the postprocess.in file to the right path shutil.copy(os.path.join(dataPath2, "VECTOR", "postprocess.in"),\ os.path.join(self.folder, self.instName, "postprocess.in.bak")) postFile = AcdOptiFileParser_KVC(os.path.join(dataPath2, "VECTOR", "postprocess.in"),"rw") #print postFile.dataDict postFile.dataDict["ModelInfo"].setValSingle("File", os.path.join(dataPath, "mesh.ncdf")) postFile.dataDict["CheckPoint"].setValSingle("Directory", os.path.join(os.path.join(dataPath2, "VECTOR"))) postFile.write() #Run AcdTool! try: AcdOptiAcdtoolWrapper.rfPost("rfPost.in", os.path.join(self.folder, self.instName)) except: self.localSolver.metaSetup['RFField']['children']['ResultDir'].setValSingle("value", origResultDir) self.localSolver.write() shutil.copy(os.path.join(self.folder, self.instName, "postprocess.in.bak"),\ os.path.join(dataPath2, "VECTOR", "postprocess.in")) os.unlink(dataPath) raise #Restore stuff self.localSolver.metaSetup['RFField']['children']['ResultDir'].setValSingle("value", origResultDir) self.localSolver.write() shutil.copy(os.path.join(self.folder, self.instName, "postprocess.in.bak"),\ os.path.join(dataPath2, "VECTOR", "postprocess.in")) os.unlink(dataPath) #Parse output ifile = open(os.path.join(self.folder, self.instName, "rfpost.out"), 'r') fileData = ifile.read() ifile.close() #Save results try: L = float(self.settings["L"]) except ValueError: print 'Couldnt parse self.settings["L"]' L = -1.0; addDic = self.parseData(fileData, L) for (k,v) in addDic: self.exportResults.pushBack(k,v) self.write()
def runAnalysis(self): print "ModeFileRecalc::runAnalysis()" assert not self.lockdown #Generate the setup file self.lockdown = True origResultDir = self.settings["ResultDir"] #Subdirectory whith the data dataPath = os.path.join(self.folder, self.instName, "data") #Path to symlink to data folder dataPath2 = os.path.join(dataPath, origResultDir) #Path to O3P etc. results thorough symlink #Create a symlink to avoid long folder names (ACDtool doesn't like that) if os.path.islink(dataPath): os.unlink(dataPath) os.symlink(self.runConfig.finishedFolder, dataPath) #UNIX only! #Modify the postprocess.in file to the right path shutil.copy(os.path.join(dataPath2, "VECTOR", "postprocess.in"),\ os.path.join(self.folder, self.instName, "postprocess.in.bak")) postFile = AcdOptiFileParser_KVC(os.path.join(dataPath2, "VECTOR", "postprocess.in"),"rw") postFile.dataDict["ModelInfo"].setValSingle("File", os.path.join(dataPath, "mesh.ncdf")) postFile.dataDict["CheckPoint"].setValSingle("Directory", os.path.join(os.path.join(dataPath2, "VECTOR"))) postFile.write() #Check that we don't destroy any data... if os.path.isfile(os.path.join(dataPath, "acdtool.log")) or os.path.isfile(os.path.join(dataPath, "acdtool.warn")): #Restore stuff shutil.copy(os.path.join(self.folder, self.instName, "postprocess.in.bak"),\ os.path.join(dataPath2, "VECTOR", "postprocess.in")) os.unlink(dataPath) raise ModeFileRecalcException_runAna("acdtool log files already exists") #Move the old modefile out of the way... oldFilesFolder = os.path.join(self.folder,self.instName, "oldModes") if os.path.isdir(oldFilesFolder): offls = os.listdir(oldFilesFolder) if len(offls) > 0: shutil.copy(os.path.join(self.folder, self.instName, "postprocess.in.bak"),\ os.path.join(dataPath2, "VECTOR", "postprocess.in")) raise ModeFileRecalcException_runAna else: os.mkdir(oldFilesFolder) files = os.listdir(dataPath2) movedFiles = [] for f in files: if f.startswith("mode.") and f.endswith(".mod"): shutil.move( os.path.join(dataPath2,f), os.path.join(oldFilesFolder,f) ) movedFiles.append(f) #Run AcdTool! try: AcdOptiAcdtoolWrapper.eigentomode(origResultDir, dataPath) except: shutil.move( os.path.join(dataPath,"acdtool.log"), os.path.join(self.folder,self.instName,"acdtool.log")) raise #Move newly created files to results dir files = os.listdir(dataPath2) for f in files: if f.startswith("mode.") and f.endswith(".mod"): shutil.move( os.path.join(dataPath2,f), os.path.join(self.folder,self.instName,f)) shutil.move( os.path.join(dataPath,"acdtool.log"), os.path.join(self.folder,self.instName,"acdtool.log")) shutil.move( os.path.join(dataPath,"acdtool.warn"), os.path.join(self.folder,self.instName,"acdtool.warn")) #Restore stuff shutil.copy(os.path.join(self.folder, self.instName, "postprocess.in.bak"),\ os.path.join(dataPath2, "VECTOR", "postprocess.in")) for f in movedFiles: shutil.move(os.path.join(oldFilesFolder,f), os.path.join(dataPath2,f)) os.rmdir(oldFilesFolder) os.unlink(dataPath) #Save results self.exportResults.pushBack("Job", "complete") self.write()