5

I'm trying to create monthly average maps as described in R.Sun in Grass. I have my DSM. In reading the page on OSGEO it mentions that it is possible without showing how. Ideas? I assume I will need to write a script.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
psxmi
  • 89
  • 3

2 Answers2

4

I guess that you need to loop over days in a month and then average. Here's attempt at a bash script. The ideas is to calculate the individual solar radiation, and then store the filenames. You can process those with r.series to calculate the monthly average.

#!/bin/bash
mdoys=( 31 59 90 120 151 181 212 243 273 304 334 365 ) 
months=( 'January' 'February' 'March' 'April' 'May' 'June' 'July' 'August' 'September' 'October' 'November' 'December' )
this_month=0
files=""
for ((doy=1;doy<365;doy++)) do

  r.sun -s elev=elevation.dem slop=slope asp=aspect \
        beam_read=beam_${doy} diff_rad=diff_${doy} day=${doy}

  if [[ ${doy} -lt ${mdoys[${this_month}]} ]] ;  then
   files=${files},beam_${doy}
  fi
  if [[ ${doy} -eq ${mdoys[${this_month}]} ]] ; then
   files=${files},beam_${doy}
   echo ${files} > rasters_${months[$this_month]}
   this_month=$((this_month+1))
   # Use r.series to process the files in rasters_January, for example
  fi
done
Jose
  • 3,332
  • 20
  • 21
4

Here a link to a plain shell script (rather than the bash solution of Jose's comment): http://www.grassbook.org/examples_menu2nd.php

Get there: rsun_crop.sh

markusN
  • 12,976
  • 31
  • 48