issues: 499196320
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
499196320 | MDU6SXNzdWU0OTkxOTYzMjA= | 3348 | Changing dtype on v0.13.0 causes Dataset attributes to be lost | 17680388 | closed | 0 | 7 | 2019-09-27T02:09:27Z | 2020-12-24T17:47:34Z | 2020-12-24T17:47:34Z | NONE | MCVE Code Sample```python import numpy as np import pandas as pd import xarray as xr np.random.seed(123) times = pd.date_range("2000-01-01", "2001-12-31", name="time") annual_cycle = np.sin(2 * np.pi * (times.dayofyear.values / 365.25 - 0.28)) base = 10 + 15 * annual_cycle.reshape(-1, 1) tmin_values = base + 3 * np.random.randn(annual_cycle.size, 3) tmax_values = base + 10 + 3 * np.random.randn(annual_cycle.size, 3) ds = xr.Dataset({"tmin": (("time", "location"), tmin_values), "tmax": (("time", "location"), tmax_values),}, {"time": times, "location": ["IA", "IN", "IL"]}) Assign an attributeds = ds.assign_attrs(CRS = 'EPSG:4326') Change dtypeds.astype(np.float32) ``` Expected Output
Problem DescriptionOn
However, on
This causes issues with large geospatial analyses (e.g. OpenDataCube workflows), as we need to change dtype to reduce memory, but also preserve CRS information that is used for downstream tools. Output of
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/3348/reactions", "total_count": 3, "+1": 3, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |