diff --git a/modules/util/viirs_l1b_l2.py b/modules/util/viirs_l1b_l2.py index 9a9f13d3dce30ce8414084300b7bae8db5b5439f..8e2ca192574e35100a401645d82a88de8eb23b60 100644 --- a/modules/util/viirs_l1b_l2.py +++ b/modules/util/viirs_l1b_l2.py @@ -3,6 +3,8 @@ import h5py from util.util import get_grid_values, get_grid_values_all, is_night, compute_lwc_iwc import glob import os +from aeolus.datasource import CLAVRx_VIIRS +from icing.moon_phase import * from pathlib import Path emis_params = ['temp_10_4um_nom', 'temp_11_0um_nom', 'temp_12_0um_nom', 'temp_13_3um_nom', 'temp_3_75um_nom', @@ -216,28 +218,23 @@ def run(data_h5f, label_h5f, data_tiles, label_tiles, mod_tile_width=64, border= def scan(directory): - for p in os.scandir(directory): - if not p.is_dir(): - continue - files = glob.glob(directory + p.name+'/'+'clavrx_snpp_viirs*.uwssec*.h5') - num_files = len(files) - - num_keep = 0 - for idx, file in enumerate(files): - h5f = h5py.File(file, 'r') - try: - solzen = get_grid_values_all(h5f, 'solar_zenith_angle') - except Exception as e: - # print(e) - h5f.close() - continue - if is_night(solzen): - num_keep += 1 - print(file) + data_src = CLAVRx_VIIRS(directory) + files = data_src.flist + + for idx, file in enumerate(files): + h5f = h5py.File(file, 'r') + ts = data_src.ftimes[0] + try: + solzen = get_grid_values_all(h5f, 'solar_zenith_angle') + except Exception as e: + # print(e) h5f.close() + continue - print(num_files, num_keep) + if is_night(solzen) and moon_phase(ts): + print(file) + h5f.close() def test_nlcomp(file):