我不能够充分实际代码在Python中但我希望我可以点你在正确的方向上如果我计算分流和汇合。可以先做一个[流线阴谋使用matplotlib] [1]。一旦你有了,你需要实际的简化数据中描述这个链接- [https://matplotlib.org/api/_as_gen/matplotlib.pyplot.streamplot.html] [2], LineCollection给出数据结构。每简化LineCollection需要计算(切向和法向量)[3]基于局部笛卡尔坐标系统的起源的想法集中在某处沿着流线。一旦你有了切向和法向量您将需要使用这个方程即散度在自然坐标系$ $ \微分算符。v_h = (e_n \压裂{\部分e_s}{\部分n} * v_h) + \压裂{\部分v_h}{\部分年代}$ $使用的组合(Frenet艾史蒂夫公式][4]这可以显示等于$ $ \压裂{| v_h |} {R_n} + \压裂{\部分v_h}{\部分年代}$ $从你的角度你只要第一项方程计算分流和汇合。所以R_n美元的曲率半径法向量(之前你已经计算)。为了计算曲率半径可以使用这个(python代码的最小二乘拟合)[5](使用最小二乘的方法——获得椭圆然后计算半径)。如果半径是积极的我. .e R_n > 0美元然后你有分流和消极的融合。 **UPDATE** If you are looking for the exact [NCL shear stretch deform][6] in Python what you can do is to use this package in python [pyspharm][7]. The data has to be global and then you need to orient the grid in a south to north direction. Once you have that you can use that package to calculate the shear, stretch and deformation parameters by using the [pyspharm's **getgrad()**][8] method to calculate the vector gradient of the wind vectors. If you pass in the components of the wind vectors(both u and v) to getgrad() you will get the zonal and meridional components of the gradient of the wind vectors. Adding and subtracting them will get you the shear and stretch. Sample code from spharm import Spharmt uspectral = Spharmt.grdtospec(u,ntruncation) vspectral = Spharmt.grdtospec(v,ntruncation) dudx,dudy = Spharmt.getgrad(uspectral) dvdx,dvdy = Spharmt.getgrad(vspectral) #shear and stretch shear = dvdx + dudy stretch = dudx - dvdy [1]: https://matplotlib.org/gallery/images_contours_and_fields/plot_streamplot.html [2]: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.streamplot.html [3]: https://scicomp.stackexchange.com/questions/16444/determine-unit-outward-normal-vector-for-a-curve/16445#16445 [4]: https://en.wikipedia.org/wiki/Frenet%E2%80%93Serret_formulas [5]: https://github.com/bdhammel/least-squares-ellipse-fitting [6]: https://www.ncl.ucar.edu/Document/Functions/Contributed/shear_stretch_deform.shtml [7]: https://pypi.org/project/pyspharm/ [8]: https://github.com/jswhit/pyspharm/blob/master/Lib/spharm.py#L845 [9]: https://ajdawson.github.io/windspharm/latest/
Baidu
map