diff --git a/modules/deeplearning/amv_raob.py b/modules/deeplearning/amv_raob.py index a77da44a47f397be9460b6695d126d548ee72979..d7d368ab0baa40642231a52d2cace8b7af4a70ed 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