orig/colorcal.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: colorcal.csh,v 1.1 2003/02/22 02:07:21 greg Exp $
axel@0
     3
#
axel@0
     4
# Compute CIE chromaticities from spectral reflectance data
axel@0
     5
#
axel@0
     6
if ( $#argv < 1 ) goto userr
axel@0
     7
set cal = .
axel@0
     8
if ( $argv[1] == "-i" ) then
axel@0
     9
	if ( $#argv < 3 ) goto userr
axel@0
    10
	shift argv
axel@0
    11
	set illum=$argv[1]
axel@0
    12
	shift argv
axel@0
    13
	foreach r ( $argv[*] )
axel@0
    14
		tabfunc -i rf < $r > /tmp/rf$$.cal
axel@0
    15
		rcalc -f $cal/cieresp.cal -f /tmp/rf$$.cal \
axel@0
    16
			-e 'r=rf($1);ty=$2*triy($1)' \
axel@0
    17
			-e '$1=ty;$2=$2*r*trix($1);$3=r*ty' \
axel@0
    18
			-e '$4=$2*r*triz($1)' \
axel@0
    19
			-e 'cond=if($1-359,831-$1,-1)' \
axel@0
    20
			$illum | total -m >> /tmp/rc$$.dat
axel@0
    21
	end
axel@0
    22
	rm -f /tmp/rf$$.cal
axel@0
    23
else
axel@0
    24
	foreach r ( $argv[*] )
axel@0
    25
		rcalc -f $cal/cieresp.cal -e 'ty=triy($1);$1=ty' \
axel@0
    26
		-e '$2=$2*trix($1);$3=$2*ty;$4=$2*triz($1)' \
axel@0
    27
		-e 'cond=if($1-359,831-$1,-1)' $r \
axel@0
    28
			| total -m >> /tmp/rc$$.dat
axel@0
    29
	end
axel@0
    30
endif
axel@0
    31
rcalc -e 'X=$2/$1;Y=$3/$1;Z=$4/$1' \
axel@0
    32
	-e 'x=X/(X+Y+Z);y=Y/(X+Y+Z);u=4*X/(X+15*Y+3*Z);v=9*Y/(X+15*Y+3*Z)' \
axel@0
    33
	-o $cal/color.fmt /tmp/rc$$.dat
axel@0
    34
rm -f /tmp/rc$$.dat
axel@0
    35
exit 0
axel@0
    36
userr:
axel@0
    37
echo "Usage: $0 [-i illum.dat] refl.dat .."
axel@0
    38
exit 1