What is the best practice for changing only the data in a DataArray?
Is it as simple as assigning to the data attribute? I don't see a proper method to do this in the documentation.
import xarray as xr
import numpy as np
import pandas as pd
# Example in DataArray
rng = np.random.default_rng(123)
temperature = 15 + 8 * rng.standard_normal((2, 2, 3))
lon = [[-99.83, -99.32], [-99.79, -99.23]]
lat = [[42.25, 42.21], [42.63, 42.59]]
time = pd.date_range("2014-09-06", periods=3)
reference_time = pd.Timestamp("2014-09-05")
da = xr.DataArray(data=temperature,
dims=["x", "y", "time"],
coords=dict(lon=(["x", "y"], lon),
lat=(["x", "y"], lat),
time=time,
reference_time=reference_time),
attrs=dict(description="Ambient temperature.",
units="degC"))
# Some new data
temperature_new = 20 + rng.standard_normal((2, 2, 3))
# Below seems like a very fragile mechanism
da.data = temperature_new