home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 619347681

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
619347681 MDU6SXNzdWU2MTkzNDc2ODE= 4068 utility function to save complex values as a netCDF file 6815844 closed 0     3 2020-05-16T01:19:16Z 2020-05-25T08:36:59Z 2020-05-25T08:36:58Z MEMBER      

Currently, we disallow to save complex values to a netCDF file. Maybe netCDF itself does not support complex values, but there may be some workarounds. It would be very handy for me.

The most naive workaround may be to split each complex value into a real and imaginary part, add some flags, and restore it when loading them from the file. Maybe we may add a special suffix to the variable name? ```python

ds = xr.Dataset({'a': ('x': [1+2j, 2+3j])}, coords={'x': [0, 1]}) ds.to_netcdf('tmp.nc', encode_complex=True) xr.load_netcdf('tmp.nc') <xarray.Dataset> Dimensions: (x: 2) Coordinates: * x (x) int64 0 1 Data variables: a__real__ (x) int64 1 2 a__imag__ (x) int64 2 3 xr.load_netcdf('tmp.nc', decode_complex=True) <xarray.Dataset> Dimensions: (x: 2) Coordinates: * x (x) int64 0 1 Data variables: a (x) complex128 (1+2j) (2+3j) ```

I think there may be a better way. Any thoughts are welcome :)

p.s. I just found that engine=h5netcdf can save complex values, but the file becomes an invalid netcdf file. I'm not sure if it worth the trouble just to make a valid netCDF file.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4068/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 0.658ms · About: xarray-datasette