On 9/25/07, <b class="gmail_sendername">Jason Snyder</b> <<a href="mailto:jmssnyder@ucdavis.edu">jmssnyder@ucdavis.edu</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I am trying to open two files in GRADS with different time indices. How can<br>I go about doing this. I want to subtract the values in one file from the<br>values in the other file. I have tried opening the files with XDFOPEN but
<br>it does not work. I am using GRADS 1.7. Is there a more advanced GRADS<br>that can allow me to do this?</blockquote><div><br>You can either type or you can lie. The verbose way requires that you be explicit about the "t" levels you are operating on:
<br><br>sdfopen <a href="http://file1.nc">file1.nc</a><br>sdfopen <a href="http://file2.nc">file2.nc</a><br>display var.1(t=1) - var.2(t=1)<br><br>Or you can lie to GrADS: just create a file2.ddf where you specify the TDEF keyword to force the same time axis as file 1; see the xdfopen documentation for info on creating DDF's. If you use a recent version of lats4d supporting the "-j" option you should be able to create a difference file like this:
<br><br>lats4d -v -i <a href="http://file.nc">file.nc</a> -j file2.ddf -o diff -func '@.1-@.2'<br><br>This will create file "<a href="http://diff.nc">diff.nc</a>" with the difference of the two. BTW, if you want to have a simple summary of the difference between the 2 files (min/max/ave) just use "stats" for format:
<br><br>lats4d -v -i <a href="http://file.nc">file.nc</a> -j file2.ddf -format stats -func '@.1-@.2'<br>
<br>This gives you a quick way to compare 2 structurally identical files. Or you can use "stats" on a single file, e.g.,<br><br>lats4d -i model -format stats<br><br>The output is something like this:<br><br><stats>
<br>+<br>+ <> Statistics on 00Z01JAN1987 for "model"<br>+ <br>+ Name Lev Min Max MEAN STDV RMS<br>+ --------- ---- ----------- ----------- ----------- ----------- -----------
<br>+ ps sfc 481.9110 1049.9100 953.2780 102.9510 958.8190<br>+ ts sfc 230.9930 318.4930 278.5030 18.7761 279.1350<br>+ pr sfc 0.0000 0.00087738 3.1217e-05 5.9594e-05
6.7267e-05<br> <br> Name Lev Min Max MEAN STDV RMS<br> --------- ---- ----------- ----------- ----------- ----------- -----------<br> ua 1000 -12.9719 20.0281
-0.5000 6.5431 6.5601<br> ua 850 -22.5107 29.7393 1.6346 8.3796 8.5361<br> ua 700 -19.0453 33.9547 3.8051 9.2721 10.0211<br> ua 500 -
26.0697 50.9303 6.8472 11.9436 13.7655<br> ua 300 -30.2449 73.7551 12.3417 16.0525 20.2465<br> ua 200 -18.9862 81.0138 14.3253 16.6570 21.9678<br> ua 100 -
19.2900 53.7100 11.3790 12.8742 17.1807<br> --------- ---- ----------- ----------- ----------- ----------- -----------<br>+ ua 7 -30.2449 81.0138 7.1190 11.9897 15.0878<br><br>
[snip]<br><br>You can pipe the output through "grep '^+'" to omit the vertical level details. This feature was added with the "-j" option. <br><br> Good Luck,<br><br> Arlindo<br><br><br>
</div></div><br><br clear="all"><br>-- <br>Arlindo da Silva<br><a href="mailto:dasilva@alum.mit.edu">dasilva@alum.mit.edu</a>