fwrite problem of 4D data
John Guhin
johnguhin at GMAIL.COM
Tue Nov 27 11:54:35 EST 2007
Thanks for the quick reply. Your method worked, except I am not sure how the
control file will look!
So I split the output in two files, one for U and the other for V. The
following is just minor modification to your script, may be helpful to
others who are following. But, I am still not sure why my original script
did not work.
---------------------------------------------------
'reinit'
'c'
'sdfopen uwnd.2002.nc'
'sdfopen vwnd.2002.nc'
'set gxout fwrite'
'set fwrite u_anom_ncep.grd'
t1=100
while(t1<161)
'set t 't1
z1=1
while(z1<18)
'set z 'z1
'set x 1 144' ; 'set y 1 73'
'define ubar=ave(uwnd,time=10apr02,time=10jun02)'
'd uwnd-ubar'
z1=z1+1
endwhile
t1=t1+1
endwhile
'disable fwrite'
'set gxout fwrite'
'set fwrite v_anom_ncep.grd'
t1=100
while(t1<161)
'set t 't1
z1=1
while(z1<18)
'set z 'z1
'set x 1 144' ; 'set y 1 73'
'define vbar=ave(vwnd.2,time=10apr02,time=10jun02)'
'd vwnd.2-vbar'
z1=z1+1
endwhile
t1=t1+1
endwhile
'disable fwrite'
---------------------------------------------------------------------------
On Nov 27, 2007 11:02 AM, Mary Jo Nath <Mary-Jo.Nath at noaa.gov> wrote:
> Try the following. (This assumes that the U and V files have the same time
> coordinates.) You might also want to post the associated CTL file for
> "u_v_anom_ncep.grd"
> if you continue to have difficulties. - MJ
>
> 'reinit'
> 'c'
>
> 'sdfopen uwnd.2002.nc'
> 'sdfopen vwnd.2002.nc'
>
> 'set gxout fwrite'
> 'set fwrite u_v_anom_ncep.grd'
>
> t1=100
>
> while(t1<161)
>
> 'set t 't1
> * write U values at time "t1" for all Z levels
> z1=1
> while(z1<18)
> 'set z 'z1
> 'set x 1 144' ; 'set y 1 73'
> 'define ubar=ave(uwnd,time=10apr02,time=10jun02)'
> 'd uwnd-ubar'
> z1=z1+1
> endwhile
>
> * Then write V values at time "t1" for all Z levels
> z1=1
> while(z1<18)
> 'set z 'z1
> 'set x 1 144' ; 'set y 1 73'
> 'define vbar=ave(vwnd.2,time=10apr02,time=10jun02)'
> 'd vwnd.2-vbar'
> z1=z1+1
> endwhile
>
> t1=t1+1
> endwhile
> 'disable fwrite'
>
>
>
> John Guhin wrote:
> > Hi,
> > I am trying to write a 4D (time, height, lat,
> > lon). This is the script I wrote, but only the first time step is
> written.
> > Any help?
> >
> > 'reinit'
> > 'c'
> >
> > 'sdfopen uwnd.2002.nc'
> > 'sdfopen vwnd.2002.nc'
> >
> > 'set gxout fwrite'
> > 'set fwrite u_v_anom_ncep.grd'
> >
> > t1=100
> > z1=1
> > while(t1<161)
> > 'set t 't1
> > while(z1<18)
> > 'set z 'z1
> >
> > 'set x 1 144' ; 'set y 1 73'
> >
> > 'define ubar=ave(uwnd,time=10apr02,time=10jun02)'
> > 'define vbar=ave(vwnd.2,time=10apr02,time=10jun02)'
> >
> > 'd uwnd-ubar'
> > 'd vwnd.2-vbar'
> >
> > z1=z1+1
> > endwhile
> > t1=t1+1
> > endwhile
> > 'disable fwrite'
> >
> >
> > How can I write the data for all time steps?
> >
> > thanks.
> >
> >
> > John Guhin
> > -
> >
> >
>
--
John Guhin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20071127/229d9490/attachment.html
More information about the gradsusr
mailing list