From fe8da3e19533a1bf2174f3b03da2b3f6ed771ac8 Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Tue, 24 Oct 2023 12:52:39 -0500 Subject: [PATCH] snapshot... --- modules/icing/util.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/modules/icing/util.py b/modules/icing/util.py index b946ff48..90991b97 100644 --- a/modules/icing/util.py +++ b/modules/icing/util.py @@ -1,6 +1,7 @@ import numpy as np import deeplearning.icing_fcn as icing_fcn import deeplearning.icing_cnn as icing_cnn +from deeplearning.icing_fcn import IcingIntensityFCN from icing.pirep_goes import setup, time_filter_3 from icing.moon_phase import moon_phase from util.util import get_time_tuple_utc, is_day, check_oblique, get_median, homedir, write_icing_file_nc4,\ @@ -12,6 +13,8 @@ from util.setup import model_path_day, model_path_night from aeolus.datasource import CLAVRx, CLAVRx_VIIRS, CLAVRx_H08, CLAVRx_H09 import h5py import datetime +import tensorflow as tf +import os # from scipy.signal import medfilt2d @@ -353,6 +356,34 @@ def run_icing_predict_image(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output elif model_type == 'FCN': model_module = icing_fcn + if day_model_path is not None: + ckpt_dir_s = os.listdir(day_model_path) + ckpt_dir = day_model_path + ckpt_dir_s[0] + + day_model = IcingIntensityFCN(day_night=day_night, l1b_or_l2=l1b_andor_l2, satellite=satellite, use_flight_altitude=use_flight_altitude) + day_model.num_data_samples = 10000 + day_model.build_model() + day_model.build_training() + day_model.build_evaluation() + + ckpt = tf.train.Checkpoint(step=tf.Variable(1), model=day_model.model) + ckpt_manager = tf.train.CheckpointManager(ckpt, ckpt_dir, max_to_keep=3) + ckpt.restore(ckpt_manager.latest_checkpoint) + + if night_model_path is not None: + ckpt_dir_s = os.listdir(night_model_path) + ckpt_dir = night_model_path + ckpt_dir_s[0] + + night_model = IcingIntensityFCN(day_night=day_night, l1b_or_l2=l1b_andor_l2, satellite=satellite, use_flight_altitude=use_flight_altitude) + night_model.num_data_samples = 10000 + night_model.build_model() + night_model.build_training() + night_model.build_evaluation() + + ckpt = tf.train.Checkpoint(step=tf.Variable(1), model=night_model.model) + ckpt_manager = tf.train.CheckpointManager(ckpt, ckpt_dir, max_to_keep=3) + ckpt.restore(ckpt_manager.latest_checkpoint) + alt_lo, alt_hi = 0.0, 15000.0 if use_flight_altitude is True: flight_levels = flight_levels @@ -440,7 +471,7 @@ def run_icing_predict_image(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output for ds_name in day_train_params: day_grd_dct[ds_name] = np.stack(day_data_dct[ds_name]) - preds_day_dct, probs_day_dct = model_module.run_evaluate_static(day_grd_dct, num_day_tiles, day_model_path, + preds_day_dct, probs_day_dct = model_module.run_evaluate_static_2(day_model, day_grd_dct, num_day_tiles, day_night='DAY', l1b_or_l2=l1b_andor_l2, prob_thresh=prob_thresh, use_flight_altitude=use_flight_altitude, @@ -465,7 +496,7 @@ def run_icing_predict_image(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output for ds_name in nght_train_params: nght_grd_dct[ds_name] = np.stack(nght_data_dct[ds_name]) - preds_nght_dct, probs_nght_dct = model_module.run_evaluate_static(nght_grd_dct, num_nght_tiles, night_model_path, + preds_nght_dct, probs_nght_dct = model_module.run_evaluate_static_2(night_model, nght_grd_dct, num_nght_tiles, day_night='NIGHT', l1b_or_l2=l1b_andor_l2, prob_thresh=prob_thresh, use_flight_altitude=use_flight_altitude, -- GitLab