Ejemplo n.º 1
0
 def create_predict_mask_lake(modis_utils_obj, data_type='test'):
     for idx in range(modis_utils_obj.get_n_tests(data_type)):
         pred = modis_utils_obj.get_inference(data_type, idx)
         pred = modis_utils_obj._preprocess_strategy_context.inverse(pred)
         predict_mask_lake_path = os.path.join(
             modis_utils_obj._predict_mask_lake_dir, data_type, '{}.dat'.format(idx))
         cache_data(mask_lake_img(pred), predict_mask_lake_path)
Ejemplo n.º 2
0
def get_groundtruth_mask_lake(data_dir, used_band, time_steps,
                              reservoir_index, test_index, data_type='test'):
    target_file_path = get_data_file_path(data_dir, reservoir_index, used_band,
                                          time_steps, data_type, 'target')
    test_path = get_target_paths(target_file_path)[test_index]
    token = test_path.split('/')
    raw_path = '/'.join(['raw_data'] + token[3:])
    img = get_im(raw_path[:-4] + '.tif')
    return mask_lake_img(img, band=used_band)
Ejemplo n.º 3
0
def get_predict_mask_lake(data_dir, used_band, crop_size, time_steps, filters,
                          kernel_size, n_hidden_layers, mask_cloud_loss,
                          reservoir_index, test_index):
    predict_dir = get_predict_dir(data_dir, reservoir_index, used_band, crop_size, time_steps,
                                  filters, kernel_size, n_hidden_layers, mask_cloud_loss)
    predict = restore_data(os.path.join(predict_dir, '{}.dat'.format(test_index)))
    if 'div' not in data_dir:
        reservoir_min, reservoir_max = get_reservoir_min_max(data_dir, reservoir_index)
        mean, std = get_reservoir_mean_std(data_dir, reservoir_index)
        predict = np.interp(predict, (np.min(predict), np.max(predict)), 
                            (reservoir_min, reservoir_max))
        predict = predict*std + mean
    else:
        predict = np.interp(predict, (np.min(predict), np.max(predict)), (-2001, 10000))
    predict_mask = mask_lake_img(predict, band=used_band)
    return predict_mask
Ejemplo n.º 4
0
def find_boundaries_mask_lake(x, water_threshold):
    x1 = mask_lake_img(x, offset=water_threshold)
    x1 = np.logical_or(x1, permanent_water_area)
    return find_boundaries(x1)
Ejemplo n.º 5
0
def find_boundaries_mask_lake(x, water_threshold):
    x1 = mask_lake_img(x, offset=water_threshold)
    return find_boundaries(x1)