Re: Time Units

From: Kyle Griffin <ksgriffin2_at_nyahnyahspammersnyahnyah>
Date: Mon Feb 11 2013 - 07:11:28 MST

Hi Ahmed,

You'll have to turn these dates into a date format understood by NCL. In
this case, you can use cd_inv_calendar to do the job.

timeUnits = "days since 1-1-1 00:00:00"
time = cd_inv_calendar(years,months,days,00,00,00.0,timeUnits,0)

When doing this, cd_inv_calendar will assign the @units itself. The choice
of units in my code is arbitrary; it could be anything here as long as you
give it to "time" for time_axis_labels to read later.

Kyle

----------------------------------------
Kyle S. Griffin
Department of Atmospheric and Oceanic Sciences
University of Wisconsin - Madison
1225 W Dayton St, Madison, WI 53706
Email: ksgriffin2@wisc.edu

On Mon, Feb 11, 2013 at 2:47 AM, Ahmed Lasheen <ahmed4kernel@gmail.com>wrote:

> Dear All,
>
> I am trying to plot station data consists of two column, the fist
> column is the data which is written in the following format (YYYYMMDD) and
> the other column is the variable. When I use the time_axis_label , I got
> the following error.
>
> function (0) time_axis_labels: The variable containing time values must
> have a 'units' attribute.
>
> I wrote the following command for defining the time units , but is also
> not true time@units="months", I know that time units is something like
> that "hours since 1-1-1 00:00:00", but I actually have the time itself not
> a number of hours or months. I don't know what to wrote for units.
>
> The following is the script
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> ;************************************************
> begin
> ;************************************************
> ; plotting parameters
> ;************************************************
> new_rows=systemfunc("wc -l a.txt| cut -d' ' -f1")
> days=systemfunc("cut -c1-2 a.txt")
> months=systemfunc("cut -c3-4 a.txt")
> years=systemfunc("cut -c5-8 a.txt")
> var=systemfunc("cut -f2 -d' ' a.txt")
> print(var)
> time=years+months+days
> print(time)
> wks = gsn_open_wks ("x11","xy") ;
> open workstation
> res = True ; plot mods desired
> res@tiMainString = "Multiple XY plot" ; add title
> res@tiMainString = "Mulitple XY plot with markers" ; add title
> resplot = True
> restick = True
> restick@ttmFormat = "%Y%N%D"
>
> time@units="months"
> time_axis_labels(tointeger(time),resplot,restick) ; call the formatting
> procedure
>
> plot = gsn_csm_xy (wks,time,tointger(var),res) ; create plot
> end
>
>
>
> I have attached the script and the data file.
> Thanks in advance
> --
> ===============
> Ahmed Lasheen
> Junior researcher at Cairo Numerical Weather Prediction Center (CNWPC)
> Egyptian Meteorological Authority(EMA)
> Cairo,Egypt
> ===============
>
> _______________________________________________
> 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 Feb 11 07:12:08 2013

This archive was generated by hypermail 2.1.8 : Wed Feb 13 2013 - 09:25:58 MST