From b1eb246821dedb55c265b4cc51a4d0a37fc281ca Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Wed, 16 Mar 2022 16:32:40 -0500
Subject: [PATCH] snapshot...

---
 modules/util/util.py | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/modules/util/util.py b/modules/util/util.py
index ce3b86dd..82469716 100644
--- a/modules/util/util.py
+++ b/modules/util/util.py
@@ -634,16 +634,35 @@ def make_for_full_domain_predict2(h5f, satellite='GOES16', domain='FD', res_fac=
 # -------------------------------------------------------------------------------------------
 
 
-def prepare_evaluate(h5f, name_list, satellite='GOES16', domain='FD'):
+def prepare_evaluate(h5f, name_list, satellite='GOES16', domain='FD', res_fac=1, offset=0):
+    w_x = 16
+    w_y = 16
+    i_0 = 0
+    j_0 = 0
+    s_x = int(w_x / res_fac)
+    s_y = int(w_y / res_fac)
 
     geos, xlen, xmin, xmax, ylen, ymin, ymax = get_cartopy_crs(satellite, domain)
-    j_0, i_0 = 0, 0
     if satellite == 'H08':
         xlen = taiwan_lenx
         ylen = taiwan_leny
         i_0 = taiwan_i0
         j_0 = taiwan_j0
 
+    n_x = int(xlen/s_x) - 1
+    n_y = int(ylen/s_y) - 1
+
+    r_x = xlen - (n_x * s_x)
+    x_d = 0 if r_x >= w_x else int((w_x - r_x)/s_x)
+    n_x -= x_d
+
+    r_y = ylen - (n_y * s_y)
+    y_d = 0 if r_y >= w_y else int((w_y - r_y)/s_y)
+    n_y -= y_d
+
+    ll = [(offset+j_0) + j*s_y for j in range(n_y)]
+    cc = [(offset+i_0) + i*s_x for i in range(n_x)]
+
     grd_dct_n = {name: [] for name in name_list}
 
     cnt_a = 0
@@ -658,9 +677,8 @@ def prepare_evaluate(h5f, name_list, satellite='GOES16', domain='FD'):
 
     solzen = get_grid_values(h5f, 'solar_zenith_angle', j_0, i_0, None, num_j=ylen, num_i=xlen)
     satzen = get_grid_values(h5f, 'sensor_zenith_angle', j_0, i_0, None, num_j=ylen, num_i=xlen)
-
-    ll = [j_0 + j for j in range(ylen)]
-    cc = [i_0 + i for i in range(xlen)]
+    solzen = solzen[0:(n_y-1)*s_y:s_y, 0:(n_x-1)*s_x:s_x]
+    satzen = satzen[0:(n_y-1)*s_y:s_y, 0:(n_x-1)*s_x:s_x]
 
     grd_dct = {name: None for name in name_list}
     for ds_name in name_list:
-- 
GitLab