使用 xarray 进行探索性数据分析
Xarray 让多维数据处理更轻松,就像 pandas 让表格数据处理更轻松一样。更棒的是,Xarray 可以在后台使用 Dask,帮助您高效快速地处理数据。
您需要对欧洲天气数据集做进一步分析。既然已经会使用 Xarray,就从一些探索性数据分析开始吧。
已为您导入 xarray 并命名为 xr。
本练习是课程的一部分
Python 中的 Dask 并行编程
练习说明
- 使用 Xarray 的
open_zarr()函数打开数据集"data/era_eu.zarr"。 - 使用 DataSet 的
.isel()方法,在time坐标上选择第 0 个索引。 - 从第 0 个索引的
ds_sel中选择变量'temp',并在ax1上绘图。 - 从第 0 个索引的
ds_sel中选择变量'precip',并在ax2上绘图。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Open the ERA5 dataset
ds = ____.____("____")
# Select the zeroth time in the DataSet
ds_sel = ds.____(____=____)
fig, (ax1, ax2) = plt.subplots(1,2, figsize=(8, 3))
# Plot the zeroth temperature field on ax1
____[____].____(ax=____)
# Plot the zeroth precipitation field on ax2
____[____].____(ax=____)
plt.show()