![](/img/trans.png)
[英]The dimension of the array of an image is 3D not 2D as it is in the Python course
[英]Python Xarray integrate a 2D array along datetime dimension
我在 Xarray 中有非常大的二維變量。 它們具有以下形式:counts(time, altitude) 其中 time 是每 10 秒的 numpy 日期時間,altitude 是浮點數,counts 是帶有偶爾 NaN 的浮點數。
我想通過對相應列進行求和或平均將分辨率降低到每 15 分鍾一次。
同樣,我想沿着高度維度中的計數行執行相同的操作。
我將不勝感激 Python 中有關如何完成此操作的一些建議(我仍在 Python 的學習曲線上)。
您可以使用 xarray 中的 resample 方法(請參閱文檔https://xarray.pydata.org/en/stable/generated/xarray.Dataset.resample.html中的示例)。
有基於 pandas 的命名時間偏移(參見https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#dateoffset-objects )。
例如,基於每日數據庫的年度平均值應該是這樣的:
ds.resample(time='Y').mean('time')
在你的情況下,它應該是:
ds.resample(time='15min').mean('time')
其中 time 是數據集中的時間變量,“15min”是https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#dateoffset-objects的命名時間偏移量
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.