ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/falsecolor.csh
Revision: 2.10
Committed: Sat Jul 31 17:56:56 2004 UTC (19 years, 9 months ago) by greg
Content type: application/x-csh
Branch: MAIN
CVS Tags: rad3R6, rad3R6P1
Changes since 2.9: +2 -2 lines
Log Message:
Added quote around label, so * doesn't mess it up

File Contents

# User Rev Content
1 greg 2.8 #!/bin/csh -fe
2 greg 2.10 # RCSid: $Id: falsecolor.csh,v 2.9 2004/03/08 21:39:32 greg Exp $
3 greg 1.1 #
4     # Create false color image with legend
5     #
6 greg 2.9 # Added user-definable legend 2004/01/20 Rob Guglielmetti
7    
8 greg 1.5 set td=/usr/tmp/fc$$
9 greg 1.1 onintr quit
10 greg 1.9 set mult=179
11 greg 1.1 set label=Nits
12     set scale=1000
13 greg 1.3 set decades=0
14 greg 1.5 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 greg 1.1 set ndivs=8
18     set picture='-'
19     set cpict=
20 greg 2.4 set loff=0
21 greg 1.5 set legwidth=100
22     set legheight=200
23 greg 1.1 while ($#argv > 0)
24     switch ($argv[1])
25 greg 2.9 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 greg 1.1 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 greg 1.3 case -log:
46     shift argv
47     set decades=$argv[1]
48     breaksw
49 greg 1.1 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 greg 1.2 shift argv
72 greg 1.1 set picture="$argv[1]"
73     set cpict="$argv[1]"
74     breaksw
75     case -cl:
76     set docont=a
77 greg 2.5 set loff=12
78 greg 1.1 breaksw
79     case -cb:
80     set docont=b
81 greg 2.5 set loff=13
82 greg 1.1 breaksw
83 greg 2.3 case -e:
84     set doextrem
85     set needfile
86     breaksw
87 greg 1.1 case -n:
88 greg 1.2 shift argv
89 greg 1.1 set ndivs="$argv[1]"
90 greg 1.2 breaksw
91 greg 1.1 default:
92 greg 1.3 echo bad option "'$argv[1]'" >/dev/tty
93 greg 1.1 exit 1
94     endsw
95     shift argv
96     end
97 greg 1.5 mkdir $td
98     cat > $td/pc0.cal <<_EOF_
99 greg 1.8 PI : 3.14159265358979323846 ;
100 greg 1.1 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 greg 1.7 btwn(a,x,b) : if(a-x,-1,b-x);
108 greg 1.5 clip(x) : if(x-1,1,if(x,x,0));
109 greg 1.1 frac(x) : x - floor(x);
110 greg 2.2 boundary(a,b) : neq(floor(ndivs*a+.5),floor(ndivs*b+.5));
111 greg 1.1
112 greg 1.6 isconta = if(btwn(0,v,1),or(boundary(vleft,vright),boundary(vabove,vbelow)),-1);
113 greg 1.5 iscontb = if(btwn(0,v,1),btwn(.4,frac(ndivs*v),.6),-1);
114 greg 1.1
115 greg 1.5 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 greg 1.4 v = map(li(1)*norm);
129 greg 1.5
130 greg 1.4 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 greg 1.1
135 greg 1.5 map(x) = x;
136 greg 1.1
137     ra = ri(nfiles);
138     ga = gi(nfiles);
139     ba = bi(nfiles);
140     _EOF_
141 greg 1.5 set pc0args=(-f $td/pc0.cal)
142     set pc1args=(-f $td/pc1.cal)
143 greg 1.1 if ($?docont) then
144 greg 1.5 set pc0args=($pc0args -e "in=iscont$docont")
145 greg 1.1 endif
146     if ("$cpict" == "") then
147 greg 1.5 set pc1args=($pc1args -e 'ra=0;ga=0;ba=0')
148 greg 1.1 else if ("$cpict" == "$picture") then
149     set cpict=
150     endif
151 greg 2.3 if ($?needfile && "$picture" == '-') then
152     cat > $td/picture
153     set picture=$td/picture
154     endif
155 greg 2.6 if ("$decades" != "0") then
156 greg 1.5 set pc1args=($pc1args -e "map(x)=if(x-10^-$decades,log10(x)/$decades+1,0)")
157 greg 1.3 set imap="imap(y)=10^((y-1)*$decades)"
158     else
159     set imap="imap(y)=y"
160     endif
161 greg 2.9 if ( $legwidth > 20 && $legheight > 40 ) then
162 greg 1.5 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 greg 2.10 ( echo "$label"; cnt $ndivs \
166 greg 1.3 | rcalc -e '$1='"($scale)*imap(($ndivs-.5-"'$1'")/$ndivs)" \
167 greg 2.7 -e "$imap" | sed -e 's/\(\.[0-9][0-9][0-9]\)[0-9]*/\1/' ) \
168 greg 2.3 | psign -s -.15 -cf 1 1 1 -cb 0 0 0 \
169     -h `ev "floor($legheight/$ndivs+.5)"` > $td/slab.pic
170 greg 2.9 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 greg 2.3 if ( $?doextrem ) then
177     pextrem -o $picture > $td/extrema
178     set minpos=`sed 2d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"`
179 greg 2.7 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 greg 2.3 set maxpos=`sed 1d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"`
181 greg 2.7 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 greg 2.3 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 greg 2.4 | pcompos $td/scol.pic 0 0 -t .2 $td/slab.pic 0 $loff \
186 greg 2.3 - $legwidth 0 $td/minv.pic $minpos $td/maxv.pic $maxpos
187     else
188     pcomb $pc0args $pc1args $picture $cpict \
189 greg 2.4 | pcompos $td/scol.pic 0 0 -t .2 $td/slab.pic 0 $loff - $legwidth 0
190 greg 2.3 endif
191 greg 1.1 quit:
192 greg 1.5 rm -rf $td