pytroll / pytroll/pyresample

`gradient_search` producing nan output for some resampling operations

Open
#449 1 comment 0 reactions 1 assignee View on GitHub

@mraspaud is already working on this.

Since Aug 5, 2022.

bug
Dominant language
Python
Stars
385
Forks
102
Avg merge
4d 2h
Merged PRs (30d)
9

Description

In the latest pyresample release the gradient_search resampler is returning arrays containing only np.nan values for some resampling operations. Previous releases did not do this.

In my workflow I'm resampling a gridded lat/lon dataset onto the SEVIRI grid, and I've used that to produce this example:

from pyresample import create_area_def
from datetime import datetime
import dask.array as da
from satpy import Scene
import xarray as xr
import numpy as np

dater = datetime.utcnow()

lon = np.arange(-180, 180, 0.25)
lat = np.arange(-90, 90+0.25, 0.25)

inv = np.random.uniform(low=0., high=1., size=(lat.shape[0], lon.shape[0]))

area_ext = (np.nanmin(lon), np.nanmin(lat), np.nanmax(lon), np.nanmax(lat))
targ_area = create_area_def("source_area",
                            "EPSG:4326",
                            area_extent=area_ext,
                            width=inv.shape[1],
                            height=inv.shape[0])

ecm_scn = Scene()

ecm_scn['test'] = xr.DataArray(da.from_array(inv),
                            coords={'y': lat, 'x': lon},
                            attrs={'start_time': dater})

ecm_scn['test'].attrs['area'] = targ_area

print("Nearest")
ecm_snm_res = ecm_scn.resample('msg_seviri_fes_3km', resampler='nearest')
print(np.nanmin(ecm_snm_res['test']), np.nanmean(ecm_snm_res['test']), np.nanmax(ecm_snm_res['test']))

print("Bilinear")
ecm_snm_res = ecm_scn.resample('msg_seviri_fes_3km', resampler='bilinear')
print(np.nanmin(ecm_snm_res['test']), np.nanmean(ecm_snm_res['test']), np.nanmax(ecm_snm_res['test']))

print("Gradient search")
ecm_snm_res = ecm_scn.resample('msg_seviri_fes_3km', resampler='gradient_search')
print(np.nanmin(ecm_snm_res['test']), np.nanmean(ecm_snm_res['test']), np.nanmax(ecm_snm_res['test']))

Prints:

Nearest
1.757739096830413e-06 0.5006533072205385 0.9999969024153488

Bilinear
0.002291159924354849 0.5006759644036226 0.9965275266396012

Gradient search
nan nan nan

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.