[ncl-talk] Overlay CurlyVectors over map and contours

Michele Petrini mpetrini139 at yahoo.it
Tue Aug 30 04:36:56 MDT 2016


Dear helpdesk,

in the .ncl file I attach I'm overlaying CurlyVectors over maps and 
contours; if my understanding of the CurlyVectors definition is right, I 
get for each velocity an array that is locally tangent to the flow; what 
I'm trying to do is to set a low velocity reference value, in order to 
get the flow pattern for higher velocities than reference (100 m/yr, see 
.pdf file) - which are the velocities I'm interested to. In order to 
have a more clear figure, I'd like to remove those arrays even lower 
than the reference, I tried with the mask function but somehow I got 
also higher velocities arrays removed - so it follows my question, am I 
misunderstanding the meaning of CurlyVectors or there is a better way to 
get out of the figure "small" arrays?

Thank you for your help,

Best
Michele

-- 

***
Michele Petrini

Ph.D. student in Earth Science and Fluid Mechanics

Università degli studi di Trieste,
Dipartimento di Matematica e Geoscienze
Palazzina C - via Weiss 1, 34128 Trieste, Italy

Email: mpetrini139 at yahoo.it
Skype: michele.petrins
Mobile: +39 3398367372

-------------- next part --------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin

  mydir1 = "/media/michele/DATA/simulations_ensemble_index/"

  mydir2 = "/home/michele/Desktop/Phd_thesis/hughes_et_al_2015_data/TimeSlices_shp/"
  
  cdf_file1a = addfile(mydir1+"Ginde037_class01_.nc","r")   
  cdf_file1b = addfile(mydir1+"Ginde037_class02_.nc","r") 


  lat        = cdf_file1a->lat
  lon        = cdf_file1a->lon
  x          = cdf_file1a->x
  y          = cdf_file1a->y
  time       = cdf_file1a->time
  ntime      = dimsizes(time)
  nlat       = dimsizes(lat&y)
  nlon       = dimsizes(lon&x)

  H_ref      = cdf_file1a->H
  Ux_ref     = cdf_file1b->Uxbar
  Uy_ref     = cdf_file1b->Uybar
  Ubx_ref     = cdf_file1b->Uxsli
  Uby_ref     = cdf_file1b->Uysli

  delete(H_ref at standard_name)
  delete(H_ref at long_name)
  delete(H_ref at units)


  H_ref = mask(H_ref,(H_ref(:,:,:).gt.1.),True)


  s_ref  = (  Ux_ref(:,:,:)*Ux_ref(:,:,:) + Uy_ref(:,:,:)*Uy_ref(:,:,:) )^0.5 + (  Ubx_ref(:,:,:)*Ubx_ref(:,:,:) + Uby_ref(:,:,:)*Uby_ref(:,:,:) )^0.5

  ;time slices: 15, 14.5, 14, 13, 12, 11 which means: 25,30,35,36,37,38

  ux0 = Ubx_ref(25,:,:)+Ux_ref(25,:,:)
  uy0 = Uby_ref(25,:,:)+Uy_ref(25,:,:)
  s0  = H_ref(25,:,:)+0.

  ux1 = Ux_ref(30,:,:)+Ubx_ref(30,:,:)
  uy1 = Uy_ref(30,:,:)+Uby_ref(30,:,:)
  s1  = H_ref(30,:,:)+0.


  ux2 = Ux_ref(35,:,:)+Ubx_ref(35,:,:)
  uy2 = Uy_ref(35,:,:)+Uby_ref(35,:,:)
  s2  = H_ref(35,:,:)+0.


  ux3 = Ux_ref(36,:,:)+Ubx_ref(36,:,:)
  uy3 = Uy_ref(36,:,:)+Uby_ref(36,:,:)
  s3  = H_ref(36,:,:)+0.


  ux4 = Ux_ref(37,:,:)+Ubx_ref(37,:,:)
  uy4 = Uy_ref(37,:,:)+Uby_ref(37,:,:)
  s4  = H_ref(37,:,:)+0.

  ux5 = Ux_ref(38,:,:)+Ubx_ref(38,:,:)
  uy5 = Uy_ref(38,:,:)+Uby_ref(38,:,:)
  s5  = H_ref(38,:,:)+0.


  wks = gsn_open_wks("pdf","ice_vel_index")
  gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")



;;create plots;;
 
        res                = True
        res at gsnDraw        = False
        res at gsnFrame       = False 
        res at tmXTOn         = False
        res at tmYROn         = False
        res at gsnLeftString  = ""
        res at gsnRightString = ""

        
;;set map;;
        mpres                   = res
        mpres at mpLimitMode            = "Corners"            ; choose range of map
        mpres at mpLeftCornerLatF       = lat(105,45)
        mpres at mpLeftCornerLonF       = lon(105,45)
        mpres at mpRightCornerLatF      = lat(185,100)
        mpres at mpRightCornerLonF      = lon(185,100)
        mpres at mpProjection           = "LambertEqualArea"
        mpres at mpCenterLatF           = 90
        mpres at mpCenterLonF           = 0
 
;;set contour;;

        cnres1                   = res
        cnres1 at cnFillOn               = True        
        cnres1 at cnFillDrawOrder        = "PostDraw"
        cnres1 at lbLabelBarOn           = True  
        cnres1 at cnLinesOn              = False     
        cnres1 at cnLineColor           = "gray25"             
        cnres1 at cnLineLabelsOn         = True                   ; no contour labels
        cnres1 at cnInfoLabelOn          = False                   ; no contour info (right left)
        cnres1 at pmTickMarkDisplayMode  = "Never" 
        cnres1 at cnLevelSelectionMode = "ManualLevels"	
        cnres1 at cnMinLevelValF  = 0.			; set the minimum contour level
        cnres1 at cnMaxLevelValF  = 2000.			; set the maximum contour level
        cnres1 at cnLevelSpacingF = 250.
        cnres1 at lbLabelStride              = 1
        cnres1 at lbLabelFont                = 1
        ;cnres1 at lbLabelFontHeightF         = 0.008  
        ;cnres1 at pmLabelBarOrthogonalPosF   = 0.  
        cnres1 at lbOrientation              = "horizontal"                    
        cnres1 at lbLabelPosition            = "bottom"                        ; Move labels to left side of labelbar
        cnres1 at lbLabelAlignment           = "InteriorEdges"
        cnres1 at lbTitleOn                  = True                            ; turn on title
        cnres1 at lbTitleString              = "~F1~Ice thickness (m)"
        ;cnres1 at lbTitleFontHeightF         = 0.011                           ; font height
        cnres1 at lbTitlePosition            = "Bottom" 
        cnres1 at tfDoNDCOverlay         = True
        cnres1 at gsnAddCyclic           = False
        cmap = read_colormap_file("WhiteBlueGreenYellowRed")
        cnres1 at cnFillPalette = cmap(50:230,:)   ; subset color map

      
;;set vector;;
        res_vc                            = res

        res_vc at vcRefMagnitudeF           = 100.             ; define vector ref mag
        res_vc at vcRefLengthF              = 0.03          ; define length of vec ref
        res_vc at vcRefAnnoArrowLineColor   = "black"         ; change ref vector color
        res_vc at vcRefAnnoArrowUseVecColor = False           ; don't use vec color for ref

        res_vc at vcGlyphStyle            = "CurlyVector"     ; turn on curly vectors
        res_vc at vcLineArrowColor        = "slateblue4"           ; change vector color
        res_vc at vcLineArrowThicknessF   = 1.2             ; change vector thickness
        res_vc at vcVectorDrawOrder       = "PostDraw"        ; draw vectors last
        res_vc at tfDoNDCOverlay         = True

        res_vc at vcMinDistanceF             = 0.016

       


        
;;plot;;

        map     = new(6,graphic)                             ; create graphic array
        contour = new(6,graphic)
        vector  = new(6,graphic)

        map(0)     = gsn_csm_map(wks,mpres)
        contour(0) = gsn_csm_contour(wks,s0(105:185,45:100),cnres1)
        vector(0)  = gsn_csm_vector(wks,ux0(105:185,45:100),uy0(105:185,45:100),res_vc)

        map(1)     = gsn_csm_map(wks,mpres)
        contour(1) = gsn_csm_contour(wks,s1(105:185,45:100),cnres1)
        vector(1)  = gsn_csm_vector(wks,ux1(105:185,45:100),uy1(105:185,45:100),res_vc)

        map(2)     = gsn_csm_map(wks,mpres)
        contour(2) = gsn_csm_contour(wks,s2(105:185,45:100),cnres1)
        vector(2)  = gsn_csm_vector(wks,ux2(105:185,45:100),uy2(105:185,45:100),res_vc)

        map(3)     = gsn_csm_map(wks,mpres)
        contour(3) = gsn_csm_contour(wks,s3(105:185,45:100),cnres1)
        vector(3)  = gsn_csm_vector(wks,ux3(105:185,45:100),uy3(105:185,45:100),res_vc)

        map(4)     = gsn_csm_map(wks,mpres)
        contour(4) = gsn_csm_contour(wks,s4(105:185,45:100),cnres1)
        vector(4)  = gsn_csm_vector(wks,ux4(105:185,45:100),uy4(105:185,45:100),res_vc)

        map(5)     = gsn_csm_map(wks,mpres)
        contour(5) = gsn_csm_contour(wks,s5(105:185,45:100),cnres1)
        vector(5)  = gsn_csm_vector(wks,ux5(105:185,45:100),uy5(105:185,45:100),res_vc)

;;overlay filled contours and vectors on the map;;

        do i=0,5
        overlay(map(i),contour(i))
        overlay(map(i),vector(i))
        end do

;drawing "map" will draw everything: map, contours, vectors, and text;;
;***********************************************************************
; Draw panel with white space added                                    *
;***********************************************************************

  res0                            = True
  res0 at txFont                     = 21
 res0 at gsnPanelFigureStrings      = (/"~F1~15 ka","~F1~14.5 ka","~F1~14 ka","~F1~13 ka","~F1~12 ka","~F1~ 11 ka"/)                     ; add strings to panel
  res0 at gsnPanelFigureStringsFontHeightF = (/0.007,0.007,0.007,0.007,0.007,0.007,0.007,0.007,0.007,0.007,0.007,0.007/)
  res0 at gsnPanelFigureStringsJust  = (/"BottomLeft","BottomLeft","BottomLeft","BottomLeft","BottomLeft","BottomLeft"/)
  res0 at gsnPanelRight              = 0.9
  res0 at gsnPanelLeft               = 0.1
  res0 at gsnPanelYWhiteSpacePercent = 0.1
  res0 at gsnPanelXWhiteSpacePercent = 0.1
  res0 at txFont                     = 13
  res0 at txFontHeightF              = 0.015
  res0 at gsnPanelRight              = 0.9
  res0 at gsnPanelLeft               = 0.1 
  res0 at gsnMaximize                = True                             ; use full page


  gsn_panel(wks,map,(/3,2/),res0)

 


end
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ice_vel_index.pdf
Type: application/pdf
Size: 1105005 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160830/09018f7d/attachment-0001.pdf 


More information about the ncl-talk mailing list