diff --git a/modules/util/viirs_l1b_l2.py b/modules/util/viirs_l1b_l2.py index 7652f68204335a53c1542e74d441d5ee18b5bc8e..9e26156495dc6535132bb8a814ac3b4cff9f5231 100644 --- a/modules/util/viirs_l1b_l2.py +++ b/modules/util/viirs_l1b_l2.py @@ -113,12 +113,12 @@ def run_all(directory, out_directory, day_night='ANY', start=10): continue try: - run(data_h5f, data_params, data_train_tiles, data_valid_tiles, num_keep_x_tiles=num_keep_x_tiles, tile_width=128, kernel_size=11, day_night=day_night) + total, kept = run(data_h5f, data_params, data_train_tiles, data_valid_tiles, num_keep_x_tiles=num_keep_x_tiles, tile_width=128, kernel_size=11, day_night=day_night) except Exception as e: print(e) data_h5f.close() continue - print(data_f) + print(data_f, int(100 * (kept/total))) f_cnt += 1 data_h5f.close() @@ -186,6 +186,9 @@ def run(data_h5f, param_s, train_tiles, valid_tiles, num_keep_x_tiles=8, tile_wi num_y_valid = int(num_keep_y_tiles * 0.1) + 1 num_y_train = num_keep_y_tiles - num_y_valid - 1 + cnt_total = 0 + cnt_kept = 0 + for j in range(num_y_train): j_a = j_start + j * j_skip j_b = j_a + tile_width @@ -194,6 +197,8 @@ def run(data_h5f, param_s, train_tiles, valid_tiles, num_keep_x_tiles=8, tile_wi i_a = i_start + i * i_skip i_b = i_a + tile_width + cnt_total += 1 + if day_night == 'DAY' and not is_day(solzen[j_a:j_b, i_a:i_b]): continue elif day_night == 'NIGHT' and is_day(solzen[j_a:j_b, i_a:i_b]): @@ -203,6 +208,7 @@ def run(data_h5f, param_s, train_tiles, valid_tiles, num_keep_x_tiles=8, tile_wi nda = keep_tile(param_s, nda) if nda is not None: train_tiles.append(nda) + cnt_kept += 1 j_start = num_y_train * tile_width + 2*tile_width for j in range(num_y_valid): @@ -213,6 +219,8 @@ def run(data_h5f, param_s, train_tiles, valid_tiles, num_keep_x_tiles=8, tile_wi i_a = i_start + i * i_skip i_b = i_a + tile_width + cnt_total += 1 + if day_night == 'DAY' and not is_day(solzen[j_a:j_b, i_a:i_b]): continue elif day_night == 'NIGHT' and is_day(solzen[j_a:j_b, i_a:i_b]): @@ -222,6 +230,9 @@ def run(data_h5f, param_s, train_tiles, valid_tiles, num_keep_x_tiles=8, tile_wi nda = keep_tile(param_s, nda) if nda is not None: valid_tiles.append(nda) + cnt_kept += 1 + + return cnt_total, cnt_kept def scan(directory):