Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loosing attributes with .chunk and .pad #337

Open
louisletoumelin opened this issue Jun 14, 2024 · 0 comments
Open

Loosing attributes with .chunk and .pad #337

louisletoumelin opened this issue Jun 14, 2024 · 0 comments

Comments

@louisletoumelin
Copy link

Hello,

Attributes disappear after calling the following DataTree method: .chunk, .pad

datatree version: '0.0.13'

import numpy as np
import pandas as pd
import xarray as xr
from datatree import DataTree

np.random.seed(0)

temperature = 15 + 8 * np.random.randn(2, 3, 4)

precipitation = 10 * np.random.rand(2, 3, 4)

lon = [-99.83, -99.32]

lat = [42.25, 42.21]

instruments = ["manufac1", "manufac2", "manufac3"]

time = pd.date_range("2014-09-06", periods=4)

reference_time = pd.Timestamp("2014-09-05")

ds = xr.Dataset(

    data_vars=dict(

        temperature=(["loc", "instrument", "time"], temperature),

        precipitation=(["loc", "instrument", "time"], precipitation),

    ),

    coords=dict(

        lon=("loc", lon),

        lat=("loc", lat),

        instrument=instruments,

        time=time,

        reference_time=reference_time,

    ),

    attrs=dict(description="Weather related data."),

)
dt = DataTree.from_dict({"simulation/one": ds, "simulation/two": ds})
dt.attrs = {"a": 0, "b":1}
dt.pad({"loc": 1}).attrs  # returns {}, expected  {"a": 0, "b":1}
dt.chunk({"loc": 1}).attrs  # returns {}, expected  {"a": 0, "b":1}

I tried to replicate the behavior with datatree version's on the xarray repo. The .pad issue disappear:
xarray version '2024.6.0'

from xarray.core.datatree import DataTree
# same operations as above
dt.pad({"loc": 1}).attrs  # OK

but the following operation raises an error

dt.chunk({"loc": 1}).attrs 

ValueError: unrecognized chunk manager dask - must be one of: []
Raised whilst mapping function over node with path /simulation/one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant