|
32 | 32 |
|
33 | 33 | from pyresample.area_config import create_area_def |
34 | 34 | from pyresample.geometry import AreaDefinition, SwathDefinition |
35 | | -from pyresample.gradient import ResampleBlocksGradientSearchResampler, create_gradient_search_resampler |
| 35 | +from pyresample.gradient import ( |
| 36 | + ResampleBlocksGradientSearchResampler, |
| 37 | + create_gradient_search_resampler, |
| 38 | + gradient_resampler_indices, |
| 39 | +) |
36 | 40 |
|
37 | 41 |
|
38 | 42 | class TestRBGradientSearchResamplerArea2Area: |
@@ -624,3 +628,23 @@ def test_index_search_with_data_requested_outside_top_left_boundary(self): |
624 | 628 | self.dst_x, self.dst_y) |
625 | 629 | np.testing.assert_allclose(res_x, expected_x) |
626 | 630 | np.testing.assert_allclose(res_y, expected_y) |
| 631 | + |
| 632 | + |
| 633 | +def test_resampling_geos_edge_to_mercator(): |
| 634 | + """Test that projecting the edges of geos onto a mercator area does not produce unnecessary NaNs.""" |
| 635 | + source_area = AreaDefinition.from_extent(area_id="side", |
| 636 | + projection={'ellps': 'WGS84', 'h': '35786400', 'lon_0': '0', |
| 637 | + 'no_defs': 'None', 'proj': 'geos', 'type': 'crs', |
| 638 | + 'units': 'm', 'x_0': '0', 'y_0': '0'}, |
| 639 | + area_extent=(-2483999.9974, 5121999.9947, -1739999.9982, 4809999.995), |
| 640 | + shape=(156, 372)) |
| 641 | + dest_area = AreaDefinition.from_extent(area_id="dest", |
| 642 | + projection={'a': '6378137', 'b': '6378137', 'k': '1', 'lat_ts': '0', |
| 643 | + 'lon_0': '0', 'nadgrids': '@null', 'no_defs': 'None', |
| 644 | + 'proj': 'merc', 'type': 'crs', 'units': 'm', 'wktext': 'None', |
| 645 | + 'x_0': '0', 'y_0': '0'}, |
| 646 | + area_extent=(-7800000.0, 8595618.56, -6073037.8378, 10321713.92), |
| 647 | + shape=(512, 512)) |
| 648 | + |
| 649 | + res = gradient_resampler_indices(source_area, dest_area, fill_value=np.nan) |
| 650 | + assert not np.any(np.isnan(res[:, :, -1])) |
0 commit comments