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 td=/usr/tmp/fc$$ |
6 |
> |
# Added user-definable legend 2004/01/20 Rob Guglielmetti |
7 |
> |
|
8 |
> |
set td=/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' |
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 redv='def_red(v)' |
18 |
> |
set grnv='def_grn(v)' |
19 |
> |
set bluv='def_blu(v)' |
20 |
|
set ndivs=8 |
21 |
|
set picture='-' |
22 |
|
set cpict= |
23 |
+ |
set loff=0 |
24 |
|
set legwidth=100 |
25 |
|
set legheight=200 |
26 |
|
while ($#argv > 0) |
27 |
|
switch ($argv[1]) |
28 |
+ |
case -lw: |
29 |
+ |
shift argv |
30 |
+ |
set legwidth="$argv[1]" |
31 |
+ |
breaksw |
32 |
+ |
case -lh: |
33 |
+ |
shift argv |
34 |
+ |
set legheight="$argv[1]" |
35 |
+ |
breaksw |
36 |
|
case -m: |
37 |
|
shift argv |
38 |
|
set mult="$argv[1]" |
77 |
|
breaksw |
78 |
|
case -cl: |
79 |
|
set docont=a |
80 |
+ |
set loff=12 |
81 |
|
breaksw |
82 |
|
case -cb: |
83 |
|
set docont=b |
84 |
+ |
set loff=13 |
85 |
|
breaksw |
86 |
+ |
case -e: |
87 |
+ |
set doextrem |
88 |
+ |
set needfile |
89 |
+ |
breaksw |
90 |
|
case -n: |
91 |
|
shift argv |
92 |
|
set ndivs="$argv[1]" |
93 |
|
breaksw |
94 |
|
default: |
95 |
< |
echo bad option "'$argv[1]'" >/dev/tty |
95 |
> |
echo bad option "'$argv[1]'" |
96 |
|
exit 1 |
97 |
|
endsw |
98 |
|
shift argv |
110 |
|
btwn(a,x,b) : if(a-x,-1,b-x); |
111 |
|
clip(x) : if(x-1,1,if(x,x,0)); |
112 |
|
frac(x) : x - floor(x); |
113 |
< |
boundary(a,b) : neq(floor(ndivs*a),floor(ndivs*b)); |
113 |
> |
boundary(a,b) : neq(floor(ndivs*a+.5),floor(ndivs*b+.5)); |
114 |
|
|
115 |
+ |
interp_arr2(i,x,f):(i+1-x)*f(i)+(x-i)*f(i+1); |
116 |
+ |
interp_arr(x,f):if(x-1,if(f(0)-x,interp_arr2(floor(x),x,f),f(f(0))),f(1)); |
117 |
+ |
def_redp(i):select(i,0.18848,0.05468174, |
118 |
+ |
0.00103547,0,7.449763e-06,0.0004390987,0.001367254,0.003076, |
119 |
+ |
0.01376382,0.06085327,0.1712073,0.2889212,0.3404111,0.3803934, |
120 |
+ |
0.4135148,0.4461151,0.4966744,0.6343959,0.7709373,0.9048474,1, |
121 |
+ |
1,0.9863); |
122 |
+ |
def_red(x):interp_arr(x/0.0454545+1,def_redp); |
123 |
+ |
def_grnp(i):select(i,0.0009766,0,0.0008966244, |
124 |
+ |
0.0264977,0.1256843,0.2865799,0.4251992,0.4775091,0.4406337, |
125 |
+ |
0.3546771,0.2374256,0.1424751,0.09136063,0.0474073,0.0181899, |
126 |
+ |
0.004181549,9.587855e-05,0,0.008718861,0.1025931,0.3106831, |
127 |
+ |
0.6447838,0.9707); |
128 |
+ |
def_grn(x):interp_arr(x/0.0454545+1,def_grnp); |
129 |
+ |
def_blup(i):select(i,0.2666,0.3638662,0.4770437, |
130 |
+ |
0.5131397,0.5363797,0.5193677,0.4091852,0.1732726,0.05331749, |
131 |
+ |
0.0457587,0.06656252,0.06819438,0.04973373,0.02796644, |
132 |
+ |
0.01131437,0.00280772,0.0002246617,0.0003480934,0.001044561, |
133 |
+ |
0.001006845,0.002297005,0.01128842,0.02539); |
134 |
+ |
def_blu(x):interp_arr(x/0.0454545+1,def_blup); |
135 |
+ |
|
136 |
|
isconta = if(btwn(0,v,1),or(boundary(vleft,vright),boundary(vabove,vbelow)),-1); |
137 |
|
iscontb = if(btwn(0,v,1),btwn(.4,frac(ndivs*v),.6),-1); |
138 |
|
|
98 |
– |
ro = if(in,clip($redv),ra); |
99 |
– |
go = if(in,clip($grnv),ga); |
100 |
– |
bo = if(in,clip($bluv),ba); |
101 |
– |
|
139 |
|
ra = 0; |
140 |
|
ga = 0; |
141 |
|
ba = 0; |
142 |
|
|
143 |
|
in = 1; |
144 |
+ |
|
145 |
+ |
ro = if(in,clip($redv),ra); |
146 |
+ |
go = if(in,clip($grnv),ga); |
147 |
+ |
bo = if(in,clip($bluv),ba); |
148 |
|
_EOF_ |
149 |
|
cat > $td/pc1.cal <<_EOF_ |
150 |
|
norm : mult/scale/le(1); |
172 |
|
else if ("$cpict" == "$picture") then |
173 |
|
set cpict= |
174 |
|
endif |
175 |
< |
if ($decades > 0) then |
175 |
> |
if ($?needfile && "$picture" == '-') then |
176 |
> |
cat > $td/picture |
177 |
> |
set picture=$td/picture |
178 |
> |
endif |
179 |
> |
if ("$decades" != "0") then |
180 |
|
set pc1args=($pc1args -e "map(x)=if(x-10^-$decades,log10(x)/$decades+1,0)") |
181 |
|
set imap="imap(y)=10^((y-1)*$decades)" |
182 |
|
else |
183 |
|
set imap="imap(y)=y" |
184 |
|
endif |
185 |
+ |
if ( $legwidth > 20 && $legheight > 40 ) then |
186 |
|
pcomb $pc0args -e 'v=(y+.5)/yres;vleft=v;vright=v' \ |
187 |
|
-e 'vbelow=(y-.5)/yres;vabove=(y+1.5)/yres' \ |
188 |
|
-x $legwidth -y $legheight > $td/scol.pic |
189 |
< |
( echo $label; cnt $ndivs \ |
189 |
> |
( echo "$label"; cnt $ndivs \ |
190 |
|
| rcalc -e '$1='"($scale)*imap(($ndivs-.5-"'$1'")/$ndivs)" \ |
191 |
< |
-e "$imap" ) \ |
192 |
< |
| psign -cf 1 1 1 -cb 0 0 0 -h `ev "floor(2*$legheight/$ndivs+.5)"` \ |
193 |
< |
| pfilt -1 -x /2 -y /2 > $td/slab.pic |
194 |
< |
pcomb $pc0args $pc1args $picture $cpict \ |
195 |
< |
| pcompos $td/scol.pic 0 0 -t .2 $td/slab.pic 25 0 - $legwidth 0 |
191 |
> |
-e "$imap" | sed -e 's/\(\.[0-9][0-9][0-9]\)[0-9]*/\1/' ) \ |
192 |
> |
| psign -s -.15 -cf 1 1 1 -cb 0 0 0 \ |
193 |
> |
-h `ev "floor($legheight/$ndivs+.5)"` > $td/slab.pic |
194 |
> |
else |
195 |
> |
set legwidth=0 |
196 |
> |
set legheight=0 |
197 |
> |
(echo "" ; echo "-Y 1 +X 1" ; echo "aaa" ) > $td/scol.pic |
198 |
> |
cp $td/scol.pic $td/slab.pic |
199 |
> |
endif |
200 |
> |
if ( $?doextrem ) then |
201 |
> |
pextrem -o $picture > $td/extrema |
202 |
> |
set minpos=`sed 2d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"` |
203 |
> |
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/'` |
204 |
> |
set maxpos=`sed 1d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"` |
205 |
> |
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/'` |
206 |
> |
psign -s -.15 -a 2 -h 16 $minval > $td/minv.pic |
207 |
> |
psign -s -.15 -a 2 -h 16 $maxval > $td/maxv.pic |
208 |
> |
pcomb $pc0args $pc1args $picture $cpict \ |
209 |
> |
| pcompos $td/scol.pic 0 0 \ |
210 |
> |
+t .1 "\!pcomb -e 'lo=1-gi(1)' $td/slab.pic" \ |
211 |
> |
`ev 2 $loff-1` -t .5 $td/slab.pic 0 $loff \ |
212 |
> |
- $legwidth 0 $td/minv.pic $minpos $td/maxv.pic $maxpos |
213 |
> |
else |
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 |
219 |
> |
endif |
220 |
|
quit: |
221 |
|
rm -rf $td |