[Thread Prev][Thread Next][Index]

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

Hi all,

! Loop over list of filenames and make plot (changing '.nc' to '.png')
  repeat/range=1:`numfiles`/name=in (let filename = filenames[i=`in`] ; \
        def sym filen basinmasks/`filename` ; \
        use ($filen)          ; \
        let filepng = {spawn:"echo ($filen) | sed s:.nc:.png:"} ; \
        def sym filep `filepng` ; \
        set win/new              ; \
        shade temp[k=1] )

I'd like to advocate another approach. Notice that the solutions proposed so far partially rely on shell commands.  Then, perhaps you might go a step further to write the loop in the shell

for ncfile in basinmasks/*.nc; do
    pngfile=$(basename "$ncfile" .nc).png # replace the extension
    ferret -script theferretscript.jnl "$ncfile" "$pngfile"

In this way, you are benefitted from the more flexible scripting capability of the shell.


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

Privacy Policy | Disclaimer | Accessibility Statement