DRIP.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:DRIP-SLIP 作者: NASA-DEVELOP 项目源码 文件源码
def sum48(newFile,extent):
    currentSum=loadtxt(os.path.join(getCurrentDirectory(),'Sum48','sum48.txt'),dtype='float',delimiter=',')
    historicFiles=sorted(glob.glob(os.path.join(getCurrentDirectory(),'Sum48','Files','*txt')))
    lastFile=loadtxt(os.path.join(getCurrentDirectory(),'Sum48','Files',historicFiles[0]),dtype='float',delimiter=',')
    currentSum=currentSum-lastFile
    currentSum=currentSum+newFile
    np.savetxt(os.path.join(getCurrentDirectory(),'Sum48','sum48.txt'),currentSum,delimiter=',')
    rotatedSum = np.rot90(currentSum)
    tiffFiles=glob.glob(os.path.join(getCurrentDirectory(),'Sum48','Tiffs','*.TIF'))
    if not tiffFiles:
        lastTifNum='1'
    else:
        tiffFiles=natsorted(tiffFiles,alg=ns.IC)
        lastTif=tiffFiles[-1]
        lastTifNum=str(int(lastTif[lastTif.rfind('_')+1:lastTif.rfind('.')])+1)
    array2raster(os.path.join(getCurrentDirectory(),'Sum48','Tiffs',timeStr[-11:-7]) + '_48HourSum_' + lastTifNum + '.TIF',[extent[0],extent[3]],extent[4],extent[5],rotatedSum,gdalconst.GDT_Float32)
    while len(tiffFiles)>48:
        os.remove(tiffFiles[0])
        tiffFiles=natsorted(glob.glob(os.path.join(getCurrentDirectory(),'Sum48','Tiffs','*.TIF')),alg=ns.IC)
    os.remove(historicFiles[0])

#sums the past 72 hours of rainfall, sends an email if exceeds threshold
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号