Exemplo n.º 1
0
def simple_Krig(SiteInfo, XYTargets, DataRecord):
    '''
    Wrapper for Kriging interpolation of all data, and save in PKL format \n
    Parameters 
    ----------
        **SiteInfo** -- Path to file with gauge location \n
        **XYTargets** -- Path to file with interpolation target locations \n
        **DataRecord** -- Path to file with variable registries \n

    Returns
    -------
        **VarField** -- file with pickled variable field \n
        **VarUnc** -- file with pickled variance of estimated variable \n
        **AvgVar** -- file with pickled average of estimated field
    '''
    
    stations, targets, records = data_load.lcsv(SiteInfo, XYTargets, 
                                                DataRecord)
    experimental_sv, record_covariance_matrix = exp_semivariogram(records, 
                                                                  stations)
    xopt, ModOpt, candidate_sv = theor_variogram(experimental_sv)
    Z, SP, ZAvg = krig(xopt[0]/3.0, targets, stations, records, 
                       record_covariance_matrix, ModOpt, xopt,
                       candidate_sv, tmin=0, tmax='def', MinNumSt=3, 
                       krig_type='Sim')

    return Z, SP, ZAvg
def simple_Krig(SiteInfo, XYTargets, DataRecord):
    '''
    Wrapper for Kriging interpolation of all data, and save in PKL format \n
    Parameters 
    ----------
        **SiteInfo** -- Path to file with gauge location \n
        **XYTargets** -- Path to file with interpolation target locations \n
        **DataRecord** -- Path to file with variable registries \n

    Returns
    -------
        **VarField** -- file with pickled variable field \n
        **VarUnc** -- file with pickled variance of estimated variable \n
        **AvgVar** -- file with pickled average of estimated field
    '''

    stations, targets, records = data_load.lcsv(SiteInfo, XYTargets,
                                                DataRecord)
    experimental_sv, record_covariance_matrix = exp_semivariogram(
        records, stations)
    xopt, ModOpt, candidate_sv = theor_variogram(experimental_sv)
    Z, SP, ZAvg = krig(xopt[0] / 3.0,
                       targets,
                       stations,
                       records,
                       record_covariance_matrix,
                       ModOpt,
                       xopt,
                       candidate_sv,
                       tmin=0,
                       tmax='def',
                       MinNumSt=3,
                       krig_type='Sim')

    return Z, SP, ZAvg
Exemplo n.º 3
0
                ssp[t, tarcoun] = sp_zeros
                zz[t, tarcoun] = 0
            
            if verbose: 
                print ('Finished step {0}/{1} at {2}'.format(n, len(data), 
                                                                 ctime()))

    return zz, ssp

if __name__ == '__main__':
    
    '''
    Module testing function
    '''
    stations, targets, records = data_load.lcsv('TestData\GaugeLoc.csv',
                                       'TestData\InterpPts.csv',
                                       'TestData\Dataset.csv')
    stations = np.array(stations)/1000.0
    targets = np.array(targets)/1000.0
    experimental_sv, record_covariance_matrix = exp_semivariogram(records, 
                                                                  stations)
    xopt, ModOpt, candidate_sv = theor_variogram(experimental_sv)
    
    meas_err_mat = np.random.rand(len(records), len(stations))    
    
    Z, SP, ZAvg = krig(10.0, targets, stations, records, 
                       record_covariance_matrix, ModOpt, xopt, candidate_sv, 
                       10 ,20, MinNumSt=3, krig_type='Ord')
    print 'Ordinary Kriging working fine'
    
    Z, SP, ZAvg = krig(10.0, targets, stations, records, 
                ssp[t, tarcoun] = sp_zeros
                zz[t, tarcoun] = 0

            if verbose:
                print('Finished step {0}/{1} at {2}'.format(
                    n, len(data), ctime()))

    return zz, ssp


if __name__ == '__main__':
    '''
    Module testing function
    '''
    stations, targets, records = data_load.lcsv('TestData\GaugeLoc.csv',
                                                'TestData\InterpPts.csv',
                                                'TestData\Dataset.csv')
    stations = np.array(stations) / 1000.0
    targets = np.array(targets) / 1000.0
    experimental_sv, record_covariance_matrix = exp_semivariogram(
        records, stations)
    xopt, ModOpt, candidate_sv = theor_variogram(experimental_sv)

    meas_err_mat = np.random.rand(len(records), len(stations))

    Z, SP, ZAvg = krig(10.0,
                       targets,
                       stations,
                       records,
                       record_covariance_matrix,
                       ModOpt,