[Thread Prev][Thread Next][Index]

Re: [ferret_users] Listing gridded data to triplets



Hi Bill,
I think the easy way to do this is using the REPEAT loop.
Here is an example with monthly_navy_winds dataset available with Ferret.
Please find the explanations inside the example. Let me know if you have
any difficulties.

Regards,

Jaison

!-------------------------------------------------------------------------
\ cancel mode verify
!
! Example : To list variable to an ascii file along with I,J,L indices
!.....................................................................

set data monthly_navy_winds ! dataset, change it accordingly

let var = uwnd[d=1] ! variable, change it accordingly

define symbol ascii = myfile.txt ! output ascii filename

cancel reg/all ! remove this and use "set reg" if needed

let ilo = `var,r=istart`
let ihi = `var,r=iend`
let jlo = `var,r=jstart`
let jhi = `var,r=jend`
let llo = `var,r=lstart`
let lhi = `var,r=lend`

! 1. change the format statement as needed
!
! 2. interchange the positions of I and J loop to get I varying faster
! than J
!
! 3. col1 col2 col3 col4
!
! L J I VAR
!
! 4. The script may take considerable time to finish if the number of
! data points are large...be patient

sp rm -f ($ascii)
REPEAT/L=`llo`:`lhi` ( ;\
REPEAT/J=`jlo`:`jhi` ( ;\
REPEAT/I=`ilo`:`ihi` ( ;\
List/nohead/file=($ascii)/FORMAT=(2x,3(f6.1,3x),f10.4)/quiet/APPEND `L`,`J`,`I`, uwnd ;\
) ;\
) ;\
)

!-------------------------------------------------------------------------

On Wed, 12 Apr 2006, Gustafson, William I wrote:

Hi,

Iım sure this question has arisen before, but I havenıt found the answer in
the archive. I am using Ferret to analyze some data that is read in from
gridded netCDF files with the resulting grid being (I,J,T). How can I get
Ferret to list the results to a text file with each line containing the
indices for time, I and J followed by the value? Each line would only
contain data from one grid cell and time, first incrementing by the
locations, and then incrementing by the times. Essentially, it would be
something like the following for a 2x2 grid:

   t1   i1   j1   value(i1,j1,t1)
   t1   i1   j2   value(i1,j2,t1)
   t1   i2   j1   value(i2,j1,t1)
   t1   i2   j2   value(i2,j2,t1)
   t2   i1   j1   value(i1,j1,t2)
   etc.

The ordering of the I and J isnıt important, as long as it is predictable. I
hope that makes sense.

Thanks for any suggestions!

-Bill


--------------------------------------------------------------------
William I. Gustafson Jr.
Atmospheric Science and Global Change Division
Pacific Northwest National Laboratory
3200 Q Ave., MSIN K9-30
Richland, WA 99352
(509)372-6110


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement