home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 1562408060

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
1562408060 I_kwDOAMm_X85dIHR8 7485 ValueError with scipy.ndimage.convolve1d 44666294 closed 0     0 2023-01-30T13:02:30Z 2023-01-30T13:19:46Z 2023-01-30T13:19:46Z NONE      

What happened?

I'm using xarray to read radar data (.nc file) and I have got ndarray data by calling to_numpy(). I have noticed that there are similar functions in xarray that can finish convolution operation, but I just want to do this by using convolve1d from scipy.ndimage. However, which makes me confused, xarray reports an error: ValueError: applied function returned data with unexpected number of dimensions. Received 2 dimension(s) but expected 0 dimensions with names: () The data in DataArray is: <xarray.DataArray 'differential_phase' (sweep: 9, azimuth: 360, range: 1000)> Coordinates: * sweep (sweep) int32 0 1 2 3 4 5 6 7 8 * azimuth (azimuth) int64 0 1 2 3 4 5 6 7 ... 352 353 354 355 356 357 358 359 * range (range) float32 250.0 500.0 750.0 ... 2.495e+05 2.498e+05 2.5e+05 Attributes: long_name: differential_phase_hv units: degrees valid_min: 0.0 valid_max: 360.0 standard_name: differential_phase_hv I'm sure the type of data I passed to convolve1d is ndarray I have added print(self) to line 82 in file xarray/core/arithmetic.py, and I got this: <xarray.DataArray 'range' ()> array(1.5)


I have uploaded a copy of data (.npz file) which can be used to test: PhiDP.zip. Rename it to PhiDP.npz, and load it with np.load.

What did you expect to happen?

No error is reported.

Minimal Complete Verifiable Example

MVCE confirmation

  • [ ] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • [ ] Complete example — the example is self-contained, including all data and the text of any traceback.
  • [ ] Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • [X] New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

Python Traceback (most recent call last): File "/home/syize/Documents/Python/college-graduate/main.py", line 12, in <module> KDP = lp.start() File "/home/syize/Documents/Python/college-graduate/radar/lp.py", line 369, in start KDP = self.calculate_KDP_from_PhiDP(convolve=True) File "/home/syize/Documents/Python/college-graduate/radar/lp.py", line 315, in calculate_KDP_from_PhiDP KDP = convolve1d(list(PhiDP), convolve_core, axis=1) / ( File "/home/syize/.local/lib/python3.10/site-packages/xarray/core/arithmetic.py", line 82, in __array_ufunc__ return apply_ufunc( File "/home/syize/.local/lib/python3.10/site-packages/xarray/core/computation.py", line 1206, in apply_ufunc return apply_dataarray_vfunc( File "/home/syize/.local/lib/python3.10/site-packages/xarray/core/computation.py", line 315, in apply_dataarray_vfunc result_var = func(*data_vars) File "/home/syize/.local/lib/python3.10/site-packages/xarray/core/computation.py", line 798, in apply_variable_ufunc raise ValueError( ValueError: applied function returned data with unexpected number of dimensions. Received 2 dimension(s) but expected 0 dimensions with names: ()

Anything else we need to know?

No response

Environment

/home/syize/.local/lib/python3.10/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils. warnings.warn("Setuptools is replacing distutils.") INSTALLED VERSIONS ------------------ commit: None python: 3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0] python-bits: 64 OS: Linux OS-release: 6.1.8-arch1-1 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: zh_CN.UTF-8 LOCALE: ('zh_CN', 'UTF-8') libhdf5: 1.12.2 libnetcdf: 4.9.0 xarray: 2022.12.0 pandas: 1.5.2 numpy: 1.23.5 scipy: 1.9.3 netCDF4: 1.6.2 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.6.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: 3.6.2 cartopy: 0.21.1 seaborn: None numbagg: None fsspec: 2023.1.0 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 66.1.1 pip: 22.3.1 conda: None pytest: None mypy: None IPython: None sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7485/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

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