display error from fwrite data

Muhammad Rahiz muhammad.rahiz at OUCE.OX.AC.UK
Mon Jul 6 16:00:48 EDT 2009


Dear Jennifer,

Thank you for the useful comments. I'm trying to do monthly average for
my 6 hourly data-set and the earlier post on the fwrite question is just
a sample of what I'm trying to do because the same method did not work
on a sample data.

So to clarify things,

I've got the following data-set which I want to average. Each time step
is 6 hrs so 124 time steps makes 31 days.

start    end      date
1         124      1960010100
125      244      1960020100
...
43586   43709   1990080100

I have the following script (in red are the ones I corrected based on
your suggestion).

-------------------------
'open rf.tmp.ctl'
'set lon 45.26 114.26'
'set lat -5.07 45.6'
'set x 1 303'
'set y 1 226'
'set t 1'
'set fwrite rf.tmp.monthly.dat'
'set gxout fwrite'
mtot = 359
m = 1
while(m<=mtot)
 fname='time.txt'
 rec = read(fname)
 IO = sublin(rec,1)
  if(IO = 1)
   say fname 'file open error'
   'quit'
  endif
  if(IO = 0)
   t1 = subwrd(rec,2)
   t2 = subwrd(rec,3)
  endif
   say 'Tstart= 't1' Tend= 't2''
'd ave(tmp,t='t1',t='t2')'
say 'ave(tmp,t='t1',t='t2')'
m = m + 1
endwhile
'disable fwrite'
------------------------------------
This, I hope, will give me monthly averages of the individual files and
subsequently write the outputs to a single file.

The corresponding descriptor file is

-------------------------------------
DSET ^rf.tmp.monthly.dat
UNDEF -9.99e8
XDEF 303 LINEAR 46.25 0.225198675496689
YDEF 226 LINEAR -5.07 0.2252
ZDEF 1 LEVELS 1008.23
TDEF 359 LINEAR 00Z01JAN1960 1mo
VARS 1
tmp 0 99 tmp
ENDVARS
----------------------------------------

It displays alright but the output from t=1 and t=10 or t=x (where x is any other number) is exactly the same! Something must be wrong with the averaging.

Ideally it should do
ave(tmp,t=1,t=124) and store averaged data in the output.file.dat,
ave(tmp,t=125,t=244) and append the averaged data in the same ouput.file.dat.

Clearly, the script is not doing this...

Muhammad
Grads 2.0.a6 on Fedora 10






Jennifer Adams wrote:
> Starting with version 2.0.a6, the undef value of GrADS output
> (including fwrite files) is -9.99e8 BY DEFAULT unless you explicitly
> set the undef value with the 'set undef' command. Please read the
> documentation:
> http://iges.org/grads/gadoc/gradcomdsetundef.html
>
> More comments inline below ...
>
>
> On Jul 6, 2009, at 10:57 AM, Muhammad Rahiz wrote:
>
>> I did a test run with fwrite, got an ouput but the display gives me
>> junk. Does anyone know why?
>>
>> This was what I did;
>>
>> 'open sample.file.ctl'
>> 'set fwrite output.bin'
>> 'set gxout fwrite'
>> 'define var.new = ave(var,t=1,t=124)
>> 'd var.new'
> There is no need to use define here. Just display your expression:
> 'd ave(var,t=1,t=124)'
>>
>> 'disable fwrite'
>>
>> I created the descriptor file (output.ctl) which contains the following,
>>
>> DSET ^output.bin
>> UNDEF -1.e34
> here you need to change -1.e34 to -9.99e8
> or
> leave it as is and add a 'set undef file 1' command to the script
> fragment above
>
>> XDEF 303 LINEAR 46.25 0.225198675496689
>> YDEF 226 LINEAR -5.07 0.2252
>> ZDEF 1 LEVELS 1008.23
>> TDEF 1 LINEAR 00Z01JAN1961 1mo
> note that your new data set has only one time step; that's all you've
> written out. In another post you mentioned you were trying to display
> other time steps ...
>
>> VARS 1
>> var.new 0 99 var.new
>> ENDVARS
>>
>> Opened the file for display;
>>
>> 'open output.ctl'
>> 'd var.new'
>>
>> Data file sample.file.bin is open as file 1
>> LON set to 46.25 114.26
>> LAT set to -5.07 45.6
>> LEV set to 1008.23 1008.23
>> Time values set: 1960:10:1:0 1960:10:1:0
>> E set to 1 1
>> Notice: Implied interpolation for file output.ctl
>> Interpolation will be performed on any data displayed from this file
> You're clearly using pdef, although you haven't included that
> information in your email. If you want useful answers to your
> questions, please present complete information, including which
> version of GrADS you are using and which OS you are running on.
> --Jennifer
>
>
>
>>
>>
>>
>> --
>> Muhammad Rahiz  |  Doctoral Student in Regional Climate Modeling
>> Climate Research Laboratory, School of Geography & the Environment
>> Oxford University Centre for the Environment
>> South Parks Road, Oxford, OX1 3QY, United Kingdom
>> Tel: +44 (0)1865-285194  Mobile: +44 (0)7854-625974
>> Email: muhammad.rahiz at ouce.ox.ac.uk <mailto:muhammad.rahiz at ouce.ox.ac.uk>
>>
>>
>>
>> <Picture1.jpg>
>
> --
> Jennifer M. Adams
> IGES/COLA
> 4041 Powder Mill Road, Suite 302
> Calverton, MD 20705
> jma at cola.iges.org <mailto:jma at cola.iges.org>
>
>
>



More information about the gradsusr mailing list