Re: how to use "time_axis_labels"?

From: BasitAli Khan <BasitAli.Khan_at_nyahnyahspammersnyahnyah>
Date: Tue May 29 2012 - 07:11:05 MDT

Thanks Arindam and Alan for your help and suggestions. Its all done nice and clean. I am copying the ncl code for wrfoutput just incase somebody else needs it.

load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"

begin

 f1 = addfile("/project/k14/basit/wrf-sims/wrf_153/times.nc","r")
 f2 = addfile("/project/k14/basit/wrf-sims/wrf_153/tauaer2.nc","r")

 wks = gsn_open_wks ("x11","outFname")

 times_f1 = wrf_user_list_times(f1)
 nTimes = dimsizes(times_f1)

 date_f1 = times_f1
 year_f1 = stringtointeger(str_get_cols(date_f1,0,3))
 month_f1 = stringtointeger(str_get_cols(date_f1,5,6))
 day_f1 = stringtointeger(str_get_cols(date_f1,8,9))
 hour_f1 = stringtointeger(str_get_cols(date_f1,11,12))
 minutes_f1 = stringtointeger(str_get_cols(date_f1,14,15))
 seconds_f1 = stringtointeger(str_get_cols(date_f1,17,18))

 aoT2 = wrf_user_getvar(f2,"TAUAER2", -1)
 aoT2_f2 = aoT2(:,0,300,300)

 units1= "days since 2006-06-02 00:00:00"
 newdate = cd_inv_calendar(year_f1,month_f1,day_f1,hour_f1,minutes_f1,seconds_f1, units1, 0)

 newdate@units= units1
 resplot =True
 restick = True
 restick@ttmFormat="%Y-%N-%D_%H:%M:%S"
 restick@ttmMajorStride=4
 restick@ttmAxis ="XB"

time_axis_labels(newdate,resplot,restick)

 plot = gsn_csm_xy(wks, newdate, aoT2_f2, resplot)

end

Thanks again,

----
Basit A. Khan, Ph.D.
Postdoctoral Research Fellow
Division of Physical Sciences & Engineering
Office# 3204, Level 3, Building 1,
King Abdullah University of Science & Technology
4700 King Abdullah Blvd, Box 2753, Thuwal 23955 –6900,
Kingdom of Saudi Arabia.
Office: +966(0)2 808 0276,  Mobile: +966(0)5 0860 3617
E-mail: basitali.khan@kaust.edu.sa<mailto:basitali.khan@kaust.edu.sa>
Skype name: basit.a.khan
From: Arindam Chakraborty <arch@caos.iisc.ernet.in<mailto:arch@caos.iisc.ernet.in>>
Reply-To: "arch13@gmail.com<mailto:arch13@gmail.com>" <arch13@gmail.com<mailto:arch13@gmail.com>>
Date: Mon, 28 May 2012 14:42:43 +0300
To: KAUST <basitali.khan@kaust.edu.sa<mailto:basitali.khan@kaust.edu.sa>>
Cc: "ncl-talk@ucar.edu<mailto:ncl-talk@ucar.edu>" <ncl-talk@ucar.edu<mailto:ncl-talk@ucar.edu>>
Subject: Re: how to use "time_axis_labels"?
hi Basit,
 you are almost there. After you convert those strings to integers (year, month, day etc individually for every time of output), use those in cd_inv_calendar() to get the coordinate value of 'time' axis. Now, to do this, you'll require to chose a 'units'. Examples are there inside that routine. Use that same units as 'units' attribute of the variable (1-d array) you've just calculated at every time of output. This variable can now be the input to time_axis_labels().
regards,
--
Dr Arindam Chakraborty
Assistant Professor
Centre for Atmospheric and Oceanic Sciences
Indian Institute of Science
Bangalore - 560 012, INDIA.
Tel: +91-80-22933074
http://caos.iisc.ernet.in/<http://caos.iisc.ernet.in/faculty/arch>
On Mon, May 28, 2012 at 4:04 PM, BasitAli Khan <BasitAli.Khan@kaust.edu.sa<mailto:BasitAli.Khan@kaust.edu.sa>> wrote:
Dear Chakraborty,
Thanks for the prompt reply.
Well, .. When you say numeric value (not a string) it means the entire date and time value should be an  integer  ….  right?  The date and time value is one string (can be obtained as one string) for every history time in wrfout. So what I do is pick the numeric part of date and time from that string and convert it into integer. But then I would have 6 different variables  I.e  year, month, day, hour, minutes and seconds. I can't obviously add them to get them in time_label_axis, I can only put them in an array however, time_axis_label won't accept any 2 dimensional array for its 0th argument.
Sorry, I am still far from reaching any solution. If you have some ncl script written  for wrfoutput, that probably could help me in getting this done.
Cheers,
----
Basit A. Khan, Ph.D.
Postdoctoral Research Fellow
Division of Physical Sciences & Engineering
Office# 3204, Level 3, Building 1,
King Abdullah University of Science & Technology
4700 King Abdullah Blvd, Box 2753, Thuwal 23955 –6900,
Kingdom of Saudi Arabia.
Office: +966(0)2 808 0276,  Mobile: +966(0)5 0860 3617
E-mail: basitali.khan@kaust.edu.sa<mailto:basitali.khan@kaust.edu.sa>
Skype name: basit.a.khan
From: Arindam Chakraborty <arch@caos.iisc.ernet.in<mailto:arch@caos.iisc.ernet.in>>
Reply-To: "arch13@gmail.com<mailto:arch13@gmail.com>" <arch13@gmail.com<mailto:arch13@gmail.com>>
Date: Mon, 28 May 2012 12:35:31 +0300
To: KAUST <basitali.khan@kaust.edu.sa<mailto:basitali.khan@kaust.edu.sa>>
Cc: "ncl-talk@ucar.edu<mailto:ncl-talk@ucar.edu>" <ncl-talk@ucar.edu<mailto:ncl-talk@ucar.edu>>
Subject: Re: how to use "time_axis_labels"?
hi Basit,
 make sure that the 0th argument to time_axis_label() is an 1-d array containing the 'time' values as numbers. The numbers must have been calculated from a origin with a proper units, specified by the "units" attribute to the 0th argument. In your case, please make sure that 'newdate' is a numerical variable and not a string, and has a units attribute something of this form: "days since yyyy-mm-dd hh:mm:ss". Check cd_inv_calendar() for more details about this "units" attribute.
regards,
--
Dr Arindam Chakraborty
On Mon, May 28, 2012 at 2:32 PM, BasitAli Khan <BasitAli.Khan@kaust.edu.sa<mailto:BasitAli.Khan@kaust.edu.sa>> wrote:
Hi NCL users,
I have been trying to use time_axis_labels to plot an xy-plot from my wrfoutput however, I am getting the following error.
fatal:Argument type mismatch on argument (0) of (time_axis_labels) can not coerce
I looked at NCL mail archive and tried Saji Hameed's solution but that also didn't work for me. I would greatly appreciate if some could help to fix this.  My script for the xy plot is copied below.
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/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
begin
 f1 = addfile("/project/k14/basit/wrf-sims/wrf_153/times.nc<http://times.nc>","r")
 f2 = addfile("/project/k14/basit/wrf-sims/wrf_153/tauaer2.nc<http://tauaer2.nc>","r")
 wks   = gsn_open_wks ("x11","outFname")
 nTimes = dimsizes(times_f1)
 date_f1    = times_f1
 year_f1    = str_get_cols(date_f1,0,3)
 month_f1   = str_get_cols(date_f1,5,6)
 day_f1     = str_get_cols(date_f1,8,9)
 hour_f1    = str_get_cols(date_f1,11,12)
 minutes_f1 = str_get_cols(date_f1,14,15)
aoT2   = wrf_user_getvar(f2,"TAUAER2", -1)
 aoT2_new = aoT2(:,0,300,300)
 newdate=year_f1+month_f1+day_f1+hour_f1+minutes_f1
 resplot =True
 restick = True
 restick@ttmFormat="%Y%N%D%H%M"
 newdate@units="200606010000"
 restick@ttmAxis ="XB"
 print(newdate)
time_axis_labels(newdate,resplot,restick)
 plot = gsn_csm_xy(wks, aoT2_new,newdate,resplot)
end
Thanks and best regards,
----
Basit A. Khan, Ph.D.
Postdoctoral Research Fellow
Division of Physical Sciences & Engineering
Office# 3204, Level 3, Building 1,
King Abdullah University of Science & Technology
4700 King Abdullah Blvd, Box 2753, Thuwal 23955 –6900,
Kingdom of Saudi Arabia.
Office: +966(0)2 808 0276,  Mobile: +966(0)5 0860 3617
E-mail: basitali.khan@kaust.edu.sa<mailto:basitali.khan@kaust.edu.sa>
Skype name: basit.a.khan
--
This message has been scanned for viruses and
dangerous content by MailScanner<http://www.mailscanner.info/>, and is
believed to be clean.
_______________________________________________
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 Tue May 29 07:11:26 2012

This archive was generated by hypermail 2.1.8 : Wed May 30 2012 - 09:25:29 MDT