[ncl-talk] Fwd: Wind barb spacing

Rabah Hachelaf hachelaf at sca.uqam.ca
Thu Jul 24 00:35:53 MDT 2014


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 at 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 at 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_remap_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 at 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 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 at 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 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 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 > 50
>>>>        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 > 50
>>>>        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 at wkWidth = 1384
>>>>    wks_type at wkHeight = 1384
>>>>   wks_type at 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 at pmTickMarkDisplayMode = "Always"
>>>>   res at mpProjection      = "Mercator"       ; choose projection
>>>>   res at mpGridAndLimbOn   = True             ; turn on lat/lon lines
>>>>   res at mpPerimOn         = True             ; turn off box around plot
>>>>   res at mpGridLatSpacingF = 45.               ; spacing for lat lines
>>>>   res at mpGridLonSpacingF = 45.               ; spacing for lon lines
>>>>   res at mpFillOn          = False
>>>>    res at mpLimitMode  = "LatLon"
>>>>     res at mpMinLatF            =   85.0
>>>>     res at mpMaxLatF            = -85.0
>>>>     res at mpMinLonF            = -180
>>>>     res at mpMaxLonF            = 180
>>>>
>>>>   res at cnFillOn          = False              ; color plot desired
>>>>   res at cnLineLabelsOn    = False             ; turn off contour lines
>>>>
>>>>   res at vpXF            = 0                 ; make plot bigger
>>>>   res at vpYF            = 1
>>>>   res at vpWidthF        = 1
>>>>   res at vpHeightF       = 1
>>>>
>>>>
>>>>   res at vcGlyphStyle            = "WindBarb"         ; select wind barbs
>>>>   res at vcRefMagnitudeF         = 1                ; make vectors larger
>>>>   res at vcRefLengthF            = 0.03              ; ref vec length
>>>>   res at vcWindBarbLineThicknessF = 8.0        ;Thickness
>>>>
>>>>
>>>>   res at vcWindBarbTickSpacingF  = 0.125   ;
>>>>
>>>>   res at vcMinDistanceF          = 0.125            ; thin out windbarbs
>>>>   res at vcMonoWindBarbColor = True
>>>>   res at vcWindBarbColor =  1
>>>>
>>>>   res at 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
>>>>
>>>>
>>>
>>
>>
>> --
>> ------------------------------
>> Cordialement,
>> Best regards,
>> Rabah Hachelaf
>>
>
>


-- 
------------------------------
Cordialement,
Best regards,
Rabah Hachelaf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140724/2aad5913/attachment-0001.html 


More information about the ncl-talk mailing list