爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3780|回复: 7

[作图] NCL官网提供的WRF流线图太密了,怎么破?

[复制链接]

新浪微博达人勋

发表于 2017-7-20 12:49:43 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
R.T.
在NCL官网找的WRF画流线图的脚本,但是画出来的图中,流线过于密集,请问如何处理?
请看附图,放大很多倍才能看到是流线图

以下是官网的脚本。

;----------------------------------------------------------------------; wrf_gsn_8.ncl;----------------------------------------------------------------------; Concepts illustrated:;   - Using gsn_csm scripts to plot WRF-ARW data;   - Drawing streamlines colored by another field over a map;   - Setting the correct WRF map projection using wrf_map_resources;   - Subsetting a color map;   - Using stLevelPalette resource to assign a color palette;   - Using opacity to emphasize or subdue overlain features;   - Increasing the thickness of map outlines;----------------------------------------------------------------------; This script is meant to show the difference between plotting WRF; data using wrf_xxx scripts, and using gsn_csm_xxx scripts.;; The first plot draws the streamlines in a basic lat/lon map; projection.;; The second plot draws the streamlines in the native projection ; provided on the WRF file.;----------------------------------------------------------------------; In NCL Versions 6.3.1 and earlier, you will get these warnings which; you can safely ignore:;;   warning:start_lat is not a valid resource in wrf_gsn_streamline at this time;   warning:start_lon is not a valid resource in wrf_gsn_streamline at this time;   warning:end_lat is not a valid resource in wrf_gsn_streamline at this time;   warning:end_lon is not a valid resource in wrf_gsn_streamline at this time;   warning:mpNestTime is not a valid resource in map at this time;----------------------------------------------------------------------; 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"begin;---Open WRF output file  filename = "wrfout_d01_2005-12-14_13:00:00"  a        = addfile(filename,"r");---Read several WRF variables at first time step  it  = 0  u   = wrf_user_getvar(a,"ua",it)    ; 3D U at mass points  v   = wrf_user_getvar(a,"va",it)    ; 3D V at mass points  lat = wrf_user_getvar(a,"lat",it)  lon = wrf_user_getvar(a,"lon",it);---Get the lowest (bottommost) level  nl  = 0  u10 = u(nl,:,:)  v10 = v(nl,:,:)  u10 = u10*1.94386                    ; Convert wind into knots  v10 = v10*1.94386  spd = sqrt(u10^2+v10^2)                ;---Change the metadata  u10@units       = "kts"  v10@units       = "kts";---Required for plotting over map (not using WRF's map projection here)  u10@lat2d = lat  u10@lon2d = lon  v10@lat2d = lat  v10@lon2d = lon  wks = gsn_open_wks("png","wrf_gsn")  res                    = True  res@gsnMaximize        = True  res@mpMinLatF          = min(lat)-1  res@mpMaxLatF          = max(lat)+1  res@mpMinLonF          = min(lon)-1  res@mpMaxLonF          = max(lon)+1  res@stLineThicknessF   = 3.0  res@tiMainString       = "U10/V10 streamlines colored by wind speed"  res@tiMainFontHeightF  = 0.015  res@mpFillOn           = False  res@mpDataBaseVersion  = "MediumRes"    ; better map outlines  res@gsnAddCyclic       = False          ; don't add longitude cyclic point;; We like the "NCV_rainbow2" colormap, but don't want to use the ; whole thing. Use read_colormap_file to read the colormap as ; an N x 4 array, and then subscript as desired.  Here we are; starting at color 19 and ending at color 240. Uncomment the; draw_color_palette call if you want to see what this colormap; looks like. ;;  draw_color_palette(wks,"NCV_rainbow2",0)  colormap = read_colormap_file("NCV_rainbow2")  res@stLevelPalette = colormap(19:240,:);---Plot streamlines in a basic lat/lon projection (cylindrical equidistant)  plot = gsn_csm_streamline_scalar_map(wks,u10,v10,spd,res);---Plot strealines in the native WRF map projection  delete([/u10@lat2d,u10@lon2d,v10@lat2d,v10@lon2d/])   ; This is important! Don't use lat/lon arrays for                                                        ; native projections  res = wrf_map_resources(a,res)                        ; Set the map resources needed for native projection  res@tfDoNDCOverlay   = True                           ; Tell NCL you are doing a native plot  res@tiMainString     = "U10/V10 streamlines colored by wind speed (native WRF projection)"  plot = gsn_csm_streamline_scalar_map(wks,u10,v10,spd,res);---Customize the some resources so we can see map outlines better  res@stLineOpacityF              = 0.5       ; make streamlines more transparent  res@mpUSStateLineColor          = "black"  res@mpNationalLineColor         = "black"  res@mpGeophysicalLineColor      = "black"  res@mpUSStateLineThicknessF     = 2.        ; default is 1.0  res@mpNationalLineThicknessF    = 2.  res@mpGeophysicalLineThicknessF = 2.  plot = gsn_csm_streamline_scalar_map(wks,u10,v10,spd,res)end
QQ截图20170720130111.jpg
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-7-20 12:50:58 | 显示全部楼层
;----------------------------------------------------------------------
; wrf_gsn_8.ncl
;----------------------------------------------------------------------
; Concepts illustrated:
;   - Using gsn_csm scripts to plot WRF-ARW data
;   - Drawing streamlines colored by another field over a map
;   - Setting the correct WRF map projection using wrf_map_resources
;   - Subsetting a color map
;   - Using stLevelPalette resource to assign a color palette
;   - Using opacity to emphasize or subdue overlain features
;   - Increasing the thickness of map outlines
;----------------------------------------------------------------------
; This script is meant to show the difference between plotting WRF
; data using wrf_xxx scripts, and using gsn_csm_xxx scripts.
;
; The first plot draws the streamlines in a basic lat/lon map
; projection.
;
; The second plot draws the streamlines in the native projection
; provided on the WRF file.
;----------------------------------------------------------------------
; In NCL Versions 6.3.1 and earlier, you will get these warnings which
; you can safely ignore:
;
;   warning:start_lat is not a valid resource in wrf_gsn_streamline at this time
;   warning:start_lon is not a valid resource in wrf_gsn_streamline at this time
;   warning:end_lat is not a valid resource in wrf_gsn_streamline at this time
;   warning:end_lon is not a valid resource in wrf_gsn_streamline at this time
;   warning:mpNestTime is not a valid resource in map at this time
;----------------------------------------------------------------------
; 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"

begin
;---Open WRF output file
  filename = "wrfout_d01_2005-12-14_13:00:00"
  a        = addfile(filename,"r")

;---Read several WRF variables at first time step
  it  = 0
  u   = wrf_user_getvar(a,"ua",it)    ; 3D U at mass points
  v   = wrf_user_getvar(a,"va",it)    ; 3D V at mass points
  lat = wrf_user_getvar(a,"lat",it)
  lon = wrf_user_getvar(a,"lon",it)

;---Get the lowest (bottommost) level
  nl  = 0
  u10 = u(nl,:,:)
  v10 = v(nl,:,:)
  u10 = u10*1.94386                    ; Convert wind into knots
  v10 = v10*1.94386
  spd = sqrt(u10^2+v10^2)               

;---Change the metadata
  u10@units       = "kts"
  v10@units       = "kts"

;---Required for plotting over map (not using WRF's map projection here)
  u10@lat2d = lat
  u10@lon2d = lon
  v10@lat2d = lat
  v10@lon2d = lon

  wks = gsn_open_wks("png","wrf_gsn")

  res                    = True
  res@gsnMaximize        = True
  res@mpMinLatF          = min(lat)-1
  res@mpMaxLatF          = max(lat)+1
  res@mpMinLonF          = min(lon)-1
  res@mpMaxLonF          = max(lon)+1
  res@stLineThicknessF   = 3.0
  res@tiMainString       = "U10/V10 streamlines colored by wind speed"
  res@tiMainFontHeightF  = 0.015
  res@mpFillOn           = False
  res@mpDataBaseVersion  = "MediumRes"    ; better map outlines

  res@gsnAddCyclic       = False          ; don't add longitude cyclic point
;
; We like the "NCV_rainbow2" colormap, but don't want to use the
; whole thing. Use read_colormap_file to read the colormap as
; an N x 4 array, and then subscript as desired.  Here we are
; starting at color 19 and ending at color 240. Uncomment the
; draw_color_palette call if you want to see what this colormap
; looks like.
;
;  draw_color_palette(wks,"NCV_rainbow2",0)

  colormap = read_colormap_file("NCV_rainbow2")
  res@stLevelPalette = colormap(19:240,:)

;---Plot streamlines in a basic lat/lon projection (cylindrical equidistant)
  plot = gsn_csm_streamline_scalar_map(wks,u10,v10,spd,res)

;---Plot strealines in the native WRF map projection
  delete([/u10@lat2d,u10@lon2d,v10@lat2d,v10@lon2d/])   ; This is important! Don't use lat/lon arrays for
                                                        ; native projections

  res = wrf_map_resources(a,res)                        ; Set the map resources needed for native projection
  res@tfDoNDCOverlay   = True                           ; Tell NCL you are doing a native plot
  res@tiMainString     = "U10/V10 streamlines colored by wind speed (native WRF projection)"

  plot = gsn_csm_streamline_scalar_map(wks,u10,v10,spd,res)

;---Customize the some resources so we can see map outlines better
  res@stLineOpacityF              = 0.5       ; make streamlines more transparent
  res@mpUSStateLineColor          = "black"
  res@mpNationalLineColor         = "black"
  res@mpGeophysicalLineColor      = "black"
  res@mpUSStateLineThicknessF     = 2.        ; default is 1.0
  res@mpNationalLineThicknessF    = 2.
  res@mpGeophysicalLineThicknessF = 2.
  plot = gsn_csm_streamline_scalar_map(wks,u10,v10,spd,res)
end
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-7-20 12:54:57 | 显示全部楼层
https://www.ncl.ucar.edu/Document/Graphics/Resources/st.shtml

[NCL - stMinLineSpacingF] Controls the minimum distance between drawn streamlines.   
Specify the minimum distance (in NDC) that a streamline in progress                  
is allowed to approach existing streamlines before being terminated.                  

[NCL - stMinDistanceF]                                                         
Specify a minimum distance (in NDC) that is to separate the grid boxes         
eligible for starting streamlines.                                             
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-7-20 13:05:20 | 显示全部楼层
::2或者 ::4
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-7-20 13:28:27 | 显示全部楼层
太密集的话 改变等值线间隔试试看?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-7-20 14:13:11 | 显示全部楼层
谢谢楼上几位,已解决了,通过设置stMinDistanceF即可.
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-7-20 14:14:21 | 显示全部楼层
chiangtp 发表于 2017-7-20 12:54
https://www.ncl.ucar.edu/Document/Graphics/Resources/st.shtml

[NCL - stMinLineSpacingF] Controls  ...

谢谢~                                 
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-7-20 14:57:40 | 显示全部楼层
变量后面加"::数字"
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表