ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/falsecolor.csh
(Generate patch)

Comparing ray/src/px/falsecolor.csh (file contents):
Revision 1.1 by greg, Thu May 23 13:45:18 1991 UTC vs.
Revision 2.18 by greg, Mon Aug 25 04:50:32 2008 UTC

# Line 1 | Line 1
1 < #!/bin/csh -f
2 < # SCCSid "$SunId$ LBL"
1 > #!/bin/csh -fe
2 > # RCSid: $Id$
3   #
4   # Create false color image with legend
5   #
6 < set tempdir=/usr/tmp/fc$$
6 > # Added user-definable legend 2004/01/20 Rob Guglielmetti
7 >
8   onintr quit
9 < set mult=470
9 > set td=`mktemp -d /tmp/fc.XXXXXX`
10 > set mult=179
11   set label=Nits
12   set scale=1000
13 < set redv='2*v-1'
14 < set grnv='if(v-.5,2-2*v,2*v)'
15 < set bluv='1-2*v'
13 > set decades=0
14 > set redv='def_red(v)'
15 > set grnv='def_grn(v)'
16 > set bluv='def_blu(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]"
# Line 23 | Line 37 | while ($#argv > 0)
37          case -s:
38                  shift argv
39                  set scale="$argv[1]"
40 +                if ("$scale" =~ [aA]*) set needfile
41                  breaksw
42          case -l:
43                  shift argv
44                  set label="$argv[1]"
45                  breaksw
46 +        case -log:
47 +                shift argv
48 +                set decades=$argv[1]
49 +                breaksw
50          case -r:
51                  shift argv
52                  set redv="$argv[1]"
# Line 40 | Line 59 | while ($#argv > 0)
59                  shift argv
60                  set bluv="$argv[1]"
61                  breaksw
62 +        case -spec:
63 +                set redv='1.6*v-.6'
64 +                set grnv='if(v-.375,1.6-1.6*v,8/3*v)'
65 +                set bluv='1-8/3*v'
66 +                breaksw
67          case -i:
68                  shift argv
69                  set picture="$argv[1]"
# Line 50 | Line 74 | while ($#argv > 0)
74                  breaksw
75          case -ip:
76          case -pi:
77 <                shiftargv
77 >                shift argv
78                  set picture="$argv[1]"
79                  set cpict="$argv[1]"
80                  breaksw
81          case -cl:
82                  set docont=a
83 +                set loff=12
84                  breaksw
85          case -cb:
86                  set docont=b
87 +                set loff=13
88                  breaksw
89 +        case -e:
90 +                set doextrem
91 +                set needfile
92 +                breaksw
93          case -n:
94 <                shiftargv
94 >                shift argv
95                  set ndivs="$argv[1]"
96 <                breadsw
96 >                breaksw
97          default:
98                  echo bad option "'$argv[1]'"
99                  exit 1
100          endsw
101          shift argv
102   end
103 < mkdir $tempdir
104 < cat > $tempdir/pc.cal <<_EOF_
103 > if ($?needfile && "$picture" == '-') then
104 >        cat > $td/picture
105 >        set picture=$td/picture
106 > endif
107 > if ("$scale" =~ [aA]*) then
108 >        set LogLmax=`phisto $picture | tail -2 | sed -n '1s/    [0-9]*$//p'`
109 >        set scale=`ev "$mult/179*10^$LogLmax"`
110 > endif
111 > cat > $td/pc0.cal <<_EOF_
112 > PI : 3.14159265358979323846 ;
113   scale : $scale ;
114   mult : $mult ;
115   ndivs : $ndivs ;
# Line 79 | Line 117 | ndivs : $ndivs ;
117   or(a,b) : if(a,a,b);
118   EPS : 1e-7;
119   neq(a,b) : if(a-b-EPS,1,b-a-EPS);
120 < btwn(a,b) : if(a-x,-1,b-x);
120 > btwn(a,x,b) : if(a-x,-1,b-x);
121 > clip(x) : if(x-1,1,if(x,x,0));
122   frac(x) : x - floor(x);
123 < boundary(a,b) : neq(floor(ndivs*a),floor(ndivs*b));
123 > boundary(a,b) : neq(floor(ndivs*a+.5),floor(ndivs*b+.5));
124  
125 < red=$redv;
126 < grn=$grnv;
127 < blu=$bluv;
125 > interp_arr2(i,x,f):(i+1-x)*f(i)+(x-i)*f(i+1);
126 > interp_arr(x,f):if(x-1,if(f(0)-x,interp_arr2(floor(x),x,f),f(f(0))),f(1));
127 > def_redp(i):select(i,0.18848,0.05468174,
128 > 0.00103547,8.311144e-08,7.449763e-06,0.0004390987,0.001367254,
129 > 0.003076,0.01376382,0.06170773,0.1739422,0.2881156,0.3299725,
130 > 0.3552663,0.372552,0.3921184,0.4363976,0.6102754,0.7757267,
131 > 0.9087369,1,1,0.9863);
132 > def_red(x):interp_arr(x/0.0454545+1,def_redp);
133 > def_grnp(i):select(i,0.0009766,2.35501e-05,
134 > 0.0008966244,0.0264977,0.1256843,0.2865799,0.4247083,0.4739468,
135 > 0.4402732,0.3671876,0.2629843,0.1725325,0.1206819,0.07316644,
136 > 0.03761026,0.01612362,0.004773749,6.830967e-06,0.00803605,
137 > 0.1008085,0.3106831,0.6447838,0.9707);
138 > def_grn(x):interp_arr(x/0.0454545+1,def_grnp);
139 > def_blup(i):select(i,0.2666,0.3638662,0.4770437,
140 > 0.5131397,0.5363797,0.5193677,0.4085123,0.1702815,0.05314236,
141 > 0.05194055,0.08564082,0.09881395,0.08324373,0.06072902,
142 > 0.0391076,0.02315354,0.01284458,0.005184709,0.001691774,
143 > 2.432735e-05,1.212949e-05,0.006659406,0.02539);
144 > def_blu(x):interp_arr(x/0.0454545+1,def_blup);
145  
146 < v = li(1)*(mult/scale);
147 < vleft = li(1,-1,0)*(mult/scale);
92 < vright = li(1,1,0)*(mult/scale);
93 < vabove = li(1,0,1)*(mult/scale);
94 < vbelow = li(1,0,-1)*(mult/scale);
95 < isconta = or(boundary(vleft,vright),boundary(vabove,vbelow));
96 < iscontb = if(btwn(0,v,1),btwn(.4,frac(ndivs*v),.6),0);
146 > isconta = if(btwn(0,v,1),or(boundary(vleft,vright),boundary(vabove,vbelow)),-1);
147 > iscontb = if(btwn(0,v,1),btwn(.4,frac(ndivs*v),.6),-1);
148  
149 < ro = if(in,red,ra);
150 < go = if(in,grn,ga);
151 < bo = if(in,blu,ba);
149 > ra = 0;
150 > ga = 0;
151 > ba = 0;
152  
153 + in = 1;
154 +
155 + ro = if(in,clip($redv),ra);
156 + go = if(in,clip($grnv),ga);
157 + bo = if(in,clip($bluv),ba);
158 + _EOF_
159 + cat > $td/pc1.cal <<_EOF_
160 + norm : mult/scale/le(1);
161 +
162 + v = map(li(1)*norm);
163 +
164 + vleft = map(li(1,-1,0)*norm);
165 + vright = map(li(1,1,0)*norm);
166 + vabove = map(li(1,0,1)*norm);
167 + vbelow = map(li(1,0,-1)*norm);
168 +
169 + map(x) = x;
170 +
171   ra = ri(nfiles);
172   ga = gi(nfiles);
173   ba = bi(nfiles);
105
106 in = 1;
174   _EOF_
175 < set pcargs=(-o -f $tempdir/pc.cal)
175 > set pc0args=(-f $td/pc0.cal)
176 > set pc1args=(-f $td/pc1.cal)
177   if ($?docont) then
178 <        set pcargs=($pcargs -e "in=iscont$docont")
178 >        set pc0args=($pc0args -e "in=iscont$docont")
179   endif
180   if ("$cpict" == "") then
181 <        set pcargs=($pcargs -e 'ra=0;ga=0;ba=0')
181 >        set pc1args=($pc1args -e 'ra=0;ga=0;ba=0')
182   else if ("$cpict" == "$picture") then
183          set cpict=
184   endif
185 < pcomb $pcargs -e 'v=(y+.5)/200;vleft=v;vright=v' \
186 <                -e 'vbelow=(y-.5)/200;vabove=(y+1.5)/200' \
187 <                -e 'ra=0;ga=0;ba=0' -x 100 -y 200 \
188 <                > $tempdir/scol.pic
189 < (echo $label; cnt $ndivs |rcalc -e '$1='"($scale)/$ndivs*($ndivs"'-.5-$1)') \
190 <        | psign -cf 1 1 1 -cb 0 0 0 -h `ev "floor(200/$ndivs+.5)"` \
191 <                > $tempdir/slab.pic
192 < pcomb $pcargs $picture $cpict \
193 <        | pcompos $tempdir/scol.pic 0 0 -t .5 $tempdir/slab.pic 25 0 - 100 0
185 > if ("$decades" != "0") then
186 >        set pc1args=($pc1args -e "map(x)=if(x-10^-$decades,log10(x)/$decades+1,0)")
187 >        set imap="imap(y)=10^((y-1)*$decades)"
188 > else
189 >        set imap="imap(y)=y"
190 > endif
191 > if ( $legwidth > 20 && $legheight > 40 ) then
192 > pcomb $pc0args -e 'v=(y+.5)/yres;vleft=v;vright=v' \
193 >                -e 'vbelow=(y-.5)/yres;vabove=(y+1.5)/yres' \
194 >                -x $legwidth -y $legheight > $td/scol.pic
195 > ( echo "$label"; cnt $ndivs \
196 >                | rcalc -e '$1='"($scale)*imap(($ndivs-.5-"'$1'")/$ndivs)" \
197 >                -e "$imap" | sed -e 's/\(\.[0-9][0-9][0-9]\)[0-9]*/\1/' ) \
198 >        | psign -s -.15 -cf 1 1 1 -cb 0 0 0 \
199 >                -h `ev "floor($legheight/$ndivs+.5)"` > $td/slab.pic
200 > else
201 >        set legwidth=0
202 >        set legheight=0
203 >        (echo "" ; echo "-Y 1 +X 1" ; echo "aaa" ) > $td/scol.pic
204 >        cp $td/scol.pic $td/slab.pic
205 > endif
206 > if ( $?doextrem ) then
207 >        pextrem -o $picture > $td/extrema
208 >        set minpos=`sed 2d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"`
209 >        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/'`
210 >        set maxpos=`sed 1d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"`
211 >        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/'`
212 >        psign -s -.15 -a 2 -h 16 $minval > $td/minv.pic
213 >        psign -s -.15 -a 2 -h 16 $maxval > $td/maxv.pic
214 >        pcomb $pc0args $pc1args $picture $cpict \
215 >                | pcompos $td/scol.pic 0 0 \
216 >                        +t .1 "\!pcomb -e 'lo=1-gi(1)' $td/slab.pic" \
217 >                        `ev 2 $loff-1` -t .5 $td/slab.pic 0 $loff \
218 >                  - $legwidth 0 $td/minv.pic $minpos $td/maxv.pic $maxpos
219 > else
220 >        pcomb $pc0args $pc1args $picture $cpict \
221 >                | pcompos $td/scol.pic 0 0 \
222 >                        +t .1 "\!pcomb -e 'lo=1-gi(1)' $td/slab.pic" \
223 >                        `ev 2 $loff-1` -t .5 $td/slab.pic 0 $loff \
224 >                        - $legwidth 0
225 > endif
226   quit:
227 < rm -rf $tempdir
227 > rm -rf $td

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines