Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More conservative approach to handle errors in area_def_names_to_extent() #30

Merged
merged 1 commit into from
Aug 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions mpop/satin/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ def area_def_names_to_extent(area_def_names, proj4_str,
except AttributeError:
boundaries = name.get_boundary_lonlats()

if (all(boundaries[0].side1 > 1e20) or
all(boundaries[0].side2 > 1e20) or
all(boundaries[0].side3 > 1e20) or
all(boundaries[0].side4 > 1e20)):
maximum_extent = list(default_extent)
continue
if (any(boundaries[0].side1 > 1e20) or
any(boundaries[0].side2 > 1e20) or
any(boundaries[0].side3 > 1e20) or
any(boundaries[0].side4 > 1e20)):
if default_extent:
maximum_extent = list(default_extent)
continue
else:
return None

lon_sides = (boundaries[0].side1, boundaries[0].side2,
boundaries[0].side3, boundaries[0].side4)
Expand All @@ -76,6 +79,8 @@ def area_def_names_to_extent(area_def_names, proj4_str,
maximum_extent = boundaries_to_extent(proj4_str, maximum_extent,
default_extent,
lon_sides, lat_sides)
if not maximum_extent:
return None

maximum_extent[0] -= 10000
maximum_extent[1] -= 10000
Expand Down Expand Up @@ -104,6 +109,11 @@ def boundaries_to_extent(proj4_str, maximum_extent, default_extent,
# replace invalid values with NaN
x_dir[np.abs(x_dir) > 1e20] = np.nan
y_dir[np.abs(y_dir) > 1e20] = np.nan

# return None when no default specified
if not default_extent:
if any(np.isnan(x_dir)) or any(np.isnan(x_dir)):
return None

# Get the maximum needed extent from different corners.
extent = [np.nanmin(x_dir),
Expand Down
6 changes: 5 additions & 1 deletion mpop/satin/mipp_xrit.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ def load_generic(satscene, options, calibrate=True, area_extent=None,
# lon0=0.0), that is, do not pass default_extent=area_extent
else:
area_extent = area_def_names_to_extent(area_def_names,
metadata.proj4_params)
metadata.proj4_params,
default_extent=None)

if area_extent is None:
LOGGER.info('Could not derive area_extent from area_def_names')

area_converted_to_extent = True

Expand Down