我的WRF输出位于曲线投影(原生朗伯保形投影)上,因此存在与之相关的2D坐标(XLONG& XLAT)。我可以通过切割数组
将数据子集化为矩形网格e.g。
xlat = constants.variables [' XLAT'] [0,749:915,220:458]
xlon = constants.variables [' XLONG'] [0,749:915,220:458]
但是,我希望将所有以特定纬度和经度为界的网格点子集,以获得一种梯形形状的网格点。我附上了一张图片,以便于理解。我希望网格点由红线界定,而不是蓝框内的网格点。
https://www.dropbox.com/s/bxnhuhyoena8a8e/WRF_StudySites.pdf?dl=0
这可以使用where()函数在NCL(NCAR命令行)中完成,但我在python中做同样的事情时遇到了麻烦。
有关如何做到这一点的任何提示?
谢谢!
答案 0 :(得分:0)
我使用了xarray
包。有关其where()
功能的说明,请参阅here。我的数据集中的经度范围为-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()