Re: ncl-talk Problems with Ut_string

From: donna Cote <d-cote_at_nyahnyahspammersnyahnyah>
Date: Sun Oct 02 2011 - 13:35:33 MDT

Ugo, I believe you are getting what you are asking NCL to do. Remember,

date(1)

    FORMAT controls the output. The only valid option for the second
    form specifies Coordinated Universal Time. Interpreted sequences
    are:

        %A locale’s full weekday name (e.g., Sunday)
        %H hour (00..23)

Now, I don't know why, even on my system, what is returned is
"Sunday 00"
$ date -u
Sun Oct 2 19:07:09 UTC 2011
$ date -u | date -d - "+%A %H"
Sunday 00
$

I cannot see your code (the attachment was stripped) and I don't see how
you are using ut_string. So, based on what part I do see, this is what I
would choose to do:

$ date -u
Sun Oct 2 19:25:07 UTC 2011
[dcote@scoopdata ~]$ ncl
  Copyright (C) 1995-2011 - All Rights Reserved
  University Corporation for Atmospheric Research
  NCAR Command Language Version 6.0.0
  The use of this software is governed by a License Agreement.
  See http://www.ncl.ucar.edu/ for more details.
ncl 0> midate="Sun Oct 2 19:11:59 UTC 2011"
ncl 1> print(midate)

Variable: midate
Type: string
Total Size: 4 bytes
             1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) Sun Oct 2 19:11:59 UTC 2011
ncl 2>
ncl 3> cmd="date -d '"+midate+"' '+%Y-%m-%d %H:%M:%S-00'"
ncl 4> print(cmd)

Variable: cmd
Type: string
Total Size: 4 bytes
             1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) date -d 'Sun Oct 2 19:11:59 UTC 2011' '+%Y-%m-%d %H:%M:%S-00'
ncl 5>
ncl 6> date2=systemfunc(cmd)
ncl 7> print(date2)

Variable: date2
Type: string
Total Size: 4 bytes
             1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 2011-10-02 14:11:59-00
ncl 8> exit
$

I would also avoid naming a variable "date".

Good luck, Donna

On 10/2/11 1:00 PM, ncl-talk-request@ucar.edu wrote:
> Date: Sun, 2 Oct 2011 17:37:24 +0000
> From: ugo merlini<ugomerlini@hotmail.com>
> Subject: Problems with Ut_string
> To:<ncl-talk@ucar.edu>
> Message-ID:<DUB108-W20B52CE9EA1FF37C2CCD27CAF50@phx.gbl>
> Content-Type: text/plain; charset="iso-8859-1"
>
>
> hi,
>
> I'm trying to make a custom date format so I extract gfs timestamp and put it in a format readable from linux shel comand (lines 300 and 301) and I obtain the right format YYYYMMDD HH (line 304) as bah command line want
>
> so i made (line 304)
>
> date2 = systemfunc("date -d '(date)' +'%A %H'")
>
> but the result is always Sunday 00
>
> Why?
>
> Regards
>
> Ugo
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Oct 2 13:35:49 2011

This archive was generated by hypermail 2.1.8 : Sun Oct 09 2011 - 13:05:26 MDT