Re: give tick marks on a longitude-time plot

From: Yi-Chih Huang <dscpln_at_nyahnyahspammersnyahnyah>
Date: Tue Nov 05 2013 - 01:01:02 MST

Hello,

    I modified Dennis' script to calculate anomies. I don't understand why
there is "Coordinate variables" problem, especially I copy variable
coordinate to the variable in the Hovmoller diagram and didn't change the
commands about time axis. In addition, I executed "dimsizes(pcps)". Why
does the warning "warning:Dimension (0) has not been defined" still show up?

    Thanks,

               Yi-Chih

########
yhuang@arc-env:/fs3/yhuang/scripts$ ncl pcpSstTime.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.
(0) a
warning:Dimension (0) has not been defined
(0) b
fatal:Coordinate variables must be the same dimension as their dimension
fatal:No coordinate variable exists for dimension (time) in variable (dpcp)
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 89 in file
pcpSstTime.ncl

###
load "$SysE/lib/ncl/helper_libs.ncl"

begin
  latS = -5.0
  latN = 5.0
  lonE = 120.0
  lonW = 280.0

  yrStrt = 1979
  yrLast = 2009

  in = addfile("/fs3/yhuang/precip.mon.mean.nc","r") ; 197901-201306
  YMDHMS = cd_calendar(in->time, 0) ; all times
                                              ; index for desired time
  iYear = ind(YMDHMS(:,0).ge.yrStrt .and. YMDHMS(:,0).le.yrLast)
                                              ; read time and region
  precip = in->precip(iYear,{latS:latN},{lonE:lonW})
  pcpClm = clmMonTLL( precip )

  xt= precip(0:23,{latS:latN},{lonE:lonW})
  ds= dimsizes(xt)
  nyr= yrLast -yrStrt +1
  pcpm= new((/ds(0),ds(2)/),float)

  yyyymmM = cd_calendar(precip&time,-1) ; verify times are correct

  dimp = dimsizes(precip)
  ntim = dimp(0)
  nlat = dimp(1)
  mlon = dimp(2)

  pcpt = dim_avg_n_Wrap( pcpClm,1 ) ; (time,lat)
  do nm= 0,11
    pcpm(nm,:) = pcpt(nm,:)
    pcpm(nm+12,:)= pcpt(nm,:)
  end do

  yStrt = (/"1981/","1985/","1996/"/)
  yLast = (/"1983/","1987/","1998/"/)
  nyrs= dimsizes(yStrt)

  in= addfile("/fs3/yhuang/precip.mon.mean.nc","r") ; 197901-201306
  prec= in->precip
  xt= prec(0:23,{latS:latN},{lonE:lonW})
  ds= dimsizes(xt)
  pcps= new((/nyrs,ds(0),ds(2)/),float)

  do ny= 0,nyrs-1 ; precipitation in ENSO years
    iYr = ind(YMDHMS(:,0).ge.yStrt(ny) .and. YMDHMS(:,0).le.yLast(ny))
                                              ; read time and region
    preci = in->precip(iYr,{latS:latN},{lonE:lonW})

    yyyymmE = cd_calendar(preci&time,-1) ; verify times are correct

    dimp = dimsizes(preci)
    ntim = dimp(0)
    nlat = dimp(1)
    mlon = dimp(2)

    pcps(ny,:,:)= dim_avg_n_Wrap( preci,1 ) ; (time,lat)
  end do

  dimp = dimsizes(pcps)
  ntim = dimp(0)
print("a")
  pcpE= dim_avg_n_Wrap( pcps, 0 )
print("b")
  dpcp= pcpE - pcpm
  copy_VarCoords(pcpE,dpcp)

  wks= gsn_open_wks("X11","pcpa")
  gsn_define_colormap(wks,"BlueRed")

  res = True
  res@gsnAddCyclic = False

  res@cnFillOn = True
  res@cnLinesOn = False ; turn off the contour
lines
  res@cnLineLabelsOn = False
  res@cnSpanFillPalette = True

  res@gsnSpreadColors = True ; use full colormap
  res@gsnSpreadColorStart = 10 ; for BlueRed
  res@gsnSpreadColorEnd = 250 ; for BlueRed

  yr= ispan(1,ntim,1)
  yr@long_name = "months"
  delete(dpcp&time)
  dpcp&time = yr
  plot = gsn_csm_hov(wks,dpcp,res)
end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Nov 5 01:01:21 2013

This archive was generated by hypermail 2.1.8 : Mon Nov 11 2013 - 09:45:34 MST