[ncl-talk] overlaying data on the map

Ciao Kai Liang ciaokailiang at gmail.com
Sun Jul 10 07:41:12 MDT 2016


Hi Rick,

Thank for suggestion. after I modify my code, the two plot  are overlaid
now (see attached) but since I use my own defined projection, the contour
plot match well but the vector cannot. Do you have any suggest to fix this
problem? I've tried assign mp resource to vector but it conflicts. Thx in
advance.

Joe
The revised code is as follows

  u  = f1->UWIND(0,0,:,:) ;U at timestep 0 135x90
  v  = f1-> VWIND(0,0,:,:) ;V at timestep 0 135x90
  ox = f3->O3(0,0,:,:)    ;ozone concentration at timestep 0 135x90

  wks = gsn_open_wks("png","overlay")
  sfile ="/nas02/depts/ese/chaq/ckliang/TWN/shape/TWN_adm2.shp"
  gsn_define_colormap(wks,"cmp_haxby")

;Map============================================
  mpres                                         = True
  mpres at gsnDraw                       = False
  mpres at gsnFrame                     = False
  mpres at mpProjection                = "LambertConformal"
  mpres at mpLambertParallel1F  = 10.0
  mpres at mpLambertParallel2F  = 40.0
  mpres at mpLambertMeridianF   = 120.0
  mpres at tfDoNDCOverlay           = True
  mpres at mpLimitMode                = "Corners"
  mpres at mpLeftCornerLonF       = LON(0,0,0,0)
  mpres at mpLeftCornerLatF        = LAT(0,0,0,0)
  mpres at mpRightCornerLonF     =
LON(0,0,dimsizes(LAT(0,0,:,0))-1,dimsizes(LAT(0,0,0,:))-1)
  mpres at mpRightCornerLatF     =
LAT(0,0,dimsizes(LAT(0,0,:,0))-1,dimsizes(LAT(0,0,0,:))-1)

  mpres at mpDataSetName             = "Earth..4"   ; This new database
contains
  mpres at mpDataBaseVersion        = "MediumRes"  ; Medium resolution database
  mpres at mpOutlineOn                   = True         ; Turn on map outlines
  mpres at mpFillOn                           = True         ; Turn on map fill
  mpres at mpOutlineBoundarySets  = "AllBoundaries"
  mpres at mpGridAndLimbOn          = True
  mpres at mpGridLineDashPattern  = 2
  mpres at mpCenterRotF                = 90.0
  mpres at gsnSpreadColors            = True             ; use full colormap
;;Contour=============================================================
  mpres at cnFillOn                        = True
  mpres at cnFillMode                    = "RasterFill"     ; use raster mode
  mpres at cnLinesOn                    = False
  mpres at gsnMaximize                = True             ; Maximize the plot
where it is drawn
  mpres at gsnSpreadColors          = True             ; use full colormap
  mpres at cnLevelSelectionMode = "ManualLevels"
  mpres at cnMinLevelValF            = 5.     ; set the minimum contour level
  mpres at cnMaxLevelValF           = 100.   ; set the maximum contour level
  mpres at cnLevelSpacingF          = 5      ; set the contour interval
  mpres at lbLabelStride                = 1
  mpres at lbLabelFont                   = "times-roman"

;;set vector==========================================================
  vcres                                           = True
  vcres at gsnDraw                         = False
  vcres at gsnFrame                      = False
  vcres at vcMinFracLengthF          = 0.0   ;-- length of min vector as
  vcres at vcRefMagnitudeF          = 10.0  ;-- make vectors larger
  vcres at vcRefLengthF                = 0.045 ;-- ref vec length
  vcres at vcMinDistanceF            = 0.01  ;-- thin out vectors
  vcres at gsnLeftString                = ""
  vcres at gsnRightString             = ""
  vcres at tiMainString                   = "Wind profile October 1 2010
00:00"; vector curly
  vcres at vcGlyphStyle                 = "CurlyVector"
;;plot====================================================================
  contour = gsn_csm_contour_map(wks,ox*1000.,mpres)
  vector  = gsn_csm_vector(wks,u,v,vcres)
  ;shapefile
  lnres                  = True
  lnres at gsLineColor      = "gray25"
  lnres at gsLineThicknessF = 1.0
  twn_id1 = gsn_add_shapefile_polylines(wks,contour,sfile,lnres)
  twn_id2 = gsn_add_shapefile_polylines(wks,vector,sfile,lnres)

  draw(contour)       ; This will draw the map and the shapefile outlines.
  draw(vector)
  frame(wks)           ; Advance the frame
end



2016-07-08 23:44 GMT+08:00 Rick Brownrigg <brownrig at ucar.edu>:

> Hi,
>
> Looking at your plot, the reference vector generated by the vector plot
> and the label bar generated by the contour plot are both present on the
> map.  I'd recommend taking a close look at the underlying data to make sure
> units, values, and spatial extent is what you think it is.
>
> Hope that helps...
> Rick
>
>
> On Fri, Jul 8, 2016 at 1:16 AM, Ciao Kai Liang <ciaokailiang at gmail.com>
> wrote:
>
>> Dear alll ncl users,
>>
>> I try to make a plot of overlaying the wind speed (vector) and the ozone
>> concentration (contour) on the map. The wind speed vector is from MCIP
>> output and ozone concentration from CMAQ model. No error message occurs but
>> I get blank on the map(attached). Is something wrong in my script? Thx in
>> advance.
>>
>> Joe
>>
>> ;read files=============================================================
>> f1 = addfile("METDOT3D","r")
>> f2 = addfile("CCTM_D502a_Linux2_x86_64ifort.ACONC.CMAQ20101001.nc","r")
>>
>> u = f1->UWINDC(0,0,:,:) ;U at timestep 0  by 90X135
>> v = f1->VWINDC(0,0,:,:) ;V at timestep 0    by 90X135
>> ox = f2->O3(0,0,:,:)         ;ozone concentration at timestep 0  by 90X135
>>
>> ;set evn===============================================================
>> wks = gsn_open_wks("png","overlay")
>> gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")
>>
>> vcres                      = True  ;Vector
>> vcres at gsnDraw    = False
>> vcres at gsnFrame  = False
>> cnres                      = vcres ;Contour
>> mpres                     = vcres ;Map
>>
>> ;Contour===============================================================
>>  cnres at gsnDraw              = False
>>  cnres at gsnFrame           = False
>>
>>  cnres at cnFillOn               = True
>>  cnres at cnFillMode           = "RasterFill"     ; use raster mode
>>  cnres at cnLinesOn            = False
>>  cnres at tmYROn               = False            ; Turn off right
>> tickmarks.
>>  cnres at tmXTOn               = False            ; Turn off top tickmarks.
>>  cnres at tmXBLabelFont        = "times-roman"
>>  cnres at tmYLLabelFont        = "times-roman"
>>  cnres at gsnMaximize          = True             ; Maximize the plot where
>> it is drawn
>>  cnres at gsnSpreadColors      = True             ; use full colormap
>>
>>  cnres at cnLevelSelectionMode = "ManualLevels"
>>  cnres at cnMinLevelValF            = 10.  ; set the minimum contour level
>>  cnres at cnMaxLevelValF           = 120.   ; set the maximum contour level
>>  cnres at cnLevelSpacingF          = 10.    ; set the contour interval
>>  cnres at lbLabelStride                 = 1
>>  cnres at lbLabelFont          = "times-roman"
>>
>>  cnres at tmXBLabelFontHeightF = 0.015
>>  cnres at tmYLLabelFontHeightF = 0.015
>>
>> ;Vector=============================================
>>   vcres at vcLevelSelectionMode     = "ManualLevels"
>>   vcres at vcMinLevelValF                = -20.0
>>   vcres at vcMaxLevelValF               = 100.0
>>   vcres at vcLevelSpacingF              = 10.0
>>   vcres at vcLevelPalette                  = "amwg_blueyellowred"   ;
>> assign color map to vectors
>>
>>   vcres at vcGlyphStyle                       = "LineArrow"
>>   vcres at vcLineArrowThicknessF      = 5
>>   vcres at vcMinDistanceF                   = 0.01
>>   vcres at vcRefLengthF                       = 0.03
>>
>>   vcres at vcGlyphStyle                          = "WindBarb"
>>   vcres at vcWindBarbLineThicknessF   = 5
>>   vcres at vcWindBarbColor                   = "Gray40"
>>
>>   vcres at vcRefAnnoOn               = True
>>   vcres at vcRefMagnitudeF           = 30
>>   vcres at vcRefAnnoString1          = "30"
>>   vcres at vcRefAnnoSide             = "Top"
>>   vcres at vcRefAnnoString2On        = False
>>   vcres at vcRefAnnoPerimOn          = False
>>   vcres at vcRefAnnoOrthogonalPosF   = -0.12
>>   vcres at vcRefAnnoParallelPosF     = 0.999
>>   vcres at vcRefAnnoBackgroundColor  = "Purple"
>>   vcres at vcVectorDrawOrder         = "PostDraw"
>>   vcres at gsnRightString            = "Wind"
>>
>> ;Map============================================
>>   mpres at mpProjection               = "LambertConformal"
>>   mpres at mpLambertParallel1F  = 10.0
>>   mpres at mpLambertParallel2F  = 40.0
>>   mpres at mpLambertMeridianF   = 120.0
>>   mpres at tfDoNDCOverlay          = True
>>   mpres at mpLimitMode               = "Corners"
>>   mpres at mpLeftCornerLonF      = LON(0,0,0,0)
>>   mpres at mpLeftCornerLatF       = LAT(0,0,0,0)
>>   mpres at mpRightCornerLonF    =
>> LON(0,0,dimsizes(LAT(0,0,:,0))-1,dimsizes(LAT(0,0,0,:))-1)
>>   mpres at mpRightCornerLatF      =
>> LAT(0,0,dimsizes(LAT(0,0,:,0))-1,dimsizes(LAT(0,0,0,:))-1)
>>
>>   mpres at mpDataSetName          = "Earth..4"   ; This new database
>> contains
>>   mpres at mpDataBaseVersion     = "MediumRes"  ; Medium resolution database
>>   mpres at mpOutlineOn                 = True         ; Turn on map outlines
>>   mpres at mpFillOn                         = True
>>   mpres at mpOutlineBoundarySets  = "AllBoundaries"
>>   mpres at mpGridAndLimbOn        = True
>>   mpres at mpGridLineDashPattern  = 2
>>   mpres at mpCenterRotF                 = 90.0
>>
>>   mpres at mpLabelsOn                   = False
>>   mpres at mpPerimOn                    = True
>>   mpres at mpGridAndLimbOn        = False
>>   mpres at mpOutlineDrawOrder     = "PostDraw"
>>   mpres at mpFillDrawOrder            = "Predraw"
>>   mpres at mpOceanFillColor           = "lightskyblue1"
>>   mpres at mpLandFillColor               = "gray"
>>
>>   mpres at mpGridAndLimbDrawOrder = "Predraw"
>>   mpres at tiMainString           =  "October 1 2010 ozone
>> concentration(ppm)"
>>
>> ;=====================================================================
>>   vcid = gsn_csm_vector(wks,u,v,vcres)
>>   cnid = gsn_csm_contour(wks,ox*1000.,cnres)
>>   mpid = gsn_csm_map(wks,mpres)
>>
>> ;---Attach the shapefile polylines using files read off gadm.org/country.
>>   lnres                  = True
>>   lnres at gsLineColor      = "gray25"
>>   lnres at gsLineThicknessF = 1.0
>>   twn_id = gsn_add_shapefile_polylines(wks,mpid,sfile,lnres)
>>
>> ;---Overlay contour, streamline, and vector plots on the map plot.
>>   overlay(mpid,cnid)
>>   overlay(mpid,vcid)
>>
>>   draw(mpid)
>>   frame(wks)
>>
>>   maximize_output(wks,True)
>> end
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>


-- 
---------------------------------------------------------------------------------------------------------
CiaoKai Liang
919-808-8069
ckliang at live.unc.edu
University of North Carolina, Gillings School of Global Public Health
170 Rosenau Hall, CB #7400 | 135 Dauer Drive | Chapel Hill, NC 27599-7400
------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160710/a14abf1a/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: overlay.png
Type: image/png
Size: 452076 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160710/a14abf1a/attachment-0001.png 


More information about the ncl-talk mailing list