月平均气温
在查看了平均气温的分析后,您只需要看看其他月份的情况。若继续使用之前的方法,这会很繁琐,因为需要在时间维度上进行大量复杂的切片来选中对应的月份。所幸借助 Xarray,这要简单得多。
环境中已提供欧洲天气数据集,对应的 Xarray DataSet 为 ds。
本练习是课程的一部分
Python 中的 Dask 并行编程
练习说明
- 使用
ds的'time'坐标中的日期时间访问器,将月份赋给变量months。 - 从
ds中选取'temp'变量,并按months进行分组。 - 对分组取均值,计算所有时间上的月平均值。
- 计算结果。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Extract the months from the time coordinates
months = ds['____'].____.____
# Select the temp DataArray and group by months
monthly_groupby = ds['____'].____(____)
# Find the mean temp by month
monthly_mean_temps = ____.____()
# Compute the result
monthly_mean_temps_computed = ____.____()
monthly_mean_temps_computed.plot(col='month', col_wrap=4, add_colorbar=False)
plt.show()