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 |
> |
set td=/usr/tmp/fc$$ |
9 |
|
onintr quit |
10 |
< |
set mult=470 |
10 |
> |
set mult=179 |
11 |
|
set label=Nits |
12 |
|
set scale=1000 |
13 |
|
set decades=0 |
14 |
< |
set redv='2*v-1' |
15 |
< |
set grnv='if(v-.5,2-2*v,2*v)' |
16 |
< |
set bluv='1-2*v' |
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]" |
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]" |
94 |
|
endsw |
95 |
|
shift argv |
96 |
|
end |
97 |
< |
mkdir $tempdir |
98 |
< |
cat > $tempdir/pc.cal <<_EOF_ |
97 |
> |
mkdir $td |
98 |
> |
cat > $td/pc0.cal <<_EOF_ |
99 |
> |
PI : 3.14159265358979323846 ; |
100 |
|
scale : $scale ; |
101 |
|
mult : $mult ; |
102 |
|
ndivs : $ndivs ; |
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,b) : if(a-x,-1,b-x); |
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),floor(ndivs*b)); |
110 |
> |
boundary(a,b) : neq(floor(ndivs*a+.5),floor(ndivs*b+.5)); |
111 |
|
|
112 |
< |
map(x) = x; |
113 |
< |
red = $redv; |
93 |
< |
grn = $grnv; |
94 |
< |
blu = $bluv; |
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 |
< |
v = map(li(1)*(mult/scale)); |
116 |
< |
vleft = map(li(1,-1,0)*(mult/scale)); |
117 |
< |
vright = map(li(1,1,0)*(mult/scale)); |
99 |
< |
vabove = map(li(1,0,1)*(mult/scale)); |
100 |
< |
vbelow = map(li(1,0,-1)*(mult/scale)); |
101 |
< |
isconta = or(boundary(vleft,vright),boundary(vabove,vbelow)); |
102 |
< |
iscontb = if(btwn(0,v,1),btwn(.4,frac(ndivs*v),.6),0); |
115 |
> |
ro = if(in,clip($redv),ra); |
116 |
> |
go = if(in,clip($grnv),ga); |
117 |
> |
bo = if(in,clip($bluv),ba); |
118 |
|
|
119 |
< |
ro = if(in,red,ra); |
120 |
< |
go = if(in,grn,ga); |
121 |
< |
bo = if(in,blu,ba); |
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); |
111 |
– |
|
112 |
– |
in = 1; |
140 |
|
_EOF_ |
141 |
< |
set pcargs=(-o -f $tempdir/pc.cal) |
141 |
> |
set pc0args=(-f $td/pc0.cal) |
142 |
> |
set pc1args=(-f $td/pc1.cal) |
143 |
|
if ($?docont) then |
144 |
< |
set pcargs=($pcargs -e "in=iscont$docont") |
144 |
> |
set pc0args=($pc0args -e "in=iscont$docont") |
145 |
|
endif |
146 |
|
if ("$cpict" == "") then |
147 |
< |
set pcargs=($pcargs -e 'ra=0;ga=0;ba=0') |
147 |
> |
set pc1args=($pc1args -e 'ra=0;ga=0;ba=0') |
148 |
|
else if ("$cpict" == "$picture") then |
149 |
|
set cpict= |
150 |
|
endif |
151 |
< |
if ($decades > 0) then |
152 |
< |
set pcargs=($pcargs -e "map(x)=log10(x)/$decades+1") |
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 |
< |
pcomb $pcargs -e 'v=(y+.5)/200;vleft=v;vright=v' \ |
162 |
< |
-e 'vbelow=(y-.5)/200;vabove=(y+1.5)/200' \ |
163 |
< |
-e 'ra=0;ga=0;ba=0' -x 100 -y 200 \ |
164 |
< |
> $tempdir/scol.pic |
165 |
< |
( echo $label; cnt $ndivs \ |
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" ) \ |
168 |
< |
| psign -cf 1 1 1 -cb 0 0 0 -h `ev "floor(2*200/$ndivs+.5)"` \ |
169 |
< |
| pfilt -1 -x /2 -y /2 > $tempdir/slab.pic |
170 |
< |
pcomb $pcargs $picture $cpict \ |
171 |
< |
| pcompos $tempdir/scol.pic 0 0 -t .2 $tempdir/slab.pic 25 0 - 100 0 |
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 $tempdir |
192 |
> |
rm -rf $td |