home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 558519267

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
558519267 MDU6SXNzdWU1NTg1MTkyNjc= 3741 DataArrayCoarsen does not have a map or reduce function 6363939 closed 0     3 2020-02-01T10:22:25Z 2021-02-23T16:01:27Z 2021-02-23T16:01:27Z NONE      

I'm trying to count unique samples when resampling to a square kilometre from a 5x5m input grid. I'd like to be able to apply the Dask.array.unique() function with return_counts=True to give me a new dimension with the original integer values and their counts.

In order to resample along spatial dimensions I assume I need to use .coarsen(), unfortunately the core.rolling.DataArrayCoarsen object does not yet implement either a .map() or .reduce() function for applying an arbitrary function when coarsening.

MCVE Code Sample

```python import xarray as xr from dask.array import unique

da = xr.DataArray([1, 1, 2, 3, 5, 3], [('x', range(0, 6))]) coarse = da2.coarsen(dim={'x': 2}).map(unique, kwargs={'return_counts': True}) coarse ```

outputs; AttributeError: 'DataArrayCoarsen' object has no attribute 'map'

N.B. core.groupby.DataArrayGroupBy has both .map() and .reduce() while core.rolling.DataArrayRolling has .reduce(). Would it make sense for all three to have the same interface?

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.7.4 (default, Sep 7 2019, 18:27:02) [Clang 10.0.1 (clang-1001.0.46.4)] python-bits: 64 OS: Darwin OS-release: 19.3.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_AU.UTF-8 LOCALE: en_AU.UTF-8 libhdf5: None libnetcdf: None xarray: 0.15.0 pandas: 1.0.0 numpy: 1.18.1 scipy: 1.4.1 netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: 1.1.2 cfgrib: None iris: None bottleneck: None dask: 2.10.1 distributed: 2.10.0 matplotlib: 3.1.2 cartopy: None seaborn: None numbagg: None setuptools: 40.8.0 pip: 19.0.3 conda: None pytest: 5.3.5 IPython: 7.11.1 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3741/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 1.241ms · About: xarray-datasette