[Thread Prev][Thread Next][Index]

Re: [ferret_users] Looping over multiple input files to plot file variables and save to png

Hi Paul,

Rather than writing your filenames to a file you can create a variable using the SPAWN function directly.

let filenames = SPAWN("/bin/ls -1 basinmask/*.nc")

Another way would be to create the file as you are at the moment and read it in via a spawn and 'cat' command

let filenames = SPAWN("cat filenames.txt")

I'd prefer the first method.


On 02/05/17 08:20, Durack, Paul J. wrote:

I have 51 netcdf files in a directory, and want to loop over each of these and for each plot the contents of a gridded variable and save this to a png file, using pyferret 7.1


I’ve been struggling with syntax, and am getting “**TMAP ERR: non-existent or not on line  filenames.txt”, with the following partial code:


spawn "ls basinmask/*.nc > filenames.txt" ! This is generating a file, but if I could create the filelist in memory this step could be removed

FILE/FORMAT=DELIMITED/var="filenames" filenames.txt ! < This generates the error

say "processing: ",($file) ! don’t get to here



The plot and save command will be a simple:


> sha basinmask4 ! Each file contains the same named variable

> frame/file=”($mypath)($myfile).png”


Can someone help me out to fill in the missing logic/syntax here?





[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement