- 积分
- 22
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-12-11
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 liuy0813 于 2014-12-19 16:22 编辑
各位:
大家好。
最近用NCL画模型结果流场图的时候碰到一个问题,特来请教
用NCL自带的岸线的最高精度情况下,港湾内的岸线与实际情况差距较大,所以我准备了一套自己的岸线,希望在这个岸线的基础上画出模型结果的流场图,但是一直叠加不上,分开画,精细岸线的图可以画出来,但是如果画出流场图之后,无法叠加...
代码如下所示。
求帮忙解决
谢谢
;*************************************************
; plot_xmbay.ncl
;
; Concepts illustrated:
; - Plotting ROMS data
; - Loading NCL functions from another script
; - Changing the reference annotation string for vectors
; - Overlaying vectors and filled contours on a map
;
; roms depth slice using roms_3d_interp with velocity overlay
; note: roms_3d_interp is working on "rho" coords
; if you specify variable "u" or "v" it is transfering them
; first to the "rho" and than interpolate.
;
;*************************************************
;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "./ROMS_utils.ncl"
undef("create_map")
function create_map(wks,title,resolution)
local a, res2
begin
res2 = True
res2@mpDataBaseVersion = resolution
res2@gsnMaximize = True
res2@gsnDraw = False
res2@gsnFrame = False
res2@mpOutlineOn = False
res2@mpFillOn = False
;---Turn on fancier tickmark labels.
res2@pmTickMarkDisplayMode = "Always"
lon1=117.80
lat1=24.20
lon2=118.35+15.0/60.0
lat2=24.4+25.0/60.0
;---Zoom in on area of interest
res2@mpLimitMode = "Corners"
res2@mpLeftCornerLatF = lat1
res2@mpLeftCornerLonF = lon1
res2@mpRightCornerLatF = lat2
res2@mpRightCornerLonF = lon2
;res2@tiMainString = title
; res2@mpGridAndLimbDrawOrder = "Predraw"
;---Create map.
map = gsn_csm_map(wks,res2)
return(map)
end
begin
;************************************************
; User settings
;************************************************
fhis="roms_his_2010_nouse.nc"
outfile = "roms_5"
depth = -2.0
rec = 1
;***********************************************
; Read data and interpolate
;***********************************************
his = addfile (fhis,"r")
lon2d = his->lon_rho
lat2d = his->lat_rho
out = roms_3d_interp(his,"salt",rec,depth)
ur = roms_3d_interp(his, "u", rec, depth) ; they are automatically put to "rho"
vr = roms_3d_interp(his, "v", rec, depth)
angle = his->angle
uvrot = uv_rot(ur,vr,angle)
urr = uvrot(0,:,:)
vrr = uvrot(1,:,:)
delete(uvrot)
delete(ur)
delete(vr)
urr@lat2d = lat2d
urr@lon2d = lon2d
vrr@lat2d = lat2d
vrr@lon2d = lon2d
out@lat2d = lat2d
out@lon2d = lon2d
minValue = 0.0
maxValue = 35.0
step = 1
stride = 5
;************************************************
; create plot
;************************************************
wks_type = "x11" ; or "eps"
wks_type@wkOrientation = "Portrait"
wks = gsn_open_wks (wks_type, outfile) ; open workstation
gsn_define_colormap(wks, "BlAqGrYeOrRevi200")
i = NhlNewColor(wks,0.8,0.8,0.8) ; add gray to colormap
reso="HighRes"
title="Coast draw test"
map = create_map(wks,title,reso)
data=asciiread("./ranges/bigzone_zhu.txt",-1,"float")
temp=reshape(data,(/dimsizes(data)/2,2/))
lat0=temp(:,1)
lon0=temp(:,0)
lnres = True
lnres@gsLineThicknessF = 3.0
lnres@gsLineColor = "brown"
lnres@gsFillColor = "gray"
lnres@gsLineColor = "black"
ln0 = gsn_add_polygon(wks,map,lon0,lat0,lnres)
ln2 = gsn_add_polyline(wks,map,lon0,lat0,lnres)
;
; Control appearance of map.
;
vres1 = True ; plot mods desired
vres1@gsnDraw = True
vres1@gsnFrame = True
vres1@gsnMaximize = True ; Maximize plot in frame
; vres1@gsnPaperOrientation = "Portrait"
; vres1@cnFillDrawOrder = "PreDraw"
vres1@cnFillOn = True ; turn on color for contours
vres1@cnLinesOn = False ; turn off contour lines
vres1@cnLineLabelsOn = False ; turn off contour line labels
vres1@cnFillMode = "RasterFill"
vres1@gsnScalarContour = True ; contours desired
vres1@gsnSpreadColors = True ; use full color map
vres1@gsnSpreadColorEnd = -2
; vres1@mpLandFillColor = "gray" ; set land to be gray
vres1@lbLabelBarOn = True
vres1@lbLabelStride = stride
vres1@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
vres1@cnMinLevelValF = minValue ; set min contour level
vres1@cnMaxLevelValF = maxValue ; set max contour level
vres1@cnLevelSpacingF = step ; set contour spacing
vres1@lbOrientation = "Vertical" ; /Vertical label bar
vres1@pmLabelBarOrthogonalPosF = -0.01 ; move label bar closer
vres1@pmLabelBarDisplayMode = "Always" ; Turn on a label bar.
vres1@lbPerimOn = False ; no box around it
vres1@lbBoxLinesOn = True ; Yes/No labelbar box lines.
vres1@vcRefMagnitudeF = 1.0 ; define vector ref mag
vres1@vcRefLengthF = 0.045 ; define length of vec ref
vres1@vcRefAnnoOrthogonalPosF = -1.0 ; move ref vector
vres1@vcRefAnnoParallelPosF = 0.108
vres1@vcRefAnnoArrowLineColor = "black" ; change ref vector color
vres1@vcRefAnnoArrowUseVecColor = False ; don't use vec color for ref
vres1@vcRefAnnoString1 = "1.0 m/s"
vres1@vcLabelsOn = False
vres1@vcLineArrowColor = "black"
vres1@vcRefAnnoOn = True
vres1@vcMonoLineArrowColor = True ; vec's colored by their mag
vres1@vcLineArrowHeadMaxSizeF = 0.008
vres1@vcLineArrowHeadMinSizeF = 0.0055
vres1@vcMinDistanceF = 0.0145 ; thin vectors , xishu with big data
vres1@vcLineArrowThicknessF = 1.5 ; change vector thickness
vres1@vcGlyphStyle = "CurlyVector" ; turn on curly vectors
lon_in1=117.80
lat_in1=24.20
lon_in2=118.35+15.0/60.0
lat_in2=24.4+25.0/60.0
; MAP
; vres1@mpProjection = "Mercator"
vres1@mpLimitMode = "Corners" ; choose range of map
vres1@mpLeftCornerLatF = lat_in1
vres1@mpLeftCornerLonF = lon_in1
vres1@mpRightCornerLatF = lat_in2
vres1@mpRightCornerLonF = lon_in2
vres1@mpDataBaseVersion = "HighRes" ; use high resolution coast
vres1@pmTickMarkDisplayMode = "Always" ; turn on tickmarks
plot1= gsn_csm_vector_scalar_map(wks,urr,vrr,out,vres1)
overlay(map,plot1)
draw(map)
frame(wks)
end
|
-
-
|