ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/dayfact.csh
(Generate patch)

Comparing ray/src/util/dayfact.csh (file contents):
Revision 1.7 by greg, Fri Jun 7 17:21:18 1991 UTC vs.
Revision 2.8 by greg, Mon Aug 25 04:50:32 2008 UTC

# Line 1 | Line 1
1   #!/bin/csh -f
2 < # SCCSid "$SunId$ LBL"
2 > # RCSid: $Id$
3   #
4   # Interactive script to calculate daylight factors
5   #
6   set nofile="none"
7 < set genskyf=$nofile
7 > set illumpic=$nofile
8   set octree=$nofile
9   set dfpict=$nofile
10   set ilpict=$nofile
11 + set dspict=$nofile
12 + set nodaysav=1
13   set fcopts=($*)
14 + set designlvl=500
15   set wporig=(0 0 0)
16   set wpsize=(1 1)
17 < set rtargs=(-ab 1 -ad 256 -as 128 -aa .15 -av .1 .1 .1)
17 > set rtargs=(-ab 1 -ad 256 -as 128 -aa .15 -av .3 .3 .3)
18   set maxres=128
19 + set td=`mktemp -d /tmp/df.XXXXXX`
20  
21   alias readvar 'echo -n Enter \!:1 "[$\!:1]: ";set ans="$<";if("$ans" != "")set \!:1="$ans"'
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.
26 > This script calculates daylight factors, illuminance levels, and/or
27 > energy savings due to daylight on a rectangular workplane and produces
28 > a contour plot from the result.  The input is a Radiance scene description
29 > (and octree) and the output is one or more color Radiance pictures.
30  
31   _EOF_
32 + echo "Have you already calculated an illuminance picture using dayfact?"
33 + readvar illumpic
34 + if ( $illumpic != $nofile ) then
35 +        if ( ! -r $illumpic ) then
36 +                echo "Cannot read $illumpic"
37 +                exit 1
38 +        endif
39 +        set title=$illumpic:r
40 +        set gotillumpic
41 +        goto getgenskyf
42 + endif
43 +
44   readvar octree
45 < if ( "$octree" == "$nofile" || ! -f "$octree" ) then
45 > if ( $octree == $nofile || ! -f $octree ) then
46          echo "You must first create an octree with"
47          echo "oconv before running this script."
48          exit 1
49   endif
50   set title="$octree:r"
35 echo "In what scene file is the gensky command located?"
36 readvar genskyf
37 if ( "$genskyf" == "$nofile" || ! -r "$genskyf" ) then
38        echo "You will not be able to compute daylight"
39        echo "factors since there is no gensky file."
40 else
41        set title=$title\ `sed -n 's/^.*\<gensky  *\([0-9][0-9]*  *[0-9][0-9]*  *[0-9][0-9.]*\).*$/\1/p' $genskyf`
42        set extamb=`xform -e $genskyf|sed -n 's/^# Ground ambient level: //p'`
43 endif
51   echo -n "Is the z-axis your zenith direction? "
52   if ( "$<" !~ [yY]* ) then
53          echo "I'm sorry, you cannot use this script"
# Line 57 | Line 64 | set rtargs=($rtargs -ar `getinfo -d<$octree|rcalc -e '
64   echo "What calculation options do you want to give to rtrace?"
65   echo "(It is very important to set the -a* options correctly.)"
66   readvar rtargs
67 + echo "Do you want to save the illuminance picture for later runs?"
68 + readvar illumpic
69 + ############
70 + getgenskyf:
71 + set genskyf=$nofile
72 + echo "In what scene file is the gensky command located?"
73 + readvar genskyf
74 + if ( $genskyf == $nofile ) then
75 +        echo "You will not be able to compute daylight factors"
76 +        echo "or energy savings since there is no gensky file."
77 + else
78 +        xform -e $genskyf > $td/gsf
79 +        grep '^# gensky ' $td/gsf
80 +        if ( $status ) then
81 +                echo "The file $genskyf does not contain a gensky command\!"
82 +                rm -f $td/gsf
83 +                goto getgenskyf
84 +        endif
85 +        set title=$title\ `sed -n 's/^# gensky  *\([0-9][0-9]*  *[0-9][0-9]*  *[0-9][0-9.]*\).*$/\1/p' $td/gsf`
86 +        set extamb=`sed -n 's/^# Ground ambient level: //p' $td/gsf`
87 +        grep -s '^# gensky .* -c' $td/gsf
88 +        set nodaysav=$status
89 +        rm -f $td/gsf
90 +        if ( $nodaysav ) then
91 +                echo "The gensky command was not done for an overcast sky"
92 +                echo "(-c option), so energy savings cannot be calculated."
93 +                echo -n "Continue anyway? "
94 +                if ( "$<" =~ [nN]* ) then
95 +                        exit 0
96 +                endif
97 +        endif
98 + endif
99   echo "Illuminance contour picture if you want one"
100   readvar ilpict
101   if ( $?extamb ) then
102          echo "Daylight factor contour picture if you want one"
103          readvar dfpict
104   endif
105 < if ( "$ilpict" == "$nofile" && "$dfpict" == "$nofile" ) then
105 > if ( ! $nodaysav ) then
106 >        echo "Energy savings contour picture if you want one"
107 >        readvar dspict
108 >        if ( $dspict != $nofile ) then
109 >                echo "Workplane design level (lux)"
110 >                readvar designlvl
111 >        endif
112 > endif
113 > if ( $ilpict == $nofile && $dfpict == $nofile && $dspict == $nofile ) then
114          echo "Since you don't want any output, I guess we're done."
115          exit 0
116   endif
117   echo "Title for output picture"
118   readvar title
119 + set sctemp=$td/sc.csh
120   cat <<'_EOF_' > $sctemp
121 < set iltemp=/usr/tmp/il$$.pic
122 < set sctemp=/usr/tmp/sc$$.csh
123 < set tltemp=/usr/tmp/tl$$.pic
124 < set tempfiles=($iltemp $sctemp $tltemp)
121 > if ( $illumpic != $nofile ) then
122 >        set iltemp=""
123 > else
124 >        set iltemp=$td/il.pic
125 >        set illumpic=$iltemp
126 > endif
127 > set tltemp=$td/tl.pic
128 > set dstemp=$td/ds.pic
129 > set temp1=$td/tfa
130   echo "Your dayfact job is finished."
131   echo "Please check for error messages below."
132   echo ""
133   set echo
134 < cnt $wpres[2] $wpres[1] \
134 > if ( ! $?gotillumpic ) then
135 >        cnt $wpres[2] $wpres[1] \
136          | rcalc -e '$1=($2+.5)/'"$wpres[1]*$wpsize[1]+$wporig[1]" \
137                  -e '$2=(1-($1+.5)/'"$wpres[2])*$wpsize[2]+$wporig[2]" \
138                  -e '$3='"$wporig[3]" -e '$4=0;$5=0;$6=1' \
139 <        | rtrace $rtargs -I -ov -faf $octree \
140 <        | pvalue -r -x $wpres[1] -y $wpres[2] -df \
141 <        | pfilt -h 20 -n 0 -x 350 -y 350 -p 1 -r 1 > $iltemp
142 < set maxval=`getinfo < $iltemp | rcalc -i 'EXPOSURE=${e}' -e '$1=3/e'`
143 < psign -h 50 " $title " | pfilt -1 -x /2 -y /2 > $tltemp
139 >        | rtrace $rtargs -h+ -I+ -ov -fac -x $wpres[1] -y $wpres[2] $octree \
140 >        > $temp1
141 >        pfilt -h 20 -n 0 -x 300 -y 300 -p 1 -r 1 $temp1 > $illumpic
142 > endif
143 > set maxval=`getinfo < $illumpic | rcalc -i 'EXPOSURE=${e}' -e '$1=3/e'`
144 > if ("$maxval" == "") set maxval=3
145 > psign -h 42 " $title " | pfilt -1 -x /2 -y /2 > $tltemp
146   '_EOF_'
147 < if ( "$ilpict" != "$nofile" ) then
148 <        echo 'falsecolor -cb -l Lux $fcopts \\
149 <                -s "$maxval*470" -m 470 -pi $iltemp \\
147 > if ( $ilpict != $nofile ) then
148 >        echo 'falsecolor -cb -l Lux -s "$maxval*179" \\
149 >                $fcopts -m 179 -ip $illumpic \\
150                  | pcompos -a 1 - $tltemp > $ilpict' >> $sctemp
151   endif
152 < if ( "$dfpict" != "$nofile" ) then
153 <        echo 'falsecolor -cb -l DF $fcopts \\
154 <                -s "100*$maxval/$extamb" -m "100/$extamb" -pi $iltemp \\
152 > if ( $dfpict != $nofile ) then
153 >        echo 'falsecolor -cb -l DF -s 16 \\
154 >                $fcopts -m "100/PI/$extamb" -ip $illumpic \\
155                  | pcompos -a 1 - $tltemp > $dfpict' >> $sctemp
156   endif
157 < echo 'rm -f $tempfiles' >> $sctemp
157 > if ( $dspict != $nofile ) then
158 >        echo 'pcomb -e "lo=1-$designlvl/20000*3.1416*$extamb/li(1)" \\
159 >                -o $illumpic | falsecolor -cb -l "%Save" -s 100 \\
160 >                $fcopts -m 100 -p $illumpic \\
161 >                | pcompos -a 1 - $tltemp > $dspict' >> $sctemp
162 > endif
163 > echo 'rm -r $td' >> $sctemp
164   (source $sctemp) |& mail `whoami` &
165   echo "Your job is started in the background."
166   echo "You will be notified by mail when it is done."

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines