<div id="result_box" dir="ltr">Thank you very much Matthias: <br><br>It works! <br>I have another question . I wish if I get several variables, these appear in columns in the text file. Is this possible?</div>
<div dir="ltr">I mean, I'd like a file.txt in which appears something similar to:</div>
<div dir="ltr"> </div>
<div dir="ltr"> Fecha u v temp hgt<br>00Z01JUN2009 -1.9065 0.225504 288.06 9385.06<br>12Z01JUN2009 1.02317 -1.33784 295.778 9385.06<br>
00Z02JUN2009 -1.15094 -3.90728 290.077 9385.06<br>12Z02JUN2009 -0.65753 -1.19813 295.153 9385.06<br></div>
<div>Thanks. Best Regards:</div>
<div> </div>
<div>Javier Peña<br><br></div>
<div class="gmail_quote">2009/11/4 Matthias Fripp <span dir="ltr"><<a href="mailto:matthias.fripp@eci.ox.ac.uk">matthias.fripp@eci.ox.ac.uk</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div style="WORD-WRAP: break-word">you could use something like this:
<div><br></div>
<div>
<div>'q time'</div>
<div>datetime = subwrd(result, 3)</div>
<div><br></div>
<div>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:</div>
<div><br></div>
<div>
<div>formatted_time = substr(datetime, 9, 4) '/' substr(datetime, 6, 3) '/' substr(datetime, 4, 2) ' ' substr(datetime, 1, 2) ':00'</div>
<div>say "formatted time: " formatted_time</div>
<div><br></div>
<div>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.</div>
<div><br></div><font color="#888888">
<div>Matthias</div>
<div><br></div></font></div>
<div>
<div></div>
<div class="h5">
<div>
<div>On Nov 4, 2009, at 4:26 PM, Javier Peña wrote:</div><br>
<blockquote type="cite">
<div dir="ltr">Hello everyone, <br> <br>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): <br> <br>* takes the values of the component or in a column <br>
'reinit' <br>'sdfopen <a href="http://prueba.nc/" target="_blank">prueba.nc</a>' <br>'set lat 41' <br>'set lon 359' <br>'set lev 1' <br>to = 1 <br>* Write the variable to a file <br>
* 'set gxout vector' <br>* 'set fwrite z: \ dummy.dat' <br>while (to <5) <br>'set t' to <br>tmp ='' <br>tmp = subwrd (rerult, 4) <br>'d u', tmp = tmp%''subwrd (result, 4) <br>
rrc = write ( 'c: \ prueba_c \ pruebas_archivo_ecmwf \ new_u.txt', tmp) <br>to = to + 1 <br>endwhile <br><br>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? <br>
<br>Date U (m / s) <br>2009/12/06 00:00 2.3 <br>2009/12/06 06:00 3.4 <br>2009/12/06 18:00 5.6 <br>2009/12/07 00:00 3.9</div>
<div><br clear="all">Thank you very much. Best regards.</div>
<div><br>Javier Peña</div></blockquote></div><br></div></div></div></div></blockquote></div><br><br clear="all"><br>-- <br>Javier Peña Álvarez<br>Energías Renovables<br><a href="mailto:javier.p@ereda.com">javier.p@ereda.com</a><br>
EREDA<br><br> Tel: +34 91 5014755<br> Fax: +34 91 5014756<br> c/ Téllez 26, 28007 MADRID<br> <a href="http://www.ereda.com">www.ereda.com</a><br>