--- ray/src/util/dayfact.csh 1991/11/28 11:49:12 2.2 +++ ray/src/util/dayfact.csh 2008/11/10 19:08:19 2.9 @@ -1,5 +1,5 @@ #!/bin/csh -f -# SCCSid "$SunId$ LBL" +# RCSid: $Id: dayfact.csh,v 2.9 2008/11/10 19:08:19 greg Exp $ # # Interactive script to calculate daylight factors # @@ -16,6 +16,7 @@ set wporig=(0 0 0) set wpsize=(1 1) set rtargs=(-ab 1 -ad 256 -as 128 -aa .15 -av .3 .3 .3) set maxres=128 +set td=`mktemp -d /tmp/df.XXXXXX` alias readvar 'echo -n Enter \!:1 "[$\!:1]: ";set ans="$<";if("$ans" != "")set \!:1="$ans"' @@ -28,9 +29,9 @@ a contour plot from the result. The input is a Radian (and octree) and the output is one or more color Radiance pictures. _EOF_ -echo -n "Have you already calculated an illuminance picture with dayfact? " -if ( "$<" =~ [yY]* ) then - readvar illumpic +echo "Have you already calculated an illuminance picture using dayfact?" +readvar illumpic +if ( $illumpic != $nofile ) then if ( ! -r $illumpic ) then echo "Cannot read $illumpic" exit 1 @@ -74,18 +75,18 @@ if ( $genskyf == $nofile ) then echo "You will not be able to compute daylight factors" echo "or energy savings since there is no gensky file." else - xform -e $genskyf > /usr/tmp/gsf$$ - grep '^# gensky ' /usr/tmp/gsf$$ + xform -e $genskyf > $td/gsf + grep '^# gensky ' $td/gsf if ( $status ) then echo "The file $genskyf does not contain a gensky command\!" - rm -f /usr/tmp/gsf$$ + rm -f $td/gsf goto getgenskyf endif - set title=$title\ `sed -n 's/^# gensky *\([0-9][0-9]* *[0-9][0-9]* *[0-9][0-9.]*\).*$/\1/p' /usr/tmp/gsf$$` - set extamb=`sed -n 's/^# Ground ambient level: //p' /usr/tmp/gsf$$` - grep -s '^# gensky .* -c' /usr/tmp/gsf$$ + set title=$title\ `sed -n 's/^# gensky *\([0-9][0-9]* *[0-9][0-9]* *[0-9][0-9.]*\).*$/\1/p' $td/gsf` + set extamb=`sed -n 's/^# Ground ambient level: //p' $td/gsf` + grep -s '^# gensky .* -c' $td/gsf set nodaysav=$status - rm -f /usr/tmp/gsf$$ + rm -f $td/gsf if ( $nodaysav ) then echo "The gensky command was not done for an overcast sky" echo "(-c option), so energy savings cannot be calculated." @@ -115,18 +116,17 @@ if ( $ilpict == $nofile && $dfpict == $nofile && $dspi endif echo "Title for output picture" readvar title -set sctemp=/usr/tmp/sc$$.csh +set sctemp=$td/sc.csh cat <<'_EOF_' > $sctemp if ( $illumpic != $nofile ) then set iltemp="" else - set iltemp=/usr/tmp/il$$.pic + set iltemp=$td/il.hdr set illumpic=$iltemp endif -set tltemp=/usr/tmp/tl$$.pic -set dstemp=/usr/tmp/ds$$.pic -set temp1=/usr/tmp/tfa$$ -set tempfiles=($iltemp $sctemp $tltemp $dstemp $temp1) +set tltemp=$td/tl.hdr +set dstemp=$td/ds.hdr +set temp1=$td/tfa echo "Your dayfact job is finished." echo "Please check for error messages below." echo "" @@ -136,11 +136,12 @@ if ( ! $?gotillumpic ) then | rcalc -e '$1=($2+.5)/'"$wpres[1]*$wpsize[1]+$wporig[1]" \ -e '$2=(1-($1+.5)/'"$wpres[2])*$wpsize[2]+$wporig[2]" \ -e '$3='"$wporig[3]" -e '$4=0;$5=0;$6=1' \ - | rtrace $rtargs -h+ -I+ -ov -faf $octree \ - | pvalue -r -y $wpres[2] +x $wpres[1] -df > $temp1 + | rtrace $rtargs -h+ -I+ -ov -fac -x $wpres[1] -y $wpres[2] $octree \ + > $temp1 pfilt -h 20 -n 0 -x 300 -y 300 -p 1 -r 1 $temp1 > $illumpic endif set maxval=`getinfo < $illumpic | rcalc -i 'EXPOSURE=${e}' -e '$1=3/e'` +if ("$maxval" == "") set maxval=3 psign -h 42 " $title " | pfilt -1 -x /2 -y /2 > $tltemp '_EOF_' if ( $ilpict != $nofile ) then @@ -149,7 +150,7 @@ if ( $ilpict != $nofile ) then | pcompos -a 1 - $tltemp > $ilpict' >> $sctemp endif if ( $dfpict != $nofile ) then - echo 'falsecolor -cb -l DF -s 50 \\ + echo 'falsecolor -cb -l DF -s 16 \\ $fcopts -m "100/PI/$extamb" -ip $illumpic \\ | pcompos -a 1 - $tltemp > $dfpict' >> $sctemp endif @@ -159,7 +160,7 @@ if ( $dspict != $nofile ) then $fcopts -m 100 -p $illumpic \\ | pcompos -a 1 - $tltemp > $dspict' >> $sctemp endif -echo 'rm -f $tempfiles' >> $sctemp +echo 'rm -r $td' >> $sctemp (source $sctemp) |& mail `whoami` & echo "Your job is started in the background." echo "You will be notified by mail when it is done."