コード例 #1
0
 def funcO2(self, val):
     Ps = np.hstack((self.Data_Grid[:, :2], val.reshape(-1, 1)))
     Ps = np.vstack((Ps, self.Data_Conditioning[:, [0, 1, 3]]))
     vdatas = variograms.semivariogram(Ps, self.lags, self.lag_tolerance)
     svs = vdatas[1] - 0.5 * (self.lags * self.trend)**2
     O2 = np.sum(((svs - self.svt) / self.svt)**2)
     return O2
コード例 #2
0
def semivariogram(data, lags, tol, model=None):
    '''
    Input:  (data)    NumPy array with three columns, the first two
                      columns should be the x and y coordinates, and
                      third should be the measurements of the variable
                      of interest
            (lags)    the lagged distance of interest
            (tol)     the allowable tolerance about (lag)
            (model)   model function taking a distance and returning
                      an approximation of the semivariance
    Output:           empirical semivariogram
    '''
    # h, sv = variograms.semivariogram(data, lags, tol)
    vdata = variograms.semivariogram(data, lags, tol)
    h, sv = vdata[0], vdata[1]
    sill = np.var(data[:, 2])
    fig, ax = subplots()
    if model:
        ax.plot(h, model(h), 'r')
    ax.plot(h, sv, 'ko-')
    ax.set_ylabel('Semivariance')
    ax.set_xlabel('Lag Distance')
    ax.set_title('Semivariogram')
    ax.text(tol * 3, sill * 1.025, str(np.round(sill, decimals=3)))
    ax.axhline(sill, ls='--', color='k')
    show()
コード例 #3
0
ファイル: model.py プロジェクト: sebitas/krige
def fitmodel( data, fct, lags, tol ):
    '''
    Input:  (P)      ndarray, data
            (model)  modeling function
                      - spherical
                      - exponential
                      - gaussian
            (lags)   lag distances
            (tol)    tolerance
    Output: (covfct) function modeling the covariance
    '''
    # calculate the semivariogram
    sv = variograms.semivariogram( data, lags, tol )
    # calculate the sill
    c = np.var( data[:,2] )
    # calculate the optimal parameters
    a = opt( fct, sv[0], sv[1], c )
    # return a covariance function
    covfct = covariance( fct, ( a, c ) )
    return covfct
コード例 #4
0
ファイル: model.py プロジェクト: the-fool/fasterGIS
def fitmodel( data, fct, lags, tol ):
    '''
    Input:  (P)      ndarray, data
            (model)  modeling function
                      - spherical
                      - exponential
                      - gaussian
            (lags)   lag distances
            (tol)    tolerance
    Output: (covfct) function modeling the covariance
    '''
    # calculate the semivariogram
    sv = variograms.semivariogram( data, lags, tol )
    # calculate the sill
    c = np.var( data[:,2] )
    # calculate the optimal parameters
    a = opt( fct, sv[0], sv[1], c )
    # return a covariance function
    covfct = covariance( fct, ( a, c ) )
    return covfct
コード例 #5
0
TBs.Table()
print("----------------------------------------------------------------------")

#Variogram calculation#
#Variogram initial
lag_number = 50
svt, dist_max, lag_size, lag_tolerance, lags = fo.variogram_parameter(
    Data_Grid, sill, nugget_var, a_range, lag_number, var_model=model)
svt_smooth, _, _, _, lag_smooth = fo.variogram_parameter(Data_Grid,
                                                         sill,
                                                         nugget_var,
                                                         a_range,
                                                         lag_number * 4,
                                                         var_model=model,
                                                         lag_size=lag_size / 4)
vdata = variograms.semivariogram(P, lags, lag_tolerance)
h, sv = vdata[0], vdata[1]
sv = sv - 0.5 * (h * pend)**2
graf.Experimental_Variogram(lags, [svt_smooth, sv],
                            sill,
                            a_range,
                            var_model=model,
                            variance=T_Phit.variance_value,
                            color_svt='red',
                            lags_svt=lag_smooth)

#Variogram simulated
lag_number = 10
svt, dist_max, lag_size, lag_tolerance_1, lags = fo.variogram_parameter(
    Data_Grid, sill, nugget_var, a_range, lag_number, var_model=model)
svt_smooth, _, _, _, lag_smooth = fo.variogram_parameter(Data_Grid,