[Thread Prev][Thread Next][Index]

Re: [ferret_users] Limitation of gif pixel?



Hi Dan,

| Thanks for your suggestion.
| I know the ps file maybe the best solution for this kind of
| application. But if I try to produce a series of 2d time series
| plot, gif file naming seems easier than ps file, like
| 
| gif:
| frame/file=test1_`l`.gif
| 
| ps:
| ferret -batch test1_1.plt
| Fprint test1_1.plt
| ferret -batch test1_2.plt
| Fprint test1_2.plt
|      .......

I see your problem.

To solve it, I use a script that automatically generates
PostScript files from a set of metafiles.  I'm attaching
a simplified version of it for an example.

Suppose you make four plots.  Ferret will name them

  metafile.plt.~1~
  metafile.plt.~2~
  metafile.plt.~3~
  metafile.plt

in this order.  If you use my script as

  $ fer2ps

it will convert the metafiles in the current directory into

  metafile001.eps
  metafile002.eps
  metafile003.eps
  metafile004.eps

in the correct order.  You can change the prefix
from "metafile" to whatever you like, by a -p option
to the script as "fer2ps -p yourprefix".  I've added
an additional option "--pdf" that generates PDF files
instead of EPS files.

The script assumes that gksm2ps (and ps2pdf if you
use the --pdf option) is in the PATH. 

Hope this helps,
Ryo
-----------------
The script uses temporary files and I haven't given
provisions for emergency exit, so that temporary files
may be left behind if you interrupt the script.
#!/bin/sh
# convert Ferret metafiles to EPS files.
#

set -u

com=`basename $0`

metafile_to_stdout() #--- use gksm2ps
{
    in_="$1"
    shift

    tmp_gksm2ps_=$com.gksm2ps.tmp-$$

    gksm2ps -R -p portrait -l cps "$@" -o "$tmp_gksm2ps_" "$in_"

    cat $tmp_gksm2ps_
    rm $tmp_gksm2ps_
}


#----
max()
{
    if [ $1 -gt $2 ]; then echo $1; else echo $2; fi
}

#----
usage_exit()
{
    echo 'Usage: fer2ps [-p <prefix>] [--pdf]'
    exit $1
}

#----- Main -----------------------------------------
pdf=''
prefix=metafile

while [ $# -gt 0 ]; do
    case "$1" in
    -p)       shift; prefix="$1";;
    --pdf)    pdf=1;;
    *)        usage_exit;;
    esac
    shift
done

#--- process files --------------
m=0
for file in metafile.plt.~*~ metafile.plt; do
    [ ! -f "$file" ] && continue
    n=`expr "$file" : 'metafile\.plt\.~\(.*\)~$'`
    if [ -z "$n" ]; then
	n=`expr $m + 1`
    else
	case "$n" in
	[0-9]|[0-9][0-9]|[0-9]|[0-9][0-9])
	    ;;
	*)
	    echo "$com: malformed filename: $file" >&2
	    continue;;
	esac
    fi
    nn=`printf '%3.3d' $n`
    ps="$prefix$nn.eps"

    metafile_to_stdout "$file" > "$ps"

    if [ -n "$pdf" ]; then
	ps2pdf "$ps"
	rm "$ps"
	out="`basename $ps .eps`.pdf"
    else
	out="$ps"
    fi
    echo "$file -> $out"
    rm "$file"

    m=`max $n $m`
done

[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement