From f409db0f748b0a9727179b552ef2770ef7e1061b Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Fri, 17 Feb 2023 15:20:02 -0600 Subject: [PATCH] snapshot... --- modules/deeplearning/cnn_cld_frac.py | 43 +++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/modules/deeplearning/cnn_cld_frac.py b/modules/deeplearning/cnn_cld_frac.py index c5ed1565..7c2824a6 100644 --- a/modules/deeplearning/cnn_cld_frac.py +++ b/modules/deeplearning/cnn_cld_frac.py @@ -1032,19 +1032,21 @@ def analyze(file='/Users/tomrink/cld_opd_out.npy'): def analyze2(nda_m, nda_i): + n_imgs = nda_m.shape[0] nda_m = np.where(nda_m < 0.5, 0, 1) nda_i = np.where(nda_i < 0.5, 0, 1) - cf_m = np.zeros((64, 64)) - cf_i = np.zeros((64, 64)) + cf_m = np.zeros((n_imgs, 64, 64)) + cf_i = np.zeros((n_imgs, 64, 64)) - for j in range(1, 65): - for i in range(1, 65): - sub_3x3 = nda_m[j-1:j+2, i-1:i+2] - cf_m[j-1, i-1] = np.sum(sub_3x3) + for k in range(n_imgs): + for j in range(1, 65): + for i in range(1, 65): + sub_3x3 = nda_m[k, j-1:j+2, i-1:i+2] + cf_m[k, j-1, i-1] = np.sum(sub_3x3) - sub_4x4 = nda_i[j*2-1:j*2+3, i*2-1:i*2+3] - cf_i[j-1, i-1] = np.sum(sub_4x4) + sub_4x4 = nda_i[k, j*2-1:j*2+3, i*2-1:i*2+3] + cf_i[k, j-1, i-1] = np.sum(sub_4x4) # cat_0 = cf_m == 0 # cat_1 = (cf_m >= 0.1) & (cf_m < 0.13) @@ -1068,21 +1070,22 @@ def analyze2(nda_m, nda_i): # cf_m[cat_8] = 8 # cf_m[cat_9] = 9 - cat_0 = (cf_m == 0) - cat_1 = (cf_m > 0) & (cf_m < 9) - cat_2 = cf_m == 9 + for k in range(n_imgs): + cat_0 = (cf_m[k, ] == 0) + cat_1 = (cf_m[k, ] > 0) & (cf_m[k, ] < 9) + cat_2 = cf_m[k, ] == 9 - cf_m[cat_0] = 0 - cf_m[cat_1] = 1 - cf_m[cat_2] = 2 + cf_m[k, cat_0] = 0 + cf_m[k, cat_1] = 1 + cf_m[k, cat_2] = 2 - cat_0 = (cf_i == 0) - cat_1 = (cf_i > 0) & (cf_i < 16) - cat_2 = cf_i == 16 + cat_0 = (cf_i[k, ] == 0) + cat_1 = (cf_i[k, ] > 0) & (cf_i[k, ] < 16) + cat_2 = cf_i[k, ] == 16 - cf_i[cat_0] = 0 - cf_i[cat_1] = 1 - cf_i[cat_2] = 2 + cf_i[k, cat_0] = 0 + cf_i[k, cat_1] = 1 + cf_i[k, cat_2] = 2 return cf_m, cf_i -- GitLab