orig/fieldcomb.csh
author Axel Jacobs <axel@jaloxa.eu>
Mon, 14 Apr 2014 22:21:17 +0100
changeset 73 87fa3132a136
parent 0 0aa115157c9c
permissions -rw-r--r--
New IES test file with spaces in file name
     1 #!/bin/csh -f
     2 # RCSid $Id: fieldcomb.csh,v 2.7 2008/11/10 19:08:19 greg Exp $
     3 #
     4 # Combine alternate lines in full frames for field rendering
     5 #
     6 # Expects numbered frames on command line, as given by ranimate
     7 #
     8 # If an odd number of frames is provided, the spare frame at the
     9 # end is linked to $spare_name for the next run
    10 #
    11 # Written by Greg Ward for Iebele Abel in August 2005
    12 #
    13 set spare_name=spare_fieldcomb_frame.hdr
    14 set odd_first=0
    15 while ($#argv > 1)
    16 	switch ($argv[1])
    17 	case -r*:
    18 		set remove_orig
    19 		breaksw
    20 	case -o*:
    21 		set odd_first=1
    22 		breaksw
    23 	case -e*:
    24 		set odd_first=0
    25 		breaksw
    26 	case -f*:
    27 		shift argv
    28 		set outfile="$argv[1]"
    29 		breaksw
    30 	default:
    31 		if ("$argv[1]" !~ -*) break
    32 		echo "Unknown option: $argv[1]"
    33 		exit 1
    34 	endsw
    35 	shift argv
    36 end
    37 if ($#argv < 2) then
    38 	echo "Usage: $0 [-e|-o][-r] [-f combined.hdr] field1.hdr field2.hdr .."
    39 	exit 1
    40 endif
    41 if ($?outfile && $#argv > 2) then
    42 	echo "Cannot use -f option with more than two input files"
    43 	exit 1
    44 endif
    45 set f1=$argv[1]:q
    46 set ext=$f1:e
    47 set basenm="`echo $f1:q | sed 's/[0-9]*\.'$ext'//'`"
    48 set curfi=`echo $f1:q | sed 's/^[^1-9]*\(.[0-9]*\)\.'$ext'$/\1/'`
    49 set fields=($argv[*]:q)
    50 if (-r $spare_name) then
    51 	set fields=($spare_name $fields:q)
    52 	@ curfi--
    53 endif
    54 @ curfr = $curfi / 2
    55 set curfi=1
    56 while ($curfi < $#fields)
    57 	@ nextfi = $curfi + 1
    58 	if ($curfr < 10) then
    59 		set fid=000$curfr
    60 	else if ($curfr < 100) then
    61 		set fid=00$curfr
    62 	else if ($curfr < 1000) then
    63 		set fid=0$curfr
    64 	else
    65 		set fid=$curfr
    66 	endif
    67        	set outf="${basenm}C$fid.$ext"
    68 	if ($?outfile) then
    69 		set outf=$outfile:q
    70 	endif
    71 	pcomb -e 'ro=ri(fld); go=gi(fld); bo=bi(fld)' \
    72 		-e 'yd=yres-1-y; odd=.5*yd-floor(.5*yd)-.25' \
    73 		-e "fld=if(odd,2-$odd_first,1+$odd_first)" \
    74 		$fields[$curfi]:q $fields[$nextfi]:q \
    75 		> $outf:q
    76 	if ($?remove_orig) rm $fields[$curfi]:q $fields[$nextfi]:q
    77 	@ curfr++
    78 	@ curfi = $nextfi + 1
    79 end
    80 rm -f $spare_name
    81 if ($curfi == $#fields) ln "${basenm}$curfi.$ext" $spare_name