Example #1
0
def compareMedianBalanceVsRegressionGivenGroundTruth(
                list_of_power, 
                num_time_sample=2000,
                origin_time_sample = 0.01,
                delta_time_sample = 0.002,  
                num_point_ricker_wavelet=100, 
                width_parameter_ricker_wavelet=10, 
                noise_level=1,
                initial_exponent_power=2, 
                max_iteration=60, 
                delta_exponent_power_tolerance=1e-12,
                output_directory='/tmp'):
    
    output = collections.namedtuple('compareMedianBalanceVsRegression', 
                                          ['list_median_balance_recovered_power', 
                                           'list_regression_recovered_power',
                                           'data_by_trace_time'
                                           'domain_time_sample']) 
    output.domain_time_sample = math_op.calculateLinearlySpacedValues(origin_time_sample, 
                                                               delta_time_sample, 
                                                               num_time_sample)
    output.data_by_trace_time = get_ricker_data(list_of_power, 
                                         num_time_sample, 
                                         num_point_ricker_wavelet, 
                                         width_parameter_ricker_wavelet, 
                                         output.domain_time_sample, 
                                         noise_level)
    output.list_median_balance_recovered_power = []
    output.list_regression_recovered_power = []
    for power, trace in zip(list_of_power, output.data_by_trace_time):    
                        #median_balance
        normalized_trace = np.squeeze(math_op.divideEachRowByItsMaxAbsValue(np.array([trace])))                       
        median_result = mb.recoverDomainWeightedGainViaMedianBalancing( normalized_trace, 
                        output.domain_time_sample,
                        initial_exponent_power,
                        max_iteration,
                        delta_exponent_power_tolerance,
                        output_directory,
                        print_to_stdout = 0,
                        logging_level=logging.CRITICAL)
        output.list_median_balance_recovered_power.append(median_result.domain_exponent_power)
                        #regression
        output_logloglinear = lll.findDomainPowerViaLogLogLinearRegresstion(
                                                                    np.abs(trace),
                                                                    output.domain_time_sample)
        output.list_regression_recovered_power.append(-output_logloglinear.slope)
    
    l2_median_balance_powers_error = np.linalg.norm(output.list_median_balance_recovered_power - list_of_power)
    l2_regression_powers_error = np.linalg.norm(output.list_regression_recovered_power - list_of_power)
    print 'l2_median_balance_powers_error= %g' % l2_median_balance_powers_error
    print 'l2_regression_powers_error = %g' % l2_regression_powers_error
    print 'l2_median_balance_powers_error / l2_regression_powers_error = %g' % (l2_median_balance_powers_error/l2_regression_powers_error)


    
    return output
Example #2
0
            break
        if case('median_balance'):
                      
            ###################################################################
            #                USER CONFIG: choose run parameters
            ###################################################################                
                            #--> input data_type
            input_data_type = 'rsf'
            num_trace = 3
            num_time_sample = 2000
            delta_time_sample = 0.002
            origin_time_sample = delta_time_sample
            origin_trace = -2
            delta_trace = 0.05            
                            #--> powers to attenuate synthetic data with
            list_of_power = math_op.calculateLinearlySpacedValues(0.25, 0.5, num_trace)    
                            #-->location of config file
            config_file = "/home/mlai/geo/mlai/median_balance/user_settings.cfg"
                            #-->change these values for code speedup
            logging_level = logging.DEBUG
            print_to_stdout = 0
                            #-->view input as family of traces or individual traces
            treat_traces_individually = 1

            ###################################################################                        
            domain_time_sample = math_op.calculateLinearlySpacedValues(
                                                        origin_time_sample,
                                                        delta_time_sample,
                                                        num_time_sample)
            domain_time_sample_with_end_point = math_op.calculateLinearlySpacedValues(
                                                        origin_time_sample,