diff --git a/pyresample/ewa/_fornav_templates.cpp b/pyresample/ewa/_fornav_templates.cpp index b4ad93158..efda23e22 100644 --- a/pyresample/ewa/_fornav_templates.cpp +++ b/pyresample/ewa/_fornav_templates.cpp @@ -245,7 +245,7 @@ int compute_ewa(size_t chan_count, int maximum_weight_mode, u0 = uimg[swath_offset]; v0 = vimg[swath_offset]; - if (u0 < 0.0 || v0 < 0.0 || __isnan(u0) || __isnan(v0)) { + if (u0 < -this_ewap->u_del || v0 < -this_ewap->v_del || __isnan(u0) || __isnan(v0)) { continue; } @@ -352,7 +352,6 @@ int compute_ewa_single(int maximum_weight_mode, IMAGE_TYPE this_val; unsigned int swath_offset; unsigned int grid_offset; - size_t chan; got_point = 0; for (row = 0, swath_offset=0; row < swath_rows; row+=1) { @@ -360,7 +359,7 @@ int compute_ewa_single(int maximum_weight_mode, u0 = uimg[swath_offset]; v0 = vimg[swath_offset]; - if (u0 < 0.0 || v0 < 0.0 || __isnan(u0) || __isnan(v0)) { + if (u0 < -this_ewap->u_del || v0 < -this_ewap->v_del || __isnan(u0) || __isnan(v0)) { continue; } diff --git a/pyresample/ewa/dask_ewa.py b/pyresample/ewa/dask_ewa.py index 33c697fed..77dde456d 100644 --- a/pyresample/ewa/dask_ewa.py +++ b/pyresample/ewa/dask_ewa.py @@ -351,8 +351,8 @@ def _run_fornav_single(self, data, out_chunks, target_geo_def, fill_value, **kwa ll2cr_blocks = self.cache['ll2cr_blocks'].items() ll2cr_numblocks = ll2cr_result.shape if isinstance(ll2cr_result, np.ndarray) else ll2cr_result.numblocks fornav_task_name = "fornav-{}".format(data.name) - maximum_weight_mode = kwargs.get('maximum_weight_mode', False) - weight_sum_min = kwargs.get('weight_sum_min', -1.0) + maximum_weight_mode = kwargs.setdefault('maximum_weight_mode', False) + weight_sum_min = kwargs.setdefault('weight_sum_min', -1.0) output_stack = self._generate_fornav_dask_tasks(out_chunks, ll2cr_blocks, fornav_task_name, diff --git a/pyresample/test/test_ewa_fornav.py b/pyresample/test/test_ewa_fornav.py index 9cee192d6..fddf0daa4 100644 --- a/pyresample/test/test_ewa_fornav.py +++ b/pyresample/test/test_ewa_fornav.py @@ -54,6 +54,28 @@ def test_fornav_swath_larger(self): self.assertTrue(((out == 1) | np.isnan(out)).all(), msg="Unexpected interpolation values were returned") + def test_fornav_swath_wide_input(self): + """Test that a swath with large input pixels on the left edge of the output.""" + from pyresample.ewa import _fornav + swath_shape = (400, 800) + data_type = np.float32 + # Create a fake row and cols array + rows = np.empty(swath_shape, dtype=np.float32) + rows[:] = np.linspace(-500, 500, 400)[:, None] + cols = np.empty(swath_shape, dtype=np.float32) + cols[:] = np.linspace(-500, 500, 800) + 0.5 + rows_per_scan = 16 + # Create a fake data swath + data = np.ones(swath_shape, dtype=data_type) + out = np.empty((800, 1000), dtype=data_type) + + grid_points_covered = _fornav.fornav_wrapper(cols, rows, (data,), (out,), + np.nan, np.nan, rows_per_scan) + one_grid_points_covered = grid_points_covered[0] + # the upper-left 500x500 square should be filled with 1s at least + assert 500 * 500 <= one_grid_points_covered <= 505 * 505 + np.testing.assert_allclose(out[:500, :500], 1) + def test_fornav_swath_smaller(self): """Test that a swath smaller than the output grid is entirely used.""" from pyresample.ewa import _fornav