rya*_*lon 5 python matplotlib matplotlib-basemap
是否有一种现成的方法可以从网格中心位置(红点)推断网格角位置(蓝点)?
我正在使用的网格不是矩形的,因此常规双线性插值似乎不是最好的方法;不过,这只是为了让我绘制我的数据使用情况pyplot.pcolormesh(),所以也许这并不重要。

网格数据示例:
import numpy as np
lons = np.array([[ 109.93299681, 109.08091365, 108.18301276, 107.23602539],
[ 108.47911382, 107.60397996, 106.68325946, 105.71386119],
[ 107.06790187, 106.17259769, 105.23214707, 104.2436463 ],
[ 105.69908292, 104.78633156, 103.82905363, 102.82453812]])
lats = np.array([[ 83.6484245 , 83.81088466, 83.97177823, 84.13098916],
[ 83.55459198, 83.71460466, 83.87294803, 84.02950188],
[ 83.4569054 , 83.61444708, 83.77022192, 83.92410637],
[ 83.35554612, 83.51060313, 83.6638013 , 83.81501464]])
Run Code Online (Sandbox Code Playgroud)
我不知道有任何强大的 matplotlib 技术可以完成您所要求的操作,但我可能有不同的解决方案。我经常必须填充/外推到网格中缺少信息的区域。为此,我使用了一个 Fortran 程序,该程序使用 F2PY(随 numpy 一起提供)编译,该程序将其创建为 python 模块。假设您有 Intel Fortran 编译器,您可以使用以下命令对其进行编译: f2py --verbose --fcompiler=intelem -c -m extrapolate fill.f90。您可以使用 python 调用该程序(完整示例请参见此处):
import extrapolate as ex
undef=2.0e+35
tx=0.9*undef
critx=0.01
cor=1.6
mxs=100
field = Zg
field=np.where(abs(field) > 50 ,undef,field)
field=ex.extrapolate.fill(int(1),int(grdROMS.xi_rho),
int(1),int(grdROMS.eta_rho),
float(tx), float(critx), float(cor), float(mxs),
np.asarray(field, order='Fortran'),
int(grdROMS.xi_rho),
int(grdROMS.eta_rho))
Run Code Online (Sandbox Code Playgroud)
该程序通过迭代方法在矩形坐标中求解具有诺依曼边界条件 (dA/dn = 0) 的拉普拉斯方程,以在包含“undef”等值的网格点处填充合理值。这对我很有用,也许你会发现它很有用。该程序可以在我的 github 帐户上找到。
| 归档时间: |
|
| 查看次数: |
1767 次 |
| 最近记录: |