From 9da710635b46a1044680e5928e6c5baefe70a08a Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Mon, 19 Apr 2021 11:01:43 -0500
Subject: [PATCH] snapshot...

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

diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py
index 80f5e950..e8bd0c97 100644
--- a/modules/icing/pirep_goes.py
+++ b/modules/icing/pirep_goes.py
@@ -1220,6 +1220,50 @@ def run_mean_std(check_cloudy=False, no_icing_to_icing_ratio=5):
     return mean_std_dct
 
 
+def run_mean_std_2(check_cloudy=False, no_icing_to_icing_ratio=5, params=train_params_day):
+    params = ['cld_height_acha', 'cld_geo_thick', 'supercooled_cloud_fraction', 'cld_temp_acha', 'cld_press_acha',
+            'cld_reff_dcomp', 'cld_opd_dcomp', 'cld_cwp_dcomp', 'iwc_dcomp', 'lwc_dcomp']
+
+    mean_std_dct = {}
+
+    flist = [f for f in glob.glob('/Users/tomrink/data/icing/fov*.h5')]
+
+    h5f_lst = [h5py.File(f, 'r') for f in flist]
+
+    if check_cloudy:
+        cld_msk = []
+        for idx, h5f in enumerate(h5f_lst):
+            cld_msk.append(h5f['cloud_mask'][:,].flatten())
+        cld_msk = np.concatenate(cld_msk)
+
+    for dname in params:
+        data = []
+        for idx, h5f in enumerate(h5f_lst):
+            data.append(h5f[dname][:,].flatten())
+
+        data = np.concatenate(data)
+
+        if check_cloudy:
+            keep = np.logical_or(cld_msk == 2, cld_msk == 3)
+            data = data[keep]
+
+        mean = np.nanmean(data)
+        data -= mean
+        std = np.nanstd(data)
+
+        print(dname,': ', mean, std)
+
+        mean_std_dct[dname] = (mean, std)
+
+    [h5f.close() for h5f in h5f_lst]
+
+    f = open('/Users/tomrink/data/icing/fovs_mean_std_day.pkl', 'wb')
+    pickle.dump(mean_std_dct, f)
+    f.close()
+
+    # return mean_std_dct
+
+
 def split_data(num_obs, perc=0.2, skip=1, shuffle=True):
     idxs = np.arange(num_obs)
     idxs = list(idxs)
-- 
GitLab