<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FRussel08</id>
	<title>GRASS-Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FRussel08"/>
	<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/wiki/Special:Contributions/%E2%9A%A0%EF%B8%8FRussel08"/>
	<updated>2026-05-26T01:59:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=R.sun&amp;diff=10815</id>
		<title>R.sun</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=R.sun&amp;diff=10815"/>
		<updated>2010-05-07T01:13:07Z</updated>

		<summary type="html">&lt;p&gt;⚠️Russel08: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Help page ==&lt;br /&gt;
&lt;br /&gt;
* {{cmd|r.sun}} manual page&lt;br /&gt;
&lt;br /&gt;
== Tips ==&lt;br /&gt;
&lt;br /&gt;
The speed of r.sun is much higher if {{cmd|r.horizon}} is used first and the resulting maps are given as input to r.sun. Background: the horizon needs to be computed only one time before, not in every step within r.sun. See the example at the end of the {{cmd|r.sun}} help page.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
Create an artificial surface containing a Gaussian mound:&lt;br /&gt;
 {{AddonCmd|r.surf.volcano}} out=gauss method=gaussian kurtosis=1&lt;br /&gt;
&lt;br /&gt;
Overlay some 200m contours to show underlying topography:&lt;br /&gt;
 r.contour in=gauss out=gauss_200m_contours step=200&lt;br /&gt;
 d.vect gauss_200m_contours color=white&lt;br /&gt;
&lt;br /&gt;
Set map's color table to highlight detail:&lt;br /&gt;
 r.colors rad_test.day355.beam col=bcyr -e&lt;br /&gt;
 d.legend rad_test.day355.beam range=1300,1500&lt;br /&gt;
&lt;br /&gt;
=== Time step ===&lt;br /&gt;
&lt;br /&gt;
The following three images demonstrate the effects of using different time '''step''' parameters.&lt;br /&gt;
&lt;br /&gt;
 r.sun -s elevin=&amp;quot;gauss&amp;quot; glob_rad=&amp;quot;rad.global.30minT&amp;quot; day=180 step=0.5&lt;br /&gt;
&lt;br /&gt;
[[File:Gauss_30min.png|400px|thumb|center|Default 30 minute time step over a Gaussian mound.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 r.sun -s elevin=&amp;quot;gauss&amp;quot; glob_rad=&amp;quot;rad.global.15minT&amp;quot; day=180 step=0.25&lt;br /&gt;
&lt;br /&gt;
[[File:Gauss_15min.png|400px|thumb|center|15 minute time step over a Gaussian mound.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 r.sun -s elevin=&amp;quot;gauss&amp;quot; glob_rad=&amp;quot;rad.global.03minT&amp;quot; day=180 step=0.05&lt;br /&gt;
&lt;br /&gt;
[[File:Gauss_03min.png|400px|thumb|center|3 minute time step over a Gaussian mound.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The 3 minute time step takes roughly ten times as long to run as the 30 minute timestep.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Seed maps ==&lt;br /&gt;
&lt;br /&gt;
Using seed maps can greatly (?, unclear) speed up processing. This is especially important if you will batch process e.g. for every day of the year.&lt;br /&gt;
&lt;br /&gt;
* aspin= and slopein= options: create slope and aspect maps with the {{cmd|r.slope.aspect}} module.&lt;br /&gt;
: ''Caution: currently buggy''. See {{trac|498}}.&lt;br /&gt;
: Estimated speedup:  ?%.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* horizon= and horizonstep= options: Pre-calculate horizon shadows by creating a series of horizon rasters with the {{cmd|r.horizon}} module.&lt;br /&gt;
: Results not as smooth as without using this option?? See {{trac|498}}.&lt;br /&gt;
: Estimated speedup:  ?%.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* latin= and longin= options: Pre-calculate latitudes and longitudes for each raster cell.&lt;br /&gt;
The following script will create a raster containing latitude as the raster value:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 # create latitude map (WGS84)&lt;br /&gt;
 g.region rast=elevation.dem&lt;br /&gt;
 r.mapcalc one=1&lt;br /&gt;
 r.out.xyz one | \&lt;br /&gt;
   cut -f1,2 -d'|' | \&lt;br /&gt;
   m.proj -oed --quiet | \&lt;br /&gt;
   sed -e 's/[ \t]/|/g' | \&lt;br /&gt;
   cut -f1-4 -d'|' | \&lt;br /&gt;
   r.in.xyz in=- z=4 out=elevation.lat&lt;br /&gt;
 g.remove one&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creating the longitude map is exactly the same but use column 3 of the {{cmd|m.proj}} output instead of column 4:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 # create longitude map (WGS84)&lt;br /&gt;
 g.region rast=elevation.dem&lt;br /&gt;
 r.mapcalc one=1&lt;br /&gt;
 r.out.xyz one | \&lt;br /&gt;
   cut -f1,2 -d'|' | \&lt;br /&gt;
   m.proj -oed --quiet | \&lt;br /&gt;
   sed -e 's/[ \t]/|/g' | \&lt;br /&gt;
   cut -f1-4 -d'|' | \&lt;br /&gt;
   r.in.xyz in=- z=3 out=elevation.lon&lt;br /&gt;
 g.remove one&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: Estimated speedup:  1.3% (in one test).&lt;br /&gt;
: See {{trac|498}}.&lt;br /&gt;
&lt;br /&gt;
The above assumes that your projection's ellipsoid is WGS84. If it isn't,  use other proj_out= terms with m.proj as required instead of the -o flag.&lt;br /&gt;
&lt;br /&gt;
== Automation ==&lt;br /&gt;
&lt;br /&gt;
It can be tedious to set up and run a long series of r.sun simulations for every day of the year. To automate this we can write a small shell script loop:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 for DAY in `seq 1 365` ; do&lt;br /&gt;
    DAY_STR=`echo $DAY | awk '{printf(&amp;quot;%.03d&amp;quot;, $1)}'`&lt;br /&gt;
    echo &amp;quot;Processing day $DAY_STR at `date` ...&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
    LINKE=&amp;quot;`g.linke_by_day.py $DAY`&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
    r.sun -s elevin=elevation.dem day=$DAY lin=$LINKE step=0.05 \&lt;br /&gt;
        beam_rad=rad_beam.$DAY_STR diff_rad=rad_diffuse.$DAY_STR \&lt;br /&gt;
        refl_rad=rad_reflected.$DAY_STR glob_rad=rad_global.$DAY_STR \&lt;br /&gt;
        insol_time=rad_insol_time.$DAY_STR&lt;br /&gt;
 done&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [https://trac.osgeo.org/grass/browser/grass-addons/raster/r.sun.tools g.linke_by_day.py] is a small program which will return the Linke coefficient for any day of the year, interpolated from monthly values. You need to edit the script to fill in values appropriate for your study area.&lt;br /&gt;
&lt;br /&gt;
* If you have a multi-core CPU and you'd like to speed things up, here is a small Bourne shell script implementing a poor-man's multi-processing trick:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
 ### r.sun mode 2 loop ###&lt;br /&gt;
 BEGIN=1&lt;br /&gt;
 END=365&lt;br /&gt;
 STEP=1&lt;br /&gt;
 NUM_CORES=4&lt;br /&gt;
&lt;br /&gt;
 for DAY in `seq $BEGIN $STEP $END` ; do&lt;br /&gt;
    DAY_STR=`echo $DAY | awk '{printf(&amp;quot;%.03d&amp;quot;, $1)}'`&lt;br /&gt;
    echo &amp;quot;Processing day $DAY_STR at `date` ...&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    LINKE=&amp;quot;`g.linke_by_day.py $DAY`&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
    CMD=&amp;quot;r.sun -s elevin=elevation.dem day=$DAY lin=$LINKE step=0.05 \&lt;br /&gt;
         beam_rad=rad_beam.$DAY_STR diff_rad=rad_diffuse.$DAY_STR \&lt;br /&gt;
         refl_rad=rad_reflected.$DAY_STR glob_rad=rad_global.$DAY_STR \&lt;br /&gt;
         insol_time=rad_insol_time.$DAY_STR --quiet&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
    # poor man's multi-threading for a multi-core CPU&lt;br /&gt;
    MODULUS=`echo &amp;quot;$DAY $STEP $NUM_CORES&amp;quot; | awk '{print $1 % ($2 * $3)}'`&lt;br /&gt;
    if [ &amp;quot;$MODULUS&amp;quot; = &amp;quot;$STEP&amp;quot; ] ; then&lt;br /&gt;
       # stall to let the background jobs finish&lt;br /&gt;
       $CMD&lt;br /&gt;
       sleep 2&lt;br /&gt;
       #while [ `pgrep -c r.sun` -ne 0 ] ; do&lt;br /&gt;
       #   sleep 5&lt;br /&gt;
       #done&lt;br /&gt;
    else&lt;br /&gt;
       $CMD &amp;amp;&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* For a r.sun Mode 1 loop, see the [[OpenMP#Alternatives|OpenMP]] page.&lt;br /&gt;
&lt;br /&gt;
== Development ==&lt;br /&gt;
&lt;br /&gt;
* Ongoing trials documented in [https://trac.osgeo.org/grass/ticket/498 trac ticket #498]&lt;br /&gt;
&lt;br /&gt;
== ToDo ==&lt;br /&gt;
&lt;br /&gt;
* Add support for [[OpenMP]] parallelization&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related Links:==&lt;br /&gt;
&lt;br /&gt;
[http://www.bodybuildingrevealed.com/'''body building''']&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Documentation]]&lt;br /&gt;
[[Category: Parallelization]]&lt;/div&gt;</summary>
		<author><name>⚠️Russel08</name></author>
	</entry>
</feed>