Commit 74500e9e authored by GROUAZEL's avatar GROUAZEL
Browse files

fix a bug with fillvalue that can not be None anymore in netcdf mapper

parent 4f6bb624
......@@ -197,10 +197,12 @@ class Resampler(object):
missing = fillvalue
if mask is None:
srcmask = numpy.array(data.mask, copy=True)
logging.debug('resampler | mask %s data type%s data.mask %s',mask,type(data),data.mask)
if extrapolation != 0:
logging.info('Read source and extrapolate over missing data')
# call extrapolation procedure (replace NaN with interpolated
# values)
logging.debug('data %s',data.shape)
data = cls.extrapolate(data, extrapolation)
# masked data to missing value
data = data.filled(missing)
......@@ -390,11 +392,12 @@ class Resampler(object):
valid_input_index, valid_output_index, index_array, distance_array\
= Resampler.__get_closest_neighbour_info(source_def,
target_def,
radius_of_influence=radius)
radius=radius)
if not valid_input_index.any():
# return None if no source data can be resampled on the
# target
return None
logging.debug('target %s srcdtaa %s',target_def.shape,srcdata)
res = kd_tree.get_sample_from_neighbour_info('nn',
target_def.shape,
srcdata,
......@@ -579,7 +582,8 @@ class Resampler(object):
fieldx = Field(varx,
target_dims,
values=reference_x,
datatype=numpy.dtype(numpy.int32))
datatype=numpy.dtype(numpy.int32),
fillvalue=-2363645994848887)
vary = Variable(
shortname='resampled_%s' % ydimname,
description='%s index of the selected pixel' % ydimname
......@@ -587,7 +591,8 @@ class Resampler(object):
fieldy = Field(vary,
target_dims,
values=reference_y,
datatype=numpy.dtype(numpy.int32))
datatype=numpy.dtype(numpy.int32),
fillvalue=-2363645994848887)
outfeature.add_field(fieldx)
outfeature.add_field(fieldy)
# Add the distance
......
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