def CheckModelOutput(self,strncPathIn,strtxtForcePathIn): #1 run model fileset = formic.FileSet(include="**/*.nc", directory=strncPathIn) nFile = 0 # print process file ID # varTimeDataArray = None; for file_name in fileset: nFile+=1 print "################################################################" print "Current file is : " + file_name + "; It is the " + str(nFile) print "################################################################" #get date info if (varTimeDataArray is None): getNcFileDate = getSingleNcFileDate(file_name) varTimeDataArray = getNcFileDate.getNcFileDate("Times","Noah") ncFileProcess = NcFileProcess(file_name) alllayerMonthMean = ncFileProcess.getAllLayerMeanTempByMonth(5,varTimeDataArray) maxListValue = max(alllayerMonthMean[0]) if (maxListValue < 250) or (maxListValue > 310): InputFileDir,InputFile = os.path.split(file_name) filename, file_extension = os.path.splitext(InputFile) strFileFix = filename+".txt" srcfile = strtxtForcePathIn + strFileFix if not os.path.exists(srcfile): print "Error there have no " + srcfile os.system("pause") exit(0) dstdir = os.path.join("F:\\worktemp\\Permafrost(Change)\\Run(S)\\", strFileFix) shutil.copy(srcfile, dstdir)
def IsPermafrost(self,varTimeDataArray,startTime = None, endTime = None): if startTime is None: startTime = datetime.datetime(2010,1,1) if endTime is None: endTime = datetime.datetime(2010,12,31) ncFileProcess = NcFileProcess(self.strncDataPath) alllayerMonthMean = ncFileProcess.getAllLayerMeanTempByMonth(5,varTimeDataArray,startTime,endTime) #alllayerDay = ncFileProcess.getAllLayerMaxMinTempByDay(5,varTimeDataArray) maxList = alllayerMonthMean[0] minList = alllayerMonthMean[1] self.IdentificationPermafrost(maxAllLevelList,minAllLevelList)
def CalCalPermafrostALT(self,varTimeDataArray,layerList = None): if layerList is None: layerList = [-0.045,-0.091,-0.166,-0.289,-0.493,-0.829,-1.383,-2.296,-3.2,-4.2,-5.2,-6.2,\ -7.2,-8.2,-9.2,-11.2,-13.2,-15.2] lenDepths = len(layerList) ncFileProcess = NcFileProcess(self.strncDataPath) maxList =[] alllayerMonthMean = ncFileProcess.getAllLayerMeanTempByMonth(0,varTimeDataArray) maxList = alllayerMonthMean[0] maxList = map(lambda x:x-273.15,maxList) ALTINFO = 15.0 if min(maxList) > 0: ALTINFO = -2.0 elif maxList[0] > 0: reList = self.getSubMax4Alt(maxList) nLen = len(reList) InterFun = interp1d( reList, layerList[0:nLen]) ALTINFO = InterFun(0.0) FALTINFO = round(float(ALTINFO),2) print FALTINFO return FALTINFO
def CalCalPermafrostMAGT(self,varTimeDataArray,layerList = None): if layerList is None: layerList = [-0.045,-0.091,-0.166,-0.289,-0.493,-0.829,-1.383,-2.296,-3.2,-4.2,-5.2,-6.2,\ -7.2,-8.2,-9.2,-11.2,-13.2,-15.2] lenDepths = len(layerList) ncFileProcess = NcFileProcess(self.strncDataPath) alllayerMonthMean = ncFileProcess.getAllLayerMeanTempByMonth(0,varTimeDataArray) maxList = map(lambda x:x-273.15,alllayerMonthMean[0]) minList = map(lambda x:x-273.15,alllayerMonthMean[1]) MAGTINFO = 0.0 DAZZINFO = 0.0 DiffMinMaxList = list(map(operator.sub, maxList, minList)) index = 0 for val in DiffMinMaxList: index = index + 1 if val < 0.5: maxVal = maxList[index-1] minVal = minList[index-1] MAGTINFO = (maxVal + minVal)/2.0 DAZZINFO = layerList[index-1] break #Use 15.2m temperature if(MAGTINFO == 0.0): maxVal = maxList[17] minVal = minList[17] MAGTINFO = (maxVal + minVal)/2.0 DAZZINFO = -15.20 # if(MAGTINFO > 0.0): MAGTINFO = 0.0 # if(MAGTINFO <-20.0): MAGTINFO = -20.0 MAGTINFO = round(float(MAGTINFO),2) print MAGTINFO,DAZZINFO return [MAGTINFO,DAZZINFO]