1 |
greg |
1.1 |
#!/bin/csh -f |
2 |
|
|
# SCCSid "$SunId$ LBL" |
3 |
|
|
# |
4 |
|
|
# Interactive script to calculate daylight factors |
5 |
|
|
# |
6 |
|
|
set nofile="none" |
7 |
|
|
set genskyf=$nofile |
8 |
|
|
set octree=$nofile |
9 |
|
|
set dfpict=$nofile |
10 |
|
|
set ilpict=$nofile |
11 |
|
|
set wporig=(0 0 0) |
12 |
|
|
set wpsize=(1 1) |
13 |
|
|
set rtargs=(-ab 1 -ad 256 -as 128 -aa .15 -av .1 .1 .1) |
14 |
|
|
|
15 |
|
|
set maxres=64 |
16 |
|
|
set iltemp=/usr/tmp/il$$.pic |
17 |
|
|
set tempfiles=($iltemp) |
18 |
|
|
|
19 |
|
|
alias readvar 'echo -n Enter \!:1 "[$\!:1]: ";set ans="$<";if("$ans" != "")set \!:1="$ans"' |
20 |
|
|
|
21 |
|
|
onintr quit |
22 |
|
|
|
23 |
|
|
cat <<_EOF_ |
24 |
|
|
DAYLIGHT FACTOR CALCULATION |
25 |
|
|
|
26 |
|
|
This script calculates daylight factors and/or illuminance levels on a |
27 |
|
|
rectangular workplane and produces a contour plot from the result. The |
28 |
|
|
input is a Radiance scene description (and octree) and the output is one |
29 |
|
|
or more color Radiance pictures. |
30 |
|
|
|
31 |
|
|
_EOF_ |
32 |
|
|
readvar octree |
33 |
|
|
if ( "$octree" == "$nofile" || ! -f "$octree" ) then |
34 |
|
|
echo "You must first create an octree with oconv" |
35 |
|
|
echo "before running this script." |
36 |
|
|
exit 1 |
37 |
|
|
endif |
38 |
|
|
echo "" |
39 |
|
|
echo "In what scene file is the gensky command located?" |
40 |
|
|
readvar genskyf |
41 |
greg |
1.2 |
if ( "$genskyf" == "$nofile" || ! -r "$genskyf" ) then |
42 |
greg |
1.1 |
echo "You will not be able to compute" |
43 |
|
|
echo "daylight factors without a gensky file" |
44 |
|
|
else |
45 |
|
|
set extamb=`xform -e $genskyf|sed -n 's/^# Ground ambient level: //p'` |
46 |
greg |
1.2 |
echo extamb = $extamb |
47 |
greg |
1.1 |
endif |
48 |
greg |
1.2 |
echo -n "Is the z-axis your zenith direction? " |
49 |
|
|
if ( "$<" !~ [yY]* ) then |
50 |
greg |
1.1 |
echo "I'm sorry, you cannot use this script" |
51 |
|
|
exit 1 |
52 |
|
|
endif |
53 |
|
|
echo "What is the origin (smallest x y z coordinates) of the workplane?" |
54 |
|
|
readvar wporig |
55 |
|
|
set wporig=($wporig) |
56 |
|
|
echo "What is the x and y size (width and length) of the workplane?" |
57 |
greg |
1.2 |
readvar wpsize |
58 |
greg |
1.1 |
set wpsize=($wpsize) |
59 |
|
|
set wpres=(`rcalc -n -e '$1=if(l,'"floor($maxres*$wpsize[1]/$wpsize[2]),$maxres);"'$2=if(l,'"$maxres,floor($maxres*$wpsize[2]/$wpsize[1]));l=$wpsize[2]-$wpsize[1]"`) |
60 |
|
|
set rtargs=($rtargs -ar `getinfo -d<$octree|rcalc -e '$1=floor(16*$4/'"($wpsize[1]+$wpsize[2]))"`) |
61 |
|
|
echo "What calculation options do you want to give to rtrace?" |
62 |
|
|
echo "(It is very important to set the -a? options correctly.)" |
63 |
|
|
readvar rtargs |
64 |
|
|
echo "Illuminance contour picture if you want one" |
65 |
|
|
readvar ilpict |
66 |
|
|
if ( $?extamb ) then |
67 |
|
|
echo "Daylight factor contour picture if you want one" |
68 |
|
|
readvar dfpict |
69 |
|
|
endif |
70 |
|
|
if ( "$ilpict" == "$nofile" && "$dfpict" == "$nofile" ) then |
71 |
|
|
echo "Since you don't want any output, I guess we're done." |
72 |
|
|
exit 0 |
73 |
|
|
endif |
74 |
|
|
echo "Starting rtrace calculation -- this will take some time..." |
75 |
greg |
1.2 |
cnt $wpres[2] $wpres[1] \ |
76 |
|
|
| rcalc -e '$1=($2+.5)/'"$wpres[1]*$wpsize[1]+$wporig[1]" \ |
77 |
|
|
-e '$2=(1-($1+.5)/'"$wpres[2])*$wpsize[2]+$wporig[2]" \ |
78 |
|
|
-e '$3='"$wporig[3]" -e '$4=0;$5=0;$6=1' \ |
79 |
greg |
1.1 |
| rtrace $rtargs -I -ov -faf $octree \ |
80 |
|
|
| pvalue -r -x $wpres[1] -y $wpres[2] -df \ |
81 |
greg |
1.2 |
| pfilt -h 20 -n 0 -x 256 -y 256 -p 1 -r 1 > $iltemp |
82 |
greg |
1.1 |
set maxval=`getinfo < $iltemp | rcalc -i 'EXPOSURE=${e}' -e '$1=3/e'` |
83 |
|
|
if ( "$ilpict" != "$nofile" ) then |
84 |
|
|
echo "Making illuminance contour picture $ilpict..." |
85 |
|
|
falsecolor -s "$maxval*470" -l Lux -log 2 -cl -pi $iltemp > $ilpict |
86 |
|
|
endif |
87 |
|
|
if ( "$dfpict" != "$nofile" ) then |
88 |
|
|
echo "Making daylight factor contour picture $dfpict..." |
89 |
|
|
falsecolor -s "$maxval/$extamb" -m "1/$extamb" -l DF \ |
90 |
|
|
-log 2 -cl -pi $iltemp > $dfpict |
91 |
|
|
endif |
92 |
|
|
echo "Done." |
93 |
|
|
quit: |
94 |
|
|
rm -f $tempfiles |