home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 177754433

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
177754433 MDU6SXNzdWUxNzc3NTQ0MzM= 1008 How to avoid the auto convert variable dtype from float32 to float64 when read netCDF file use open_dataset? 12339722 closed 0     6 2016-09-19T10:51:29Z 2018-03-28T22:37:00Z 2018-03-28T22:37:00Z NONE      

when i read some netCDF4 file using xr.open_dataset, it seems this method would auto convert the variable type from float32 to float64, how to avoid it ?

Use xarry.open_dataset

python import xarray as xr xr.open_dataset('cat.20151003200633.nc')

will yield output as follow

<xarray.Dataset> Dimensions: (x: 461, y: 461, z: 9) Coordinates: * x (x) float32 -230.0 -229.0 -228.0 -227.0 -226.0 -225.0 -224.0 ... * y (y) float32 -230.0 -229.0 -228.0 -227.0 -226.0 -225.0 -224.0 ... * z (z) float32 0.4 1.4 2.3 3.2 4.3 5.8 9.7 14.5 19.3 Data variables: dbz (z, y, x) float64 nan nan nan nan nan nan nan nan nan nan nan ... vr (z, y, x) float64 nan nan nan nan nan nan nan nan nan nan nan ... sw (z, y, x) float64 nan nan nan nan nan nan nan nan nan nan nan ...

Variables dtype of dbz, vr and sw in this file have been convert to float64, which actually is float32.

Use netCDF4.Dataset

python import netCDF4 as ncf ncf.Dataset('cat.20151003200633.nc')

will yield output as follow

<type 'netCDF4._netCDF4.Dataset'> root group (NETCDF4 data model, file format HDF5): .......... dimensions(sizes): x(461), y(461), z(9) variables(dimensions): float32 x(x), float32 y(y), float32 z(z), float32 dbz(z,y,x), float32 vr(z,y,x), float32 sw(z,y,x) groups:

The netCDF4.Dataset produce the right variable type, while the xarray.open_dataset not.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1008/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
  • 6 rows from issue in issue_comments
Powered by Datasette · Queries took 73.357ms · About: xarray-datasette