ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/falsecolor.csh
Revision: 2.9
Committed: Mon Mar 8 21:39:32 2004 UTC (20 years, 1 month ago) by greg
Content type: application/x-csh
Branch: MAIN
Changes since 2.8: +18 -1 lines
Log Message:
Put in Rob Guglielmetti's falsecolor -lw and -lh options

File Contents

# Content
1 #!/bin/csh -fe
2 # RCSid: $Id: falsecolor.csh,v 2.8 2003/02/22 02:07:27 greg Exp $
3 #
4 # Create false color image with legend
5 #
6 # Added user-definable legend 2004/01/20 Rob Guglielmetti
7
8 set td=/usr/tmp/fc$$
9 onintr quit
10 set mult=179
11 set label=Nits
12 set scale=1000
13 set decades=0
14 set redv='1.6*v-.6'
15 set grnv='if(v-.375,1.6-1.6*v,8/3*v)'
16 set bluv='1-8/3*v'
17 set ndivs=8
18 set picture='-'
19 set cpict=
20 set loff=0
21 set legwidth=100
22 set legheight=200
23 while ($#argv > 0)
24 switch ($argv[1])
25 case -lw:
26 shift argv
27 set legwidth="$argv[1]"
28 breaksw
29 case -lh:
30 shift argv
31 set legheight="$argv[1]"
32 breaksw
33 case -m:
34 shift argv
35 set mult="$argv[1]"
36 breaksw
37 case -s:
38 shift argv
39 set scale="$argv[1]"
40 breaksw
41 case -l:
42 shift argv
43 set label="$argv[1]"
44 breaksw
45 case -log:
46 shift argv
47 set decades=$argv[1]
48 breaksw
49 case -r:
50 shift argv
51 set redv="$argv[1]"
52 breaksw
53 case -g:
54 shift argv
55 set grnv="$argv[1]"
56 breaksw
57 case -b:
58 shift argv
59 set bluv="$argv[1]"
60 breaksw
61 case -i:
62 shift argv
63 set picture="$argv[1]"
64 breaksw
65 case -p:
66 shift argv
67 set cpict="$argv[1]"
68 breaksw
69 case -ip:
70 case -pi:
71 shift argv
72 set picture="$argv[1]"
73 set cpict="$argv[1]"
74 breaksw
75 case -cl:
76 set docont=a
77 set loff=12
78 breaksw
79 case -cb:
80 set docont=b
81 set loff=13
82 breaksw
83 case -e:
84 set doextrem
85 set needfile
86 breaksw
87 case -n:
88 shift argv
89 set ndivs="$argv[1]"
90 breaksw
91 default:
92 echo bad option "'$argv[1]'" >/dev/tty
93 exit 1
94 endsw
95 shift argv
96 end
97 mkdir $td
98 cat > $td/pc0.cal <<_EOF_
99 PI : 3.14159265358979323846 ;
100 scale : $scale ;
101 mult : $mult ;
102 ndivs : $ndivs ;
103
104 or(a,b) : if(a,a,b);
105 EPS : 1e-7;
106 neq(a,b) : if(a-b-EPS,1,b-a-EPS);
107 btwn(a,x,b) : if(a-x,-1,b-x);
108 clip(x) : if(x-1,1,if(x,x,0));
109 frac(x) : x - floor(x);
110 boundary(a,b) : neq(floor(ndivs*a+.5),floor(ndivs*b+.5));
111
112 isconta = if(btwn(0,v,1),or(boundary(vleft,vright),boundary(vabove,vbelow)),-1);
113 iscontb = if(btwn(0,v,1),btwn(.4,frac(ndivs*v),.6),-1);
114
115 ro = if(in,clip($redv),ra);
116 go = if(in,clip($grnv),ga);
117 bo = if(in,clip($bluv),ba);
118
119 ra = 0;
120 ga = 0;
121 ba = 0;
122
123 in = 1;
124 _EOF_
125 cat > $td/pc1.cal <<_EOF_
126 norm : mult/scale/le(1);
127
128 v = map(li(1)*norm);
129
130 vleft = map(li(1,-1,0)*norm);
131 vright = map(li(1,1,0)*norm);
132 vabove = map(li(1,0,1)*norm);
133 vbelow = map(li(1,0,-1)*norm);
134
135 map(x) = x;
136
137 ra = ri(nfiles);
138 ga = gi(nfiles);
139 ba = bi(nfiles);
140 _EOF_
141 set pc0args=(-f $td/pc0.cal)
142 set pc1args=(-f $td/pc1.cal)
143 if ($?docont) then
144 set pc0args=($pc0args -e "in=iscont$docont")
145 endif
146 if ("$cpict" == "") then
147 set pc1args=($pc1args -e 'ra=0;ga=0;ba=0')
148 else if ("$cpict" == "$picture") then
149 set cpict=
150 endif
151 if ($?needfile && "$picture" == '-') then
152 cat > $td/picture
153 set picture=$td/picture
154 endif
155 if ("$decades" != "0") then
156 set pc1args=($pc1args -e "map(x)=if(x-10^-$decades,log10(x)/$decades+1,0)")
157 set imap="imap(y)=10^((y-1)*$decades)"
158 else
159 set imap="imap(y)=y"
160 endif
161 if ( $legwidth > 20 && $legheight > 40 ) then
162 pcomb $pc0args -e 'v=(y+.5)/yres;vleft=v;vright=v' \
163 -e 'vbelow=(y-.5)/yres;vabove=(y+1.5)/yres' \
164 -x $legwidth -y $legheight > $td/scol.pic
165 ( echo $label; cnt $ndivs \
166 | rcalc -e '$1='"($scale)*imap(($ndivs-.5-"'$1'")/$ndivs)" \
167 -e "$imap" | sed -e 's/\(\.[0-9][0-9][0-9]\)[0-9]*/\1/' ) \
168 | psign -s -.15 -cf 1 1 1 -cb 0 0 0 \
169 -h `ev "floor($legheight/$ndivs+.5)"` > $td/slab.pic
170 else
171 set legwidth=0
172 set legheight=0
173 (echo "" ; echo "-Y 1 +X 1" ; echo "aaa" ) > $td/scol.pic
174 cp $td/scol.pic $td/slab.pic
175 endif
176 if ( $?doextrem ) then
177 pextrem -o $picture > $td/extrema
178 set minpos=`sed 2d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"`
179 set minval=`rcalc -e '$1=($3*.27+$4*.67+$5*.06)*'"$mult" $td/extrema | sed -e 2d -e 's/\(\.[0-9][0-9][0-9]\)[0-9]*/\1/'`
180 set maxpos=`sed 1d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"`
181 set maxval=`rcalc -e '$1=($3*.27+$4*.67+$5*.06)*'"$mult" $td/extrema | sed -e 1d -e 's/\(\.[0-9][0-9][0-9]\)[0-9]*/\1/'`
182 psign -s -.15 -a 2 -h 16 $minval > $td/minv.pic
183 psign -s -.15 -a 2 -h 16 $maxval > $td/maxv.pic
184 pcomb $pc0args $pc1args $picture $cpict \
185 | pcompos $td/scol.pic 0 0 -t .2 $td/slab.pic 0 $loff \
186 - $legwidth 0 $td/minv.pic $minpos $td/maxv.pic $maxpos
187 else
188 pcomb $pc0args $pc1args $picture $cpict \
189 | pcompos $td/scol.pic 0 0 -t .2 $td/slab.pic 0 $loff - $legwidth 0
190 endif
191 quit:
192 rm -rf $td