Exemplo n.º 1
0
def stagnant(savepath, predepth, zdata):
    # 得到道路积水深度数据
    data = zdata
    rdata = np.nan_to_num(data[:56])
    mes = pd.read_csv(glovar.roadpath, index_col=0)
    stationlon, stationlat = mes['Lon'].values, mes['Lat'].values  # 提取出道路坐标
    datas = FloodModel.cal2(rdata, predepth)

    #data = FloodModel.cal2(data, dr)
    # 此处需要加快速度,插值到道路点的速度过慢
    roadpoint = [
        interp.grid_interp_to_station([glovar.longrid, glovar.latgrid, data],
                                      stationlon, stationlat) for data in datas
    ]
    result = np.nan_to_num(roadpoint)
    result[result < 0] = 0
    flooding_index = np.piecewise(result, [
        result <= 0.4,
        (result > 0.4) & (result <= 1.0), (result > 1.0) & (result <= 1.5),
        (result > 1.5) & (result <= 2.0), result > 2.0
    ], [1, 2, 3, 4, 5])

    Writefile.write_to_csv(savepath, flooding_index, 'floodindex',
                           glovar.fnames, glovar.filetime)
    return roadpoint
Exemplo n.º 2
0
def predepth():
    # 前一时刻积水深度,此处需在服务器端测试优化
    dr = np.zeros(shape=(801, 1381))   # 目前默认前一时刻积水深度为0
    now = datetime.datetime.now()
    znwgtm = Znwg.znwgtime()
    *_, ftp = Writefile.readxml(glovar.trafficpath, 1)
    grib = Datainterface.GribData()
    remote_url = os.path.join(r'\\ANALYSIS\\CMPA', now.strftime('%Y'), now.strftime('%Y%m%d'))
    localdir = r'/home/cqkj/QHTraffic/Product/Product/mirror/rainlive'
    grib.mirror('FRT_CHN_0P05_3HOR', remote_url, localdir, ftp)
    rname = sorted(os.listdir(localdir))[-1]
    rpath = localdir + rname
    data, lat, lon, _ = Znwg.arrange((grib.readGrib(rpath)))
    data = interp.interpolateGridData(data, lat, lon, glovar.lat, glovar.lon)
    dataset = data[np.newaxis, ]                # 符合形状要求
    res = FloodModel.cal2(dataset, dr)
    return res[0]
Exemplo n.º 3
0
def floodsk(predata, data):
    # 计算前一时刻积水深度, data为sk降水, predata为实况前一时刻降水, 返回各点数据
    dr = np.zeros_like(predata)  # predata前一时刻降水
    pre = FloodModel.cal2(predata[np.newaxis, ], dr)
    datas = FloodModel.cal2(data[np.newaxis, ], pre)
    return datas