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

Only use PugL1bTools as it extends PugFile (simplify)

parent a869885b
No related branches found
No related tags found
No related merge requests found
......@@ -727,16 +727,15 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa
# Navigation, convert to BT/REFL
try:
pug_c = PugFile(local_path, 'Rad')
pug_l1b_c = PugL1bTools(local_path)
except Exception as exc:
print(exc)
return None, None, None, None
bt_or_refl = None
if pug_c.bt_or_refl == 'bt':
if pug_l1b_c.bt_or_refl == 'bt':
bt_or_refl = pug_l1b_c.bt
elif pug_c.bt_or_refl == 'refl':
elif pug_l1b_c.bt_or_refl == 'refl':
bt_or_refl = pug_l1b_c.refl
if TRIPLET or CONV3D:
......@@ -748,15 +747,14 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa
# Navigation, convert to BT/REFL
try:
pug_l = PugFile(local_path_l, 'Rad')
pug_l1b_l = PugL1bTools(local_path_l)
except Exception as exc:
print(exc)
return None, None, None, None
if pug_l.bt_or_refl == 'bt':
if pug_l1b_l.bt_or_refl == 'bt':
bt_or_refl_l = pug_l1b_l.bt
elif pug_l.bt_or_refl == 'refl':
elif pug_l1b_l.bt_or_refl == 'refl':
bt_or_refl_l = pug_l1b_l.refl
# copy from archive to local drive
......@@ -767,35 +765,34 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa
# Navigation, convert to BT/REFL
try:
pug_r = PugFile(local_path_r, 'Rad')
pug_l1b_r = PugL1bTools(local_path_r)
except Exception as exc:
print(exc)
return None, None, None, None
if pug_r.bt_or_refl == 'bt':
if pug_l1b_r.bt_or_refl == 'bt':
bt_or_refl_r = pug_l1b_r.bt
elif pug_r.bt_or_refl == 'refl':
elif pug_l1b_r.bt_or_refl == 'refl':
bt_or_refl_r = pug_l1b_r.refl
if daynight != 'ANY':
if step[ch_idx] == 1:
if geoloc_2km is None:
geoloc_2km = pug_c.geo
geoloc_2km = pug_l1b_c.geo
glons = geoloc_2km.lon
glats = geoloc_2km.lat
elif step[ch_idx] == 4:
if geoloc_hkm is None:
geoloc_hkm = pug_c.geo
geoloc_hkm = pug_l1b_c.geo
glons = geoloc_hkm.lon
glats = geoloc_hkm.lat
elif step[ch_idx] == 2:
if geoloc_1km is None:
geoloc_1km = pug_c.geo
geoloc_1km = pug_l1b_c.geo
glons = geoloc_1km.lon
glats = geoloc_1km.lat
alt_fnc = get_solar_alt_func(pug_c, glons, glats, dt_obj)
alt_fnc = get_solar_alt_func(pug_l1b_c, glons, glats, dt_obj)
images = []
images_l = []
......@@ -803,7 +800,7 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa
for idx, lon in enumerate(lons):
lat = lats[idx]
if ch_idx == 0:
l, c = pug_c.lat_lon_to_l_c(lat, lon)
l, c = pug_l1b_c.lat_lon_to_l_c(lat, lon)
l_s.append(l)
c_s.append(c)
else:
......@@ -824,7 +821,7 @@ def get_images(lons, lats, timestamp, channel_list, half_width, step, do_norm=Fa
l_b = l + half_width[ch_idx]
c_a = c - half_width[ch_idx]
c_b = c + half_width[ch_idx]
if (l_a >= 0 and l_b < pug_c.shape[0]) and (c_a >= 0 and c_b < pug_c.shape[1]):
if (l_a >= 0 and l_b < pug_l1b_c.shape[0]) and (c_a >= 0 and c_b < pug_l1b_c.shape[1]):
img = bt_or_refl[l_a:l_b:step[ch_idx], c_a:c_b:step[ch_idx]]
if do_norm:
img = prepare_image(img, ch)
......
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