示例#1
0
def sta_value_ensemble_near_by_sta(sta_to,
                                   nearNum=100,
                                   sta_from=None,
                                   drop_frist=False):
    if (sta_to is None):
        return None
    if (sta_from is None):
        sta_from = copy.deepcopy(sta_to)
    xyz_sta0 = lon_lat_to_cartesian(sta_to['lon'].values[:],
                                    sta_to['lat'].values[:],
                                    R=meteva.base.basicdata.ER)
    xyz_sta1 = lon_lat_to_cartesian(sta_from['lon'].values[:],
                                    sta_from['lat'].values[:],
                                    R=meteva.base.basicdata.ER)
    tree = cKDTree(xyz_sta0)
    _, indexs = tree.query(xyz_sta1, k=nearNum)
    data_name = meteva.base.get_stadata_names(sta_from)[0]
    input_dat = sta_from[data_name].values
    sta_ensemble = sta_to[meteva.base.get_coord_names()]
    for i in range(nearNum):
        data_name = "data" + str(i)
        sta_ensemble[data_name] = input_dat[indexs[:, i]]
    if drop_frist:
        sta_ensemble = sta_ensemble.drop(columns=['data0'])
    return sta_ensemble
示例#2
0
def get_nearby_sta_dis_ensemble(sta_to,nearNum = 100,sta_from = None,drop_frist = False):
    if(sta_to is None):
        return None
    if(sta_from is None):
        sta_from = copy.deepcopy(sta_to)
    xyz_sta0 = lon_lat_to_cartesian(sta_to['lon'].values[:], sta_to['lat'].values[:],R = meteva.base.basicdata.ER)
    xyz_sta1 = lon_lat_to_cartesian(sta_from['lon'].values[:], sta_from['lat'].values[:],R = meteva.base.basicdata.ER)
    tree = cKDTree(xyz_sta0)
    d,_ = tree.query(xyz_sta1, k=nearNum)
    sta_ensemble = sta_to[meteva.base.get_coord_names()]
    for i in range(nearNum):
        data_name = "data" + str(i)
        sta_ensemble[data_name] = d[:,i]
    if drop_frist:
        sta_ensemble = sta_ensemble.drop(columns=['data0'])
    return sta_ensemble
示例#3
0
文件: nearing.py 项目: zph2074/meteva
def values_list_list_in_r_of_sta(sta_to,
                                 r=40,
                                 sta_from=None,
                                 drop_first=False):
    '''

    :param sta_to:
    :param r:
    :param sta_from:
    :param drop_first:
    :return: 返回的站点将会和sta_to 一致
    '''
    if (sta_to is None):
        return None
    if (sta_from is None):
        sta_from = copy.deepcopy(sta_to)
    sta_from = meteva.base.not_IV(sta_from)
    #print(sta_from)
    xyz_sta0 = lon_lat_to_cartesian(sta_to['lon'].values[:],
                                    sta_to['lat'].values[:],
                                    R=meteva.base.basicdata.ER)
    xyz_sta1 = lon_lat_to_cartesian(sta_from['lon'].values[:],
                                    sta_from['lat'].values[:],
                                    R=meteva.base.basicdata.ER)
    tree = cKDTree(xyz_sta1)
    data_name = meteva.base.get_stadata_names(sta_from)[0]
    input_dat = sta_from[data_name].values
    indexs_list = tree.query_ball_point(xyz_sta0, r=r)

    values_list = []
    if drop_first:
        for indexs in indexs_list:
            if len(indexs) > 1:
                values = input_dat[indexs[1:]]
                values_list.append(values)
            else:
                values_list.append([meteva.base.IV])
    else:
        for indexs in indexs_list:
            values = input_dat[indexs]
            values_list.append(values)

    return values_list