- 积分
- 4208
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-4-26
- 最后登录
- 1970-1-1
|
发表于 2019-5-23 22:09:20
|
显示全部楼层
ncl的一个站点插值成格点的例子
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" ;将台站资料插值至格点资料,必须加载库
begin
regrid_On = True ; 需要插值
;!! 注意,本文所用台站资料分辨率较低,若直接用该资料进行绘图,会导致江苏边界处出现一些空白。因此,为达到较好的效果,
;;;该脚本首先将降水资料插值到分辨率为0.1°的均匀网格上。但请注意,这种低分辨率转为高分辨率的结果误差较大。
preci = fbindirread("/home/ncl/data/preci-160-JJA-30yr.grd",0,(/30,160/),"float")
;printVarSummary(preci)
preci!0 = "year"
preci!1 = "stations"
preci&year = ispan(1979,2008,1)
preci&stations = ispan(1,160,1)
var = dim_avg_n_Wrap(preci,0) ; 气候平均
;; 读取各个台站的经纬度坐标
path_station = "/home/ncl/data/160stations.txt"
station = asciiread(path_station,(/160,2/),"float")
lat = station(:,0)
lon = station(:,1)
;是否进行插值,这里插值的目的仅是为了美观,其差值可能存在一定的误差
if(regrid_On)
minlat = min(lat)
maxlat = max(lat)
minlon = min(lon)
maxlon = max(lon)
Opt = True
Opt@SrcGridLat = lat
Opt@SrcGridLon = lon
Opt@DstLLCorner = (/floor(minlat)-0.1,floor(minlon)+0.1/)
Opt@DstURCorner = (/ceil(maxlat)-0.1, ceil(maxlon)+0.1/)
Opt@DstGridType = "0.1deg" ; 插值后的分辨率
Opt@ForceOverwrite = True
Opt@Debug = True
Opt@InterpMethod = "patch" ; 或者 "bilinear"
var := ESMF_regrid(var,Opt) ; 由于插值后数组维数大小与原Var不一致,所以需在=前加:,重新赋值定义
end if
wks = gsn_open_wks("png","/home/ncl/plot/plot-preci-jiangsu")
gsn_define_colormap(wks,"GMT_drywet")
res =True
res@gsnDraw = False
res@gsnFrame = False
res@gsnAddCyclic = False
res@gsnMaximize = True
;; 若不插值,直接用台站资料绘制
if(.not.regrid_On)
res@sfXArray = lon
res@sfYArray = lat
end if
;; 设置经纬线
res@mpGridAndLimbOn = True
res@mpGridLineColor = "black"
res@mpGridLatSpacingF = 1
res@mpGridLonSpacingF = 1
res@mpGridLineDashPattern = 16
res@mpGridLineThicknessF = 0.2
res@mpMaxLatF = 36
res@mpMinLatF = 30
res@mpMaxLonF = 123
res@mpMinLonF = 116
res@mpDataBaseVersion = "Ncarg4_1"
res@mpDataSetName = "Earth..4"
res@mpAreaMaskingOn = True
res@mpMaskAreaSpecifiers = (/"China:jiangsu"/)
res@mpOceanFillColor = 0
res@mpInlandWaterFillColor = 0
res@mpLandFillColor = 0
res@mpOutlineOn = True
res@mpOutlineSpecifiers = "China:jiangsu"
res@mpOutlineBoundarySets = "NoBoundaries"
;;设置坐标标签及字体的大小
res@pmTickMarkDisplayMode = "Always"
res@tmXBLabelFontHeightF = 0.018 ; YL±êÇ©×Öìå′óD¡»áí¬2½±ä»ˉ£¬ËùòÔ2»óÃéèÖÃ
;;设置等值线
res@cnFillOn = True
res@cnLineColor = "white"
res@cnLineThicknessF = 0.5
res@lbOrientation = "Vertical" ;垂直摆放
res@cnLevelSelectionMode = "ManualLevels"
res@cnMinLevelValF = 500
res@cnMaxLevelValF = 560
res@cnLevelSpacingF = 10
res@cnFillDrawOrder = "PreDraw"
res@cnLineDrawOrder = "PreDraw"
plot = gsn_csm_contour_map(wks,var,res)
draw(plot)
frame(wks)
end |
|