Re: Fwd: Wind barb spacing

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 23 2014 - 15:26:08 MDT

Hi Rabah,
The vcMinDistanceF resource is really designed to even out the spacing of
(usually more dense) grids of vectors where the map projection leads to
crowding in some areas of the plot.

In your case, where you want to draw only a very sparse number of vectors,
it would make more sense to use vector subscripting on the arrays.
The NCL function that could help you is 'ind_nearest_coord'.
I am attaching a modified version of the example barb_1.ncl that should do
what you want. If you want to run this script you can download the data
file '83.nc' from the data link in the NCL example page.




On Tue, Jul 22, 2014 at 5:38 PM, Rabah Hachelaf <hachelaf@sca.uqam.ca>
wrote:

>
> Hi NCL users,
>
> I am using "vcMinDistanceF" to control wind barb spacing from GFS data.
> according to my understanding when i want plot the whole world map
>
> -180 to 180 longitude is mapped to 0-1 in NDC space
> and -90 to 90 latitude is mapped to 0-1 in NDC space
>
> if so and if i want to draw a wind barb each 45°, vcMinDistanceF sho=
uld be
> 0.125
> and when testing this i get a kind of random spacing (please see attached
> image)
>
> So is there any solution to control barb spacing according geographical
> distance (in degrees).
>
> Thank you for help.
> below is you find my ncl script used :
>
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> ;************************************************
> begin
>
> ;************************************************
> ; read in GRIB2 file
> ;************************************************
> a = addfile("gfs.t00z.pgrb2f00.grib2","r")
> ;************************************************
> ;;; get variables: temperature, longitude, latitude
>
> t2m = a->TMP_P0_2L108_GLL0(:,:)
> lon = a->lon_0
> lat = a->lat_0
> uu= a->UGRD_P0_L6_GLL0
> vv= a->VGRD_P0_L6_GLL0
>
>
> if (any(uu.lt.1000.)) then
> x1D = ndtooned (uu) ; convert to 1D array
> i50 = ind(x1D.lt.1000.) ; all indices x1D > 5=
0
> x1D(i50) = -30 ; set all array syntax
> uu = onedtond(x1D, dimsizes(uu)); return to the original
> array
> delete (x1D) ; x1D no longer needed
> delete (i50) ; i50 no longer needed
> end if
>
> if (any(vv.lt.1000.)) then
> x1D = ndtooned (vv) ; convert to 1D array
> i50 = ind(x1D.lt.1000.) ; all indices x1D > 5=
0
> x1D(i50) = -30 ; set all array syntax
> vv = onedtond(x1D, dimsizes(vv)); return to the original
> array
> delete (x1D) ; x1D no longer needed
> delete (i50) ; i50 no longer needed
> end if
>
> ;
>
> ; create plot
> ;************************************************
> wks_type="png"
>
> wks_type@wkWidth = 1384
> wks_type@wkHeight = 1384
> wks_type@wkBackgroundOpacityF = 1.0
>
>
> wks = gsn_open_wks(wks_type,"wind_barb") ; open a ncgm file
> gsn_define_colormap(wks,"gui_default")
>
> setvalues wks
> "wkBackgroundColor" : (/1.,1.,1./)
> end setvalues
>
>
> res = True ; plot mods desired
> res@pmTickMarkDisplayMode = "Always"
> res@mpProjection = "Mercator" ; choose projection
> res@mpGridAndLimbOn = True ; turn on lat/lon lines
> res@mpPerimOn = True ; turn off box around plot
> res@mpGridLatSpacingF = 45. ; spacing for lat lines
> res@mpGridLonSpacingF = 45. ; spacing for lon lines
> res@mpFillOn = False
> res@mpLimitMode = "LatLon"
> res@mpMinLatF = 85.0
> res@mpMaxLatF = -85.0
> res@mpMinLonF = -180
> res@mpMaxLonF = 180
>
> res@cnFillOn = False ; color plot desired
> res@cnLineLabelsOn = False ; turn off contour lines
>
> res@vpXF = 0 ; make plot bigger
> res@vpYF = 1
> res@vpWidthF = 1
> res@vpHeightF = 1
>
>
> res@vcGlyphStyle = "WindBarb" ; select wind barbs
> res@vcRefMagnitudeF = 1 ; make vectors larger
> res@vcRefLengthF = 0.03 ; ref vec length
> res@vcWindBarbLineThicknessF = 8.0 ;Thickness
>
>
> res@vcWindBarbTickSpacingF = 0.125 ;
>
> res@vcMinDistanceF = 0.125 ; thin out windbarbs
> res@vcMonoWindBarbColor = True
> res@vcWindBarbColor = 1
>
> res@mpOutlineOn = True ; turn on map outline
> plot1=gsn_csm_vector_map(wks,uu,vv,res)
>
>
>
> ------------------------------
> Cordialement,
> Best regards,
> Rabah Hachelaf
> ____
> ( )
> ( )
> (___ __)
> /////////
>
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

Received on Wed Jul 23 09:26:17 2014

This archive was generated by hypermail 2.1.8 : Fri Aug 01 2014 - 15:10:55 MDT