[ncl-talk] Wrong tickmarks (?) using gsn_csm_contour_map_overlay

Michele Petrini mpetrini139 at yahoo.it
Thu Jul 2 08:47:09 MDT 2015


Dear helpdesk,
I am plotting two overlaid contours over a map with 
gsn_csm_contour_map_overlay. Everything works pretty fine but the 
tickmarks. I set res1 at pmTickMarkDisplayMode  = "Always" and I get the 
output you can see in the .ps I attach. What I made wrong? Furthermore, 
is it possible to have longitude and latitude tickmarks on just one side 
(bottom and left sides, resp.) of the plot?

Thank you,

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
  
  mydir    = "/home/michele/Desktop/WORK_GRISLI/GRISLI/lgm_NH40/Netcdf-Resu/"
  cdf_file1 = addfile(mydir+"shelf011_class01_0.nc","r")
  cdf_file2 = addfile(mydir+"shelf011_class02_0.nc","r")

;********************************************************************************
;retrieve variables and parameters                                              *
;********************************************************************************
  
  lat    = cdf_file1->lat
  lon    = cdf_file1->lon
  x      = cdf_file1->x
  y      = cdf_file1->y
  time   = cdf_file1->time
  ntime  = dimsizes(time)
  nlat   = dimsizes(lat&y)
  nlon   = dimsizes(lon&x)
  grmask = cdf_file1->Mk
  Hice   = cdf_file1->H
  Stopo  = cdf_file1->S
  flmask = cdf_file2->posx
  
  print(ntime)

;********************************************************************************
;reorder arrays                                                                 *
;********************************************************************************

  lat    = lat(y|:,x|:)               
  lon    = lon(y|:,x|:)
  Hice   = Hice(time|:,y|:,x|:)
  Stopo  = Stopo(time|:,y|:,x|:)
  Mk     = grmask(time|:,y|:,x|:)
  flmask = flmask(time|:,y|:,x1|:)
  
;*********************************************************************************
;play with variables (cut slices, define new, mask, where, statements ...)       *
;*********************************************************************************
  
  Mk0          = Mk(0,:,:)
  Mktf         = Mk(ntime-1,:,:)
  Hice0        = Hice(0,:,:)
  Stopo0       = Stopo(0,:,:)
  Hicetf       = Hice(ntime-1,:,:)
  Stopotf      = Stopo(ntime-1,:,:)
  flmask0      = flmask(0,:,:)
  flmasktf     = flmask(ntime-1,:,:)

;**************set the floating ice to 0 in Hice0 and Hice25 in order to plot (and then evaluate) the grounded ice only (including ice streams and grounding zone). 

  begin
   do j=0,nlon-1
    do i=0,nlat-1
     if(flmask0(i,j) .eq. 3. .or. flmask0(i,j) .eq. 2.) then
       Hice0(i,j) = 0.5
     end if
    end do
   end do
  end
 
  begin
   do j=0,nlon-1
    do i=0,nlat-1
      if(flmasktf(i,j) .eq. 3. .or. flmasktf(i,j) .eq. 2.) then
         Hicetf(i,j) = 0.5
       end if
     end do
    end do
  end

  begin
   do k=0,ntime-1
    do i=0,nlat-1
     do j=0,nlon-1
       if(flmask(k,i,j).eq. 3. .or. flmask(k,i,j).eq. 2. .or. Hice(k,i,j) .lt. 1.1) then
         Hice(k,i,j) = 0
       end if
     end do
    end do
   end do
  end 
        

;**************

  Mk0where     = where(Mk0(:,:).gt.0.5,1,0)                                   ; along with resources, draw the line 0.5
  Mktfwhere    = where(Mktf(:,:).gt.0.5,1,0)                           
  Hice0mask    = mask(Hice0,(Hice0(:,:).gt.1.1),True)                         ; mask the less than 1.1 ice thickness (ocean that is)
  Hicetfmask   = mask(Hicetf,(Hicetf(:,:).gt.1.1),True) 
  Stopo0where  = where(Stopo0(:,:).gt. 0.2,1.,0.)                             ; along with resources, draw the line 0.2
  Stopotfwhere = where(Stopotf(:,:).gt. 0.2,1.,0.)

;*********************************************************************************
;open the workstation and define the colormap                                    *
;*********************************************************************************

  wks = gsn_open_wks("ps","Greenland")
  gsn_define_colormap(wks,"gui_default")
  plot = new(2,graphic)                             ; create graphic array

;*********************************************************************************
;set the resources                                                               *
;*********************************************************************************
 
;**********************Resource list for the ice thickness
  res1 = True
 
  res1 at gsnAddCyclic           = False
 
  res1 at mpLimitMode            = "Corners"            ; choose range of map
  res1 at mpLeftCornerLatF       = lat(65,76)
  res1 at mpLeftCornerLonF       = lon(65,76)
  res1 at mpRightCornerLatF      = lat(125,139)
  res1 at mpRightCornerLonF      = lon(125,139)

  res1 at mpProjection           = "LambertEqualArea"
  res1 at mpCenterLatF           = 90
  res1 at mpCenterLonF           = 0
  res1 at mpOutlineOn            =  True
  
  res1 at tfDoNDCOverlay         = True

  res1 at cnFillOn               = True      
  res1 at cnLevelSelectionMode   = "ManualLevels"    			
  res1 at cnMinLevelValF         = 0
  res1 at cnMaxLevelValF         = 5000
  res1 at cnLevelSpacingF        = 200
  res1 at gsnDraw                = False                 ; do not draw picture
  res1 at gsnFrame               = False                 ; do not advance frame

  res1 at cnLinesOn              = False                 ;  contour lines
  res1 at cnLineLabelsOn         = False                 ; no contour labels
  res1 at gsnSpreadColors        = True                  ; use total colormap
  res1 at gsnSpreadColorStart    = 2 
  res1 at gsnSpreadColorEnd      = 27
  res1 at cnInfoLabelOn          = False                 ; no contour info (right left)

  res1 at pmTickMarkDisplayMode  = "Always"              ; lat lon tickmarks 
  
  res1 at lbLabelBarOn           = True
  res1 at lbLabelFontHeightF     = 0.04
  res1 at lbLabelFont            = "helvetica"
  res1 at lbOrientation	      = "horizontal"           ; vertical label bar
  res1 at lbLabelPosition        = "bottom"               ; Move labels to left side of labelbar
  res1 at lbTitleOn              = True                   ; turn on title
  res1 at lbTitleString          = "Topography (m)"
  ;res1 at lbTitleDirection       = "Down"              ; letter angle
  ;res1 at lbTitleAngleF          = 90.                 ; title angle
  res1 at lbTitleFontHeightF     = 0.04                 ; font height
  res1 at lbTitlePosition        = "Bottom"               ; title location

  res1 at vpWidthF = 1.2
  res1 at vpHeightF = 1.

;**********************Resource list for the topography

  res2                        = True                ; plot mods desired
  res2 at cnFillOn               = False               ; color fill
  res2 at gsnDraw                = False               ; do not draw picture
  res2 at gsnFrame               = False               ; do not advance frame
  res2 at cnLevelSelectionMode   = "ManualLevels"      ; set manual contour levels
  res2 at cnMinLevelValF         =  0.                 ; set min contour level
  res2 at cnMaxLevelValF         =  1.                 ; set max contour level
  res2 at cnLevelSpacingF        =  0.5 
  res2 at cnInfoLabelOn          = False               ; no info label 
  res2 at cnLineLabelsOn         = False
  res2 at cnLineThicknessF       = 2              	    ; thicker contours
  res2 at cnLineColor            = "red"
  res2 at gsnAddCyclic           = False               ; regional data

  res2 at tfDoNDCOverlay         = True

  res2 at tiMainOn               = True
  res2 at tiMainString           = " "
  
;**********************Resource list for the grounded mask

  res3 = True
  
  res3 at cnFillOn               = False               ; color fill
  res3 at gsnDraw                = False               ; do not draw picture
  res3 at gsnFrame               = False               ; do not advance frame
  res3 at cnLevelSelectionMode   = "ManualLevels"      ; set manual contour levels
  res3 at cnMinLevelValF         =  0.                 ; set min contour level
  res3 at cnMaxLevelValF         =  1.                 ; set max contour level
  res3 at cnLevelSpacingF        =  0.5
  res3 at cnInfoLabelOn          = False               ; no info label
  res3 at cnLineLabelsOn         = False
  res3 at cnLineThicknessF       = 2                   ; thicker contours
  res3 at cnLineColor            = "Orange"
  res3 at gsnAddCyclic           = False               ; regional data
  res3 at cnFillDrawOrder        = "Postdraw"
  res3 at tfDoNDCOverlay         = True

  res3 at tiMainOn               = True
  res3 at tiMainString           = " "

 
;*********************************************************************
;Plot ice thickness contours over topography at 2 different times    *
;*********************************************************************

  res1 at gsnLeftString            = "Greenland 30,000 kyrs BP grounded ice"

  res1 at gsnLeftStringFontHeightF = 0.04
  res1 at txFont                   = 21
  
  plot(0) = gsn_csm_contour_map_overlay(wks,Hice0mask(65:125,76:139),Mk0where(65:125,76:139),res1,res2)
    
  res1 at gsnLeftString            = "Greenland 5,000 kyrs BP grounded ice"
  res1 at gsnLeftStringFontHeightF = 0.04
  res1 at txFont                   = 21

  plot(1) = gsn_csm_contour_map_overlay(wks,Hicetfmask(65:125,76:139),Mktfwhere(65:125,76:139),res1,res2)    
  
;***********************************************************************
; Draw panel with white space added                                    *
;***********************************************************************

  resP                       = True
  resP at txFont                = 21
  resP at gsnPanelFigureStrings = (/"a.","b."/)                     ; add strings to panel

  resP at gsnPanelFigureStringsFont        = "helvetica"
  resP at gsnPanelFigureStringsPerimOn     = True
  resP at gsnPanelFigureStringsFontHeightF = 0.010
  resP at amJust                           = "TopLeft"

  resP at gsnPanelLabel             = True                           ; add common colorbar
  resP at lbLabelStride             = 1
  resP at lbLabelAngleF             = 45
  resP at lbLabelAlignment          = "InteriorEdges"
  resP at pmLabelBarOrthogonalPosF  = -0.03                          ; Move labelbar to the left
  resP at lbLabelFontHeightF        = 0.008
  resP at lbLabelFont               = "helvetica"
  resP at lbLabelPosition           = "Bottom"                        ; Move labels to left side
  resP at lbTitleOn                 = True		                   ; turn on title
  resP at lbTitleString             = "Ice thickness (m)"
  resP at lbTitleFontHeightF        = 0.009                           ; font height
  resP at lbTitlePosition           = "Bottom"                        ; title location

  resP at gsnPanelRight = 0.9
  resP at gsnPanelLeft = 0.1 
 
  resP at gsnPanelYWhiteSpacePercent = 0.1
  resP at gsnPanelXWhiteSpacePercent = 0.1
 
  txres               = True                                     ; text mods desired
  txres at txFontHeightF = 0.008                                    ; font smaller. default big
 
 
  gsn_panel(wks,plot,(/1,2/),resP)

;******************************************************************************************
; Evaluate the ice volume variation (Sea Level Equivalent) throughout the simulation time * 
;******************************************************************************************
 
  vol = new((/ntime,nlat,nlon/),double)                   
  vol = (/ Hice /)
 

  begin
  do k = 0,ntime-1
   do i = 0,nlat-1
     do j = 0,nlon-1
       if(vol(k,i,j).gt. 1.1) then
         vol(k,i,j) = vol(k,i,j) * 1600000000.
       else
         vol(k,i,j) = 0.
       end if 
     end do
   end do
  end do
  end
  
  volvar1 = new((/ntime-1/),double,"No_FillValue")   

  begin
   do i = 0,24
    volvar1(i) = sum(vol(i+1,69:80,79:103))- sum(vol(i,69:80,79:103))
   end do
  end
  
  volvar1tot = sum(volvar1)
  
  volvar2 =  new((/ntime-1/),double,"No_FillValue")        

  begin
   do i = 0,24
    volvar2(i) = sum(vol(i+1,81:97,79:139))- sum(vol(i,81:97,79:139))
   end do
  end

  volvar2tot = sum(volvar2)
 
  volvar3 =  new((/ntime-1/),double,"No_FillValue")        

  begin
   do i = 0,24
    volvar3(i) = sum(vol(i+1,98:122,96:139))- sum(vol(i,98:122,96:139))
   end do
  end

  volvar3tot = sum(volvar3)

  volvartot    = volvar1tot + volvar2tot + volvar3tot
  volvartotSLE = volvartot*(917./1025.)*(1./361320000000000.)

  print(volvartotSLE+" metres SLE") 

  end
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Greenland.ps
Type: application/postscript
Size: 700684 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150702/2678833a/attachment-0001.ps 


More information about the ncl-talk mailing list