Re: x axis Major Tick Marks

From: Yi-Chih Huang <dscpln_at_nyahnyahspammersnyahnyah>
Date: Mon Nov 11 2013 - 17:19:29 MST

Mary,

    The result of 1985-87 is not good enough. So I am working on 1996-98.
 The numbers of yrF are around 1996-1999 as follows. But still I got the
warning and there is no tick mark or labeling on x axis. The situation is
different from the script you created. Then how to debug?

    Thanks much,

              Yi-Chih

#####
yhuang@arc-env:/fs3/yhuang/scripts$ ncl dipoleMth.ncl
 Copyright (C) 1995-2013 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 6.1.2
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.

Variable: yrF
Type: float
Total Size: 144 bytes
            36 values
Number of Dimensions: 1
Dimensions and sizes: [36]
Coordinates:
Number Of Attributes: 1
  _FillValue : 9.96921e+36
(0) 1996
(1) 1996.083
(2) 1996.167
(3) 1996.25
(4) 1996.333
(5) 1996.417
(6) 1996.5
(7) 1996.583
(8) 1996.667
(9) 1996.75
(10) 1996.833
(11) 1996.917
(12) 1997
(13) 1997.083
(14) 1997.167
(15) 1997.25
(16) 1997.333
(17) 1997.417
(18) 1997.5
(19) 1997.583
(20) 1997.667
(21) 1997.75
(22) 1997.833
(23) 1997.917
(24) 1998
(25) 1998.083
(26) 1998.167
(27) 1998.25
(28) 1998.333
(29) 1998.417
(30) 1998.5
(31) 1998.583
(32) 1998.667
(33) 1998.75
(34) 1998.833
(35) 1998.917
warning:ManualComputeMajorTickMarks: The precision specified is smaller
than the precision needed tick mark labels may not be correct
warning:ManualComputeMajorTickMarks: The precision specified is smaller
than the precision needed tick mark labels may not be correct

######
load "$SysE/lib/ncl/helper_libs.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin
  dirSst= "/fs3/SysE_DB/saji/OISST/Monthly/Mean/"
  dirU= "/fs3/SysE_DB/nmm/CFSR/Monthly/Mean/"
; dir2= (/"1981/","1982/","1983/"/)
; dir2= (/"1985/","1986/","1987/"/)
  dir2= (/"1996/","1997/","1998/"/)
  mth=
(/199601,199602,199603,199604,199605,199606,199607,199608,199609,199610,199611,199612,\

 199701,199702,199703,199704,199705,199706,199707,199708,199709,199710,199711,199712,\

 199801,199802,199803,199804,199805,199806,199807,199808,199809,199810,199811,199812/)
  varName= (/"sst","us"/)
  nyr= dimsizes(dir2)

  dim= dimsizes(mth)
  yrF= new (dim, float)

  do nd=0,dim-1
     yyyy = mth(nd)/100
     mon = mth(nd)-yyyy*100
     yrF(nd) = yyyy + (mon-1)/12.
  end do
print(yrF)

  xx= new((/nyr*12/),float,"No_FillValue")
  yy= new((/nyr*12/),float,"No_FillValue")
  zz= new((/nyr*12/),float,"No_FillValue")

  do ny= 0,nyr-1
    dir = str_concat(dirSst+dir2(ny))
    fil= systemfunc("cd "+dir+" ; ls sst.nc")
    f= addfile (dir+fil, "r")
    x= f->$varName(0)$
    dims = getfilevardims(f,varName(0))

    x1= x($dims(0)$|:,{$dims(1)$|10:-10},{$dims(2)$|50:70}) ; first domain
    xs= dim_avg_n_Wrap( x1, (/1,2/) )

    y1= x($dims(0)$|:,{$dims(1)$|0:-10},{$dims(2)$|110:90}) ; second domain
    ys= dim_avg_n_Wrap( y1, (/1,2/) )

    do i= 0,11
      m= ny*12 +i
      xx(m)= xs(i)
      yy(m)= ys(i)
    end do
  end do

  dt= xx - yy
  dt= dim_standardize(dt, 0)

  do ny= 0,nyr-1
    dir = str_concat(dirU+dir2(ny))
    fil= systemfunc("cd "+dir+" ; ls us.nc")
    f= addfile (dir+fil, "r")
    y= f->$varName(1)$
    dims = getfilevardims(f,varName(1))

    y1:= y($dims(0)$|:,{$dims(1)$|5:-5},{$dims(2)$|70:90})
    ys= dim_avg_n_Wrap( y1, (/1,2/) )

    z1:= y($dims(0)$|:,{$dims(1)$|5:-5},{$dims(2)$|:})
    zs= dim_avg_n_Wrap( z1, (/1,2/) )

    do i= 0,11
      m= ny*12 +i
      yy(m)= ys(i)
      zz(m)= zs(i)
    end do
  end do

  du= yy - zz
  du= dim_standardize(du, 0)

  wks = gsn_open_wks ("X11", "dipoleMth97" )
  res = True
  res@gsnScale = True

; these four resources allow the user to stretch the plot size, and
; decide exactly where on the page to draw it.

  res@vpXF = 0.10 ; In page coordinates, where to start
  res@vpYF = 0.75 ; the plot
  res@vpHeightF = 0.43 ; Changes the aspect ratio
  res@vpWidthF = 0.85

  res@trYMinF = -3.0 ; min value on y-axis
  res@trYMaxF = 3.0 ; max value on y-axis

  res@tiYAxisString = "Anomalies" ; y-axis label
; res@tiMainString = "Dipole Mode Index and

  res@gsnYRefLine = 0. ; reference line
  res@gsnXYBarChart = True ; create bar chart
  res@gsnXYBarChartColors2 = (/"blue"/)

  res@tmXBMode = "Manual"
  res@tmXBTickStartF = 1986
  res@tmXBTickEndF = 1988
  res@tmXBTickSpacingF= 1
  res@tmXBPrecision = 4

  res@gsnDraw = False
  res@gsnFrame = False

  plot1= gsn_csm_xy (wks,yrF,dt,res)
  res@gsnXYBarChartColors2 =(/"red"/)
  plot2= gsn_csm_xy (wks,yrF,du,res)

  lbres = True
  lbres@vpWidthF = 0.2 ; labelbar width
  lbres@vpHeightF = 0.1 ; labelbar height
  lbres@lbBoxMajorExtentF = 0.36 ; puts space between color boxes
  lbres@lbFillColors = (/"blue","red"/)
  lbres@lbMonoFillPattern = True ; Solid fill pattern
  lbres@lbLabelFontHeightF = 0.020 ; font height. default is small
  lbres@lbLabelJust = "CenterLeft" ; left justify labels
  lbres@lbPerimOn = False
  lbres@lgPerimColor = "white"
  labels = (/"Dipole Mode Index","Equitorial Zonal Wind Anomaly"/)
  gsn_labelbar_ndc(wks,2,labels,0.10,0.25,lbres) ; draw right
labelbar column

  overlay(plot1,plot2)
  maximize_output(wks,True)
  frame(wks)
end

On Tue, Nov 12, 2013 at 1:43 AM, Mary Haley <haley@ucar.edu> wrote:

>
> My guess is that your X axis values are not in the same range as the tick
> mark values you are trying to give it.
>
> If you run the script below, you will see the same error. Part of the
> problem is because the "x" values go from 1000 to 9000 in steps of 1000,
> but I'm trying to put tickmarks at locations 1986, 1987, and 1988, which is
> just a very small fraction of the full range of my X axis.
>
> 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/csm/contributed.ncl"
>
> begin
> x = ispan(1000,9000,1000)
> y = (/0.,0.71,1.,0.7,0.002,-0.71,-1.,-0.71,-0.003/)
>
> printMinMax(x,0)
>
> wks = gsn_open_wks("x11","xy")
>
> res = True
> res@tmXBMode = "Manual"
> res@tmXBTickStartF = 1986
> res@tmXBTickEndF = 1988
> res@tmXBTickSpacingF= 1
> res@tmXBPrecision = 4
> plot = gsn_csm_xy(wks,x,y,res)
>
> end
>
> In your case, your X axis is represented by "yrF" and you are trying to
> put tickmarks at locations 1986, 1987, and 1988.
>
> I don't know what "yrF" looks like, but it needs to be somewhere near the
> range 1986-1988, otherwise you won't see any tickmark values.
>
> I'm not sure why you are setting tmXBPrecision. I don't think you need
> this.
>
> Print out your "yrF" values to see what they look like:
>
> print(yrF)
>
> Please look at your data before posting to ncl-talk, and make sure that
> what you are plotting is in the range you are expecting.
>
> Use procedures like "print", "printMinMax", and "printVarSummary" to learn
> more about your data.
>
> Also look over our posting guidelines, as there are suggestions for how
> find answers on your own without always having to post to ncl-talk:
>
> http://www.ncl.ucar.edu/Support/posting_guidelines.shtml
>
> --Mary
>
>
> On Nov 10, 2013, at 6:48 PM, Yi-Chih Huang <dscpln@gmail.com> wrote:
>
> > Hello,
> >
> > I am trying to give 1986, 1987, and 1988 on x axis. But I got the
> warning below. There is no tick mark or any labeling on x axis. Is there
> anyone knowing what is wrong with my script?
> >
> > Thanks much,
> >
> > Yi-Chih
> >
> > #####
> > yhuang@arc-env:/fs3/yhuang/scripts$ ncl dipoleMth.ncl
> > Copyright (C) 1995-2013 - All Rights Reserved
> > University Corporation for Atmospheric Research
> > NCAR Command Language Version 6.1.2
> > The use of this software is governed by a License Agreement.
> > See http://www.ncl.ucar.edu/ for more details.
> > warning:ManualComputeMajorTickMarks: The precision specified is smaller
> than the precision needed tick mark labels may not be correct
> > warning:ManualComputeMajorTickMarks: The precision specified is smaller
> than the precision needed tick mark labels may not be correct
> > warning:ManualComputeMajorTickMarks: The precision specified is smaller
> than the precision needed tick mark labels may not be correct
> > warning:ManualComputeMajorTickMarks: The precision specified is smaller
> than the precision needed tick mark labels may not be correct
> > warning:ManualComputeMajorTickMarks: The precision specified is smaller
> than the precision needed tick mark labels may not be correct
> > warning:ManualComputeMajorTickMarks: The precision specified is smaller
> than the precision needed tick mark labels may not be correct
> > warning:ManualComputeMajorTickMarks: The precision specified is smaller
> than the precision needed tick mark labels may not be correct
> > warning:ManualComputeMajorTickMarks: The precision specified is smaller
> than the precision needed tick mark labels may not be correct
> > warning:ManualComputeMajorTickMarks: The precision specified is smaller
> than the precision needed tick mark labels may not be correct
> > warning:ManualComputeMajorTickMarks: The precision specified is smaller
> than the precision needed tick mark labels may not be correct
> > warning:ManualComputeMajorTickMarks: The precision specified is smaller
> than the precision needed tick mark labels may not be correct
> > warning:ManualComputeMajorTickMarks: The precision specified is smaller
> than the precision needed tick mark labels may not be correct
> >
> > #####
> > begin
> > dirSst= "/fs3/SysE_DB/saji/OISST/Monthly/Mean/"
> > dirU= "/fs3/SysE_DB/nmm/CFSR/Monthly/Mean/"
> > ; dir2= (/"1981/","1982/","1983/"/)
> > dir2= (/"1986/","1987/","1988/"/)
> > ; dir2= (/"1996/","1997/","1998/"/)
> > mth=
> (/198601,198602,198603,198604,198605,198606,198607,198608,198609,198610,198611,198612,\
> >
> 198701,198702,198703,198704,198705,198706,198707,198708,198709,198710,198711,198712,\
> >
> 198801,198802,198803,198804,198805,198806,198807,198808,198809,198810,198811,198812/)
> > varName= (/"sst","us"/)
> > nyr= dimsizes(dir2)
> >
> > dim= dimsizes(mth)
> > yrF= new (dim, float)
> > do nd=0,dim-1
> > yyyy = mth(nd)/100
> > mon = mth(nd)-yyyy*100
> > yrF(nd) = yyyy + (mon-1)/12.
> > end do
> >
> > xx= new((/nyr*12/),float,"No_FillValue")
> > yy= new((/nyr*12/),float,"No_FillValue")
> > zz= new((/nyr*12/),float,"No_FillValue")
> >
> > do ny= 0,nyr-1
> > dir = str_concat(dirSst+dir2(ny))
> > fil= systemfunc("cd "+dir+" ; ls sst.nc")
> > f= addfile (dir+fil, "r")
> > x= f->$varName(0)$
> > dims = getfilevardims(f,varName(0))
> >
> > x1= x($dims(0)$|:,{$dims(1)$|10:-10},{$dims(2)$|50:70}) ; first
> domain
> > xs= dim_avg_n_Wrap( x1, (/1,2/) )
> >
> > y1= x($dims(0)$|:,{$dims(1)$|0:-10},{$dims(2)$|110:90}) ; second
> domain
> > ys= dim_avg_n_Wrap( y1, (/1,2/) )
> >
> > do i= 0,11
> > m= ny*12 +i
> > xx(m)= xs(i)
> > yy(m)= ys(i)
> > end do
> > end do
> >
> > dt= xx - yy
> > dt= dim_standardize(dt, 0)
> >
> > do ny= 0,nyr-1
> > dir = str_concat(dirU+dir2(ny))
> > fil= systemfunc("cd "+dir+" ; ls us.nc")
> > f= addfile (dir+fil, "r")
> > y= f->$varName(1)$
> > dims = getfilevardims(f,varName(1))
> >
> > y1:= y($dims(0)$|:,{$dims(1)$|5:-5},{$dims(2)$|70:90})
> > ys= dim_avg_n_Wrap( y1, (/1,2/) )
> >
> > z1:= y($dims(0)$|:,{$dims(1)$|5:-5},{$dims(2)$|:})
> > zs= dim_avg_n_Wrap( z1, (/1,2/) )
> >
> > do i= 0,11
> > m= ny*12 +i
> > yy(m)= ys(i)
> > zz(m)= zs(i)
> > end do
> > end do
> >
> > du= yy - zz
> > du= dim_standardize(du, 0)
> >
> > wks = gsn_open_wks ("X11", "dipoleMth87" )
> > res = True
> > res@gsnScale = True
> >
> > ; these four resources allow the user to stretch the plot size, and
> > ; decide exactly where on the page to draw it.
> >
> > res@vpXF = 0.10 ; In page coordinates, where to start
> > res@vpYF = 0.75 ; the plot
> > res@vpHeightF = 0.43 ; Changes the aspect ratio
> > res@vpWidthF = 0.85
> >
> > res@trYMinF = -3.0 ; min value on y-axis
> > res@trYMaxF = 3.0 ; max value on y-axis
> >
> > res@tiYAxisString = "Anomalies" ; y-axis label
> > ; res@tiMainString = "Dipole Mode Index and
> >
> > res@gsnYRefLine = 0. ; reference line
> > res@gsnXYBarChart = True ; create bar chart
> > res@gsnXYBarChartColors2 = (/"blue"/)
> >
> > res@tmXBMode = "Manual"
> > res@tmXBTickStartF = 1986
> > res@tmXBTickEndF = 1988
> > res@tmXBTickSpacingF= 1
> > res@tmXBPrecision = 4
> >
> > res@gsnDraw = False
> > res@gsnFrame = False
> >
> > plot1= gsn_csm_xy (wks,yrF,dt,res)
> > res@gsnXYBarChartColors2 =(/"red"/)
> > plot2= gsn_csm_xy (wks,yrF,du,res)
> >
> > lbres = True
> > lbres@vpWidthF = 0.2 ; labelbar width
> > lbres@vpHeightF = 0.1 ; labelbar height
> > lbres@lbBoxMajorExtentF = 0.36 ; puts space between color
> boxes
> > lbres@lbFillColors = (/"blue","red"/)
> > lbres@lbMonoFillPattern = True ; Solid fill pattern
> > lbres@lbLabelFontHeightF = 0.020 ; font height. default is
> small
> > lbres@lbLabelJust = "CenterLeft" ; left justify labels
> > lbres@lbPerimOn = False
> > lbres@lgPerimColor = "white"
> > labels = (/"Dipole Mode Index","Equitorial Zonal Wind Anomaly"/)
> > gsn_labelbar_ndc(wks,2,labels,0.10,0.25,lbres) ; draw right
> labelbar column
> >
> > overlay(plot1,plot2)
> > maximize_output(wks,True)
> > frame(wks)
> > 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
Received on Mon Nov 11 17:19:47 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 22 2013 - 09:36:32 MST