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

Resampling a User Defined Scene #487

Closed
sfinkens opened this issue Nov 5, 2018 · 1 comment
Closed

Resampling a User Defined Scene #487

sfinkens opened this issue Nov 5, 2018 · 1 comment

Comments

@sfinkens
Copy link
Member

sfinkens commented Nov 5, 2018

Describe the bug
I have trouble resampling a user defined Scene. I tried with and without chunking, but neither seems to work.

To Reproduce

import satpy
import xarray as xr
import numpy as np
import datetime as dt
import pyresample.geometry

mlons, mlats = np.meshgrid(np.arange(10), np.arange(10))
area_def = pyresample.geometry.SwathDefinition(lons=xr.DataArray(mlons, dims=('y', 'x')),
                                               lats=xr.DataArray(mlats, dims=('y', 'x')))

scene = satpy.Scene()
scene['test'] = xr.DataArray(
    data=np.zeros((10, 10)),
    dims=('y', 'x'),
    attrs={'name': 'test',
           'start_time': dt.datetime(2018, 1, 1),
           'area': area_def}).chunk(4096)

resampled = scene.resample('seviri_0deg')
scene['test'].values
resampled['test'].values

Expected behavior
The scene to be resampled.

Actual results

  1. Without chunking:
Traceback (most recent call last):
  File "test.py", line 19, in <module>
    resampled = scene.resample('seviri_0deg')
  File "/cmsaf/cmsaf-ops3/sfinkens/virtualenvs/satpy/lib/python2.7/site-packages/satpy/scene.py", line 1000, in resample
    **resample_kwargs)
  File "/cmsaf/cmsaf-ops3/sfinkens/virtualenvs/satpy/lib/python2.7/site-packages/satpy/scene.py", line 958, in _resampled_scene
    **kwargs)
  File "/cmsaf/cmsaf-ops3/sfinkens/virtualenvs/satpy/lib/python2.7/site-packages/satpy/resample.py", line 877, in resample_dataset
    new_data = resample(source_area, dataset, destination_area, **kwargs)
  File "/cmsaf/cmsaf-ops3/sfinkens/virtualenvs/satpy/lib/python2.7/site-packages/satpy/resample.py", line 849, in resample
    res = resampler_instance.resample(data, **kwargs)
  File "/cmsaf/cmsaf-ops3/sfinkens/virtualenvs/satpy/lib/python2.7/site-packages/satpy/resample.py", line 263, in resample
    cache_id = self.precompute(cache_dir=cache_dir, **kwargs)
  File "/cmsaf/cmsaf-ops3/sfinkens/virtualenvs/satpy/lib/python2.7/site-packages/satpy/resample.py", line 341, in precompute
    self.resampler.get_neighbour_info(mask=mask)
  File "/cmsaf/cmsaf-ops3/sfinkens/virtualenvs/satpy/lib/python2.7/site-packages/pyresample/kd_tree.py", line 1038, in get_neighbour_info
    chunks=chunks)
  File "/cmsaf/cmsaf-ops3/sfinkens/virtualenvs/satpy/lib/python2.7/site-packages/pyresample/kd_tree.py", line 988, in _create_resample_kdtree
    chunks=chunks)
  File "/cmsaf/cmsaf-ops3/sfinkens/virtualenvs/satpy/lib/python2.7/site-packages/pyresample/geometry.py", line 207, in get_lonlats_dask
    chunks=chunks)
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/dask/array/core.py", line 1990, in from_array
    chunks = normalize_chunks(chunks, x.shape)
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/dask/array/core.py", line 1907, in normalize_chunks
    raise ValueError(CHUNKS_NONE_ERROR_MESSAGE)
ValueError: You must specify a chunks= keyword argument.
This specifies the chunksize of your array blocks.
  1. With chunking, i.e. DataArray(...).chunk(4096)
Traceback (most recent call last):
  File "test.py", line 21, in <module>
    resampled['test'].values
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/xarray/core/dataarray.py", line 404, in values
    return self.variable.values
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/xarray/core/variable.py", line 387, in values
    return _as_array_or_item(self._data)
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/xarray/core/variable.py", line 211, in _as_array_or_item
    data = np.asarray(data)
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/numpy/core/numeric.py", line 492, in asarray
    return array(a, dtype, copy=False, order=order)
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/dask/array/core.py", line 1198, in __array__
    x = self.compute()
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/dask/base.py", line 155, in compute
    (result,) = compute(self, traverse=False, **kwargs)
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/dask/base.py", line 404, in compute
    results = get(dsk, keys, **kwargs)
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/dask/threaded.py", line 75, in get
    pack_exception=pack_exception, **kwargs)
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/dask/local.py", line 521, in get_async
    raise_exception(exc, tb)
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/dask/local.py", line 290, in execute_task
    result = _execute_task(task, data)
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/dask/local.py", line 270, in _execute_task
    args2 = [_execute_task(a, cache) for a in args]
  File "/cmsaf/nfshome/routcm/Modules_CentOS/python/2.7.14/lib/python2.7/site-packages/dask/local.py", line 271, in _execute_task
    return func(*args2)
  File "/cmsaf/cmsaf-ops3/sfinkens/virtualenvs/satpy/lib/python2.7/site-packages/pyresample/kd_tree.py", line 924, in query_no_distance
    mask=mask)
  File "kdtree.pyx", line 132, in pykdtree.kdtree.KDTree.query (pykdtree/kdtree.c:2080)
TypeError: query() got an unexpected keyword argument 'mask'

Text output of actual results or error messages including full tracebacks if applicable.

Environment Info:

  • OS: Linux
  • SatPy Version: satpy-0.9.1+393.g5dd28ea5 (current master)
  • PyResample Version: 1.10.2
  • Dask Version: 0.17.2
  • xarray version: 0.10.3
@sfinkens
Copy link
Member Author

sfinkens commented Nov 5, 2018

Updating pyresample and pykdtree did the trick

@sfinkens sfinkens closed this as completed Nov 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant