Beispiel #1
0
def iceData():
    # 获取ec数据信息(气温、降水、地温、湿度、积雪深度)
    ectime = ecmwf.ecreptime()
    fh = [i for i in range(12, 181, 3)]  # 20点的预报获取今天8:00的ec预报
    *_, dics = Writefile.readxml(glovar.trafficpath, 4)
    dicslist = dics.split(',')
    lonlatset, dataset = [], []
    for dic in dicslist:
        newdata = []
        lon, lat, data = Datainterface.micapsdata(ectime, dic, fh)
        lonlatset.append((lon, lat))
        for i in range(data.shape[0] - 1):
            if (np.isnan(data[i]).all() == True) and (i + 1 <= data.shape[0]):
                data[i] = data[i + 1] / 2
                data[i + 1] = data[i + 1] / 2
                newdata.append(
                    interp.interpolateGridData(data[i], lat, lon, glovar.lat,
                                               glovar.lon))
            else:
                newdata.append(
                    interp.interpolateGridData(data[i], lat, lon, glovar.lat,
                                               glovar.lon))
        newdata = np.array(newdata)
        # newdata[newdata<0] = 0                    # 保证数据正确性
        dataset.append(newdata)  # 保存插值后的数据集
    return np.array(dataset)
Beispiel #2
0
def main():
    saltedata = saltedata(path)
    snowpre = np.random.randint(0, 1, size=(801 * 1381, 1))
    snow = SnowDepth()
    rep = ecmwf.ecreptime()
    fh = [i for i in range(12, 181, 3)]
    region = [
        float(i) for i in ','.join(
            Writefile.readxml(
                r'/home/cqkj/QHTraffic/Product/Traffic/SNOD/config.xml',
                0)).split(',')
    ]
    new_lon = np.arange(region[0], region[2], region[-1])
    new_lat = np.arange(region[1], region[3], region[-1])
    lonlatset, dataset = [], []
    # 提取数据及经纬度(双重循环,看能否改进)
    for dic in snow.dics:
        lon, lat, data = Datainterface.micapsdata(rep, dic, fh)
        lonlatset.append((lon, lat))
        for i in range(data.shape[0] - 1):
            if (np.isnan(data[i]).all() == True) and (i + 1 <= data.shape[0]):
                data[i] = data[i + 1] / 2
                data[i + 1] = data[i + 1] / 2
                interp.interpolateGridData(data, lat, lon, new_lat, new_lon)
            else:
                interp.interpolateGridData(data, lat, lon, new_lat, new_lon)
        dataset.append(data)  # 保存插值后的数据集
    depthgrid = snow.clcsd(dataset, new_lat, new_lon, saltedata, snowpre)
    snow.write(depthgrid, new_lat, new_lon)
    dangerindex = snow.clcindex(depthgrid, new_lat, new_lon)
    snow.write(dangerindex, type=1)
Beispiel #3
0
def presnow():
    # 得到前一时刻积雪深度
    ectime = ecmwf.ecreptime()
    fh = [0]
    dic = 'ECMWF_HR/SNOD'
    lon, lat, data = Datainterface.micapsdata(ectime, dic, fh)
    return interp.interpolateGridData(data, lat, lon, glovar.lat, glovar.lon)
Beispiel #4
0
def main():
    ice = Roadic()
    rep = ecmwf.ecreptime()
    fh = [i for i in range(12, 181, 3)]
    region = [float(i) for i in ','.join(Writefile.readxml(glovar.trafficpath, 0)).split(',')]
    new_lon = np.arange(region[0], region[2], region[-1])
    new_lat = np.arange(region[1], region[3], region[-1])
    lonlatset, dataset = [], []
    # 提取数据及经纬度(双重循环,看能否改进)
    for dic in ice.dics:
        lon, lat, data = Datainterface.micapsdata(rep, dic, fh)
        lonlatset.append((lon, lat))
        for i in range(data.shape[0] - 1):
            if (np.isnan(data[i]).all() == True) and (i + 1 <= data.shape[0]):
                data[i] = data[i + 1] / 2
                data[i+1] = data[i + 1] / 2
                interp.interpolateGridData(data,lat,lon,new_lat, new_lon)
            else:
                interp.interpolateGridData(data, lat, lon,new_lat, new_lon)
        dataset.append(data)                     # 保存插值后的数据集
    icgrid = ice.icegrid(dataset, new_lat, new_lon)
    savepath, indexpath = Writefile.readxml(glovar.trafficpath, 1)[2:]
    write(savepath, icgrid, 'Roadic', new_lat, new_lon)               # 先保存厚度网格数据
    iceroad = ice.depth2onezero(icgrid, new_lat, new_lon)
    ################################################################################
    # 获取cimiss数据集,此处仅为读取,实况数据获取及保存由另一程序实现
    cmissdata = np.loadtxt('/home/cqkj/QHTraffic/qhroadic/cmsk.csv', delimiter=',')
    icedays = RoadIceindex(cmissdata, iceroad)
    roadicing = icedays.iceday()
    write(indexpath, roadicing, 'RoadicIndex', type=1)