- 积分
- 3492
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2021-3-2
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 是冉冉升起的冉 于 2023-11-15 15:45 编辑
Q:画斜刨图大圆路径用ncl中这个函数gc_latlon,但是这里面有个常数npts,两个点之间选取的点数,不知道这个变量的设置是怎么选取的,以及最后画图的时候,经纬度不是均匀的,这种情况怎么办!!
画图最后出现这个警告
warning:ScalarFieldSetValues: irregular coordinate array sfXArray non-monotonic: defaulting sfXArray------------------------------------------------------------------------------------------------------------------------------------------------------------------------
参照ncl官网刨面图中,NCL Graphics: Pressure/Height vs. Latitude (ucar.edu),第五个例子的第三张图,画刨面主要使用的两个函数:
官网中的例子是曲面网格,因此先使用ESMF_regrid_with_weights进行网格化。
大圆路径:gc_latlon 其中设置的npts为x轴的点数目,根据需要设置,一般设置越大数据越密。
插值:linint2_points_Wrap使用双线性插值从直线网格插值到非结构化网格。
家园中的有一个例子感觉有一点问题,最后画图设置的经纬度,因为地球是球面,所以经纬度不是均匀的,设置时需要画gc_latlon 函数对应的经纬度。
实际中遇到的问题:
在选择的经度范围跨越半球时,两点之间的方向不可控制,这是因为gc_latlon这个函数的问题,试了多次也没解决,只能选择不跨越半球了。
[size=13.3333px]If the two specified points are exactly opposite one another on the globe, the code does not fail, but the direction of the great circle route will be somewhat unpredictable. Setting npts[size=13.3333px] <= 2 has the effect of just calculating the great circle distance between the two input points. No lat/lon points will be interpolated in between.
[size=13.3333px]最后出现的警告,猜测是由于网格的不均匀分布造成的,但画图的结果好像没有影响。
;=================================================================
;----------------斜刨面
; calculate great circle along transect
npts=600 ;The actual number of interpolated points is npts-2.
N1=npts-1
nLabels = 5 ;x轴坐标想要的标签数目
fiCyclicX =True ;注意数据是否循环
;选取的两个点
leftlat = 45
rightlat = 80
leftlon = 300
rightlon = 357.5
;attention:数据是从0-360 or -180-180
;lonFlip 可以使用该函数转换
dist = gc_latlon(leftlat,leftlon, rightlat,rightlon, npts,2) ;大圆路径
;插值 变量为Fx_pos_10_area
xlon=Fx_pos_10_area&lon
xlat=Fx_pos_10_area&lat
Fx_pos_10_cross = linint2_points_Wrap(xlon,xlat,Fx_pos_10_area,fiCyclicX,dist@gclon,dist@gclat,2)
;插值后赋予变量属性
Fx_pos_10_cross!0 = "time"
Fx_pos_10_cross!1 = "level"
Fx_pos_10_cross&level= Fx_pos_10_area&level
;-----对应的经纬度
latXsecUser = dist@gclat ; convenience
lonXsecUser = dist@gclon
print (dist@gclat+" "+dist@gclon ) ; print the lats/lons
;---------画图时x轴坐标设置
;数据从0-360
XBValues_pos = toint( fspan(0,N1,nLabels) )
XBLabels_pos = new(nLabels,"string")
do i=0,nLabels-1
x = lonXsecUser(XBValues_pos(i))
y = latXsecUser(XBValues_pos(i))
if(x.lt.180)then
XBLabels_pos(i) = sprintf("%3.1f", y)+"N"+"~C~"+sprintf("%3.1f", x)+"E"
else if(x.gt.180.and.x.le.360)then
x1=360-x
XBLabels_pos(i) = sprintf("%3.1f", y)+"N"+"~C~"+sprintf("%3.1f",x1)+"W"
else if(x.eq.180.or.x.eq.360)then
XBLabels_pos(i) = sprintf("%5.1f", y)+"N"+"~C~"+sprintf("%5.1f", x)
end if
end if
end if
end do
res@tmXBMode = "Explicit"
res@tmXBValues = XBValues_pos
res@tmXBLabels = XBLabels_pos
|
|