From a1f9635bb0b73ce722f75951b05779ca94a8851f Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Mon, 12 Apr 2021 15:33:45 -0500
Subject: [PATCH] snapshot...

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

diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py
index 6192d9d2..9306f8fe 100644
--- a/modules/icing/pirep_goes.py
+++ b/modules/icing/pirep_goes.py
@@ -10,6 +10,7 @@ import h5py
 import re
 import datetime
 from datetime import timezone
+import glob
 
 goes_date_format = '%Y%j%H'
 goes16_directory = '/arcdata/goes/grb/goes16'  # /year/date/abi/L1b/RadC
@@ -1129,4 +1130,41 @@ def box_extract(outfile='/Users/tomrink/box_out.h5', train_params=train_params_d
         h5f.close()
 
     h5f_out.close()
-    h5f_expl.close()
\ No newline at end of file
+    h5f_expl.close()
+
+
+def run_mean_std():
+    ds_list = ['cld_height_acha', 'cld_geo_thick', 'cld_press_acha',
+               'supercooled_cloud_fraction', 'cld_temp_acha', 'cld_opd_acha',
+               'cld_reff_acha', 'cld_reff_dcomp', 'cld_reff_dcomp_1', 'cld_reff_dcomp_2', 'cld_reff_dcomp_3',
+               'cld_opd_dcomp', 'cld_opd_dcomp_1', 'cld_opd_dcomp_2', 'cld_opd_dcomp_3', 'cld_cwp_dcomp', 'iwc_dcomp',
+               'lwc_dcomp', 'cld_emiss_acha', 'conv_cloud_fraction']
+
+    mean_dct = {}
+    std_dct = {}
+
+    ice_flist = [f for f in glob.glob('/home/rink/data/icing/', 'icing*.h5')]
+    no_ice_flist = [f for f in glob.glob('/home/rink/data/icing/', 'no_icing*.h5')]
+
+    ice_h5f_lst = [h5py.File(f, 'r') for f in ice_flist]
+    no_ice_h5f_lst = [h5py.File(f, 'r') for f in no_ice_flist]
+
+    data = []
+    for dname in ds_list:
+        for ice_h5f, idx in enumerate(ice_h5f_lst):
+            no_ice_h5f = no_ice_h5f_lst[idx]
+            data.append(ice_h5f[dname][:,].flatten())
+            data.append(no_ice_h5f[dname][:,].flatten())
+
+        data = np.concatenate(data)
+        mean = np.mean(data)
+        data -= mean
+        std = np.std(data)
+
+        mean_dct[dname] = mean
+        std_dct[dname] = std
+
+    [h5f.close() for h5f in ice_h5f]
+    [h5f.close() for h5f in no_ice_h5f]
+
+    return mean_dct, std_dct
-- 
GitLab