Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gradient_search producing nan output for some resampling operations #449

Open
simonrp84 opened this issue Aug 5, 2022 · 1 comment · May be fixed by #456
Open

gradient_search producing nan output for some resampling operations #449

simonrp84 opened this issue Aug 5, 2022 · 1 comment · May be fixed by #456
Assignees
Labels

Comments

@simonrp84
Copy link
Member

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
@mraspaud
Copy link
Member

mraspaud commented Aug 5, 2022

Thanks a lot for reporting this!

@mraspaud mraspaud self-assigned this Aug 5, 2022
@mraspaud mraspaud added the bug label Aug 5, 2022
@mraspaud mraspaud linked a pull request Sep 21, 2022 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants