3 |
|
# |
4 |
|
# Create false color image with legend |
5 |
|
# |
6 |
< |
set tempdir=/usr/tmp/fc$$ |
6 |
> |
set td=/usr/tmp/fc$$ |
7 |
|
onintr quit |
8 |
< |
set mult=470 |
8 |
> |
set mult=179 |
9 |
|
set label=Nits |
10 |
|
set scale=1000 |
11 |
|
set decades=0 |
12 |
< |
set redv='2*v-1' |
13 |
< |
set grnv='if(v-.5,2-2*v,2*v)' |
14 |
< |
set bluv='1-2*v' |
12 |
> |
set redv='1.6*v-.6' |
13 |
> |
set grnv='if(v-.375,1.6-1.6*v,8/3*v)' |
14 |
> |
set bluv='1-8/3*v' |
15 |
|
set ndivs=8 |
16 |
|
set picture='-' |
17 |
|
set cpict= |
18 |
+ |
set legwidth=100 |
19 |
+ |
set legheight=200 |
20 |
|
while ($#argv > 0) |
21 |
|
switch ($argv[1]) |
22 |
|
case -m: |
67 |
|
case -cb: |
68 |
|
set docont=b |
69 |
|
breaksw |
70 |
+ |
case -e: |
71 |
+ |
set doextrem |
72 |
+ |
set needfile |
73 |
+ |
breaksw |
74 |
|
case -n: |
75 |
|
shift argv |
76 |
|
set ndivs="$argv[1]" |
81 |
|
endsw |
82 |
|
shift argv |
83 |
|
end |
84 |
< |
mkdir $tempdir |
85 |
< |
cat > $tempdir/pc.cal <<_EOF_ |
84 |
> |
mkdir $td |
85 |
> |
cat > $td/pc0.cal <<_EOF_ |
86 |
> |
PI : 3.14159265358979323846 ; |
87 |
|
scale : $scale ; |
88 |
|
mult : $mult ; |
89 |
|
ndivs : $ndivs ; |
91 |
|
or(a,b) : if(a,a,b); |
92 |
|
EPS : 1e-7; |
93 |
|
neq(a,b) : if(a-b-EPS,1,b-a-EPS); |
94 |
< |
btwn(a,b) : if(a-x,-1,b-x); |
94 |
> |
btwn(a,x,b) : if(a-x,-1,b-x); |
95 |
> |
clip(x) : if(x-1,1,if(x,x,0)); |
96 |
|
frac(x) : x - floor(x); |
97 |
< |
boundary(a,b) : neq(floor(ndivs*a),floor(ndivs*b)); |
97 |
> |
boundary(a,b) : neq(floor(ndivs*a+.5),floor(ndivs*b+.5)); |
98 |
|
|
99 |
< |
map(x) = x; |
100 |
< |
red = $redv; |
93 |
< |
grn = $grnv; |
94 |
< |
blu = $bluv; |
99 |
> |
isconta = if(btwn(0,v,1),or(boundary(vleft,vright),boundary(vabove,vbelow)),-1); |
100 |
> |
iscontb = if(btwn(0,v,1),btwn(.4,frac(ndivs*v),.6),-1); |
101 |
|
|
102 |
< |
v = map(li(1)*(mult/scale)); |
103 |
< |
vleft = map(li(1,-1,0)*(mult/scale)); |
104 |
< |
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); |
102 |
> |
ro = if(in,clip($redv),ra); |
103 |
> |
go = if(in,clip($grnv),ga); |
104 |
> |
bo = if(in,clip($bluv),ba); |
105 |
|
|
106 |
< |
ro = if(in,red,ra); |
107 |
< |
go = if(in,grn,ga); |
108 |
< |
bo = if(in,blu,ba); |
106 |
> |
ra = 0; |
107 |
> |
ga = 0; |
108 |
> |
ba = 0; |
109 |
|
|
110 |
+ |
in = 1; |
111 |
+ |
_EOF_ |
112 |
+ |
cat > $td/pc1.cal <<_EOF_ |
113 |
+ |
norm : mult/scale/le(1); |
114 |
+ |
|
115 |
+ |
v = map(li(1)*norm); |
116 |
+ |
|
117 |
+ |
vleft = map(li(1,-1,0)*norm); |
118 |
+ |
vright = map(li(1,1,0)*norm); |
119 |
+ |
vabove = map(li(1,0,1)*norm); |
120 |
+ |
vbelow = map(li(1,0,-1)*norm); |
121 |
+ |
|
122 |
+ |
map(x) = x; |
123 |
+ |
|
124 |
|
ra = ri(nfiles); |
125 |
|
ga = gi(nfiles); |
126 |
|
ba = bi(nfiles); |
111 |
– |
|
112 |
– |
in = 1; |
127 |
|
_EOF_ |
128 |
< |
set pcargs=(-o -f $tempdir/pc.cal) |
128 |
> |
set pc0args=(-f $td/pc0.cal) |
129 |
> |
set pc1args=(-f $td/pc1.cal) |
130 |
|
if ($?docont) then |
131 |
< |
set pcargs=($pcargs -e "in=iscont$docont") |
131 |
> |
set pc0args=($pc0args -e "in=iscont$docont") |
132 |
|
endif |
133 |
|
if ("$cpict" == "") then |
134 |
< |
set pcargs=($pcargs -e 'ra=0;ga=0;ba=0') |
134 |
> |
set pc1args=($pc1args -e 'ra=0;ga=0;ba=0') |
135 |
|
else if ("$cpict" == "$picture") then |
136 |
|
set cpict= |
137 |
|
endif |
138 |
+ |
if ($?needfile && "$picture" == '-') then |
139 |
+ |
cat > $td/picture |
140 |
+ |
set picture=$td/picture |
141 |
+ |
endif |
142 |
|
if ($decades > 0) then |
143 |
< |
set pcargs=($pcargs -e "map(x)=log10(x)/$decades+1") |
143 |
> |
set pc1args=($pc1args -e "map(x)=if(x-10^-$decades,log10(x)/$decades+1,0)") |
144 |
|
set imap="imap(y)=10^((y-1)*$decades)" |
145 |
|
else |
146 |
|
set imap="imap(y)=y" |
147 |
|
endif |
148 |
< |
pcomb $pcargs -e 'v=(y+.5)/200;vleft=v;vright=v' \ |
149 |
< |
-e 'vbelow=(y-.5)/200;vabove=(y+1.5)/200' \ |
150 |
< |
-e 'ra=0;ga=0;ba=0' -x 100 -y 200 \ |
132 |
< |
> $tempdir/scol.pic |
148 |
> |
pcomb $pc0args -e 'v=(y+.5)/yres;vleft=v;vright=v' \ |
149 |
> |
-e 'vbelow=(y-.5)/yres;vabove=(y+1.5)/yres' \ |
150 |
> |
-x $legwidth -y $legheight > $td/scol.pic |
151 |
|
( echo $label; cnt $ndivs \ |
152 |
|
| rcalc -e '$1='"($scale)*imap(($ndivs-.5-"'$1'")/$ndivs)" \ |
153 |
|
-e "$imap" ) \ |
154 |
< |
| psign -cf 1 1 1 -cb 0 0 0 -h `ev "floor(2*200/$ndivs+.5)"` \ |
155 |
< |
| pfilt -1 -x /2 -y /2 > $tempdir/slab.pic |
156 |
< |
pcomb $pcargs $picture $cpict \ |
157 |
< |
| pcompos $tempdir/scol.pic 0 0 -t .2 $tempdir/slab.pic 25 0 - 100 0 |
154 |
> |
| psign -s -.15 -cf 1 1 1 -cb 0 0 0 \ |
155 |
> |
-h `ev "floor($legheight/$ndivs+.5)"` > $td/slab.pic |
156 |
> |
if ( $?doextrem ) then |
157 |
> |
pextrem -o $picture > $td/extrema |
158 |
> |
set minpos=`sed 2d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"` |
159 |
> |
set minval=`rcalc -e '$1=($3*.3+$4*.59+$5*.11)*'"$mult" $td/extrema | sed -e 2d -e 's/\(.....\).*$/\1/'` |
160 |
> |
set maxpos=`sed 1d $td/extrema | rcalc -e '$2=$2;$1=$1+'"$legwidth"` |
161 |
> |
set maxval=`rcalc -e '$1=($3*.3+$4*.59+$5*.11)*'"$mult" $td/extrema | sed -e 1d -e 's/\(.....\).*$/\1/'` |
162 |
> |
psign -s -.15 -a 2 -h 16 $minval > $td/minv.pic |
163 |
> |
psign -s -.15 -a 2 -h 16 $maxval > $td/maxv.pic |
164 |
> |
pcomb $pc0args $pc1args $picture $cpict \ |
165 |
> |
| pcompos $td/scol.pic 0 0 -t .2 $td/slab.pic 0 20 \ |
166 |
> |
- $legwidth 0 $td/minv.pic $minpos $td/maxv.pic $maxpos |
167 |
> |
else |
168 |
> |
pcomb $pc0args $pc1args $picture $cpict \ |
169 |
> |
| pcompos $td/scol.pic 0 0 -t .2 $td/slab.pic 0 20 - $legwidth 0 |
170 |
> |
endif |
171 |
|
quit: |
172 |
< |
rm -rf $tempdir |
172 |
> |
rm -rf $td |