[Thread Prev][Thread Next][Index]
Re: Automate ferret
On Fri, 21 Jan 2005, Rolando S. Balotro wrote:
>I have tons of *.nc files to process. I need to open them individually
>and pick a data from a selected data point. Is there a way to automate
>this?
Hi Rolando,
Here is what I do in a situation that is similar I hope to
yours. Suppose I have a set of netcdf files, all containing the SAME
VARIABLE NAME say temperature(T_28) of a vertical profile, and I want
to extract the temperature at 100m. Then interactively on my unix
machine I type
touch T_28at100m.d
foreach file ( `ls *.ctd` )
echo 'use '$file >! job.jnl
echo 'list/nohead/app/file=T_28at100m.d T_28[z=100]' >> job.jnl
echo 'quit' >> job.jnl
ferret < job.jnl >! job.out
echo $file' processed'
end
The script runs through all the netcdf files named *.ctd in this
directly, appends the value of T_28[z=100] to the ASCII file T_28at100m.d,
and gives me a progress report on the screen ...
hy0103001.ctd processed
hy0103002.ctd processed
hy0103003.ctd processed
hy0103004.ctd processed
hy0103005.ctd processed
hy0103006.ctd processed
hy0103007.ctd processed
hy0103008.ctd processed
hy0103009.ctd processed
...
To check the results
more T_28at100m.d
gives
2.936
3.101
2.136
2.124
2.772
2.330
1.814
1.431
1.829
...
You can use
foreach file (`cat myfile.list`)
if the files you want are named in the file myfile.list and in practice
I would probably add extra info to the output record, such as the
latitude and longitude of the profile.
A script based this idea would perhaps accept the pointer filename
(myfile.list) , the output filename (T_28at100m.d), and the variable(s) to
be extracted (T_28[z=100]) as command line arguments, but often it is
just as easy to do it interactively.
Good luck,
Mick
|!!! Mick.Spillane@noaa.gov !!!|
|__Room 2070 Bldg#3 NOAA/PMEL__|
|____Phone_:_(206)526-6780_____|
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement