Commit 55d2305d authored by Jeff Piollé's avatar Jeff Piollé
Browse files

fixed calculation of resolution to get rid of warning

parent 4b521c6d
......@@ -337,9 +337,20 @@ class Resampler(object):
# resolution = numpy.amin(abs(numpy.diff(srclat)))
resolution = 1
else:
# estimate resolution from latitude
y, x = srclat.shape
resolution = abs(srclat[y / 2, x / 2] - srclat[y / 2 + 1, x / 2])
#contiguous_lat = numpy.ma.flatnotmasked_contiguous(srclat[:, x / 2])
#if contiguous_lat is list:
# sublats =
resolution = numpy.ma.abs(
srclat[0:-1, x / 2] - srclat[1:, x / 2]
).mean()
if resolution is numpy.ma.masked:
logging.warning(
"Data spatial resolution could not be estimated"
)
radius = resolution * 100000. / 2. * 1.6
logging.debug("Radius for resampling : %s", radius)
return source_def, target_def, radius
......@@ -347,7 +358,7 @@ class Resampler(object):
def __get_closest_neighbour_info(cls,
source_def,
target_def,
radius=None,
radius,
):
"""Returns the indexes for a closest neighbour resampling.
......@@ -463,7 +474,8 @@ class Resampler(object):
target_lats = target.get_lat().astype('float32')
if isinstance(target, Grid) and len(target_lons.shape) == 1:
target_lons, target_lats = numpy.meshgrid(target_lons, target_lats)
source_def, target_def, radius = Resampler.__get_pyresample_def(
source_def, target_def, calc_radius = Resampler.__get_pyresample_def(
source_lats,
source_lons,
source.__class__.__name__,
......@@ -488,7 +500,7 @@ class Resampler(object):
index_array, distance_array\
= Resampler.__get_closest_neighbour_info(source_def,
target_def,
radius)
calc_radius)
first = False
if not valid_input_index.any():
# return None if no source data can be resampled on the
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment