def performCalculations(fileList, baseName, outputPath, functionList): for f in functionList: if f == 'AVG': newfile = '{0}.avg.tif'.format(baseName) ofl = path.join(outputPath, newfile) calcAverage(fileList, ofl) elif f == 'STD': newfile = '{0}.std.tif'.format(baseName) ofl = path.join(outputPath, newfile) calcStDev(fileList, ofl) elif f == 'MAX': newfile = '{0}.max.tif'.format(baseName) ofl = path.join(outputPath, newfile) calcMax(fileList, ofl) elif f == 'MIN': newfile = '{0}.min.tif'.format(baseName) ofl = path.join(outputPath, newfile) calcMin(fileList, ofl) elif f == 'SUM': newfile = '{0}.sum.tif'.format(baseName) ofl = path.join(outputPath, newfile) calcSum(fileList, ofl) else: print f, ' is not a valid function.' return 0
def matchDayNightFiles(dayPath, nightPath, outPath): dayFiles = list(listdir(dayPath)) nightFiles = set(listdir(nightPath)) print "Day files: ", dayFiles print "Night files: ", nightFiles for fl in dayFiles: # find matching night file d_fl, ext = path.splitext(path.basename(path.normpath(fl))) if (ext == '.tif'): d_t = d_fl.rpartition('.') # night files end in 06, day files end in 01 n_fl = d_t[0] + d_t[1] + '06' + ext if (n_fl) in nightFiles: avg_fl = path.join(outPath, d_t[0] + d_t[1] + 'avg' + ext) dp = path.join(dayPath, d_fl+ext) np = path.join(nightPath, n_fl) calcAverage([dp, np], avg_fl) return 0
def performCalculations(fileList, baseName, outputPath, functionList): for f in functionList: if f == "AVG": newfile = "{0}.avg.tif".format(baseName) ofl = path.join(outputPath, newfile) calcAverage(fileList, ofl) elif f == "STD": newfile = "{0}.std.tif".format(baseName) ofl = path.join(outputPath, newfile) calcStDev(fileList, ofl) elif f == "MAX": newfile = "{0}.max.tif".format(baseName) ofl = path.join(outputPath, newfile) calcMax(fileList, ofl) elif f == "MIN": newfile = "{0}.min.tif".format(baseName) ofl = path.join(outputPath, newfile) calcMin(fileList, ofl) else: print f, " is not a valid function." return 0