diff --git a/modules/deeplearning/srcnn_l1b_l2.py b/modules/deeplearning/srcnn_l1b_l2.py index 34b77bed8e9f42c3961700e277bc9d3c9d869f63..b3c0d9ed6de04f724d4aa058d08d5a46bcb4c072 100644 --- a/modules/deeplearning/srcnn_l1b_l2.py +++ b/modules/deeplearning/srcnn_l1b_l2.py @@ -7,6 +7,7 @@ import os, datetime import numpy as np import pickle import h5py +from scipy.ndimage import gaussian_filter # L1B M/I-bands: /apollo/cloud/scratch/cwhite/VIIRS_HRES/2019/2019_01_01/ # CLAVRx: /apollo/cloud/scratch/Satellite_Output/VIIRS_HRES/2019/2019_01_01/ @@ -754,6 +755,7 @@ def run_evaluate_static(in_file, out_file, ckpt_dir): # grd_b = normalize(grd_b, 'refl_0_65um_nom', mean_std_dct) grd_c = get_grid_values_all(h5f, label_param) + # grd_c = gaussian_filter(grd_c, sigma=1.0) grd_c = grd_c[y_0:y_0+sub_y, x_0:x_0+sub_x] hr_grd_c = grd_c.copy() hr_grd_c = hr_grd_c[y_128, x_128] @@ -777,39 +779,6 @@ def run_evaluate_static(in_file, out_file, ckpt_dir): return out_sr, None, None -def analyze(fpath='/Users/tomrink/clavrx_snpp_viirs.A2019080.0100.001.2019080064252.uwssec_B00038315.level2.h5', param='cloud_probability'): - h5f = h5py.File(fpath, 'r') - grd = get_grid_values_all(h5f, param) - grd = np.where(np.isnan(grd), 0, grd) - bt = get_grid_values_all(h5f, 'temp_11_0um_nom') - refl = get_grid_values_all(h5f, 'refl_0_65um_nom') - grd = grd[2432:4032, 2432:4032] - bt = bt[2432:4032, 2432:4032] - refl = refl[2432:4032, 2432:4032] - print(grd.shape) - - grd_lr = grd[::2, ::2] - print(grd_lr.shape) - leny, lenx = grd_lr.shape - rnd = np.random.normal(loc=0, scale=0.001, size=grd_lr.size) - grd_lr = grd_lr + rnd.reshape(grd_lr.shape) - if param == 'cloud_probability': - grd_lr = np.where(grd_lr < 0, 0, grd_lr) - grd_lr = np.where(grd_lr > 1, 1, grd_lr) - - x = np.arange(lenx) - y = np.arange(leny) - x_up = np.arange(0, lenx, 0.5) - y_up = np.arange(0, leny, 0.5) - - grd_hr = resample_2d_linear_one(x, y, grd_lr, x_up, y_up) - print(grd_hr.shape) - - h5f.close() - - return grd, grd_lr, grd_hr, bt, refl - - if __name__ == "__main__": nn = SRCNN() nn.run('matchup_filename')