[ncl-talk] Error with "time_axis_labels(cd_date, resT1, restick)"

Barry Lynn barry.h.lynn at gmail.com
Thu Jul 11 08:39:29 MDT 2019


Hi:

Look within for how I extract year, month, etc, and then use it to obtain
the time-var (just day and time, but you can add back the month).

I then write some fraction of the times on the xaxis.

Barry

On Thu, Jul 11, 2019 at 12:52 PM Zilore Mumba <zmumba at gmail.com> wrote:

> thanks Barry, you can please send me the code. i will appreciate.
> Good day
>
> On Thu, Jul 11, 2019 at 11:23 AM Barry Lynn <barry.h.lynn at gmail.com>
> wrote:
>
>> Hi Zilore:
>>
>> If you are "simply" trying to put time information on your xaxis, then I
>> can probably send you the code to do it.  It is a few more lines than what
>> you are using, but if you can separate out the year, month, day, etc from
>> the string, then it is straightforward to use.
>>
>> Barry
>>
>> On Thu, Jul 11, 2019 at 12:09 PM Zilore Mumba <zmumba at gmail.com> wrote:
>>
>>> Sorry, my intention is not to cause any confusion. I did load the
>>> package. What I was requesting is assistance on whether I called the
>>> package with the correct arguments.
>>> My sincere apologies if I have caused any wasted time or irirtation.
>>>
>>> On Thu, Jul 11, 2019 at 1:14 AM Rick Brownrigg <brownrig at ucar.edu>
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I'm confused by this thread -- where does cd_string enter? I don't see
>>>> it referenced in the script.
>>>>
>>>> If the error messages are saying time_axis_labels is undefined, then as
>>>> Dave has pointed out, the docs say to load:
>>>>
>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
>>>>
>>>> See:
>>>>
>>>> http://ncl.ucar.edu/Document/Functions/User_contributed/time_axis_labels.shtml
>>>>
>>>> Rick
>>>>
>>>>
>>>> On Wed, Jul 10, 2019 at 3:07 PM Zilore Mumba via ncl-talk <
>>>> ncl-talk at ucar.edu> wrote:
>>>>
>>>>> Thanks Barry, I did not realise that the contribute script I used was
>>>>> from WRF.
>>>>> However even with the right script I still get the same error. Perhaps
>>>>> you could help me, look at the script and see where am doing it wrong,
>>>>> especially where I use cd_calendar and date&time.
>>>>> The script is below. I know it is cumbersome because you do not have
>>>>> my data. But I will appreciate any help
>>>>> ;-----------------------------------------------------------------
>>>>> ;  Adapted from DKRZ - NCL Example:   NCL_xy_multiple_lines_axis.ncl
>>>>> ;-----------------------------------------------------------------
>>>>>
>>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"
>>>>>
>>>>> begin
>>>>>
>>>>>    filein =
>>>>> "/home/zmumba/DATA/tasmax_AFR-44_CNRM-CERFACS-CNRM-CM5_historical_r1i1p1_CLMcom-CCLM4-8-17_v1_day_19960101-20001231.nc"
>>>>>           ; file name
>>>>>
>>>>>    f = addfile(filein,"r")                  ; open file
>>>>>
>>>>>    tmax = f->tasmax(:,{-15},{25})           ; read tmax, all
>>>>> timesteps, 15S/25E
>>>>>
>>>>>    t = f->time                              ; for use in x-axis label
>>>>>    cd_date = cd_calendar(t, -2)
>>>>>
>>>>> ; open a workstation
>>>>>    wks_type = "X11"                         ; graphics output type
>>>>>    wks_type at wkWidth   =  1024               ; graphics output width
>>>>> in pixels
>>>>>    wks_type at wkHeight  =  1024               ; graphics output height
>>>>> in pixels
>>>>>
>>>>>    wks = gsn_open_wks(wks_type, "plot_xy_tie_series")
>>>>>
>>>>> ; resources for variable tmax y-axis
>>>>>    res                      =  True
>>>>>    res at xyLineThicknessF     =  3.0                        ; set line
>>>>> thickness
>>>>>    res at xyLineColor          =  "red"                      ; set line
>>>>> color
>>>>>    res at xyDashPatterns       =  0                          ; solid line
>>>>>    res at tmXBLabelFontHeightF = 0.010
>>>>>    res at tiYAxisString        =  "Daily Max. 2m" + " " +
>>>>> tmax at standard_name +"  "+ "at 15S/25E"
>>>>>               ; axis string
>>>>>
>>>>>    restick                    = True                      ; resource
>>>>> object
>>>>>    restick at ttmFormat          = "%d %c"
>>>>>    restick at ttmAxis            = "YL"
>>>>>    restick at ttmMajorStride     = 20
>>>>>    restick at ttmValues          = cd_date
>>>>>
>>>>>    time_axis_labels(date&time,res,restick)
>>>>>
>>>>> ; create the plot
>>>>>    plot = gsn_csm_xy(wks, t, tmax, res)
>>>>>
>>>>> end
>>>>>
>>>>> On Tue, Jul 9, 2019 at 7:33 PM Barry Lynn <barry.h.lynn at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Try this one.
>>>>>>
>>>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"
>>>>>>
>>>>>> On Tue, Jul 9, 2019 at 7:18 PM Dave Allured - NOAA Affiliate via
>>>>>> ncl-talk <ncl-talk at ucar.edu> wrote:
>>>>>>
>>>>>>> That is not the correct load command for this function.
>>>>>>> Time_axis_labels is loaded separately.  Please go to the documentation page
>>>>>>> for time_axis_labels, find the correct load command at the top of that
>>>>>>> page, and add it to your script.
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jul 9, 2019 at 12:27 AM Zilore Mumba <zmumba at gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Thanks Dave for the hint. i did load the contributed package. I
>>>>>>>> still get the same error. The package I loaded is
>>>>>>>> "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
>>>>>>>> When I check this script I do not see anywhere where there is a
>>>>>>>> function like "time_axis_labels".
>>>>>>>> I will continue to probe and see where am going wrong
>>>>>>>> Incidentally, example6 on
>>>>>>>> https://www.ncl.ucar.edu/Document/Functions/User_contributed/time_axis_labels.shtml,
>>>>>>>> gives
>>>>>>>>
>>>>>>>> *time_axis_labels*( data&time,  res, restick )
>>>>>>>>
>>>>>>>> I assumed there was a mistake  on data&time and corrected it to
>>>>>>>> *time_axis_labels*( date&time,  res, restick )
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>> Zilore
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Jul 8, 2019 at 10:00 PM Dave Allured - NOAA Affiliate <
>>>>>>>> dave.allured at noaa.gov> wrote:
>>>>>>>>
>>>>>>>>> This is one of the contributed functions that is not loaded
>>>>>>>>> automatically.  You are missing a "load" command.  NCL gave you a clue:
>>>>>>>>>  "possibly an undefined procedure".  Please look at the top of the function
>>>>>>>>> documentation page.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Jul 8, 2019 at 9:14 AM Zilore Mumba via ncl-talk <
>>>>>>>>> ncl-talk at ucar.edu> wrote:
>>>>>>>>>
>>>>>>>>>> I am trying to plot a time series. I have converted the dates in
>>>>>>>>>> the file to the format YYYYMMDD with the function
>>>>>>>>>>    t = f->time                            ; to get time in file
>>>>>>>>>>    cd_date = cd_calendar(t, -2)   ; print(cd_date) prints
>>>>>>>>>> correctly, eg 19960101,...
>>>>>>>>>> Then to prepare the format for the x-axis label, I have:
>>>>>>>>>>
>>>>>>>>>>  resT1  = true
>>>>>>>>>>
>>>>>>>>>>  some resources
>>>>>>>>>>  ..............
>>>>>>>>>>
>>>>>>>>>>  restick = True
>>>>>>>>>>  restick at ttmFormat = "%d %c"
>>>>>>>>>>  restick at ttmAxis = "YL"
>>>>>>>>>>  restick at ttmMajorStride = 20
>>>>>>>>>>  *time_axis_labels*( data&time,  res, restick )
>>>>>>>>>>
>>>>>>>>>> I am getting the error:
>>>>>>>>>> fatal:syntax error: line 57 in file two-line-plot.ncl before or near \n
>>>>>>>>>>    time_axis_labels( data&time,  resT1, restick )
>>>>>>>>>> -------------------------------------------------^
>>>>>>>>>>
>>>>>>>>>> fatal:syntax error: possibly an undefined procedure
>>>>>>>>>> fatal:syntax error: line 72 in file two-line-plot.ncl before or near \n
>>>>>>>>>>    time_axis_labels(cd_date,resT1,restick)
>>>>>>>>>> ------------------------------------------^
>>>>>>>>>>
>>>>>>>>>> fatal:syntax error: possibly an undefined procedure
>>>>>>>>>> fatal:Syntax Error in block, block not executed
>>>>>>>>>> fatal:error at line 76 in file two-line-plot.ncl
>>>>>>>>>>
>>>>>>>>>> Is the
>>>>>>>>>>
>>>>>>>>>> *time_axis_labels function still valid, or is there an alternative function?*
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> *Help will be appreciated.*
>>>>>>>>>>
>>>>>>>>>> *Zilore*
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>> ncl-talk mailing list
>>>>>>> ncl-talk at ucar.edu
>>>>>>> List instructions, subscriber options, unsubscribe:
>>>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Barry H. Lynn, Ph.D
>>>>>> Senior Associate Scientist, Lecturer,
>>>>>> The Institute of the Earth Science,
>>>>>> The Hebrew University of Jerusalem,
>>>>>> Givat Ram, Jerusalem 91904, Israel
>>>>>> Tel: 972 547 231 170
>>>>>> Fax: (972)-25662581
>>>>>>
>>>>>> C.E.O, Weather It Is, LTD
>>>>>> Weather and Climate Focus
>>>>>> http://weather-it-is.com
>>>>>> Jerusalem, Israel
>>>>>> Local: 02 930 9525
>>>>>> Cell: 054 7 231 170
>>>>>> Int-IS: x972 2 930 9525
>>>>>>
>>>>>> _______________________________________________
>>>>> ncl-talk mailing list
>>>>> ncl-talk at ucar.edu
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>
>> --
>> Barry H. Lynn, Ph.D
>> Senior Associate Scientist, Lecturer,
>> The Institute of the Earth Science,
>> The Hebrew University of Jerusalem,
>> Givat Ram, Jerusalem 91904, Israel
>> Tel: 972 547 231 170
>> Fax: (972)-25662581
>>
>> C.E.O, Weather It Is, LTD
>> Weather and Climate Focus
>> http://weather-it-is.com
>> Jerusalem, Israel
>> Local: 02 930 9525
>> Cell: 054 7 231 170
>> Int-IS: x972 2 930 9525
>>
>>

-- 
Barry H. Lynn, Ph.D
Senior Associate Scientist, Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190711/2c382f37/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: read_write_graph_JA.ncl
Type: application/octet-stream
Size: 10531 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190711/2c382f37/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OBS_vs_Mod_Jer.000005.png
Type: image/png
Size: 205678 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190711/2c382f37/attachment-0001.png>


More information about the ncl-talk mailing list