home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 411650684

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
411650684 MDU6SXNzdWU0MTE2NTA2ODQ= 2774 Applying the stack function to DataArray resulted in data type changes on coordinates 17244571 open 0     2 2019-02-18T21:28:19Z 2019-02-20T06:30:50Z   NONE      

Code Sample, a copy-pastable example if possible

A "Minimal, Complete and Verifiable Example" will make it much easier for maintainers to help you: http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports

```python

My source xarray.DataArray da is:

<xarray.DataArray (time: 744, latitude: 106, longitude: 193)> dask.array<shape=(744, 106, 193), dtype=float64, chunksize=(2, 106, 193)> Coordinates: * latitude (latitude) float32 -39.2 -39.149525 ... -33.950478 -33.9 * longitude (longitude) float32 140.8 140.84792 140.89584 ... 149.95209 150.0 * time (time) datetime64[ns] 2017-01-01 ... 2017-01-31T23:00:00

I applied stack() to it:

da_stacked = da.stack(z=['time', 'latitude', 'longitude'])

```

Problem description

This resulted in latitude and longitude changed from float32 to float64 and their data precision lost.

Now the da_stacked becomes:

<xarray.DataArray (z: 15220752)> dask.array<shape=(15220752,), dtype=float64, chunksize=(40916,)> Coordinates: * z (z) MultiIndex - time (z) datetime64[ns] 2017-01-01 2017-01-01 ... 2017-01-01 - latitude (z) float64 -39.2 -39.2 -39.2 -39.2 ... -39.2 -39.2 -39.2 -39.2 - longitude (z) float64 140.8 140.8 140.9 140.9 ... 142.0 142.1 142.1 142.2

How can I keep the coordinates as same as the source DataArray object while applying the stack function?

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2774/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

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