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