Example #1
0
def apply_height_updates(data_mms,
                         data_updates,
                         res_update,
                         r,
                         global_shift=0):

    # Indexing
    d_update = rasterize(data_updates, res_update, dim=2)
    d_mms = rasterize(data_mms, res_update, dim=2)

    # Points at the borders leads bugs - thus remove the cell-id
    d_mms = remove_border_pts(d_mms, res_update, r)

    # Initialize container
    data_updated = []

    for key, value in d_mms.iteritems():
        sub_mms = data_mms[value]
        update_value = data_updates[d_update[key][0], 2]
        sub_mms[:, :3] = sub_mms[:, :3] - [0, 0, update_value] - [
            0, 0, global_shift
        ]  # Must be minus here
        data_updated.extend(sub_mms)

    return np.array(data_updated)
Example #2
0
def calc_difference_mms_ref(data_mms,
                            data_ref,
                            res_diff,
                            r,
                            is_plot=is_plot_flag):

    difference = np.zeros((int(r / res_diff), int(r / res_diff)))

    d_mms_sub = rasterize(data_mms, res_diff, dim=2)
    d_ref_sub = rasterize(data_ref, res_diff, dim=2)

    for subkey, subvalue in d_mms_sub.iteritems():
        m, n = np.int0(subkey.split('+'))
        z_mms = np.median(data_mms[subvalue, 2])
        z_ref = data_ref[d_ref_sub[subkey], 2][0] + shift
        difference[m, n] = z_mms - z_ref

    if is_plot:
        plt.figure()
        plt.imshow(difference, vmin=-0.3, vmax=0.3)
        plt.colorbar()
        plt.figure()
        plt.hist(difference, bins='auto')
        plt.show()

    return difference
Example #3
0
def update_pointcloud(data_mms, data_update, res_update):
    
    # Create index according to updates resolution
    d_update = rasterize(data_update, res_update, dim = 2)        
    d_mms_runid = rasterize(data_mms, res_update, dim = 2)
    
    # Apply change for each cell regarding updates resolution
    data_updated = []
    for key, value in d_mms_runid.iteritems():
        sub_mms = data_mms[value]
        if key in d_update:
            update_value = data_update[d_update[key][0],2]
            sub_mms[:,:3] = sub_mms[:,:3] - [0,0,update_value]
            data_updated.extend(sub_mms) # Must be minus here
    return np.array(data_updated) 
Example #4
0
def grid_difference_filter_based(fn_ref, res_ref, data_mms, nonvalue,
                                 raster_size, threshold_height_diff):

    d_mms = rasterize(data_mms, res_ref, dim=2)

    # read reference
    data_ref, d_ref = read_ascii_xyz(fn_ref,
                                     delimiter=' ',
                                     skiprows=7,
                                     dtype=np.float,
                                     e=res_ref,
                                     dim=2)

    # calculate the difference
    difference = nonvalue * np.ones((raster_size, raster_size))

    reduce_list = []

    for key, value in d_mms.iteritems():
        m, n = np.int0(key.split('+'))
        z_mms = data_mms[value, 2]
        mean_mms = np.mean(z_mms)

        mean_ref = data_ref[d_ref[key], 2]
        delta = mean_mms - mean_ref

        if delta > threshold_height_diff:
            reduce_list.extend(value)
        else:
            difference[m, n] = mean_mms - mean_ref

    return difference, reduce_list
Example #5
0
def down_sampling(merged, res_output, method):

    d_merged = rasterize(merged, res_output, dim=3)
    reduced_cloud = [
        method(merged[value], axis=0) for key, value in d_merged.iteritems()
    ]

    return np.array(reduced_cloud)
Example #6
0
def calc_diff_core(fn, args):

    mms_dir, ref_dir, res_ref, r, x_offset, y_offset, geoid, sigma_geoid = args

    data_mms = load_mms(fn, args)
    #data_mms = read_bin(mms_dir + fn, 7)
    data_ref = read_bin(ref_dir + fn, 7)

    d_ref = rasterize(data_ref, res_ref, dim=2)

    shift_value, shift_img = shiftvalue(np.array(data_mms), res_ref,
                                        np.array(data_ref), d_ref, 1., r)

    return fn, shift_value, shift_img
Example #7
0
def grid_difference(fn_ref, res_ref, data_mms, nonvalue, raster_size):

    d_mms = rasterize(data_mms, res_ref, dim=2)

    # read reference
    data_ref, d_ref = read_ascii_xyz(fn_ref,
                                     delimiter=' ',
                                     skiprows=7,
                                     dtype=np.float,
                                     e=res_ref,
                                     dim=2)

    # calculate the difference
    difference = nonvalue * np.ones((raster_size, raster_size))

    for key, value in d_mms.iteritems():
        m, n = np.int0(key.split('+'))
        z_mms = data_mms[value, 2]
        mean_mms = np.mean(z_mms)

        mean_ref = data_ref[d_ref[key], 2]
        difference[m, n] = mean_mms - mean_ref

    return difference
Example #8
0
        height_needed = find_time_without_value(dict_shift_value, list_mms)    
        dict_shift_value, num_changes = insert_values_based_on_neigbours(dict_shift_value, height_needed)  
        count += 1

     
#fn = "0000002b_ffffff09.ply"
fn = "0000002a_ffffff08.ply"
#fn = "00000027_ffffff05.ply"
#fn = "00000020_fffffec3.ply"
if 1:
#for fn in list_mms:
    
    data_mms = read_bin(mms_dir + fn, 7)
    data_ref = read_bin(ref_dir + fn, 7)
    
    d_ref = rasterize(data_ref, res_ref, dim = 2)
    d_mms = rasterize(data_mms, res_ref, dim = 2)
    
    data_mms = np.array(data_mms)
    data_ref = np.array(data_ref)
    
    index_list = []
    
    # Correction for old dtm with bad interpolation
    for key, value in d_mms.iteritems():
        x, y = [int(k) for k in key.split('+')]
        
        z_mms = data_mms[value,2]
        z_ref = data_ref[d_ref[key], 2][0] + shift
        
        dz = z_mms -z_ref