def matching(a=a, wrfFolder=wrfFolder, verbose=False, display=False, saveImage=False): count = 0 a.load() a.truncate(0, newObject=False) # debug ################################################################ if display: # a.show() # time.sleep(1) tr.showArrayWithAxes(a) if saveImage: plt.close() tr.showArrayWithAxes(a, display=False, outputPath=outputFolder + str(int(time.time())) + a.name + ".png") # end debug ############################################################ wrfPathList = os.listdir(wrfFolder) wrfPathList = [v for v in wrfPathList if ".dat" in v and "wrf" in v] # trimming wrfPathList.sort() scores = [] for wrfPath in wrfPathList: # read the data one-by-one + split the data files wrfFrames = read1Wrf(wrfPath=wrfPath) for w in wrfFrames: w.truncate(0, newObject=False) # debug ################################################################ if saveImage: plt.close() tr.showArrayWithAxes( w, display=False, outputPath=outputFolder + str(int(time.time())) + w.name + ".png" ) if display: # w.show() # time.sleep(1) plt.close() tr.showArrayWithAxes(w) # end debug ############################################################ if verbose: print count, a.name, "v", w.name, ":", count += 1 score = getScore(a, w) # key line if verbose: print score scores.append({"radar": a.name, "wrf": w.name, "score": score}) # ordering the results scores.sort(key=lambda v: v["score"], reverse=True) return scores
def matching(a=a0, wepsFolder=wepsFolder, thres=0, maxTimeDiff=6, timeInterval=3, key1="", key2="", verbose=False, display=False, saveImage=False): count = 0 a.load() a.truncate(thres, newObject=False) if verbose: print "=================================" print 'name, dataTime:' print a.name print a.dataTime # debug ################################################################ if display: #a.show() #time.sleep(1) tr.showArrayWithAxes(a) if saveImage: plt.close() tr.showArrayWithAxes(a, display=False, outputPath=outputFolder+ str(int(time.time()))+a.name+ ".png") # end debug ############################################################ scores = [] wrfFolders = getWrfFolders(wepsFolder, a=a, maxTimeDiff=maxTimeDiff, key1=key1) for wrfFolder in wrfFolders: wrfPathList=os.listdir(wrfFolder) wrfPathList = [wrfFolder+v for v in wrfPathList if ".dat" in v and "wrf" in v] #trimming wrfPathList = [v for v in wrfPathList if key2 in v] #trimming wrfPathList.sort() if verbose: print "key2:", key2 print "wrfPathList:" print '\n'.join([str(v) for v in wrfPathList]) if wrfPathList == []: continue for wrfPath in wrfPathList: # read the data one-by-one + split the data files wrfFrames = read1Wrf(wrfPath=wrfPath) startIndex, endIndex = getWrfFrameIndices(a=a, wrfFolder=wrfFolder, maxTimeDiff=maxTimeDiff, timeInterval=timeInterval, verbose=verbose) startIndex = max(0, startIndex) endIndex = min(numberOfFramesPerModel-1, endIndex) # fixed 2014-06-11 if verbose: print "=================================" print wrfPath, "start and end indices:", startIndex, endIndex for w in wrfFrames[startIndex: endIndex+1]: w.truncate(thres, newObject=False) # debug ################################################################ if saveImage: plt.close() tr.showArrayWithAxes(w, display=False,outputPath=outputFolder+ str(int(time.time()))+w.name+ ".png") if display: #w.show() #time.sleep(1) plt.close() tr.showArrayWithAxes(w) # end debug ############################################################ if verbose: print count, a.name, "v", w.name, ":", count +=1 score = getScore(a, w, thres=thres) # key line if verbose: print score scores.append({'radar':a.name, 'score': score, 'wrfFolder': wrfFolder.split('/')[-2], 'wrf': w.name, }) #ordering the results scores.sort(key=lambda v:v['score'], reverse=True) return scores
def matching(a=a, wepsFolder=wepsFolder, thres=0, maxTimeDiff=6, timeInterval=3, verbose=False, display=False, saveImage=False): count = 0 a.load() a.truncate(thres, newObject=False) # debug ################################################################ if display: #a.show() #time.sleep(1) tr.showArrayWithAxes(a) if saveImage: plt.close() tr.showArrayWithAxes(a, display=False, outputPath=outputFolder+ str(int(time.time()))+a.name+ ".png") # end debug ############################################################ scores = [] wrfFolders = getWrfFolders(wepsFolder, a=a, maxTimeDiff=maxTimeDiff) for wrfFolder in wrfFolders: wrfPathList=os.listdir(wrfFolder) wrfPathList = [wrfFolder+v for v in wrfPathList if ".dat" in v and "wrf" in v] #trimming wrfPathList.sort() for wrfPath in wrfPathList: # read the data one-by-one + split the data files wrfFrames = read1Wrf(wrfPath=wrfPath) startIndex, endIndex = getWrfFrameIndices(a=a, wrfFolder=wrfFolder, maxTimeDiff=maxTimeDiff, timeInterval=timeInterval) startIndex = max(0, startIndex) endIndex = min(len(wrfPathList)-1, endIndex) if verbose: print wrfPath, "start and end indices:", startIndex, endIndex for w in wrfFrames[startIndex: endIndex+1]: w.truncate(thres, newObject=False) # debug ################################################################ if saveImage: plt.close() tr.showArrayWithAxes(w, display=False,outputPath=outputFolder+ str(int(time.time()))+w.name+ ".png") if display: #w.show() #time.sleep(1) plt.close() tr.showArrayWithAxes(w) # end debug ############################################################ if verbose: print count, a.name, "v", w.name, ":", count +=1 score = getScore(a, w) # key line if verbose: print score scores.append({'radar':a.name, 'wrf': w.name, 'score': score }) #ordering the results scores.sort(key=lambda v:v['score'], reverse=True) return scores