From 999c0015ae4abbf32ec64c2dcd5a484114c2d394 Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Tue, 7 Nov 2023 10:55:44 -0600 Subject: [PATCH] snapshot... --- modules/icing/util.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/icing/util.py b/modules/icing/util.py index daa876ad..13e79119 100644 --- a/modules/icing/util.py +++ b/modules/icing/util.py @@ -447,7 +447,7 @@ def write_icing_file(clvrx_str_time, output_dir, preds_dct, probs_dct, x, y, lon def write_icing_file_nc4(clvrx_str_time, output_dir, preds_dct, probs_dct, x, y, lons, lats, elems, lines, satellite='GOES16', domain='CONUS', - has_time=False, use_nan=False, prob_thresh=0.5, bt_10_4=None): + has_time=False, use_nan=False, prob_thresh=0.5, bt_10_4=None, cld_top_hgt_max=None): outfile_name = output_dir + 'icing_prediction_'+clvrx_str_time+'.nc' rootgrp = Dataset(outfile_name, 'w', format='NETCDF4') @@ -537,6 +537,13 @@ def write_icing_file_nc4(clvrx_str_time, output_dir, preds_dct, probs_dct, bt_ds.setncattr('grid_mapping', 'Projection') bt_ds[:,] = bt_10_4 + if cld_top_hgt_max is not None: + cth_ds = rootgrp.createVariable('cld_top_hgt_max', 'f4', var_dim_list) + cth_ds.setncattr('coordinates', geo_coords) + cth_ds.setncattr('grid_mapping', 'Projection') + cth_ds.units = 'meter' + cth_ds[:,] = cld_top_hgt_max + lon_ds = rootgrp.createVariable('longitude', 'f4', [dim_1_name, dim_0_name]) lon_ds.units = 'degrees_east' lon_ds[:,] = lons @@ -792,6 +799,7 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h avg_bt = [] day_cth_max = [] nght_cth_max = [] + cth_max = [] for j in range(num_lines): for i in range(num_elems): @@ -800,6 +808,7 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h c = cth[k].flatten() c_m = np.mean(np.sort(c[np.invert(np.isnan(c))])[-2:]) + cth_max.append(c_m) c_m = 0 if 2000 > c_m >= 0 else c_m c_m = 1 if 4000 > c_m >= 2000 else c_m @@ -934,11 +943,14 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h avg_bt = np.array(avg_bt) bt_10_4_2d = avg_bt.reshape((num_lines, num_elems)) + cth_max = np.array(cth_max) + cth_max = cth_max.reshape((num_lines, num_elems)) + if satellite == 'GOES16' or satellite == 'H08' or satellite == 'H09': write_icing_file_nc4(clvrx_str_time, output_dir, preds_2d_dct, probs_2d_dct, x_rad, y_rad, lons_2d, lats_2d, cc, ll, satellite=satellite, domain=domain, use_nan=use_nan, has_time=has_time, - prob_thresh=prob_thresh, bt_10_4=bt_10_4_2d) + prob_thresh=prob_thresh, bt_10_4=bt_10_4_2d, cld_top_hgt_max=cth_max) elif satellite == 'VIIRS': write_icing_file_nc4_viirs(clvrx_str_time, output_dir, preds_2d_dct, probs_2d_dct, lons_2d, lats_2d, -- GitLab