Re: Problem with the function time_axis_labels

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 03 2014 - 16:15:56 MDT

When you call "addfiles", this returns a List type and not a file pointer like "addfile" returns.
To read variables using a List type, you must include the [:] syntax.

Try this:

times = wrf_times_c(a[:]->Times,0)

On Jun 3, 2014, at 11:55 AM, Luis Cesareo Cana Cascallar <luis.cana@ulpgc.es> wrote:

> Dear Mary,
>
> I’ve seen this example prior to write my script, but I found a problem. If I follow the steps suggested by time_labels_3.ncl, I get the following error:
> ==========
> NCAR Command Language Version 6.2.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> fatal:(a) not reference to a valid file
> fatal:["Execute.c":8567]:Execute: Error occurred at or near line 74 in file Comparar_series_temporales.ncl
> ==========
> and this is line 74:
> times = wrf_times_c(a->Times,0)
>
>
> There is a big difference between the example and my script: the example opens one single file (a); however I must open several files, and I do it with the following code:
>
> ===============
> ; get list of all files and open as "one big file"
>
> DATADir = "/Users/lcana/Results/Time_series/"
> FILES = systemfunc (" ls -1 " + DATADir + "wrfout_d02_2007* ")
> numFILES = dimsizes(FILES)
> a = addfiles(FILES,"r")
> ===============
>
> In my script, (a) refers to several files. Is this the reason of the error in line 74? If so, how can I do it using several files?
>
> Best,
>
> Luis
>
>
>
> El 03/06/2014, a las 16:11, Mary Haley <haley@ucar.edu> escribió:
>
>> Dear Luis,
>>
>> The error:
>>
>> fatal:Argument type mismatch on argument (0) of (time_axis_labels) can not coerce
>>
>> is telling you that the first input argument to time_axis_labels is the wrong type. Usually when I see this message, I go to the documentation for the function to see what that first argument is supposed to be:
>>
>> http://www.ncl.ucar.edu/Document/Functions/User_contributed/time_axis_labels.shtml
>>
>> "time_axis_labels" is expecting a numeric time value, but you are giving it a string value.
>>
>> You need to convert these string values to numeric values before calling time_axis_labels, and you can do this with the wrf_times_c function. Please see example "time_labels_3.ncl" at:
>>
>> http://www.ncl.ucar.edu/Applications/time_labels.shtml#ex3
>>
>> --Mary
>>
>> On Jun 2, 2014, at 10:01 AM, Luis Cesareo Cana Cascallar <luis.cana@ulpgc.es> wrote:
>>
>>> Dear all,
>>> I’m plotting time series of several variables taken from a WRF output. I get the time information from the wrf file to use it as the input for the X axis. These lines resume how I do it:
>>>
>>> ===============================================
>>>
>>> times = wrf_user_getvar(a,"times",-1) ; get all times in the file
>>> print(times)
>>>
>>>
>>>
>>> resplot = True
>>> restick = True
>>> restick@ttmFormat = "%N/%D %H:%M"
>>>
>>> time_axis_labels (times,resplot,restick)
>>>
>>> t2_plot = gsn_csm_xy(wks,times,t2_point,resplot)
>>> ===============================================
>>>
>>> I printed the variable “times” and it shows the following:
>>>
>>> **********************************
>>> Variable: times
>>> Type: string
>>> Total Size: 240 bytes
>>> 30 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes:
>>> [30]
>>> Coordinates:
>>> Number Of Attributes: 2
>>> _FillValue :
>>> missing
>>> description :
>>> times in file
>>> (0)
>>> 2007-04-10_06:00:00
>>> (1)
>>> 2007-04-10_06:30:00
>>> (2)
>>> 2007-04-10_07:00:00
>>> (3)
>>> 2007-04-10_07:30:00
>>> (4)
>>> 2007-04-10_08:00:00
>>> (5)
>>> 2007-04-10_08:30:00
>>> (6)
>>> 2007-04-10_09:00:00
>>> (7)
>>> 2007-04-10_09:30:00
>>> (8)
>>> 2007-04-10_10:00:00
>>> (9)
>>> 2007-04-10_10:30:00
>>> (10)
>>> 2007-04-10_11:00:00
>>> (11)
>>> 2007-04-10_11:30:00
>>> (12)
>>> 2007-04-10_12:00:00
>>> (13)
>>> 2007-04-10_12:30:00
>>> (14)
>>> 2007-04-10_13:00:00
>>> (15)
>>> 2007-04-10_13:30:00
>>> (16)
>>> 2007-04-10_14:00:00
>>> (17)
>>> 2007-04-10_14:30:00
>>> (18)
>>> 2007-04-10_15:00:00
>>> (19)
>>> 2007-04-10_15:30:00
>>> (20)
>>> 2007-04-10_16:00:00
>>> (21)
>>> 2007-04-10_16:30:00
>>> (22)
>>> 2007-04-10_17:00:00
>>> (23)
>>> 2007-04-10_17:30:00
>>> (24)
>>> 2007-04-10_18:00:00
>>> (25)
>>> 2007-04-10_18:30:00
>>> (26)
>>> 2007-04-10_19:00:00
>>> (27)
>>> 2007-04-10_19:30:00
>>> (28)
>>> 2007-04-10_20:00:00
>>> (29)
>>> 2007-04-10_20:30:00
>>> **********************************
>>>
>>> It looks OK for me, but when I run the script, I get the following error:
>>> fatal:Argument type mismatch on argument (0) of (time_axis_labels) can not coerce
>>> fatal:["Execute.c":8567]:Execute: Error occurred at or near line 118 in file Comparar_series_temporales.ncl
>>>
>>> It seems that there is something wrong when I call time_axis_labels. Could anyone tell me how to do it to get a nice formatted X axis with the hour:minute as the tick mark?
>>> Thanks in advance,
>>>
>>> Luis
>>> ULPGC
>>>
>>> _______________________________________________
>>> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jun 03 16:16:09 2014

This archive was generated by hypermail 2.1.8 : Sat Jun 07 2014 - 11:03:12 MDT