From 94ccdb5d24d9be5d503e3f90c510a319f8766f2b Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Wed, 31 Mar 2021 15:35:27 -0500
Subject: [PATCH] snapshot...

---
 modules/icing/pirep_goes.py | 49 +++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py
index 75f5792e..595c0953 100644
--- a/modules/icing/pirep_goes.py
+++ b/modules/icing/pirep_goes.py
@@ -624,6 +624,55 @@ def analyze2(filename, filename_l1b):
     plt.show()
 
 
+def run_daynight(filename, filename_l1b, day_night='ANY'):
+    f = h5py.File(filename, 'r')
+    f_l1b = h5py.File(filename_l1b, 'r')
+
+    solzen = f['solar_zenith_angle'][:, 10:30, 10:30]
+    num_obs = solzen.shape[0]
+
+    idxs = []
+    for i in range(num_obs):
+        if day_night == 'NIGHT':
+            if is_night(solzen[i,]):
+                idxs.append(i)
+        elif day_night == 'DAY':
+            if not is_night(solzen[i,]):
+                idxs.append(i)
+
+    keep_idxs = np.array(idxs)
+
+    data_dct = {}
+    for didx, ds_name in enumerate(ds_list):
+        data_dct[ds_name] = f[ds_name][keep_idxs,]
+
+    lon_c = f['longitude'][keep_idxs]
+    lat_c = f['latitude'][keep_idxs]
+    time_s = f['time'][keep_idxs]
+    fl_alt_s = f['icing_altitude'][keep_idxs]
+    ice_int_s = f['icing_intensity'][keep_idxs]
+    unq_ids = f['unique_id'][keep_idxs]
+
+    path, fname = os.path.split(filename)
+    fbase, fext = os.path.splitext(fname)
+    outfile = path + '/' + fbase + '_' + day_night + fext
+
+    create_file(outfile, data_dct, ds_list, ds_types, lon_c, lat_c, time_s, fl_alt_s, ice_int_s, unq_ids)
+
+    data_dct = {}
+    for didx, ds_name in enumerate(l1b_ds_list):
+        data_dct[ds_name] = f_l1b[ds_name][keep_idxs]
+
+    path, fname = os.path.split(filename_l1b)
+    fbase, fext = os.path.splitext(fname)
+    outfile_l1b = path + '/' + fbase + '_' + 'QC' + '_' + day_night + fext
+
+    create_file(outfile_l1b, data_dct, l1b_ds_list, l1b_ds_types, lon_c, lat_c, time_s, fl_alt_s, ice_int_s, unq_ids)
+
+    f.close()
+    f_l1b.close()
+
+
 def run_qc(filename, filename_l1b, day_night='ANY'):
     f = h5py.File(filename, 'r')
     icing_alt = f['icing_altitude'][:]
-- 
GitLab