@@ -194,6 +194,49 @@ def test_fornav_swath_larger_float32(self):
194194 msg = "Unexpected interpolation values were returned" )
195195
196196
197+ def _partial_coverage_swath (dtype ):
198+ """Create an all-ones swath that covers only part of a 1000x1000 grid.
199+
200+ The right side of the grid is left uncovered so the output is guaranteed
201+ to contain fill pixels as well as data pixels.
202+ """
203+ swath_shape = (1600 , 3200 )
204+ rows = np .empty (swath_shape , dtype = np .float32 )
205+ rows [:] = np .linspace (- 500 , 2500 , swath_shape [0 ])[:, None ]
206+ cols = np .empty (swath_shape , dtype = np .float32 )
207+ cols [:] = np .linspace (- 2500 , 500 , swath_shape [1 ])
208+ data = np .ones (swath_shape , dtype = dtype )
209+ out = np .empty ((1000 , 1000 ), dtype = dtype )
210+ return cols , rows , data , out
211+
212+
213+ @pytest .mark .parametrize (
214+ ("dtype" , "fill" , "expected_fill" ),
215+ [
216+ (np .int8 , 0 , 0 ),
217+ (np .int8 , None , 127 ),
218+ (np .float32 , 0.0 , 0.0 ),
219+ (np .float32 , None , np .nan ),
220+ (np .float64 , - 999.0 , - 999.0 ),
221+ (np .float64 , np .nan , np .nan ),
222+ ],
223+ )
224+ def test_fornav_fill_used_in_output (dtype , fill , expected_fill ):
225+ """Test that the user-supplied or default fill value is written to uncovered pixels (#689)."""
226+ from pyresample .ewa import fornav
227+ cols , rows , data , out = _partial_coverage_swath (dtype )
228+
229+ grid_points_covered , out_res = fornav (cols , rows , None , data ,
230+ rows_per_scan = 16 , fill = fill , out = out )
231+
232+ assert out is out_res
233+ assert grid_points_covered > 0
234+ # The swath was all 1s so every grid cell is either data or the fill value
235+ is_fill = np .isnan (out ) if np .isnan (expected_fill ) else out == expected_fill
236+ assert ((out == 1 ) | is_fill ).all (), "Output should only contain data and fill values"
237+ assert is_fill .any (), "Uncovered pixels should contain the fill value"
238+
239+
197240@pytest .mark .parametrize (
198241 ("dtype" , "input_fill" , "output_fill" ),
199242 [
0 commit comments