User Tools

Site Tools


resources:sol-pen-script

Solar Penetration Script

An ancient (~2003) script to automate the creation of a series of a pair of Radiance images: one fixed (e.g. from above with the roof clipped off) and one from the view direction of the sun. Adjust as required - probably best not to use as a style guide for shell scripting…

#!/bin/csh -f

#  Script to generate sequence of images -- scene must be centred on the origin.
#  
#	John Mardaljevic                     
#	School of Civil & Building Engineering
#	Loughborough University
#	Loughborough
#	Leicestershire
#	LE11 3TU, UK
#	
#	j.mardaljevic@lboro.ac.uk
#
#  Set month and day and geographical coordinates
#

set oct = cen_x.oct

set day   = 01

set lat   =   39.1
set lon   =   86.3 
set mer   =   75.0
set coord = (-a $lat -o $lon -m $mer)

set id = some-tag

foreach mon (01 02 03 04 05 06)

if($mon =~ 01) set month = January
if($mon =~ 02) set month = February
if($mon =~ 03) set month = March
if($mon =~ 04) set month = April
if($mon =~ 05) set month = May
if($mon =~ 06) set month = June
if($mon =~ 07) set month = July
if($mon =~ 08) set month = August
if($mon =~ 09) set month = September
if($mon =~ 10) set month = October
if($mon =~ 11) set month = November
if($mon =~ 12) set month = December

foreach hri (08 09 10 11 12 13 14 15 16 17 18 19 20) 

  foreach mn (00 15 30 45)

   set hr = $hri":"$mn

   set hrh = $hri"h"$mn

   set skypar = ($mon $day $hr +i $coord -r 1.0e+06)

   set skyout = `gensky $skypar`
   echo "Sun altitude  " $skyout[25]

   if (`expr $skyout[25] \<= 0`) goto BELOW_HORIZ

   set xv = $skyout[47]
   set yv = $skyout[48]
   set zv = $skyout[49]

   set vfac = 1000
   set ang =  4
   set vh = $ang
   set vv = $ang

   set xp = `rcalc -n -e '$1='"$xv"'*'"$vfac"`
   set yp = `rcalc -n -e '$1='"$yv"'*'"$vfac"`
   set zp = `rcalc -n -e '$1='"$zv"'*'"$vfac"`

   set xd = `rcalc -n -e '$1='"$xv"'*-1'`
   set yd = `rcalc -n -e '$1='"$yv"'*-1'`
   set zd = `rcalc -n -e '$1='"$zv"'*-1'`

   set dim =  600

   gensky $skypar \
	| oconv -w -i $oct - \
	| rpict -w -vp $xp $yp $zp -vd $xd $yd $zd -vh $vh -vv $vv -x $dim -y $dim \
	| pfilt -1 -e 0.06  -x /2 -y /2  \
	| pcompos - 0 0 '\!psign -h 20 '"$month"' '"$day"' '"$hrh" 0 0 \
	>! tmp1.hdr

   gensky $skypar \
	| oconv -w -i $oct - \
	| rpict -w -vf tclip.vf -av 0.0 0.5 0.0  -x $dim -y $dim \
	| pfilt -1 -e 0.50  -x /2 -y /2  \
	| pcompos - 300 0 tmp1.hdr 0 0 \
	>! $id"_"$mon"_"$day"_"$hrh.hdr

   rm tmp1.hdr

   echo "Completed image ..." $id"_"$mon"_"$day"_"$hrh

   BELOW_HORIZ:

   end

end

end

resources/sol-pen-script.txt · Last modified: 2015/07/06 19:32 by cbdm

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki