diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py index 80f5e9502031fd4ed06c5ea721dd2ab8b030133a..e8bd0c97659d89db6e416bcac31dd8462c573a44 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)