From 0f434569b79396dbe837ea472f468f81a69a094b Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Fri, 4 Mar 2022 15:40:47 -0600
Subject: [PATCH] minor...

---
 modules/icing/pirep_goes.py | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py
index c7d836f8..d2346629 100644
--- a/modules/icing/pirep_goes.py
+++ b/modules/icing/pirep_goes.py
@@ -63,6 +63,7 @@ ds_range = ['actual_range' for i in range(23)] + [None for i in range(3)]
 
 # An example file for accessing and copying metadata
 a_clvr_file = homedir+'data/clavrx/clavrx_OR_ABI-L1b-RadC-M3C01_G16_s20190020002186.level2.nc'
+#a_clvr_file = homedir+'data/clavrx/RadC/265/clavrx_OR_ABI-L1b-RadC-M6C01_G16_s20212651711172.level2.nc'
 # VIIRS
 #a_clvr_file = homedir+'data/clavrx/clavrx_snpp_viirs.A2019071.0000.001.2019071061610.uwssec_B00038187.level2.h5'
 
@@ -740,15 +741,16 @@ def process_boeing(ice_dct, no_ice_dct):
 def analyze2(filename, filename_l1b):
     f = h5py.File(filename, 'r')
     icing_alt = f['icing_altitude'][:]
-    cld_top_hgt = f['cld_height_acha'][:, 10:30, 10:30]
-    cld_phase = f['cloud_phase'][:, 10:30, 10:30]
-    cld_opd_dc = f['cld_opd_dcomp'][:, 10:30, 10:30]
-    cld_opd = f['cld_opd_acha'][:, 10:30, 10:30]
-    solzen = f['solar_zenith_angle'][:, 10:30, 10:30]
+    cld_top_hgt = f['cld_height_acha'][:, 12:28, 12:28]
+    cld_phase = f['cloud_phase'][:, 12:28, 12:28]
+    cld_opd_dc = f['cld_opd_dcomp'][:, 12:28, 12:28]
+    cld_opd = f['cld_opd_acha'][:, 12:28, 12:28]
+    solzen = f['solar_zenith_angle'][:, 12:28, 12:28]
 
     f_l1b = h5py.File(filename_l1b, 'r')
-    bt_11um = f_l1b['temp_11_0um_nom'][:, 10:30, 10:30]
+    bt_11um = f_l1b['temp_11_0um_nom'][:, 12:28, 12:28]
 
+    bt_11um = bt_11um.flatten()
     cld_opd = cld_opd.flatten()
     cld_opd_dc = cld_opd_dc.flatten()
     solzen = solzen.flatten()
@@ -760,10 +762,9 @@ def analyze2(filename, filename_l1b):
     cld_opd_dc = cld_opd_dc[keep]
     solzen = solzen[keep]
 
-    plt.hist(cld_opd, bins=20)
-    plt.show()
-    plt.hist(cld_opd_dc, bins=20)
-    plt.show()
+    bt_11um = bt_11um[np.invert(np.isnan(bt_11um))]
+
+    return cld_opd, bt_11um
 
 
 # --------------------------------------------
@@ -1227,6 +1228,13 @@ def fov_extract(icing_files, no_icing_files, trnfile='/home/rink/fovs_l1b_train.
 
 def tile_extract(icing_files, no_icing_files, trnfile='/home/rink/tiles_train.h5', tstfile='/home/rink/tiles_test.h5', L1B_or_L2='L1B',
                  cld_mask_name='cloud_mask', augment=False, do_split=True):
+    # 16x16
+    n_a, n_b = 12, 28
+    m_a, m_b = 12, 28
+    # 10x10
+    # n_a, n_b = 15, 25
+    # m_a, m_b = 15, 25
+
     icing_int_s = []
     ice_time_s = []
     no_ice_time_s = []
@@ -1264,9 +1272,9 @@ def tile_extract(icing_files, no_icing_files, trnfile='/home/rink/tiles_train.h5
         flt_altitude = f['icing_altitude'][:]
 
         for i in range(num_obs):
-            cld_msk = f[cld_mask_name][i, 12:28, 12:28]
+            cld_msk = f[cld_mask_name][i, n_a:n_b, m_a:m_b]
             for ds_name in params:
-                dat = f[ds_name][i, 12:28, 12:28]
+                dat = f[ds_name][i, n_a:n_b, m_a:m_b]
                 if L1B_or_L2 == 'L2':
                     keep = np.logical_or(cld_msk == 2, cld_msk == 3)  # cloudy
                     np.where(keep, dat, np.nan)
@@ -1304,9 +1312,9 @@ def tile_extract(icing_files, no_icing_files, trnfile='/home/rink/tiles_train.h5
         flt_altitude = f['icing_altitude'][:]
 
         for i in range(num_obs):
-            cld_msk = f[cld_mask_name][i, 12:28, 12:28]
+            cld_msk = f[cld_mask_name][i, n_a:n_b, m_a:m_b]
             for ds_name in params:
-                dat = f[ds_name][i, 12:28, 12:28]
+                dat = f[ds_name][i, n_a:n_b, m_a:m_b]
                 if L1B_or_L2 == 'L2':
                     keep = np.logical_or(cld_msk == 2, cld_msk == 3)  # cloudy
                     np.where(keep, dat, np.nan)
-- 
GitLab