问题描述
我想替换 xr.DataArray 中的一些数据不是基于条件,而是基于多个时间点的特定点(并非像使用 .where
那样的所有点。
举个例子: 我有以下 DataArray
anom = xr.DataArray(data=np.random.rand(4,4,4),dims=["lat","lon","time"],coords={"lat": [-180,-90,90],"lon": [-90,-45,45],"time": [1,2,3,4]})
new = [.5,.5,.5]
并且想要检查 lat=20
、lon=20
、超过三个 time
步的值并取最大值。我可以使用 .sel
选择它,然后像这样将值与 .where
进行比较:
x = anom.sel(lat=20,lon=20,method="nearest").sel(time=slice(2,4))
x = x.where(x > new,other=new)
但我在这一点上被卡住了。我不知道我现在如何用新的 anom.sel(lat=20,4))
值覆盖 anom 中的值(特别是在 x
处)。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)