[GRASS-dev] Linke turbidity in r.sun.daily
Nikos Alexandris
nik at nikosalexandris.net
Fri May 15 05:10:48 PDT 2015
* Vaclav Petras <wenzeslaus at gmail.com> [2015-04-09 21:13:56 -0400]:
> On Thu, Apr 9, 2015 at 5:32 PM, Nikos Alexandris <nik at nikosalexandris.net>
> wrote:
>
> > @Vaclav, Anna: ping
> >
> > May I push changes for the r.sun.daily script in the add-ons repository?
> >
> >
> Sure, you consulted the changes and you have the access, so you are in
> charge now.
I have another use-case, hence another update to the script. Does
anyone care to have a look at the proposed diff (really a quick hack, no
extensive testing done but it works for me).
Nikos
-------------- next part --------------
Index: r.sun.daily.html
===================================================================
--- r.sun.daily.html (revision 65242)
+++ r.sun.daily.html (working copy)
@@ -17,8 +17,6 @@
Series of maps are (if flag <i>t</i> is checked) registered
to space time raster dataset with relative time and point time (not interval time).
-For GRASS 6, only timestamp is assigned.
-
<h2>EXAMPLE</h2>
<div class="code"><pre>
@@ -42,6 +40,7 @@
<h2>AUTHOR</h2>
Vaclav Petras, Anna Petrasova<br>
+Nikos Alexandris, support for linke, albedo, latitude, longitude, horizon maps<br>
<p>
<i>Last changed: $Date$</i>
Index: r.sun.daily.py
===================================================================
--- r.sun.daily.py (revision 65242)
+++ r.sun.daily.py (working copy)
@@ -37,6 +37,16 @@
#%end
#%option
+#% key: aspect_value
+#% key_desc: integer
+#% type: integer
+#% description: A single value of the orientation (aspect), 270 is south
+#% options: 0-360
+#% answer: 270
+#% required : no
+#%end
+
+#%option
#% key: slope
#% type: string
#% gisprompt: old,cell,raster
@@ -43,6 +53,15 @@
#% description: Name of the input slope raster map (terrain slope or solar panel inclination) [decimal degrees]
#%end
+#%option
+#% key: slope_value
+#% key_desc: float
+#% type: double
+#% description: A single value of inclination (slope)
+#% answer: 0.0
+#% required : no
+#%end
+
#%option G_OPT_R_INPUT
#% key: linke
#% type: string
@@ -69,7 +88,7 @@
#% key: albedo
#% type: string
#% gisprompt: old,cell,raster
-#% description: Name of the Linke atmospheric turbidity coefficient input raster map [-]
+#% description: Name of the ground albedo coefficient input raster map [-]
#% required : no
#%end
@@ -273,7 +292,7 @@
map_=name)
-def run_r_sun(elevation, aspect, slope, latitude, longitude,
+def run_r_sun(elevation, aspect, aspect_value, slope, slope_value, latitude, longitude,
linke, linke_value, albedo, albedo_value,
horizon_basename, horizon_step,
day, step, beam_rad, diff_rad, refl_rad, glob_rad, suffix):
@@ -283,6 +302,8 @@
to instruct for user requested inputs and outputs.
Optional inputs:
+ - aspect OR aspect_value
+ - slope OR slope_value
- latitude
- longitude
- linke OR single linke value
@@ -298,6 +319,14 @@
params.update({'refl_rad': refl_rad + suffix})
if glob_rad:
params.update({'glob_rad': glob_rad + suffix})
+ if aspect:
+ params.update({'aspect': aspect})
+ if aspect_value:
+ params.update({'aspect_value': aspect_value})
+ if slope:
+ params.update({'slope': slope})
+ if slope_value:
+ params.update({'slope_value': slope_value})
if linke:
params.update({'linke': linke})
if linke_value:
@@ -310,8 +339,7 @@
params.update({'horizon_basename': horizon_basename})
params.update({'horizon_step': horizon_step})
- grass.run_command('r.sun', elevation=elevation, aspect=aspect,
- slope=slope, day=day, step=step,
+ grass.run_command('r.sun', elevation=elevation, day=day, step=step,
overwrite=core.overwrite(), quiet=True,
**params)
@@ -367,7 +395,9 @@
# required
elevation_input = options['elevation']
aspect_input = options['aspect']
+ aspect_value = options['aspect_value']
slope_input = options['slope']
+ slope_value = options['slope_value']
# optional
latitude = options['lat']
@@ -438,21 +468,25 @@
start_day, end_day, day_step)
# check for slope/aspect
- if not aspect_input or not slope_input:
+ if not (aspect_value and aspect_input) or not (slope_value and slope_input):
params = {}
- if not aspect_input:
+
+ if not aspect_value and not aspect_input:
aspect_input = create_tmp_map_name('aspect')
params.update({'aspect': aspect_input})
REMOVE.append(aspect_input)
- if not slope_input:
+ grass.info(_("Running r.slope.aspect..."))
+ grass.run_command('r.slope.aspect', elevation=elevation_input,
+ quiet=True, **params)
+
+ if not slope_value and not slope_input:
slope_input = create_tmp_map_name('slope')
params.update({'slope': slope_input})
REMOVE.append(slope_input)
+ grass.info(_("Running r.slope.aspect..."))
+ grass.run_command('r.slope.aspect', elevation=elevation_input,
+ quiet=True, **params)
- grass.info(_("Running r.slope.aspect..."))
- grass.run_command('r.slope.aspect', elevation=elevation_input,
- quiet=True, **params)
-
if beam_rad:
grass.mapcalc('{beam} = 0'.format(beam=beam_rad), quiet=True)
if diff_rad:
@@ -479,7 +513,8 @@
suffix = '_' + format_order(day)
proc_list.append(Process(target=run_r_sun,
args=(elevation_input,
- aspect_input, slope_input,
+ aspect_input, aspect_value,
+ slope_input, slope_value,
latitude, longitude,
linke_input, linke_value,
albedo_input, albedo_value,
More information about the grass-dev
mailing list