From e41a6d34713161e6f042de7a2a584b7335b1270e Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Sun, 7 Feb 2021 16:39:25 -0600 Subject: [PATCH] Only use PugL1bTools as it extends PugFile (simplify) --- modules/deeplearning/amv_raob.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/modules/deeplearning/amv_raob.py b/modules/deeplearning/amv_raob.py index a77da44a..d7d368ab 100644 --- a/modules/deeplearning/amv_raob.py +++ b/modules/deeplearning/amv_raob.py @@ -698,6 +698,24 @@ def get_interpolated_scalar(ds_0, ds_1, time0, time1, fld_name, time, lons, lats return intrp_vals +path_to_reader_dict = {} + + +def get_reader(path): + if len(path_to_reader_dict) > 50: + path_to_reader_dict.clear() + + rdr = path_to_reader_dict.get(path) + if rdr is None: + rdr = PugL1bTools(path) + path_to_reader_dict[path] = rdr + return rdr + + +def clear_readers(): + path_to_reader_dict.clear() + + def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=False, daynight='ANY'): global geoloc_2km, geoloc_1km, geoloc_hkm @@ -727,7 +745,7 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa # Navigation, convert to BT/REFL try: - pug_l1b_c = PugL1bTools(local_path) + pug_l1b_c = get_reader(local_path) except Exception as exc: print(exc) return None, None, None, None @@ -747,7 +765,7 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa # Navigation, convert to BT/REFL try: - pug_l1b_l = PugL1bTools(local_path_l) + pug_l1b_l = get_reader(local_path_l) except Exception as exc: print(exc) return None, None, None, None @@ -765,7 +783,7 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa # Navigation, convert to BT/REFL try: - pug_l1b_r = PugL1bTools(local_path_r) + pug_l1b_r = get_reader(local_path_r) except Exception as exc: print(exc) return None, None, None, None -- GitLab