Re: tmXBValues is not working

From: Yi-Chih Huang <dscpln_at_nyahnyahspammersnyahnyah>
Date: Sat Dec 21 2013 - 23:38:59 MST

Will,

    "res@tmXBValues = ymt&month" is working.

    Thank you very much,

           Yi-Chih

On Sun, Dec 22, 2013 at 3:35 PM, Will Hobbs <Will.Hobbs@utas.edu.au> wrote:

> Yi-Cheh
>
> Forget using ispan(), and try the following:
>
> > res@tmXBValues = ymt&month
>
>
>
> From: Yi-Chih Huang <dscpln@gmail.com>
> Date: Sunday, 22 December 2013 5:27 PM
>
> To: Will Hobbs <will.hobbs@utas.edu.au>
> Cc: ncl-talk <ncl-talk@ucar.edu>
> Subject: Re: tmXBValues is not working
>
> Will,
>
> Thanks much. The range of x axis is [38881..38973]; but I want to
> show Jun-Sep instead of [38881..38973]. Even when I gave the following
> commands, 30.66 is not acceptable for ispan. [38881..38973] are from data.
> If I gave res@tmXBValues = ispan(38881,38973,30), it is working, but the
> time span of x axis is more than Sep. I wonder what would be a simple way
> to give exact Jun-Sep on x axis when the data of x axis is irregular.
> Unfortunately, this is a common situation.
>
> Thanks much,
>
> Yi-Chih
>
> res@trXMaxF = 38973
> res@trXMinF = 38881
> res@tmXBMode = "Explicit"
> res@tmXBValues = ispan(38881,38973,30.66)
> res@tmXBLabels = (/"Jun","Jul","Aug","Sep"/)
>
> #####
> Variable: ymt
> Type: float
> Total Size: 3600 bytes
> 900 values
> Number of Dimensions: 2
> Dimensions and sizes: [lat | 225] x [month | 4]
> Coordinates:
> lat: [-30..40]
> month: [38881..38973]
> Number Of Attributes: 13
> _FillValue : 1e+20
> DataFreq : Monthly
> average_op_ncl : dim_avg_n over dimension(s): lon
> lv_ISBL1 : 500
> center : US National Weather Service - NCEP (WMC)
> long_name : Temperature
> units : K
> level_indicator : 100
> gds_grid_type : 0
> parameter_table_version : 2
> parameter_number : 11
> model : Climate Data Assimilation System (CDAS)
> initial_time : 02/05/2006 (00:00)
>
>
> On Sun, Dec 22, 2013 at 3:14 PM, Will Hobbs <Will.Hobbs@utas.edu.au>wrote:
>
>> Yi-Cheh
>>
>> The problem is that you are setting a range of x using the tmXBValues
>> resource that is outside the range of the time coord for the data that you
>> are trying to plot.
>>
>> Th data you are trying to plot has x-coords (i.e. time) in the
>> range 38881-38973, but your plot domain specified by tmXBValues is 6-9; 6-9
>> is obviously not in the range of your input time data, so your plotting
>> domain has no data.
>>
>> You need to EITHER set tmXBValues so that the numbers correspond to the
>> values in the input data, OR change the time coord array of your data so
>> that it matches the range of tmXBValues.
>>
>> Will
>>
>> From: Yi-Chih Huang <dscpln@gmail.com>
>> Date: Sunday, 22 December 2013 11:48 AM
>>
>> To: Will Hobbs <will.hobbs@utas.edu.au>
>> Cc: ncl-talk <ncl-talk@ucar.edu>
>> Subject: Re: tmXBValues is not working
>>
>> Will,
>>
>> Y axis is latitude. The script is as follows. I got several
>> warnings. I wonder what is the problem?
>>
>> Thanks,
>>
>> Yi-Chih
>>
>> warning:ContourPlotSetValues: X coordinates out of data range:
>> defaulting
>> warning:ContourPlotSetValues: X coordinates out of data range: defaulting
>> warning:ContourPlotSetValues: X coordinates out of data range: defaulting
>>
>> #####
>> 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
>> latS = -30.0
>> latN = 40.0
>> lonE = 70.0
>> lonW = 90.0
>>
>> dir1 = "/fs3/SysE_DB/nmm/NMM/Monthly/Mean/"
>> yrStrt = 1981
>> yrLast = 2006
>> year = ispan(yrStrt, yrLast,1) ; integer
>> yrDir = year + "/" ; string
>> varName= (/"precip"/)
>> nyr = dimsizes(year)
>>
>> dir = str_concat(dir1+yrDir(0))
>> fil = systemfunc("cd "+dir+" ; ls precip.nc") ;;;;;;;; read
>> precipitation
>> f = addfile (dir+fil, "r")
>> x = f->$varName(0)$
>> dims= getfilevardims(f,varName(0))
>> xs = x(:,{latS:latN},{lonE:lonW}) ; JJAS tropical Pacific
>> xu = dim_avg_n_Wrap( xs,0)
>> ds = dimsizes(xs)
>> xx = new((/nyr,ds(0),ds(1),ds(2)/),float)
>>
>> delete (fil)
>> do ny= 0,nyr-1
>> dir = str_concat(dir1+yrDir(ny))
>> fil = systemfunc("cd "+dir+" ; ls precip.nc")
>> f = addfile (dir+fil, "r")
>>
>> x := f->$varName(0)$
>> dims= getfilevardims(f,varName(0))
>> xs := x(:,{latS:latN},{lonE:lonW}) ; Indian Ocean
>> xx(ny,:,:,:)= xs
>> end do
>> printMinMax(xx,True)
>> printVarSummary(xx)
>>
>> xx!0 = "year"
>> xx!1 = "time"
>> pcpy = dim_avg_n_Wrap( xx,0 ) *86400 ; kg/m^2/s -> mm/day
>> copy_VarMeta(xs,pcpy)
>> pcp = dim_avg_n_Wrap( pcpy,2 )
>> printVarSummary(pcp)
>> pcp!0 = "time"
>> pcp!1 = "lat"
>> ymIn = pcp(lat|:,time|:)
>> printMinMax(pcp,True)
>> printVarSummary(ymIn)
>>
>> lonE = 120.0
>> lonW = 140.0
>>
>> delete (xx)
>> xx = new((/nyr,ds(0),ds(1),ds(2)/),float)
>> do ny= 0,nyr-1
>> dims = getfilevardims(f,varName(0))
>> xs := x(:,{latS:latN},{lonE:lonW}) ; Indian Ocean
>> xx(ny,:,:,:)= xs
>> end do
>>
>> xx!0 = "year"
>> xx!1 = "time"
>> pcpy = dim_avg_n_Wrap( xx,0 ) *86400 ; kg/m^2/s -> mm/day
>> copy_VarMeta(xs,pcpy)
>> printVarSummary(pcpy)
>> printVarSummary(pcp )
>> pcp = dim_avg_n_Wrap( pcpy,2 )
>> pcp!0 = "time"
>> pcp!1 = "lat"
>> ymAu = pcp(lat|:,time|:)
>> printMinMax(pcp,True)
>> printVarSummary(ymAu)
>>
>> dir1 = "/fs3/SysE_DB/nmm/NMM/Monthly/Mean/"
>> year = ispan(yrStrt, yrLast,1) ; integer
>> dirY = year + "/" ; string
>> dir = str_concat(dir1+dirY(0))
>>
>> lvl = (/"200","500"/)
>> nlvl = dimsizes(lvl)
>> varName= (/"temp"/)
>> nyr = yrLast -yrStrt +1
>>
>> lonE = 30.0
>> lonW = 110.0
>>
>> dir = str_concat(dir1+dirY(0))
>> fil = systemfunc("cd "+dir+" ; ls temp_500.nc")
>> f = addfile (dir+fil(0), "r")
>> t = f->$varName(0)$
>> dims = getfilevardims(f,varName(0))
>> ts = t($dims(0)$|:,{$dims(1)$|latS:latN},{$dims(2)$|lonE:lonW})
>> ds = dimsizes(ts)
>> ty = new((/nyr,4,nlvl,ds(1),ds(2)/),float) ; only JJAS in NMM
>> data
>>
>> delete (fil)
>> do ny= 0,nyr-1
>> dir = str_concat(dir1+dirY(ny))
>> fil = systemfunc("cd "+dir+" ; ls temp_200.nctemp_500.nc")
>> nlvl = dimsizes(fil)
>>
>> do nl= 0,nlvl-1
>> f = addfile (dir+fil(nl), "r")
>> t = f->$varName(0)$
>> dims = getfilevardims(f,varName(0))
>> ts = t($dims(0)$|:,{$dims(1)$|latS:latN},{$dims(2)$|lonE:lonW})
>> ty(ny,:,nl,:,:)= ts
>> end do
>> end do
>>
>> ty!0 = "year"
>> ty!1 = "time"
>> ty!2 = "label"
>> tl = dim_avg_n_Wrap( ty, 2 )
>> tm = dim_avg_n_Wrap( tl, 0 )
>> tlat = dim_avg_n_Wrap( tm, 2 )
>> ymt = tlat(lat|:,time|:)
>> printVarSummary(ymt)
>>
>> wks= gsn_open_wks("X11","ITCZtime_NMM")
>> 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
>> res@trYMaxF = 40
>> res@trYMinF = -30
>> res@trXMaxF = 6
>> res@trXMinF = 9
>> res@tmXBMode = "Explicit"
>> res@tmXBValues = ispan(6,9,1)
>> res@tmXBLabels = (/"Jun","Jul","Aug","Sep"/)
>> res@tmXTMode = "Explicit"
>> res@tmXTValues = ispan(6,9,1)
>> res@tmXTLabels = (/"Jun","Jul","Aug","Sep"/)
>>
>> ; res@vpWidthF = 0.8
>> ; res@vpHeightF = 0.4
>>
>> res@gsnDraw = False
>> res@gsnFrame = False
>>
>> plot = new(3,graphic)
>> res@gsnLeftString = "Average Monthly Rate of Precipitation"
>> res@cnLevelSelectionMode = "ManualLevels"
>> res@gsnRightString = "mm/day"
>> res@cnMinLevelValF = 1
>> res@cnMaxLevelValF = 11
>> res@cnLevelSpacingF = 1
>>
>> plot(0) = gsn_csm_lat_time(wks, ymIn, res)
>> plot(1) = gsn_csm_lat_time(wks, ymAu, res)
>>
>> res@gsnLeftString = "Temperature"
>> res@gsnRightString = "K"
>> res@cnMinLevelValF = 232
>> res@cnMaxLevelValF = 248
>> res@cnLevelSpacingF = 2
>> plot(2) = gsn_csm_lat_time(wks, ymt , res)
>> gsn_panel(wks,plot,(/3,1/),False)
>>
>> ; return ([/ymIn,ymAu,ymt/])
>> end
>>
>>
>> On Sun, Dec 22, 2013 at 9:20 AM, Will Hobbs <Will.Hobbs@utas.edu.au>wrote:
>>
>>> Yi-Cheh
>>>
>>> I can't possibly answer that question in detail without knowing more
>>> about the y-data that you are trying to plot.
>>>
>>> However, put simply you will need to create a dummy array for your
>>> time that just gives the month index. Assuming that you have a valid time
>>> coord system, you could try this (again, with the caveat that I really
>>> don't know what you are trying to plot:
>>>
>>> > tdum = cd_calendar(y&time, -5) ; integer array giving year,
>>> month,day and time for each data point
>>> >xdum = tdum(:,1) ;integer array of
>>> months,numbered 1-12
>>> > res@tmXMinF = 6
>>> > res@tmXMaxF = 9
>>> > res@tmXBMode = "Explicit"
>>> > res@tmXBValues = ispan(6,9,1)
>>> ; label indices for Jun-Sep only
>>> > res@tmXBLabels = (/"Jun","Jul","Aug","Sep"/)
>>>
>>> >plot = gsn_csm_xy(wks, xdum, y, res)
>>>
>>>
>>> This is just one way of many of doing what you are trying to do, and
>>> may or may not be the most effective given the data you have.
>>>
>>> Will
>>>
>>> From: Yi-Chih Huang <dscpln@gmail.com>
>>> Date: Sunday, 22 December 2013 11:10 AM
>>> To: Will Hobbs <will.hobbs@utas.edu.au>
>>> Cc: ncl-talk <ncl-talk@ucar.edu>
>>> Subject: Re: tmXBValues is not working
>>>
>>> Will,
>>>
>>> Thanks for the reply. I don't want 38881-38973 showing up on x
>>> axis, but Jun-Sep. How to make sure that x-array in gsn_csm_xy() is
>>> within the range of tmXBValues (i.e. 0-3)?
>>>
>>> Thanks much,
>>>
>>> Yi-Chih
>>>
>>>
>>> On Sun, Dec 22, 2013 at 9:06 AM, Will Hobbs <Will.Hobbs@utas.edu.au>wrote:
>>>
>>>> Yi-Chih
>>>>
>>>> Have you ensured that the x-array in gsn_csm_xy() is within the range
>>>> of tmXBValues (i.e. 0-3)?
>>>>
>>>> Your post is a bit unclear, but it sounds like you have an x-array
>>>> of 38881-38973, which is outside your plot domain (i.e. 0-3).
>>>>
>>>> Will
>>>>
>>>> From: Yi-Chih Huang <dscpln@gmail.com>
>>>> Date: Sunday, 22 December 2013 10:34 AM
>>>> To: ncl-talk <ncl-talk@ucar.edu>
>>>> Subject: tmXBValues is not working
>>>>
>>>> Hello,
>>>>
>>>> I am trying to label x axis by the following two sets of
>>>> commands. However, nothing was labeling on x axis for the first set of
>>>> commands; The time range [38881..38973] was labeled on x axis for the
>>>> second set of commands. Could anyone indicate the right commands to label
>>>> x axis?
>>>>
>>>> res@tmXBMode = "Explicit"
>>>> res@tmXBValues = ispan(0,3,1)
>>>> res@tmXBLabels = (/"Jun","Jul","Aug","Sep"/)
>>>>
>>>> res@tmXTMode = "Explicit"
>>>> res@tmXTValues = ispan(0,3,1)
>>>> res@tmXTLabels = (/"Jun","Jul","Aug","Sep"/)
>>>>
>>>> Thanks much,
>>>>
>>>> Yi-Chih
>>>>
>>>
>>>
>>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sat Dec 21 23:39:14 2013

This archive was generated by hypermail 2.1.8 : Mon Jan 06 2014 - 13:02:22 MST