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

Only use PugL1bTools as it extends PugFile (simplify)

parent 7e570ff6
No related branches found
No related tags found
No related merge requests found
...@@ -698,6 +698,24 @@ def get_interpolated_scalar(ds_0, ds_1, time0, time1, fld_name, time, lons, lats ...@@ -698,6 +698,24 @@ def get_interpolated_scalar(ds_0, ds_1, time0, time1, fld_name, time, lons, lats
return intrp_vals 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'): def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=False, daynight='ANY'):
global geoloc_2km, geoloc_1km, geoloc_hkm 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 ...@@ -727,7 +745,7 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa
# Navigation, convert to BT/REFL # Navigation, convert to BT/REFL
try: try:
pug_l1b_c = PugL1bTools(local_path) pug_l1b_c = get_reader(local_path)
except Exception as exc: except Exception as exc:
print(exc) print(exc)
return None, None, None, None return None, None, None, None
...@@ -747,7 +765,7 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa ...@@ -747,7 +765,7 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa
# Navigation, convert to BT/REFL # Navigation, convert to BT/REFL
try: try:
pug_l1b_l = PugL1bTools(local_path_l) pug_l1b_l = get_reader(local_path_l)
except Exception as exc: except Exception as exc:
print(exc) print(exc)
return None, None, None, None return None, None, None, None
...@@ -765,7 +783,7 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa ...@@ -765,7 +783,7 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa
# Navigation, convert to BT/REFL # Navigation, convert to BT/REFL
try: try:
pug_l1b_r = PugL1bTools(local_path_r) pug_l1b_r = get_reader(local_path_r)
except Exception as exc: except Exception as exc:
print(exc) print(exc)
return None, None, None, None return None, None, None, None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment