# This is a top-level module file that contains functions to handle # status values and job statuses with the MPE workflow. # Logan Karsten # National Center for Atmospheric Research # Research Applications Laboratory # karsten@ucar.edu # 303-497-2693 #from ConfigParser import SafeConfigParser import configparser import ioMod class statusMeta: def __init__(self): # Initialize empty object conaining variables. self.host = [] self.owner = [] self.errMsg = [] self.statusMsg = [] self.configPath = [] self.ncepWcoss = [] self.logFile = [] self.outDir = [] self.tmpDir = [] self.logDir = [] self.st4Dir = [] self.mrmsDir = [] self.hrrrDir = [] self.rapDir = [] self.hrrrWghtPath = [] self.rapWghtPath = [] self.mrmsWghtPath = [] self.hrapNwmWghtPath = [] self.numHoursBack = [] self.accDuration = [] self.geoFile = [] self.landMetaFile = [] self.rqiThresh = [] self.rqiStepMin = [] self.dReal = [] self.dInit = [] self.dEnd = [] self.dCurr = [] self.dBegAcc = [] self.dEndAcc = [] self.nLoopSteps = [] self.lockPath = [] self.rfcMsk = [] self.haveRfcMsk = False self.haveAccData = False self.emcAccOk = False self.useRqiMsk = False self.haveHourlyMPE = False self.flatLine = False self.useMrmsGc = False self.hrrrFcstHr = [] self.useHrrr = False self.useRap = False self.threshMM = [] self.logHandle = None self.rfcsMskOut = [] self.rfcsExcludeHrly = [] def readConfig(self): """ Function to read in run options from the Python configuration file. This gets called once at the beginning when the workflow is initialized. """ # Read in the configuration file. #parser = SafeConfigParser() parser = configparser.ConfigParser() try: parser.read(self.configPath) except: self.errMsg = "ERROR: Unable to open/read configuration file: " + self.configPath raise try: self.ncepWcoss = int(parser.get('logistics','ncepWcoss')) self.outDir = str(parser.get('logistics','outDir')) self.tmpDir = str(parser.get('logistics','tmpDir')) self.logDir = str(parser.get('logistics','logDir')) self.st4Dir = str(parser.get('logistics','stageIVDir')) self.mrmsDir = str(parser.get('logistics','mrmsDir')) self.hrrrDir = str(parser.get('logistics','hrrrDir')) self.rapDir = str(parser.get('logistics','rapDir')) self.geoFile = str(parser.get('logistics','geo1kmPath')) self.landMetaFile = str(parser.get('logistics','landMetaPath')) self.hrrrWghtPath = str(parser.get('logistics','hrrrHrapWghtPath')) self.rapWghtPath = str(parser.get('logistics','rapWghtPath')) self.mrmsWghtPath = str(parser.get('logistics','mrmsWghtPath')) self.hrapNwmWghtPath = str(parser.get('logistics','hrapNwmWghtPath')) self.numHoursBack = int(parser.get('logistics','numHoursProc')) self.accDuration = int(parser.get('logistics','accDuration')) self.rfcsExcludeHrly = str(parser.get('logistics','rfcsExcludeHourly')) self.rfcsExcludeHrly = self.rfcsExcludeHrly.split(' ') # Check to make sure a valid option has been passed...... if len(self.rfcsExcludeHrly[0]) != 0: for rfcCheckTmp in range(0,len(self.rfcsExcludeHrly)): if self.rfcsExcludeHrly[rfcCheckTmp] != 'CBRFC' and \ self.rfcsExcludeHrly[rfcCheckTmp] != 'CNRFC' and \ self.rfcsExcludeHrly[rfcCheckTmp] != 'NERFC' and \ self.rfcsExcludeHrly[rfcCheckTmp] != 'NWRFC' and \ self.rfcsExcludeHrly[rfcCheckTmp] != 'ABRFC' and \ self.rfcsExcludeHrly[rfcCheckTmp] != 'SERFC' and \ self.rfcsExcludeHrly[rfcCheckTmp] != 'WGRFC' and \ self.rfcsExcludeHrly[rfcCheckTmp] != 'WGRFC_special' and \ self.rfcsExcludeHrly[rfcCheckTmp] != 'NCRFC' and \ self.rfcsExcludeHrly[rfcCheckTmp] != 'LMRFC' and \ self.rfcsExcludeHrly[rfcCheckTmp] != 'MARFC' and \ self.rfcsExcludeHrly[rfcCheckTmp] != 'OHRFC' and \ self.rfcsExcludeHrly[rfcCheckTmp] != 'MBRFC': self.errMsg = "ERROR: Invalid rfcsExcludeHourly: " + self.rfcsExcludeHrly[rfcCheckTmp] + \ " Found in MPE.config" raise Exception() self.rfcsMskOut = str(parser.get('logistics','rfcsMaskOut')) self.rfcsMskOut = self.rfcsMskOut.split(' ') # Check to make sure a valid option has been passed...... if len(self.rfcsMskOut[0]) != 0: for rfcCheckTmp in range(0,len(self.rfcsMskOut)): if self.rfcsMskOut[rfcCheckTmp] != 'CBRFC' and \ self.rfcsMskOut[rfcCheckTmp] != 'CNRFC' and \ self.rfcsMskOut[rfcCheckTmp] != 'NERFC' and \ self.rfcsMskOut[rfcCheckTmp] != 'NWRFC' and \ self.rfcsMskOut[rfcCheckTmp] != 'ABRFC' and \ self.rfcsMskOut[rfcCheckTmp] != 'SERFC' and \ self.rfcsMskOut[rfcCheckTmp] != 'WGRFC' and \ self.rfcsMskOut[rfcCheckTmp] != 'WGRFC_special' and \ self.rfcsMskOut[rfcCheckTmp] != 'NCRFC' and \ self.rfcsMskOut[rfcCheckTmp] != 'LMRFC' and \ self.rfcsMskOut[rfcCheckTmp] != 'MARFC' and \ self.rfcsMskOut[rfcCheckTmp] != 'OHRFC' and \ self.rfcsMskOut[rfcCheckTmp] != 'MBRFC': self.errMsg = "ERROR: Invalid rfcsMaskOut: " + self.rfcsMskOut[rfcCheckTmp] + \ " Found in MPE.config" raise Exception() self.rqiThresh = float(parser.get('mpe_params','rqiThresh')) self.rqiStepMin = int(parser.get('mpe_params','rqiStepMinutes')) self.rfcMsk = str(parser.get('mpe_params','rfcGrid')) self.hrrrFcstHr = int(parser.get('mpe_params','hrrrFcstHr')) self.threshMM = float(parser.get('mpe_params','thresholdMM')) except: if len(self.errMsg) == 0: self.errMsg = "ERROR: Unable to pull data from configuration file: " + self.configPath raise # Sanity checking. try: ioMod.checkStaticMeta(self) except: raise