[ncl-talk] Wind Speed Vector plots on contour plot using ECMWF analysis

Lara Quitián Hernández laraquitianhernandez at gmail.com
Tue Jul 18 09:34:32 MDT 2017


Good afternoon from Spain,

I'm attempting to produce a vector/contour plot of a specific area from
ECMWF analysis data. Firstly, my script decodes the ECMWF variables u10 and
v1 with the "doubletofloat" function. Secondly, I calculate the wind module
(SPD) in order to generate a contour plot of the wind speed
(succesfully obtained).
The problem arises when I try to overlay the vector plot on this contour
plot. In this case, I obtained a vector plot that has nothing to do with
the contour plot.

Appear to be specific problems associated with coordinates and other
issues, because I received error messages such as: "A valid longitude
coordinate array should have a 'units' attribute equal to one of the
following values: (0)     'degrees_east' 'degrees-east' 'degree_east'
'degrees east' 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE'
'deg east' "

Here is the script:

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

input = addfile("../10wind_an.nc", "r")

  Lon    = input->longitude
  Lat    = input->latitude
  v10       = input->v10
  u10       = input->u10
  timean    =input->time

;;;;;;;; variables u10 y v10 se encuentran codificadas  ;;;;;;;;;;;;;;

u1 = doubletofloat(u10 at scale_factor)   ;a=scale_factor
u2 = doubletofloat(u10 at add_offset)     ;b=add_offset

v1 = doubletofloat(v10 at scale_factor)
v2 = doubletofloat(v10 at add_offset)


  U10_0 = (u10*u1)+u2   ;y=ax+b siendo x=u10
  V10_0 = (v10*v1)+v2   ;y=ax+b siendo x=v10

;printVarSummary(U10_0)   ;24x141x201

;Wind Speed module
  SPD_0=(U10_0^2+V10_0^2)^(0.5)

; Set basic resources
     res=True
     pltres = True          ; Plotting resources
     mpres = True           ; Map resources
     time_utc=cd_calendar(timean,3)
     ntimes = dimsizes(time_utc)

    do it = 0,ntimes-1,1           ; TIME LOOP

  SPD  = SPD_0(it,:,:)
  U10  = U10_0(it,:,:)
  V10  = V10_0(it,:,:)

;printVarSummary(U10)    ;141x201

  SPD at description = "Wind Speed"
  SPD at units = "m/s"

  wks_type = "png"
  wks_type at wkWidth = 2000
  wks_type at wkHeight = 2000
  wks = gsn_open_wks(wks_type, "../spd_AN/SPD_AN_" + time_utc(it) + "")
  gsn_define_colormap(wks,"BlAqGrYeOrRe")


  res at cnFillOn             = True               ; turn on color for contours
  res at cnLinesOn            = False              ; turn off contour lines
  res at cnLineLabelsOn       = False              ; turn off contour line
labels
  res at gsnScalarContour     = True               ; contours desired
  res at cnFillPalette               = "WhiteBlueGreenYellowRed"

  res at mpLandFillColor      = "gray"            ; set land to be gray
  res at mpMinLatF = 26.50                                      ; set the
minimum latitude
  res at mpMaxLatF = 40.00                                    ; set the
maximum latitude
  res at mpMinLonF = -30.50                                   ; set the
minimum longitude
  res at mpMaxLonF = -11.50

  res at lbOrientation            = "Vertical"     ; vertical label bar
  res at pmLabelBarOrthogonalPosF = -0.01          ; move label bar closer

; note, when doing a subregion, NCL determines the range of the data from
; the full domain. If you wish to just consider the domain you are plotting,
; you must manually set those levels.

  res at cnLevelSelectionMode = "ManualLevels"     ; set manual contour levels
  res at cnMinLevelValF       = 0.0               ; set min contour level
  res at cnMaxLevelValF       = 24                 ; set max contour level
  res at cnLevelSpacingF      = 2.0               ; set contour spacing

  res at vcRefMagnitudeF           = 4.0             ; define vector ref mag
  res at vcRefLengthF              = 0.045           ; define length of vec ref
  res at vcRefAnnoOrthogonalPosF   = -1.0            ; move ref vector
  res at vcRefAnnoArrowLineColor   = "black"         ; change ref vector color
  res at vcRefAnnoArrowUseVecColor = False           ; don't use vec color for
ref

  res at vcGlyphStyle            = "WindBarb"     ; turn on curly vectors
  res at vcLineArrowColor        = "white"           ; change vector color
  res at vcLineArrowThicknessF   = 2.0               ; change vector thickness
  res at vcVectorDrawOrder       = "PostDraw"        ; draw vectors last

 plot=gsn_csm_vector_scalar_map_ce(wks,U10,V10,SPD,res)

draw(plot)
frame(wks)

    end do
end

----

Any help would be really appreciated. Thank you in advance.

Regards,
Lara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170718/61387270/attachment.html 


More information about the ncl-talk mailing list