On Tue, Mar 1, 2011 at 7:09 PM, Muhammad Rahiz <span dir="ltr"><<a href="mailto:muhammad.rahiz@ouce.ox.ac.uk">muhammad.rahiz@ouce.ox.ac.uk</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Dear Felix,<br>
<br>
The attached script may do what you want. What it does is to draw the values of lon-lat from a text file, and for each lon-lat value, it extracts value of variable at each time step and appends to an output txt file.<br>
<br>
The output file would contain the following (without headers);<br>
<br>
timestep lat lon var<br>
x.1.x 30.0 70 2.3<br>
...<br>
x.120.x 30.0 70 2.1<br>
x.1.x 35.0 69.1 1.2<br>
...<br>
x.120.x 35.0 69.1 1.3<br>
<br>
If you want to extract the timesteps, grep it;<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
grep "x.1.x" output.txt > timestep.1.txt<br>
grep "x.120.x" output.txt > timestep.120.txt<br>
</blockquote>
<br>
or in a shell script;<br>
<br>
#!/bin/bash<br>
<br>
for i in `seq 1 120`; do # where 120 = no. of timesteps<br>
grep "x.'$i'.x" output.txt > timestep.$i.txt<br>
done<br>
<br>
I've yet to test the script with multiple files according to your file specifications as I did not manage to download the files from the link you gave. Nonethless, this wouldn't be a problem as you can make the same "while-endwhile" loop to read in the files as I did for coordinates.txt. Or easier, concantenate the files.<br>
<br>
Do tell us how it goes...<div class="im"><br>
<br>
Muhammad Rahiz<br>
Researcher & DPhil Candidate (Climate Systems & Policy)<br>
School of Geography & the Environment<br>
University of Oxford<br>
<br>
On Tue, 1 Mar 2011, Felix Mutua wrote:<br>
<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">
Hi Muhammad,<br>
I'm using TRMM 3B42 Rainfall data sample on this link.. The data is Netcdf<br>
with each 3hrs as a different file..I.e 3*8*365 files(=timesteps)in a<br>
year...<br>
<br>
I was thinking of doing a shell script to open and run the grads script for<br>
all the time steps producing the text output for<br>
some modelling application.. I'm running Opengrads in Windows and also I<br>
have access to a Unix server-based one..<br>
<br>
Thanks and Regards<br>
<br>
On Tue, Mar 1, 2011 at 6:32 PM, Muhammad Rahiz<br>
<<a href="mailto:muhammad.rahiz@ouce.ox.ac.uk" target="_blank">muhammad.rahiz@ouce.ox.ac.uk</a>> wrote:<br>
Hi Felix,<br>
<br>
At each lon & lat, you want to extract rainfall at every time<br>
step i.e. 3 hours? Is that what you want to do? If yes, then<br>
1. how many time steps are you dealing with?<br>
2. what is the format of your file i.e. ctl or netcdf? If ctl,<br>
then I need two samples of the filename.<br>
3. are you using GrADS in windows or linux?<br>
<br>
Off the top of my head, what you need is a double loop. If you<br>
could give me the details above, then I could modify a similar<br>
script that I have.<br>
<br>
--<br>
Muhammad Rahiz<br>
Researcher & DPhil Candidate (Climate Systems & Policy)<br>
School of Geography & the Environment<br>
University of Oxford<br>
<br>
On Tue, 1 Mar 2011, Felix Mutua wrote:<br>
<br>
Thanks Muhammad,<br>
I've looked at it before...But my challenge is that I have<br>
to do this for<br>
many files (TRMM 3 hrly precipitation data) for one<br>
year..Is there a way I<br>
can automate or just get the formatted output in Grads?<br>
<br>
Thanks<br>
<br>
Regards<br>
<br>
On Tue, Mar 1, 2011 at 5:28 PM, Muhammad Rahiz<br>
<<a href="mailto:muhammad.rahiz@ouce.ox.ac.uk" target="_blank">muhammad.rahiz@ouce.ox.ac.uk</a>> wrote:<br></div></div>
You need the <a href="http://fprintf.gs" target="_blank">fprintf.gs</a> script, availableathttp://<a href="http://cookbooks.opengrads.org/index.php?title=Recipe-002:_Saving_GrADS_v" target="_blank">cookbooks.opengrads.org/index.php?title=Recipe-002:_Saving_GrADS_v</a><div>
<div></div><div class="h5"><br>
ar<br>
iable_data_to_a_text_file.<br>
<br>
<br>
Muhammad Rahiz<br>
Researcher & DPhil Candidate (Climate Systems & Policy)<br>
School of Geography & the Environment<br>
University of Oxford<br>
<br>
<br>
On Tue, 1 Mar 2011, Felix Mutua wrote:<br>
<br>
Hi All, Could someone kindly assist..I'm trying to export<br>
a variable into an<br>
text output in this format ( with header)<br>
<br>
Lat Lon Pre<br>
...........................................................<br>
1.5 34.5 4.56<br>
2.0 34.0 3.46<br>
.. .... ......<br>
.. .... ......<br>
<br>
For a specified period...<br>
<br>
Any help greatly appreciated<br>
<br>
<br>
Regards<br>
<br>
Felix <br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
_________________________________________________________<br>
Felix Mutua<br>
School of Engineering, The University of Tokyo<br>
River Engineering and Environment Laboratory<br>
7-3-1 Hongo Bunkyo-ku, Tokyo 113-8656, Japan<br>
Phone +81-80-3553-0339,E-mail: <a href="mailto:Felix.mutua@gmail.com" target="_blank">Felix.mutua@gmail.com</a>,<br>
<a href="mailto:f-mutua@hydra.t.u-tokyo.ac.jp" target="_blank">f-mutua@hydra.t.u-tokyo.ac.jp</a><br>
Skype: Felix.mutua<br>
<br>
<br>
</div></div></blockquote>
<br>_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br></blockquote></div><br>If you are a python programmer, take a look at this pygrads recipe:<div><br></div><div><a href="http://cookbooks.opengrads.org/index.php?title=Recipe-003:_Using_PyGrADS_to_save_variable_data_to_a_text_file">http://cookbooks.opengrads.org/index.php?title=Recipe-003:_Using_PyGrADS_to_save_variable_data_to_a_text_file</a></div>
<div><br></div><div>I think it does exactly what you want.</div><div><br></div><div> Arlindo<br><div><br></div><div><br clear="all"><br>-- <br>Arlindo da Silva<br><a href="mailto:dasilva@alum.mit.edu">dasilva@alum.mit.edu</a><br>
</div></div>