Пример #1
0
def gp_adjust(lon, lat, gp_x, gp_y):
    x,y,z = sphere.spherical_to_cartesian((lon, lat))
    az_x, az_y = sphere.polar_to_az(lon, lat)
    xc = gp_x.predict([x,y,z])
    yc = gp_y.predict([x,y,z])
    corr_touch_lon, corr_touch_lat = sphere.az_to_polar(az_x+xc, az_y+yc)
    return corr_touch_lon, corr_touch_lat
Пример #2
0
def train_gp_sp(calibration, n=None):
    """Train a pair of squared-exponential Gaussian processes to predict offsets
    in azimuthal equidistant space. The GPs are trained on x, y inputs in the
    azimuthal space, and there is one GP for the x' and y' outputs.
    
    Returns a pair of GP objects (gp_x, gp_y) that perform the prediction."""
    unique_targets = calibration.groupby(["target_x", "target_y"]).mean()    
    
    if n is not None:
        unique_targets = unique_targets.loc[random.sample(unique_targets.index, n)]
        
    target_x = unique_targets["target_az_x"]
    target_y = unique_targets["target_az_y"]
    corr_x = unique_targets["touch_az_x"]
    corr_y = unique_targets["touch_az_y"]
    resid_x = np.array(target_x - corr_x)
    resid_y = np.array(target_y - corr_y)    
    x,y,z = sphere.spherical_to_cartesian((unique_targets["touch_lon"], unique_targets["touch_lat"]))    
    target = np.vstack((x,y,z)).transpose()    
    gp_x = gaussian_process.GaussianProcess(theta0=1e-2, thetaL=1e-7, thetaU=3e1, nugget=1e-3, random_start=10)
    gp_y = gaussian_process.GaussianProcess(theta0=1e-2, thetaL=1e-7, thetaU=3e1, nugget=1e-3, random_start=10)
    gp_x.fit(target, resid_x)
    gp_y.fit(target, resid_y)    
    
    return gp_x, gp_y