Skip to content
Snippets Groups Projects
Commit 999c0015 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent 47d0da92
Branches
No related tags found
No related merge requests found
...@@ -447,7 +447,7 @@ def write_icing_file(clvrx_str_time, output_dir, preds_dct, probs_dct, x, y, lon ...@@ -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, def write_icing_file_nc4(clvrx_str_time, output_dir, preds_dct, probs_dct,
x, y, lons, lats, elems, lines, satellite='GOES16', domain='CONUS', 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' outfile_name = output_dir + 'icing_prediction_'+clvrx_str_time+'.nc'
rootgrp = Dataset(outfile_name, 'w', format='NETCDF4') 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, ...@@ -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.setncattr('grid_mapping', 'Projection')
bt_ds[:,] = bt_10_4 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 = rootgrp.createVariable('longitude', 'f4', [dim_1_name, dim_0_name])
lon_ds.units = 'degrees_east' lon_ds.units = 'degrees_east'
lon_ds[:,] = lons lon_ds[:,] = lons
...@@ -792,6 +799,7 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h ...@@ -792,6 +799,7 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h
avg_bt = [] avg_bt = []
day_cth_max = [] day_cth_max = []
nght_cth_max = [] nght_cth_max = []
cth_max = []
for j in range(num_lines): for j in range(num_lines):
for i in range(num_elems): for i in range(num_elems):
...@@ -800,6 +808,7 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h ...@@ -800,6 +808,7 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h
c = cth[k].flatten() c = cth[k].flatten()
c_m = np.mean(np.sort(c[np.invert(np.isnan(c))])[-2:]) 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 = 0 if 2000 > c_m >= 0 else c_m
c_m = 1 if 4000 > c_m >= 2000 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 ...@@ -934,11 +943,14 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h
avg_bt = np.array(avg_bt) avg_bt = np.array(avg_bt)
bt_10_4_2d = avg_bt.reshape((num_lines, num_elems)) 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': if satellite == 'GOES16' or satellite == 'H08' or satellite == 'H09':
write_icing_file_nc4(clvrx_str_time, output_dir, preds_2d_dct, probs_2d_dct, 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, x_rad, y_rad, lons_2d, lats_2d, cc, ll,
satellite=satellite, domain=domain, use_nan=use_nan, has_time=has_time, 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': elif satellite == 'VIIRS':
write_icing_file_nc4_viirs(clvrx_str_time, output_dir, preds_2d_dct, probs_2d_dct, write_icing_file_nc4_viirs(clvrx_str_time, output_dir, preds_2d_dct, probs_2d_dct,
lons_2d, lats_2d, lons_2d, lats_2d,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment