1 |
#!/bin/csh -f |
2 |
# SCCSid "$SunId$ LBL" |
3 |
# |
4 |
# Create false color image with legend |
5 |
# |
6 |
set tempdir=/usr/tmp/fc$$ |
7 |
onintr quit |
8 |
set mult=470 |
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' |
15 |
set ndivs=8 |
16 |
set picture='-' |
17 |
set cpict= |
18 |
while ($#argv > 0) |
19 |
switch ($argv[1]) |
20 |
case -m: |
21 |
shift argv |
22 |
set mult="$argv[1]" |
23 |
breaksw |
24 |
case -s: |
25 |
shift argv |
26 |
set scale="$argv[1]" |
27 |
breaksw |
28 |
case -l: |
29 |
shift argv |
30 |
set label="$argv[1]" |
31 |
breaksw |
32 |
case -log: |
33 |
shift argv |
34 |
set decades=$argv[1] |
35 |
breaksw |
36 |
case -r: |
37 |
shift argv |
38 |
set redv="$argv[1]" |
39 |
breaksw |
40 |
case -g: |
41 |
shift argv |
42 |
set grnv="$argv[1]" |
43 |
breaksw |
44 |
case -b: |
45 |
shift argv |
46 |
set bluv="$argv[1]" |
47 |
breaksw |
48 |
case -i: |
49 |
shift argv |
50 |
set picture="$argv[1]" |
51 |
breaksw |
52 |
case -p: |
53 |
shift argv |
54 |
set cpict="$argv[1]" |
55 |
breaksw |
56 |
case -ip: |
57 |
case -pi: |
58 |
shift argv |
59 |
set picture="$argv[1]" |
60 |
set cpict="$argv[1]" |
61 |
breaksw |
62 |
case -cl: |
63 |
set docont=a |
64 |
breaksw |
65 |
case -cb: |
66 |
set docont=b |
67 |
breaksw |
68 |
case -n: |
69 |
shift argv |
70 |
set ndivs="$argv[1]" |
71 |
breaksw |
72 |
default: |
73 |
echo bad option "'$argv[1]'" >/dev/tty |
74 |
exit 1 |
75 |
endsw |
76 |
shift argv |
77 |
end |
78 |
mkdir $tempdir |
79 |
cat > $tempdir/pc.cal <<_EOF_ |
80 |
scale : $scale ; |
81 |
mult : $mult ; |
82 |
ndivs : $ndivs ; |
83 |
|
84 |
or(a,b) : if(a,a,b); |
85 |
EPS : 1e-7; |
86 |
neq(a,b) : if(a-b-EPS,1,b-a-EPS); |
87 |
btwn(a,b) : if(a-x,-1,b-x); |
88 |
frac(x) : x - floor(x); |
89 |
boundary(a,b) : neq(floor(ndivs*a),floor(ndivs*b)); |
90 |
|
91 |
map(x) = x; |
92 |
red = $redv; |
93 |
grn = $grnv; |
94 |
blu = $bluv; |
95 |
|
96 |
v = map(li(1)*(mult/scale)); |
97 |
vleft = map(li(1,-1,0)*(mult/scale)); |
98 |
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); |
103 |
|
104 |
ro = if(in,red,ra); |
105 |
go = if(in,grn,ga); |
106 |
bo = if(in,blu,ba); |
107 |
|
108 |
ra = ri(nfiles); |
109 |
ga = gi(nfiles); |
110 |
ba = bi(nfiles); |
111 |
|
112 |
in = 1; |
113 |
_EOF_ |
114 |
set pcargs=(-o -f $tempdir/pc.cal) |
115 |
if ($?docont) then |
116 |
set pcargs=($pcargs -e "in=iscont$docont") |
117 |
endif |
118 |
if ("$cpict" == "") then |
119 |
set pcargs=($pcargs -e 'ra=0;ga=0;ba=0') |
120 |
else if ("$cpict" == "$picture") then |
121 |
set cpict= |
122 |
endif |
123 |
if ($decades > 0) then |
124 |
set pcargs=($pcargs -e "map(x)=log10(x)/$decades+1") |
125 |
set imap="imap(y)=10^((y-1)*$decades)" |
126 |
else |
127 |
set imap="imap(y)=y" |
128 |
endif |
129 |
pcomb $pcargs -e 'v=(y+.5)/200;vleft=v;vright=v' \ |
130 |
-e 'vbelow=(y-.5)/200;vabove=(y+1.5)/200' \ |
131 |
-e 'ra=0;ga=0;ba=0' -x 100 -y 200 \ |
132 |
> $tempdir/scol.pic |
133 |
( echo $label; cnt $ndivs \ |
134 |
| rcalc -e '$1='"($scale)*imap(($ndivs-.5-"'$1'")/$ndivs)" \ |
135 |
-e "$imap" ) \ |
136 |
| psign -cf 1 1 1 -cb 0 0 0 -h `ev "floor(2*200/$ndivs+.5)"` \ |
137 |
| pfilt -1 -x /2 -y /2 > $tempdir/slab.pic |
138 |
pcomb $pcargs $picture $cpict \ |
139 |
| pcompos $tempdir/scol.pic 0 0 -t .2 $tempdir/slab.pic 25 0 - 100 0 |
140 |
quit: |
141 |
rm -rf $tempdir |