📜  xarray 添加坐标 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:19.133000             🧑  作者: Mango

代码示例1
>>> da = xr.DataArray(
...     np.random.rand(4),
...     coords=[np.array([358, 359, 0, 1])],
...     dims="lon",
... )
>>> da

array([0.5488135 , 0.71518937, 0.60276338, 0.54488318])
Coordinates:
  * lon      (lon) int64 358 359 0 1
  
>>> da.assign_coords(lon=(((da.lon + 180) % 360) - 180))

array([0.5488135 , 0.71518937, 0.60276338, 0.54488318])
Coordinates:
  * lon      (lon) int64 -2 -1 0 1