Re: Cannot draw vector properly in radar (r,theta) plot

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri May 09 2014 - 12:37:42 MDT

Sorry, I answered this wrong because I was in a hurry.

You have vectors on a curvilinear (2D) grid, which is definitely valid. It's vectors on an unstructured grid that are not allowed.

If you can provide your data files, we can take a look. I'm not exactly sure what's going on with the "overlay" call, and we need to see your data in order to debug this.

--Mary

On May 9, 2014, at 11:55 AM, Mary Haley <haley@ucar.edu> wrote:

> Xiaomin,
>
> You are correct that the issue is you can't draw vectors that are on a 2D grid. This is high on our list of things to add to NCL. Currently, you can only draw vectors that are on a rectilinear grid (one represented by 1D coordinate arrays).
>
> I will add your email to the ticket we have on 2D vectors.
>
> --Mary
>
> On May 7, 2014, at 2:27 AM, Xiaomin Chen <xiaominc@hawaii.edu> wrote:
>
>> Hi, there!
>>
>> I'm trying to make a X-Y vector plot in polar coordinates (r,theta space) and my data is in corresponding polar coordinates with the size of 101*360 (r*theta).
>>
>> I've tried to attach the two-dimensional arrays documenting the data position in the catersian corrdinate to attributes "vfYArray" and "vfXArray" , similar to "sfXArray" in scaler field in the NCL radar plot sample. Note that the vfXArray or vfYArray must be two-dimensional when drawing vector in NCL.
>>
>> I run the ncl script and no error information is reported. However, the x-y coordinate seems not right and there are no Xtick or Ytick shown in the output figure. In addition, the spatial mapping from the data to r-theta coordinate are not right. I've also tried to change both the contour and vector coordinate array to be 2-dimensional, but the result turns out to be a image in a rectangular box (should be a circle shape).
>>
>> So, does anyone ever succeed to draw a vector plot ( gsn_csm_vector) in radar plot? I'll appreciate that if you can share your code. I guess the problem is in the 2-D coordinate array.
>>
>> Thanks!
>> Xiaomin
>>
>>
>> The code are here:
>> ;**************************************************************
>> ; radar_5.ncl
>> ;
>> ; Concepts illustrated:
>> ; - Drawing four radar plots in a page, each using different colormap
>> ; - Plotting radar (r,theta) data, treat like station data.
>> ; - Adding radar grid circles and lines with polylines
>> ; - Reading binary data using "cbinread"
>> ; Example script to produce plots for a WRF real-data run,
>> ; with the ARW coordinate dynamics option.
>> ;**************************************************************
>> 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
>> ;=============== Read Azimutal mean Variables ====================
>> ntimes =37
>> lm =101
>> ln=361 ;azimuthal points
>> ;=============================================================
>> fout1 = "./ASYM/VT_VR_W_PV_PRECIP_aym.dat"
>> setfileoption("bin","ReadByteOrder","BigEndian")
>> vta = fbindirread(fout1,0,(/ntimes-1,ln*lm/),"float")
>> vra = fbindirread(fout1,1,(/ntimes-1,ln*lm/),"float")
>> dbza = fbindirread(fout1,2,(/ntimes-1,ln*lm/),"float")
>>
>>
>> do it =1,ntimes-2
>>
>> uprime = new((/ln,lm/),"float")
>> vprime = new((/ln,lm/),"float")
>> x1 = new((/ln,lm/),"float")
>> y1 = new((/ln,lm/),"float")
>> dr =1.0
>> deg2rad = 0.017453292519943
>> do tt=0,ln-1 ;theta->from due north
>> rad=tt*deg2rad
>> sin_=sin(rad)
>> cos_=cos(rad)
>> do rr=0,lm-1 ;r
>> x1(tt,rr)=sin_*(rr*dr)
>> y1(tt,rr)=cos_*(rr*dr)
>> uprime(tt,rr)=sin_*vra(it,tt*101+rr)-cos_*vta(it,tt*101+rr)
>> vprime(tt,rr)=sin_*vta(it,tt*101+rr)+cos_*vra(it,tt*101+rr)
>> end do
>> end do
>>
>> ; Plotting options for Wind Vectors
>> type = "x11"
>> ; type = "pdf"
>> wks=gsn_open_wks(type,"Asy_Plane_panels")
>> vres = True
>> vres@gsnDraw = False
>> vres@gsnFrame = False
>> ;---Set coordinate arrays
>> vres@vfXArray = x1 ;Vector Field Attribute
>> vres@vfYArray = y1
>> vres@gsnRightString = ""
>> vres@gsnLeftString = ""
>> vres@vcGlyphStyle = "LineArrow" ;Set the type of Vector
>> vres@vcLineArrowThicknessF = 1.5
>> vres@vcRefMagnitudeF = 15.0
>> vres@vcRefLengthF = 0.045
>> ;============= Reference Bar Setting =======================
>> vres@vcRefAnnoOrthogonalPosF =-0.22 ;Reference Bar position Vertical
>> vres@vcRefAnnoParallelPosF = 0.997 ;Reference Bar horizontal position
>> vres@vcRefAnnoFontHeightF = 0.015
>> ;========================================================
>> vres@vcMinDistanceF = 0.017
>>
>> vector = gsn_csm_vector(wks,uprime,vprime,vres)
>>
>> ;========= Draw DBZ contour ==========================
>> res = True
>> res@gsnDraw = False
>> res@gsnFrame = False
>> res@gsnMaximize = True
>>
>> res@cnFillOn = True
>> res@cnLinesOn = False
>> ; res@cnFillMode = "RasterFill"
>> ; res@gsnSpreadColors = True
>> res@cnLevelSelectionMode = "ManualLevels"
>>
>> res@lbOrientation = "Vertical"
>> res@lbRasterFillOn = False
>> ; res@lbBoxLinesOn = False
>>
>> ;---------read data, (ln,lm) means (theta,r) ->(361,101)--------------
>> ;-------------make the 1D XArray and YArray------------------------
>> x = new(ln*lm,"float")
>> y = new(ln*lm,"float")
>> deg2rad = 0.017453292519943
>> do tt=0,ln-1 ;theta->from due north
>> rad=tt*deg2rad
>> sin_=sin(rad)
>> cos_=cos(rad)
>> do rr=0,lm-1 ;r
>> x(tt*101+rr)=sin_*rr*dr
>> y(tt*101+rr)=cos_*rr*dr
>> end do
>> end do
>>
>> ;---Set coordinate arrays
>> res@sfXArray = x
>> res@sfYArray = y
>> ;----ploting with local resources and colormap for each 1 of 4--------
>> ; ------ Pressure anomaly'
>> res@cnFillDrawOrder = "Predraw"
>> res@gsnLeftString = "REF"
>> res@gsnRightString = "dBz"
>> res@cnFillPalette = "radar"
>> ; res@cnSpanFillPalette = True
>> res@cnMinLevelValF = -9.
>> res@cnMaxLevelValF =4.
>> res@cnLevelSpacingF = 1.
>>
>> plot = gsn_csm_contour(wks,dbza(it,:),res)
>>
>>
>> overlay(plot,vector)
>>
>> draw(plot)
>> frame(wks)
>>
>> end do
>> end
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri May 9 12:37:51 2014

This archive was generated by hypermail 2.1.8 : Fri May 09 2014 - 15:23:17 MDT