Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
lahtinep committed Jan 16, 2025
2 parents 91fcbba + e2c20c9 commit 84d5b62
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ jobs:
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
mamba-version: "1.5.10"
python-version: ${{ matrix.python-version }}
environment-file: continuous_integration/environment.yaml
activate-environment: test-environment
channels: conda-forge
conda-remove-defaults: true
channel-priority: strict

- name: Install unstable dependencies
if: matrix.experimental == true
Expand Down
2 changes: 1 addition & 1 deletion pyresample/gradient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def gradient_resampler(data, source_area, target_area, method='bilinear'):
method=method)


def gradient_resampler_indices_block(block_info=None, **kwargs):
def gradient_resampler_indices_block(block_info, **kwargs):
"""Do the gradient search resampling using block_info for areas, returning the resulting indices."""
source_area = block_info[0]["area"]
target_area = block_info[None]["area"]
Expand Down
1 change: 1 addition & 0 deletions pyresample/gradient/_gradient_search.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ cdef void one_step_gradient_search_no_gil(const data_type[:, :, :] data,

for _ in range(x_size):
if isinf(dst_x[i, j]):
j += col_step
continue
cnt = 0
while True:
Expand Down
26 changes: 25 additions & 1 deletion pyresample/test/test_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@

from pyresample.area_config import create_area_def
from pyresample.geometry import AreaDefinition, SwathDefinition
from pyresample.gradient import ResampleBlocksGradientSearchResampler, create_gradient_search_resampler
from pyresample.gradient import (
ResampleBlocksGradientSearchResampler,
create_gradient_search_resampler,
gradient_resampler_indices,
)


class TestRBGradientSearchResamplerArea2Area:
Expand Down Expand Up @@ -624,3 +628,23 @@ def test_index_search_with_data_requested_outside_top_left_boundary(self):
self.dst_x, self.dst_y)
np.testing.assert_allclose(res_x, expected_x)
np.testing.assert_allclose(res_y, expected_y)


def test_resampling_geos_edge_to_mercator():
"""Test that projecting the edges of geos onto a mercator area does not produce unnecessary NaNs."""
source_area = AreaDefinition.from_extent(area_id="side",
projection={'ellps': 'WGS84', 'h': '35786400', 'lon_0': '0',
'no_defs': 'None', 'proj': 'geos', 'type': 'crs',
'units': 'm', 'x_0': '0', 'y_0': '0'},
area_extent=(-2483999.9974, 5121999.9947, -1739999.9982, 4809999.995),
shape=(156, 372))
dest_area = AreaDefinition.from_extent(area_id="dest",
projection={'a': '6378137', 'b': '6378137', 'k': '1', 'lat_ts': '0',
'lon_0': '0', 'nadgrids': '@null', 'no_defs': 'None',
'proj': 'merc', 'type': 'crs', 'units': 'm', 'wktext': 'None',
'x_0': '0', 'y_0': '0'},
area_extent=(-7800000.0, 8595618.56, -6073037.8378, 10321713.92),
shape=(512, 512))

res = gradient_resampler_indices(source_area, dest_area, fill_value=np.nan)
assert not np.any(np.isnan(res[:, :, -1]))

0 comments on commit 84d5b62

Please sign in to comment.