[Thread Prev][Thread Next][Index]

Re: [ferret_users] read sequence of data files



Hi all,
To build on what Ryo suggests, one can to do this kind of thing with the REPEAT/RANGE= /NAME= syntax

my_list = {"mydata001.nc","mydata002.nc","mydata003.nc","mydata004.nc"}
let r1 = 1
let r2 = 3
repeat/range=`r1`:`r2`/name=m (let fname = my_list[i=`m`]; go process `fname`)

This would allow you to have a master list of files, and then the script could choose among the files, doing some subset of them if desired.

Ansley

Ryo Furue wrote:

Hello Ilana,

| A student is writing a script to work with a big sequence of data
| files. [. . .] I was wondering if there's any function that allows
| ferret to read and select the specific files (batch mode?),

The following solution isn't quite automatic, but it's manageable
unless you have hundreds of files:

!--- main script file ---
go process mydata001.nc
go process mydata002.nc
go process mydata003.nc
! . . . and so on . . . .

!--- another script file named "process.jnl" ---
define symbol datafile "($1)" !! get the argument
set data ($datafile) !! open the file
! . . . do something on the data . . .
cancel data/all !! close the file

The idea is that you create a "subroutine" to process your data
and you pass the filename to it as an argument.

If I needed process hundreds of data files systematically,
I would generate a ferret script corresponding to the
main script above, by using a scripting language like Ruby,
Perl, and shell.

Ryo


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement