Python - 曲线图上的子集 WRF 数据



我有一个曲线投影(原生朗伯共形投影)上的WRF输出,因此有与之关联的2D坐标(XLONG和XLAT)。 我能够通过切片数组将数据子集化为矩形网格

例如

xlat = 常量.变量['XLAT'][0,749:915,220:458]

xlon = 常量.变量['XLONG'][0,749:915,220:458]

但是,我想对所有以特定纬度和经度为界的网格点进行子集化,以获得网格点的梯形形状。 我附上了一张图片,使其易于理解。 我想要以红线为界的网格点,而不是蓝色框中的网格点。

https://www.dropbox.com/s/bxnhuhyoena8a8e/WRF_StudySites.pdf?dl=0

这可以在NCL(NCAR命令行)中使用where()函数完成,但是我在python中做同样的事情时遇到了麻烦。

关于我如何做到这一点的任何提示?

谢谢!

我为此使用了xarray包。有关其where()功能的说明,请参阅此处。我的数据集中的经度范围从 -5 到 13,因此条件 XLONG>0 仅返回我的部分数据(按预期)。

例如:

import xarray as xr
import matplotlib.pyplot as plt
# Load dataset with xarray (I only import T2 here, and only the first time)
wrftemp = xr.open_dataset('wrfout_d01_.....').T2.isel(Time=1)
# Make a figure of the T2 temperature field
fig,(ax1,ax2) = plt.subplots(1,2)
wrftemp.plot(ax=ax1)
wrftemp.where(wrftemp.XLONG>0).plot(ax=ax2)
plt.show()

最新更新