- 积分
- 557
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2018-6-14
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 阿萨德撒 于 2020-4-21 11:40 编辑
;*************************************************
; WRF_pcp_1.ncl
;
; Concepts illustrated:
; - Plotting WRF data
; - Overlaying WRF precipitation on terrain map using wrf_xxx functions
; - Changing the size of a PNG image
; - Creating two contour plots with two sets of filled contours
; - Creating a color map using RGB triplets
; - Creating a color map using RGBA quadruplets
; - Explicitly setting contour levels
; - Adding a title to a labelbar
; - Drawing fully transparent filled contours
; - Creating horizontal and vertical labelbars
; - Adding a vertical title to a labelbar
;
; These files are loaded by default in NCL V6.2.0 and newer
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
; load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
;----------------------------------------------------------------------
; Main code
;----------------------------------------------------------------------
begin
;
; Open file and get variables.
;
a = addfile("20190710.nc","r")
;
; Terrain
;
ter = wrf_user_getvar(a,"HGT",0)
ter@description = "Terrain Height"
ter@units = "m"
;
; Get non-convective, convective
; Calculate total precipitation
;
scale = 6. ; Artificial scale factor to see all colors
rain_exp = wrf_user_getvar(a,"RAINNC",-1) /22.4
rain_con = wrf_user_getvar(a,"RAINC", -1) /22.4
rain_tot = (rain_exp + rain_con) * scale
rain_tot@description = "Total Precipitation (inches)"
; Define contour levels here so we can determine up front
; what the merged color maps should be.
precip_levels = (/ .01, 0.25, 0.50, 0.75, \
1.00, 1.25, 1.50, 1.75, \
2.00, 2.25, 2.50, 2.75, \
3.00, 3.25, 3.50, 3.75, \
4.00, 4.25, 4.50, 4.75, \
5.00,5.25,5.5,5.75,6.0 /)
ter_levels = (/ .01, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, \
15, 16 ,17,18,19,20,21,22,23,24,25,26,27,28,29,30/) * 100.
wtype = "png"
wtype@wkWidth = 1500 ; Increase size for a slightly
wtype@wkHeight = 1500 ; better looking PNG.
wks = gsn_open_wks(wtype,"WRF_pcp") ; Send graphics to PNG file
;
; Set up resource list that will be shared between the
; two wrf_contour calls.
;
res = True
res@gsnDraw = False
res@gsnFrame = False
res@cnLevelSelectionMode = "ExplicitLevels"
res@cnFillOn = True
res@cnLinesOn = False
minlat = 30
maxlat = 40
minlon = 120
maxlon = 130
loc = wrf_user_ll_to_ij(a,(/minlon,maxlon/),(/minlat,maxlat/),res)
;
; Generate plot of terrain for background.
;
; First set up resource list specific to terrain plot.
;
opts_ter = res
opts_ter@cnLevels = ter_levels
;
; In order to use cnFillPalette with wrf_contour, you must
; gsnSpreadColors to False and cnSpanFillPalette to True.
;
opts_ter@gsnSpreadColors = False
opts_ter@cnSpanFillPalette = True
opts_ter@cnFillPalette = earth_pal()
; Resources to control labelbar title, size, and location.
opts_ter@lbTitleString = "Terrain"
opts_ter@pmLabelBarWidthF = 0.8
opts_ter@pmLabelBarHeightF = 0.35
opts_ter@pmLabelBarOrthogonalPosF = -0.18
; Create terrain contours (no drawing done yet).
contour_ter = wrf_contour(a,wks,ter,opts_ter)
print(contour_ter)
; Plotting options for precipitation
opts_r = res
opts_r@cnLevels = precip_levels
opts_r@gsnSpreadColors = False
opts_r@cnSpanFillPalette = True
opts_r@cnFillPalette = precip_pal()
opts_r@cnSmoothingDistanceF = .005
; Resources to control precipitation labelbar, which will be
; vertical.
opts_r@lbTitleString = "Total Precipitation"
opts_r@lbTitleDirection = "Down"
opts_r@lbTitleJust = "CenterRight"
opts_r@lbTitlePosition = "Right"
opts_r@lbTitleOffsetF = 0.07
opts_r@lbOrientation = "Vertical"
opts_r@pmLabelBarSide = "Right"
opts_r@pmLabelBarHeightF = 0.77
opts_r@pmLabelBarWidthF = 0.11
opts_r@pmLabelBarOrthogonalPosF = 0.03
opts_r@lbBoxMinorExtentF = 0.4
cnConstFEnableFill = True
; Total Precipitation (color fill)
contour_tot = wrf_contour(a, wks, rain_tot(0,:,:), opts_r)
;
; Use the special wrf_map_overlays function to figure out
; the correct map projection and do the overlay.
;
; Set up two resource lists for wrf_map_overlays.
;
pltres = True
mpres = True
mpres@mpOutlineOn=True
mpres@mpGeophysicalLineThicknessF=2.0
mpres@mpNationalLineThicknessF=2.0
mpres@mpGeophysicalLineColor = "Black"
mpres@mpNationalLineColor = "Black"
mpres@mpUSStateLineColor = "Black"
mpres@mpGridLineColor = "Black"
mpres@mpLimbLineColor = "Black"
mpres@mpPerimLineColor = "Black"
; mpres@mpGeophysicalLineThicknessF = .5
; mpres@mpUSStateLineThicknessF = .5
; mpres@mpDataBaseVersion = "HighRes"
; mpres@mpDataResolution = "FinestResolution"
plot = wrf_map_overlays(a,wks,(/contour_ter,contour_tot/),pltres,mpres)
end
|
|