def generateRunConfigDict(self): """ Return a DataDict saved by the RunConfig specifiying the information neccessary to load the analysis using loadAnalysisByDict() for loading the analysis . """ assert self.type in AnalysisInterface.getTypes() d = DataDict() d.pushBack("type", self.type) d.pushBack("name", self.instName) return d
def __init__(self, folder, name, runConfig): print "RFpost_local::__init__()" self.type = "RFpost_local" self.folder = folder self.instName = name self.runConfig = runConfig #Load paramFile self.__paramFile = AcdOptiFileParser_simple(os.path.join(folder, name, "paramFile.set"), 'rw') if self.__paramFile.dataDict["fileID"] != "Analysis::RFpost_local": raise RFpostException("Got fileID='" + self.__paramFile.dataDict["fileID"] + "'") self.lockdown = DataDict.boolconv(self.__paramFile.dataDict["lockdown"]) self.exportResults = self.__paramFile.dataDict["export"] #Load RFpost solverManager self.localSolver = AcdOptiSolverManager("rfPost.in", os.path.join(folder,name)) if self.lockdown: self.localSolver.lockdown = True #Load the settings if len(self.__paramFile.dataDict.getVals("settings")) == 0: self.__paramFile.dataDict.pushBack("settings", DataDict()) self.__paramFile.dataDict["settings"].pushBack("L","") self.__paramFile.write() self.settings = self.__paramFile.dataDict["settings"]
def __populateTasksList(self): print "RunnerSetup::__populateTasksList()" self.__tasksListStore.clear() for (jobName, job) in self.runner.getJobs(): #Name, command, args, tasks, tasksNode, tasksNuma, ?aprun, jobObject self.__tasksListStore.append([jobName, job["command"], job["commandArgs"],\ int(job["tasks"]), int(job["tasksNode"]), int(job["tasksNuma"]),\ DataDict.boolconv(job["aprun"]), job])
def __updateDynamicTable_recursive(self,metaSetup,parentIter): """ Method that recursively calls itself whenever it encounters a "dict" entry in the metaSetupFile. """ print "SolverSetup::__updateDynamicTable_recursive()" for (key,val) in metaSetup: #print (key,val) type = val["type"] if type == "dict": iter = self.__dynamicTableTree.append(parentIter,\ [key, type, "", DataDict.boolconv(val["enabled"]), not DataDict.boolconv(val["must"]), False, val]) self.__updateDynamicTable_recursive(val["children"], iter) #elif type=="fnameNoEx" or type=="fnameEx" or type=="string": else: iter = self.__dynamicTableTree.append(parentIter,\ [key, type, val["value"], DataDict.boolconv(val["enabled"]), not DataDict.boolconv(val["must"]), True, val]) print "SolverSetup::__updateDynamicTable_recursive() - return"
def event_cellRenderer_enabled_toggled(self, cellrenderertoggle, path, data=None): print "SolverSetup::event_cellRenderer_enabled_toggled(), path='" + str(path) + "', row= '" + self.__rowStringer(self.__dynamicTableTree[path]) + "'" data = self.__dynamicTableTree[path][-1] if DataDict.boolconv(data["enabled"]): data.setValSingle("enabled", "False") else: data.setValSingle("enabled", "True") self.__dynamicTableTree[path][3] = not self.__dynamicTableTree[path][3]
def ParsePowerThorughSurface(self,sectionNamesList,sectionList): """ Parses 'powerThroughSurface' sections, returns a DataDict with one entry (another dataDict) for each section found. """ ptsSects = self.__findMySections(sectionNamesList, sectionList, "powerThroughSurface") retDict = DataDict() for sec in ptsSects: secDict = DataDict() secDict.pushBack("surfaceID", re.match(r"surfaceID\s*:\s*(\d+)",sec[1].strip()).group(1)) secDict.pushBack("ModeID", re.match(r"ModeID\s*:\s*(\d+)",sec[2].strip()).group(1)) pow = re.match(r"Power\s*:\s*\(\s*("+redigits+r"),\s*("+redigits+r")\s*\)\s*\(W\)", sec[3].strip()) secDict.pushBack("Power_real", pow.group(1)) secDict.pushBack("Power_imag", pow.group(2)) retDict.pushBack("surf", secDict) return retDict
def __init__(self, folder, name, runConfig): print "FileList::__init__()" self.type = "FileList" self.folder = folder self.instName = name self.runConfig = runConfig self.__paramFile = AcdOptiFileParser_simple(os.path.join(folder, name), "rw") if self.__paramFile.dataDict["fileID"] != "Analysis::FileList": raise FileListException("Got fileID='" + self.__paramFile.dataDict["fileID"] + "'") self.lockdown = DataDict.boolconv(self.__paramFile.dataDict["lockdown"]) self.exportResults = self.__paramFile.dataDict["export"]
def __init__(self, folder, name, runConfig): print "GroupVelocity::__init__()" self.type = "GroupVelocity" self.folder = folder self.instName = name self.runConfig = runConfig self.__paramFile = AcdOptiFileParser_simple(os.path.join(folder, name), 'rw') if self.__paramFile.dataDict["fileID"] != "Analysis::GroupVelocity": raise GroupVelocityException("Got fileID='" + self.__paramFile.dataDict["fileID"] + "'") self.lockdown = DataDict.boolconv(self.__paramFile.dataDict["lockdown"]) self.exportResults = self.__paramFile.dataDict["export"] self.settings = self.__paramFile.dataDict["settings"]
def __init__(self, folder, name, runConfig): print "ModeFileRecalc::__init__()" self.type = "ModeFileRecalc" self.folder = folder self.instName = name self.runConfig = runConfig #Load paramFile self.__paramFile = AcdOptiFileParser_simple(os.path.join(folder, name, "paramFile.set"), 'rw') if self.__paramFile.dataDict["fileID"] != "Analysis::ModeFileRecalc": raise ModeFileRecalcException("Got fileID='" + self.__paramFile.dataDict["fileID"] + "'") self.lockdown = DataDict.boolconv(self.__paramFile.dataDict["lockdown"]) self.exportResults = self.__paramFile.dataDict["export"] #Load the settings self.settings = self.__paramFile.dataDict["settings"]
def event_dynamicTable_cursorChanged(self, widget, data=None): print "SolverSetup::event_dynamicTable_cursorChanged()" #Get the currently selected row (path,column) = self.__dynamicTable.get_cursor() if not path: #Nothing selected... self.__copyButton.set_sensitive(False) self.__delButton.set_sensitive(False) return row = self.__dynamicTableTree[path] if DataDict.boolconv(row[-1]["single"]): self.__copyButton.set_sensitive(False) self.__delButton.set_sensitive(False) else: self.__copyButton.set_sensitive(True) #Is it alone? Can't delete the last instance... #Find the parent "children" dict parent = None if len(path) == 1: #Top-level parent = self.solverSetup.metaSetup parentChild = parent#["options"] else: parentRow = self.__dynamicTableTree[path[:-1]] parent = parentRow[-1] parentChild = parent["children"] #Search for siblings with same name findings = 0 for (k,v) in parentChild: if k == row[0]: findings += 1 if findings > 1: self.__delButton.set_sensitive(True) else: self.__delButton.set_sensitive(False)
def __init__(self, folder, collection): print "Scan2D_Tune::__init__()" super(Scan2D_Tune,self).__init__(folder,collection,"ParameterScan::Scan2D_Tune") self.scanParameter1_name = self._paramFile.dataDict["scanParameter1_name"] self.scanParameter1_min = float(self._paramFile.dataDict["scanParameter1_min"]) self.scanParameter1_max = float(self._paramFile.dataDict["scanParameter1_max"]) self.scanParameter1_num = int(self._paramFile.dataDict["scanParameter1_num"]) self.scanParameter2_name = self._paramFile.dataDict["scanParameter2_name"] self.scanParameter2_min = float(self._paramFile.dataDict["scanParameter2_min"]) self.scanParameter2_max = float(self._paramFile.dataDict["scanParameter2_max"]) self.scanParameter2_num = int(self._paramFile.dataDict["scanParameter2_num"]) self.tune_parameter = self._paramFile.dataDict["tune_parameter"] self.tune_anaVariable = self._paramFile.dataDict["tune_anaVariable"] self.tune_targetValue = float(self._paramFile.dataDict["tune_targetValue"]) self.tune_initialPoints = [] for (k,v) in self._paramFile.dataDict["tune_initialPoints"]: self.tune_initialPoints.append(k) self.tune_model = [] try: tune_ipModelDict = self._paramFile.dataDict["tune_ipModelDict"] self.tune_useModelPoints = DataDict.boolconv(self._paramFile.dataDict["tune_useModelPoints"]) except AcdOptiException_dataDict_getValsSingle: print "Scan2D_Tune::__init__(): Adding tune_ipModelDict and tune_useModelPoints to paramFile" self._paramFile.dataDict.pushBack("tune_ipModelDict", DataDict()) self._paramFile.dataDict.pushBack("tune_useModelPoints", "False") self._paramFile.write() tune_ipModelDict = DataDict() self.tune_useModelPoints = False i = 0 for (k,v) in tune_ipModelDict: assert k == str(i) self.tune_model.append(float(v)) i += 1 #Initialize slave scan collection in same folder self.slaveScanCollection = ParameterScanCollection(folder, collection,self)
def __init__(self, folder, name, runConfig): print "Omega3P_modeInfo::__init__()" self.type = "Omega3P_modeInfo" self.folder = folder self.instName = name self.runConfig = runConfig self.__paramFile = AcdOptiFileParser_simple(os.path.join(folder, name), 'rw') if self.__paramFile.dataDict["fileID"] != "Analysis::Omega3P_modeInfo": raise Omega3P_modeInfo_exception("Got fileID='" + self.__paramFile.dataDict["fileID"] + "'") self.lockdown = DataDict.boolconv(self.__paramFile.dataDict["lockdown"]) self.exportResults = self.__paramFile.dataDict["export"] if "modes" in self.exportResults: #Convert to new format print "Converting to new format..." modes = self.exportResults["modes"].copy() self.exportResults.clear() for (k,v) in modes: self.exportResults.pushBack(k,v) self.write()
def __init__(self,folder,collection, typ): from ParameterScanCollection import ParameterScanCollection assert typ in ParameterScanCollection.parameterScanTypes or "ParameterScan::"+ typ in ParameterScanCollection.parameterScanTypes self.type = typ self.folder = folder self.scanCollection = collection #Construct the instance name from folder instName = folder if instName[-1] == "/": instName = instName[0:-1] self.instName = instName = os.path.split(instName)[1] #Load paramFile.set self._paramFile = AcdOptiFileParser_simple(os.path.join(folder, "paramFile_scan.set"), 'rw') if self._paramFile.dataDict["fileID"] != self.type: raise ParameterScanInterfaceException_init("Got fileID='" + self._paramFile.dataDict["fileID"] + "'") if self._paramFile.dataDict.getValSingle("instName") != self.instName: raise ParameterScanInterfaceException_init("instName doesn't match folder name") self.lockdown = DataDict.boolconv(self._paramFile.dataDict["lockdown"]) baseGeomInstance_name = self._paramFile.dataDict["baseGeomInstance_name"] if baseGeomInstance_name == "": self.baseGeomInstance = None assert len(self._paramFile.dataDict["slaveGeoms"]) == 0 assert self.lockdown == False else: self.baseGeomInstance = self.getProject().geomCollection.geomInstances[baseGeomInstance_name] self.slaveGeoms = {} for (geomName, nothingOfInterest) in self._paramFile.dataDict["slaveGeoms"]: #Mutal referencing self.slaveGeoms[geomName] = self.getProject().geomCollection.geomInstances[geomName] self.slaveGeoms[geomName].scanInstances.append(self) if len(self.slaveGeoms) > 0: assert self.lockdown == True
def parseData(self, dataString, L=-1.0): #Split into sections by looking for [NAME] sectionNamesList = [] sectionList = [] sectionBuffer = [] braceCounter = 0 for line in dataString.splitlines(): #Look for new sections if len(sectionNamesList) == len(sectionList): mobj = re.match(r"\[(\w*)\]",line) if mobj: sectionNamesList.append(mobj.group(1)) #Scan to the end of section else: if line.strip().startswith("{"): braceCounter += 1 elif line.strip().startswith("}"): braceCounter -=1 sectionBuffer.append(line) if braceCounter == 0: #Reached end of a section sectionList.append(sectionBuffer) sectionBuffer = [] assert len(sectionNamesList) == len(sectionList) #Filter through sections to find the interesting results retDict = DataDict() retDict.pushBack("RoverQ", self.ParseRoverQ(sectionNamesList, sectionList,L)) retDict.pushBack("maxFieldsOnSurface", self.ParseMaxFieldsOnSurface(sectionNamesList, sectionList,retDict)) #This depends on RoverQ's results, accessed through retDict retDict.pushBack("powerThroughSurface", self.ParsePowerThorughSurface(sectionNamesList, sectionList)) retDict.pushBack("fieldSurfPlaneIntersect", self.ParseFieldSurfPlaneIntersect(sectionNamesList, sectionList, retDict)) #Depends on RoverQ retDict.pushBack("field2SurfsIntersect", self.ParseField2SurfsIntersect(sectionNamesList, sectionList, retDict)) #Depends on RoverQ retDict.pushBack("fieldSurfRotPlaneIntersect", self.ParseFieldSurfRotPlaneIntersect(sectionNamesList, sectionList, retDict)) #Depends on RoverQ return retDict
def event_button_add(self,widget,data=None): print "RunnerSetup::event_button_add()" newJob = DataDict() newJob.pushBack("aprun", "False") newJob.pushBack("command", "") newJob.pushBack("commandArgs", "") newJob.pushBack("tasks", "-1") newJob.pushBack("tasksNode", "-1") newJob.pushBack("tasksNuma", "-1") self.__tasksListStore.append(["NewTask", "", -1, -1, -1, -1, False, newJob]) self.event_tasksList_cursorChanged(self.__tasksList, None)
def event_tasksList_aprunToggled(self,cellrenderertoggle, path, data=None): print "SolverSetup::event_cellRenderer_enabled_toggled(), path='" + str(path) + "'" job = self.__tasksListStore[path][-1] self.__tasksListStore[path][6] = not self.__tasksListStore[path][6] job.setValSingle("aprun", str(not DataDict.boolconv(job["aprun"])))
def __init__(self,frameManager,runner): print "RunnerSetup_Hopper::__init__()" InfoFrameComponent.__init__(self, frameManager) self.runner = runner self.baseWidget = gtk.VBox() #Torque stuff: tqm = self.runner.getTorqueMeta() print tqm self.baseWidget.pack_start(gtk.Label("Torque information:"), expand=False,padding=5) self.__torqueTable = gtk.Table(4,2,False) self.__queueCombo = gtk.combo_box_entry_new_text() #self.__queueCombo.append_text(tqm["queue"]) self.__queueCombo.append_text("regular") self.__queueCombo.append_text("debug") if tqm["queue"] == "regular": self.__queueCombo.set_active(0) else: self.__queueCombo.set_active(1) self.__torqueTable.attach(gtk.Label("Queue:"), 0,1,0,1, xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL) self.__torqueTable.attach(self.__queueCombo , 1,2,0,1, xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL) self.__walltimeEdit = gtk.Entry() if self.__checkWalltime(tqm["walltime"]): self.__walltimeEdit.set_text(tqm["walltime"]) else: self.__walltimeEdit.set_text("hh:mm:ss") self.__torqueTable.attach(gtk.Label("Walltime:"), 0,1,1,2,xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL) self.__torqueTable.attach(self.__walltimeEdit , 1,2,1,2,xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL) self.__repoEdit = gtk.Entry() self.__repoEdit.set_text(tqm["repo"]) self.__torqueTable.attach(gtk.Label("Repository:"), 0,1,2,3,xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL) self.__torqueTable.attach(self.__repoEdit , 1,2,2,3,xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL) self.__importvarsCheck = gtk.CheckButton() if DataDict.boolconv(tqm["importVars"]): self.__importvarsCheck.set_active(True) else: self.__importvarsCheck.set_active(False) self.__torqueTable.attach(gtk.Label("Import variables:"), 0,1,3,4,xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL) self.__torqueTable.attach(self.__importvarsCheck , 1,2,3,4,xoptions=gtk.FILL|gtk.EXPAND, yoptions=gtk.FILL) self.baseWidget.pack_start(self.__torqueTable, expand=False) self.baseWidget.pack_start(gtk.HSeparator(), expand=False,padding=10) #Commands stuff #Name, command, commandArgs, tasks, tasksNode, tasksNuma, ?aprun, job self.__tasksListStore = gtk.ListStore(str, str, str, int, int, int, bool, object) self.__tasksList = gtk.TreeView(self.__tasksListStore) self.__tasksRenderers = [] self.__tasksColumns = [] self.__tasksRenderers.append(gtk.CellRendererText()) self.__tasksRenderers[-1].set_property("editable", True) self.__tasksRenderers[-1].connect('edited', self.event_tasksList_textEdit, "name") self.__tasksColumns.append(gtk.TreeViewColumn("Name", self.__tasksRenderers[-1], text=0)) self.__tasksList.append_column(self.__tasksColumns[-1]) self.__tasksRenderers.append(gtk.CellRendererText()) self.__tasksRenderers[-1].set_property("editable", True) self.__tasksRenderers[-1].connect('edited', self.event_tasksList_textEdit, "command") self.__tasksColumns.append(gtk.TreeViewColumn("Command", self.__tasksRenderers[-1], text=1)) self.__tasksColumns[-1].set_expand(True) self.__tasksList.append_column(self.__tasksColumns[-1]) self.__tasksRenderers.append(gtk.CellRendererText()) self.__tasksRenderers[-1].connect('edited', self.event_tasksList_textEdit, "commandArgs") self.__tasksColumns.append(gtk.TreeViewColumn("Command arguments", self.__tasksRenderers[-1], text=2, visible=6, editable=6)) self.__tasksList.append_column(self.__tasksColumns[-1]) self.__tasksRenderers.append(gtk.CellRendererText()) self.__tasksRenderers[-1].connect('edited', self.event_tasksList_textEdit, "tasks") self.__tasksColumns.append(gtk.TreeViewColumn("# Tasks", self.__tasksRenderers[-1], text=3, visible=6, editable=6)) self.__tasksList.append_column(self.__tasksColumns[-1]) self.__tasksRenderers.append(gtk.CellRendererText()) self.__tasksRenderers[-1].connect('edited', self.event_tasksList_textEdit, "tasksNode") self.__tasksColumns.append(gtk.TreeViewColumn("(# tasks pr. node)", self.__tasksRenderers[-1], text=4, visible=6, editable=6)) self.__tasksList.append_column(self.__tasksColumns[-1]) self.__tasksRenderers.append(gtk.CellRendererText()) self.__tasksRenderers[-1].connect('edited', self.event_tasksList_textEdit, "tasksNuma") self.__tasksColumns.append(gtk.TreeViewColumn("(# tasks pr. NUMAnode)", self.__tasksRenderers[-1], text=5, visible=6, editable=6)) self.__tasksList.append_column(self.__tasksColumns[-1]) self.__tasksRenderers.append(gtk.CellRendererToggle()) self.__tasksRenderers[-1].connect("toggled", self.event_tasksList_aprunToggled, None) self.__tasksColumns.append(gtk.TreeViewColumn("Use aprun", self.__tasksRenderers[-1], active=6)) self.__tasksList.append_column(self.__tasksColumns[-1]) self.__scrollWindow = gtk.ScrolledWindow() self.__scrollWindow.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) self.__scrollWindow.add(self.__tasksList) self.baseWidget.pack_start(self.__scrollWindow, expand=True) self.__populateTasksList() self.__tasksList.connect("cursor-changed", self.event_tasksList_cursorChanged, None) self.__tasksButtonsBox = gtk.HBox() self.__tasksMoveUpButton = gtk.Button("Move entry up") self.__tasksButtonsBox.pack_start(self.__tasksMoveUpButton) self.__tasksMoveUpButton.connect("clicked", self.event_button_moveUp, None) self.__tasksAddButton = gtk.Button("_Add new task") self.__tasksButtonsBox.pack_start(self.__tasksAddButton) self.__tasksAddButton.connect("clicked", self.event_button_add, None) self.__tasksDelButton = gtk.Button("_Delete task") self.__tasksButtonsBox.pack_start(self.__tasksDelButton) self.__tasksDelButton.connect("clicked", self.event_button_del, None) self.__tasksMoveDownButton = gtk.Button("Move entry down") self.__tasksButtonsBox.pack_start(self.__tasksMoveDownButton) self.__tasksMoveDownButton.connect("clicked", self.event_button_moveDown, None) self.event_tasksList_cursorChanged(self.__tasksList, None) self.baseWidget.pack_start(self.__tasksButtonsBox, expand=False) self.baseWidget.pack_start(gtk.HSeparator(), expand=False,padding=10) self.__closeButton = gtk.Button("_Close") self.__closeButton.connect("clicked", self.event_button_close, None) self.baseWidget.pack_start(self.__closeButton, expand=False) if self.runner.lockdown: self.__queueCombo.set_sensitive(False) self.__walltimeEdit.set_sensitive(False) self.__repoEdit.set_sensitive(False) self.__importvarsCheck.set_sensitive(False) self.__tasksList.set_sensitive(False) self.__tasksAddButton.set_sensitive(False) self.__tasksDelButton.set_sensitive(False) self.__tasksMoveUpButton.set_sensitive(False) self.__tasksMoveDownButton.set_sensitive(False) self.baseWidget.show_all()
def ParseMaxFieldsOnSurface(self,sectionNamesList,sectionList,retDataROQ=None): """ Parses 'maxFieldsOnSurface' sections, returns a DataDict with one entry (another dataDict) for each section found. Dependent on output from RoverQ analysis for normalization, which it searches for through "retData". Skipped if not found. """ mfosSec = self.__findMySections(sectionNamesList, sectionList, "maxFieldsOnSurface") retDict = DataDict() #print mfosSec for sec in mfosSec: secDict = DataDict() surfID_match = re.match("surfaceID :[ ]*([0-9]*)", sec[1].strip()) #print sec[1].strip(), surfID_match.groups() surfID = surfID_match.group(1) secDict.pushBack("surfaceID", surfID) print "sec=", sec for i in xrange(2,len(sec)-1,4): #print "*****", i, sec[i], sec[i+1], sec[i+2] modDict = DataDict() print "sec[" + str(i) + "] = '" + sec[i] + "'" modID_match = re.match("ModeID :[ ]*([0-9]*)", sec[i].strip()) modID = modID_match.group(1) modDict.pushBack("modeID", modID) Emax_match = re.match(r"Emax :[ ]*([0-9]*\.[0-9]*e\+[0-9]*)",sec[i+1].strip()) Emax = Emax_match.group(1) modDict.pushBack("Emax", Emax) Hmax_match = re.match(r"Hmax :[ ]*([0-9]*\.[0-9]*e\+[0-9]*)",sec[i+2].strip()) Hmax = Hmax_match.group(1) modDict.pushBack("Hmax", Hmax) SCmax_match = re.match(r"SCmax :[ ]*([0-9]*\.[0-9]*e\+[0-9]*)",sec[i+3].strip()) SCmax = SCmax_match.group(1) modDict.pushBack("SCmax", SCmax) if retDataROQ != None: try: RoQ = retDataROQ["RoverQ"] Ez_ave = None for mode in RoQ.getVals("mode"): if int(mode["ModeID"]) == int(modID): assert Ez_ave == None Ez_ave = float(mode["Ez_ave"]) if Ez_ave != None: modDict.pushBack("Ez_ave", str(Ez_ave)) modDict.pushBack("Emax_norm", str(float(Emax)/Ez_ave)) modDict.pushBack("Hmax_norm", str(float(Hmax)/Ez_ave)) modDict.pushBack("SCmax_norm", str(float(SCmax)/Ez_ave/Ez_ave)) else: print "Didn't find Ez_ave" except AcdOptiException_dataDict_getValsSingle: print "No normalization found, skipping" secDict.pushBack("mode", modDict) retDict.pushBack("surf", secDict) return retDict
def ParseFieldSurfRotPlaneIntersect(self,sectionNamesList,sectionList, retDataROQ=None): """ Parses 'FieldSurfRotPlaneIntersect' sections, returns a DataDict with one entry (another dataDict) for each section found. Dependent on output from RoverQ analysis for normalization, which it searches for through "retData". Skipped if not found. """ ptsSects = self.__findMySections(sectionNamesList, sectionList, "fieldSurfRotPlaneIntersect") retDict = DataDict() for sec in ptsSects: secDict = DataDict() secDict.pushBack("surfaceID", re.match(r"surfaceID\s*:\s*(\d+)",sec[1].strip()).group(1)) modID = re.match(r"ModeID\s*:\s*(\d+)",sec[2].strip()).group(1); secDict.pushBack("ModeID", modID) secDict.pushBack("rotAngle", re.match(r"rotAngle\s*:\s*("+redigits2+r")\s*\[deg\]",sec[3].strip()).group(1)) Ematch = re.match(r"maxE\s*:\s*(" + redigits + r")\s*\(V/m\)\s*at\s*\(\s*(" + redigits + ")\s*,\s*(" + redigits + r")\s*,\s*(" + redigits + ")\s*\)",sec[4].strip()) Emax = Ematch.group(1); secDict.pushBack("Emax", Emax) Hmatch = re.match(r"maxH\s*:\s*(" + redigits + r")\s*\(A/m\)\s*at\s*\(\s*(" + redigits + ")\s*,\s*(" + redigits + r")\s*,\s*(" + redigits + ")\s*\)",sec[5].strip()) Hmax = Hmatch.group(1); secDict.pushBack("Hmax", Hmax) SCmatch = re.match(r"maxSC\s*:\s*(" + redigits + r")\s*\(VA/m\^2\)\s*at\s*\(\s*(" + redigits + ")\s*,\s*(" + redigits + r")\s*,\s*(" + redigits + ")\s*\)\s*\(assumed mu_r = 1\)",sec[6].strip()) SCmax = SCmatch.group(1); secDict.pushBack("SCmax", SCmax) if retDataROQ != None: try: RoQ = retDataROQ["RoverQ"] Ez_ave = None for mode in RoQ.getVals("mode"): if int(mode["ModeID"]) == int(modID): assert Ez_ave == None Ez_ave = float(mode["Ez_ave"]) if Ez_ave != None: secDict.pushBack("Ez_ave", str(Ez_ave)) secDict.pushBack("Emax_norm", str(float(Emax)/Ez_ave)) secDict.pushBack("Hmax_norm", str(float(Hmax)/Ez_ave)) secDict.pushBack("SCmax_norm", str(float(SCmax)/Ez_ave/Ez_ave)) else: print "Didn't find Ez_ave" except AcdOptiException_dataDict_getValsSingle: print "No normalization found, skipping" retDict.pushBack("surf", secDict) return retDict
def ParseRoverQ(self,sectionNamesList,sectionList,L=-1.0): "Parses RoverQ sections, returns a DataDict. Assumes there to be only one RoverQ." RoQsec = self.__findMySections(sectionNamesList, sectionList, "RoverQ") if len(RoQsec) == 0: return(DataDict()) elif len(RoQsec) > 1: raise RFpostException_runAna("More than one RoverQ section encountered in input file '" + self.fname + "'") RoQsec = RoQsec[0] loi = [] #Lines of interest trigger = False for line in RoQsec: if trigger: #We are capturing! if line.strip() == "}": break loi.append(line) else: #Ready for trigger if line.strip().startswith("ModeID"): trigger = True #Parse line-for-line retDict = DataDict() for line in loi: ldic = DataDict() ls = re.match(r'\s*(\d+)\s+('+redigits+")\s+\(\s*("+redigits+"),\s*(" + redigits + ")\s*\)\s*("+redigits+")\s*("+redigits+")",line) #ls = line.split() ldic.pushBack("ModeID", ls.group(1)) ldic.pushBack("Frequency", ls.group(2)) #Hz ldic.pushBack("Vr", ls.group(3)) ldic.pushBack("Vi", ls.group(4)) ldic.pushBack("Vabs", ls.group(5)) #V if L != -1.0: ldic.pushBack("Ez_ave", str(float(ldic["Vabs"])/(L/1000.0))) #V/m ldic.pushBack("RoQ", ls.group(6)) if L != -1.0: ldic.pushBack("RoQ_norm", str(float(ls.group(6))/L)) #Ohm/mm (weird unit, but changing would mean data containing two versions :/) retDict.pushBack("mode",ldic) return retDict