Re: Fwd: Wind barb spacing

From: Rabah Hachelaf <hachelaf_at_nyahnyahspammersnyahnyah>
Date: Thu Jul 24 2014 - 00:35:53 MDT

Thanks for replay David,

The variable used in your example had lat,lon dimension, but in my case
(GFS grib2 file) variables had point grid index as dimension.
here is the summary of one variable.

 ncl 4> printVarSummary(uu)

Variable: uu
Type: float
Total Size: 1039680 bytes
            259920 values
Number of Dimensions: 2
Dimensions and sizes: [lat_0 | 361] x [lon_0 | 720]
Coordinates:
            lat_0: [90..-90]
            lon_0: [ 0..359.5]
Number Of Attributes: 13
  center : US National Weather Service - NCEP (WMC)
  production_status : Operational products
  long_name : U-component of wind
  units : m s-1
  _FillValue : 1e+20
  grid_type : Latitude/longitude
  parameter_discipline_and_category : Meteorological products, Momentum
  parameter_template_discipline_category_number : ( 0, 0, 2, 2 )
  level_type : Maximum wind level
  level : 0
  forecast_time : 0
  forecast_time_units : hours
  initial_time : 07/23/2014 (00:00)



2014-07-23 21:06 GMT-04:00 David Brown <dbrown@ucar.edu>:

> I imagine your "trick" can work, but it seems like a bit of overkill in
> terms of the processing required for the problem you posed initially. But
> then again I do not know what your ultimate goal is.
> -dave
>
>
> On Wed, Jul 23, 2014 at 3:43 PM, Rabah Hachelaf <hachelaf@sca.uqam.ca>
> wrote:
>
>> Hi David,
>>
>> Thanks for your replay ,
>> I think i solved my problem by using a regridding my data , i used this
>> function *area_conserve_remap_Wrap
>> <https://www.ncl.ucar.edu/Document/Functions/Contributed/area_conserve_r=
emap_Wrap.shtml>*
>> to transform the native grid (720X361) to a new grid regarding my
>> distance requested for my case (8 X 5)
>> and it seems work.
>>
>> What do you think about this trick.
>>
>> Rabah
>>
>>
>> 2014-07-23 17:26 GMT-04:00 David Brown <dbrown@ucar.edu>:
>>
>> 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 arr=
ays.
>>> 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 d=
ata
>>> 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 dat=
a.
>>>> 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 =
should
>>>> 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 geographica=
l
>>>> 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 arr=
ay
>>>> i50 = ind(x1D.lt.1000.) ; all indices x1D =
> 50
>>>> x1D(i50) = -30 ; set all array synt=
ax
>>>> uu = onedtond(x1D, dimsizes(uu)); return to the origin=
al
>>>> 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 arr=
ay
>>>> i50 = ind(x1D.lt.1000.) ; all indices x1D =
> 50
>>>> x1D(i50) = -30 ; set all array syn=
tax
>>>> vv = onedtond(x1D, dimsizes(vv)); return to the origin=
al
>>>> 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 fi=
le
>>>> gsn_define_colormap(wks,"gui_default")
>>>>
>>>> setvalues wks
>>>> "wkBackgroundColor" : (/1.,1.,1./)
>>>> end setvalues
>>>>
>>>>
>>>> res = True ; plot mods desir=
ed
>>>> res@pmTickMarkDisplayMode = "Always"
>>>> res@mpProjection = "Mercator" ; choose projection
>>>> res@mpGridAndLimbOn = True ; turn on lat/lon lines
>>>> res@mpPerimOn = True ; turn off box around plo=
t
>>>> 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 bar=
bs
>>>> res@vcRefMagnitudeF = 1 ; make vectors larg=
er
>>>> res@vcRefLengthF = 0.03 ; ref vec length
>>>> res@vcWindBarbLineThicknessF = 8.0 ;Thickness
>>>>
>>>>
>>>> res@vcWindBarbTickSpacingF = 0.125 ;
>>>>
>>>> res@vcMinDistanceF = 0.125 ; thin out windbarb=
s
>>>> res@vcMonoWindBarbColor = True
>>>> res@vcWindBarbColor = 1
>>>>
>>>> res@mpOutlineOn = True ; turn on map outlin=
e
>>>> 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
>>>>
>>>>
>>>
>>
>>
>> --
>> ------------------------------
>> Cordialement,
>> Best regards,
>> Rabah Hachelaf
>>
>
>


--
------------------------------
Cordialement,
Best regards,
Rabah Hachelaf

Received on Thu Jul 24 06:36:00 2014

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