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