how obtain the date from a NetCdf file

Javier Peña javier.p at EREDA.COM
Thu Nov 5 04:13:36 EST 2009


Thank you very much Matthias:

It works!
I have another question . I wish if I get several variables, these appear in
columns in the text file. Is this possible?
I mean, I'd like a file.txt in which appears something similar to:

   Fecha                   u             v              temp         hgt
00Z01JUN2009   -1.9065     0.225504     288.06        9385.06
12Z01JUN2009   1.02317    -1.33784      295.778      9385.06
00Z02JUN2009   -1.15094   -3.90728      290.077      9385.06
12Z02JUN2009   -0.65753  -1.19813       295.153      9385.06
Thanks. Best  Regards:

Javier Peña

2009/11/4 Matthias Fripp <matthias.fripp at eci.ox.ac.uk>

> you could use something like this:
>
>  'q time'
> datetime = subwrd(result, 3)
>
> That will give you the date and time in grads format, e.g.,
> "00Z01JAN1979". If you want, you could go further, with something like this:
>
>  formatted_time = substr(datetime, 9, 4) '/' substr(datetime, 6, 3) '/'
> substr(datetime, 4, 2) ' ' substr(datetime, 1, 2) ':00'
> say "formatted time: " formatted_time
>
> Unfortunately, I don't know any way to convert "JAN" to "01" within grads.
> So you may need to use awk (or similar) to convert the dates after-the-fact,
> in which case you might as well just write the datetime directly to the
> file, and then convert that later.
>
> Matthias
>
>   On Nov 4, 2009, at 4:26 PM, Javier Peña wrote:
>
>  Hello everyone,
>
> I have a netcdf file from which I can obtain any of the variables with the
> following script (for example to get u wind component):
>
> * takes the values of the component or in a column
> 'reinit'
> 'sdfopen prueba.nc'
> 'set lat 41'
> 'set lon 359'
> 'set lev 1'
> to = 1
> * Write the variable to a file
> * 'set gxout vector'
> * 'set fwrite z: \ dummy.dat'
> while (to <5)
> 'set t' to
> tmp =''
> tmp = subwrd (rerult, 4)
> 'd u', tmp = tmp%''subwrd (result, 4)
> rrc = write ( 'c: \ prueba_c \ pruebas_archivo_ecmwf \ new_u.txt', tmp)
> to = to + 1
> endwhile
>
> but my question is, can I get the date which belongs each variable value?
> That is, if I have values for the velocity component u: 2.3, 3.4, 5.6, 3.9,
> can I get a. txt what next?
>
> Date                         U (m / s)
> 2009/12/06 00:00          2.3
> 2009/12/06 06:00          3.4
> 2009/12/06 18:00          5.6
> 2009/12/07 00:00          3.9
>
> Thank you very much. Best regards.
>
> Javier Peña
>
>
>


-- 
Javier Peña Álvarez
Energías Renovables
javier.p at ereda.com
EREDA

                           Tel:  +34 91 5014755
                           Fax: +34 91 5014756
                 c/ Téllez 26, 28007 MADRID
                                   www.ereda.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20091105/7b7e2712/attachment.html 


More information about the gradsusr mailing list