[GRASS-SVN] r62149 - in grass-addons/grass7/raster: r.sun.daily r.sun.hourly
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Oct 1 09:50:21 PDT 2014
Author: lucadelu
Date: 2014-10-01 09:50:21 -0700 (Wed, 01 Oct 2014)
New Revision: 62149
Modified:
grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py
grass-addons/grass7/raster/r.sun.hourly/r.sun.hourly.py
Log:
r.sun.*: fixed erroneus parameter's names in r.sun, pep8 cleaning
Modified: grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py
===================================================================
--- grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py 2014-10-01 16:46:00 UTC (rev 62148)
+++ grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py 2014-10-01 16:50:21 UTC (rev 62149)
@@ -184,9 +184,8 @@
params.update({'glob_rad': glob_rad + suffix})
if is_grass_7():
- grass.run_command('r.sun', elev_in=elevation, asp_in=aspect,
- slope_in=slope,
- day=day, step=step,
+ grass.run_command('r.sun', elevation=elevation, aspect=aspect,
+ slope=slope, day=day, step=step,
overwrite=core.overwrite(), quiet=True,
**params)
else:
@@ -206,7 +205,8 @@
def set_time_stamp(raster, day):
- grass.run_command('r.timestamp', map=raster, date='%d days' % day, quiet=True)
+ grass.run_command('r.timestamp', map=raster, date='%d days' % day,
+ quiet=True)
def format_order(number, zeros=3):
@@ -219,7 +219,8 @@
for day in range(start_day, end_day + 1, day_step):
map_ = '%s%s%s' % (basename, '_', format_order(day))
if grass.find_file(map_, element='cell', mapset=mapset)['file']:
- grass.fatal(_("Raster map <%s> already exists. Change the base name or allow overwrite.") % map_)
+ grass.fatal(_("Raster map <%s> already exists. Change the base "
+ "name or allow overwrite.") % map_)
def sum_maps(sum_, basename, suffixes):
@@ -309,7 +310,8 @@
REMOVE.append(slope_input)
grass.info(_("Running r.slope.aspect..."))
- grass.run_command('r.slope.aspect', elevation=elevation_input, quiet=True, **params)
+ grass.run_command('r.slope.aspect', elevation=elevation_input,
+ quiet=True, **params)
if beam_rad:
grass.mapcalc('%s=0' % beam_rad, quiet=True)
@@ -393,11 +395,14 @@
core.info(_("Registering created maps into temporal dataset..."))
import grass.temporal as tgis
- def registerToTemporal(basename, suffixes, mapset, start_day, day_step, title, desc):
+ def registerToTemporal(basename, suffixes, mapset, start_day, day_step,
+ title, desc):
maps = ','.join([basename + suf + '@' + mapset for suf in suffixes])
- tgis.open_new_space_time_dataset(basename, type='strds', temporaltype='relative',
+ tgis.open_new_space_time_dataset(basename, type='strds',
+ temporaltype='relative',
title=title, descr=desc,
- semantic='sum', dbif=None, overwrite=grass.overwrite())
+ semantic='sum', dbif=None,
+ overwrite=grass.overwrite())
tgis.register_maps_in_space_time_dataset(
type='rast', name=basename, maps=maps, start=start_day, end=None,
unit='days', increment=day_step, dbif=None, interval=False)
@@ -406,20 +411,22 @@
mapset = grass.gisenv()['MAPSET']
if beam_rad_basename_user:
- registerToTemporal(beam_rad_basename, suffixes_all, mapset, start_day, day_step,
- title="Beam irradiation",
+ registerToTemporal(beam_rad_basename, suffixes_all, mapset,
+ start_day, day_step, title="Beam irradiation",
desc="Output beam irradiation raster maps [Wh.m-2.day-1]")
if diff_rad_basename_user:
- registerToTemporal(diff_rad_basename, suffixes_all, mapset, start_day, day_step,
+ registerToTemporal(diff_rad_basename, suffixes_all, mapset,
+ start_day, day_step,
title="Diffuse irradiation",
desc="Output diffuse irradiation raster maps [Wh.m-2.day-1]")
if refl_rad_basename_user:
- registerToTemporal(refl_rad_basename, suffixes_all, mapset, start_day, day_step,
+ registerToTemporal(refl_rad_basename, suffixes_all, mapset,
+ start_day, day_step,
title="Reflected irradiation",
desc="Output reflected irradiation raster maps [Wh.m-2.day-1]")
if glob_rad_basename_user:
- registerToTemporal(glob_rad_basename, suffixes_all, mapset, start_day, day_step,
- title="Total irradiation",
+ registerToTemporal(glob_rad_basename, suffixes_all, mapset,
+ start_day, day_step, title="Total irradiation",
desc="Output total irradiation raster maps [Wh.m-2.day-1]")
else:
Modified: grass-addons/grass7/raster/r.sun.hourly/r.sun.hourly.py
===================================================================
--- grass-addons/grass7/raster/r.sun.hourly/r.sun.hourly.py 2014-10-01 16:46:00 UTC (rev 62148)
+++ grass-addons/grass7/raster/r.sun.hourly/r.sun.hourly.py 2014-10-01 16:50:21 UTC (rev 62149)
@@ -177,15 +177,13 @@
params.update({'incidout': incidout + suffix})
if is_grass_7():
- grass.run_command('r.sun', elev_in=elevation, asp_in=aspect,
- slope_in=slope,
- day=day, time=time,
+ grass.run_command('r.sun', elevation=elevation, aspect=aspect,
+ slope=slope, day=day, time=time,
overwrite=core.overwrite(), quiet=True,
**params)
else:
grass.run_command('r.sun', elevin=elevation, aspin=aspect,
- slopein=slope,
- day=day, time=time,
+ slopein=slope, day=day, time=time,
overwrite=core.overwrite(), quiet=True,
**params)
if binary:
@@ -193,7 +191,7 @@
if not output:
continue
exp='{out} = if({inp} > 0, 1, 0)'.format(out=output + suffix + binaryTmpName,
- inp=output + suffix)
+ inp=output + suffix)
grass.mapcalc(exp=exp, overwrite=core.overwrite())
grass.run_command('g.rename', rast=[output + suffix + binaryTmpName,
output + suffix],
@@ -203,7 +201,7 @@
def set_color_table(rasters, binary=False):
table = 'gyr'
if binary:
- table='grey'
+ table = 'grey'
if is_grass_7():
grass.run_command('r.colors', map=rasters, col=table, quiet=True)
else:
@@ -226,8 +224,8 @@
for time in frange(start_time, end_time, time_step):
maps = []
maps.append('{name}{delim}{time}'.format(name=basename,
- delim='_',
- time=format_time(time)))
+ delim='_',
+ time=format_time(time)))
if binary:
maps.append('{name}{delim}{time}{binary}'.format(name=basename,
delim='_',
@@ -235,7 +233,8 @@
binary=binaryTmpName))
for map_ in maps:
if grass.find_file(map_, element='cell', mapset=mapset)['file']:
- grass.fatal(_("Raster map <%s> already exists. Change the base name or allow overwrite.") % map_)
+ grass.fatal(_("Raster map <%s> already exists. Change the base"
+ " name or allow overwrite.") % map_)
def frange(x, y, step):
@@ -252,7 +251,8 @@
month_names = ["", "jan", "feb", "mar", "apr", "may", "jun",
"jul", "aug", "sep", "oct", "nov", "dec"]
return "%.2i %s %.4i %.2i:%.2i:%.2i" % (dt.day, month_names[dt.month],
- dt.year, dt.hour, dt.minute, dt.second)
+ dt.year, dt.hour, dt.minute,
+ dt.second)
def main():
@@ -295,13 +295,17 @@
# here we check all the days
if not grass.overwrite():
check_time_map_names(beam_rad_basename, grass.gisenv()['MAPSET'],
- start_time, end_time, time_step, binary, binaryTmpName)
+ start_time, end_time, time_step, binary,
+ binaryTmpName)
check_time_map_names(diff_rad_basename, grass.gisenv()['MAPSET'],
- start_time, end_time, time_step, binary, binaryTmpName)
+ start_time, end_time, time_step, binary,
+ binaryTmpName)
check_time_map_names(refl_rad_basename, grass.gisenv()['MAPSET'],
- start_time, end_time, time_step, binary, binaryTmpName)
+ start_time, end_time, time_step, binary,
+ binaryTmpName)
check_time_map_names(glob_rad_basename, grass.gisenv()['MAPSET'],
- start_time, end_time, time_step, binary, binaryTmpName)
+ start_time, end_time, time_step, binary,
+ binaryTmpName)
# check for slope/aspect
if not aspect_input or not slope_input:
@@ -316,7 +320,8 @@
TMP.append(slope_input)
grass.info(_("Running r.slope.aspect..."))
- grass.run_command('r.slope.aspect', elevation=elevation_input, quiet=True, **params)
+ grass.run_command('r.slope.aspect', elevation=elevation_input,
+ quiet=True, **params)
grass.info(_("Running r.sun in a loop..."))
count = 0
@@ -370,14 +375,17 @@
core.info(_("Registering created maps into temporal dataset..."))
import grass.temporal as tgis
- def registerToTemporal(basename, suffixes, mapset, start_time, time_step, title, desc):
+ def registerToTemporal(basename, suffixes, mapset, start_time,
+ time_step, title, desc):
maps = ','.join([basename + suf + '@' + mapset for suf in suffixes])
- tgis.open_new_space_time_dataset(basename, type='strds', temporaltype='absolute',
+ tgis.open_new_space_time_dataset(basename, type='strds',
+ temporaltype='absolute',
title=title, descr=desc,
- semantic='mean', dbif=None, overwrite=grass.overwrite())
+ semantic='mean', dbif=None,
+ overwrite=grass.overwrite())
tgis.register_maps_in_space_time_dataset(
- type='rast', name=basename, maps=maps, start=start_time, end=None,
- increment=time_step, dbif=None, interval=False)
+ type='rast', name=basename, maps=maps, start=start_time,
+ end=None, increment=time_step, dbif=None, interval=False)
# Make sure the temporal database exists
tgis.init()
@@ -390,24 +398,24 @@
step = "%d seconds" % step.seconds
if beam_rad_basename:
- registerToTemporal(beam_rad_basename, suffixes_all, mapset, start, step,
- title="Beam irradiance",
+ registerToTemporal(beam_rad_basename, suffixes_all, mapset, start,
+ step, title="Beam irradiance",
desc="Output beam irradiance raster maps [Wh.m-2]")
if diff_rad_basename:
- registerToTemporal(diff_rad_basename, suffixes_all, mapset, start, step,
- title="Diffuse irradiance",
+ registerToTemporal(diff_rad_basename, suffixes_all, mapset, start,
+ step, title="Diffuse irradiance",
desc="Output diffuse irradiance raster maps [Wh.m-2]")
if refl_rad_basename:
- registerToTemporal(refl_rad_basename, suffixes_all, mapset, start, step,
- title="Reflected irradiance",
+ registerToTemporal(refl_rad_basename, suffixes_all, mapset, start,
+ step, title="Reflected irradiance",
desc="Output reflected irradiance raster maps [Wh.m-2]")
if glob_rad_basename:
- registerToTemporal(glob_rad_basename, suffixes_all, mapset, start, step,
- title="Total irradiance",
+ registerToTemporal(glob_rad_basename, suffixes_all, mapset, start,
+ step, title="Total irradiance",
desc="Output total irradiance raster maps [Wh.m-2]")
if incidout_basename:
- registerToTemporal(incidout_basename, suffixes_all, mapset, start, step,
- title="Incidence angle",
+ registerToTemporal(incidout_basename, suffixes_all, mapset, start,
+ step, title="Incidence angle",
desc="Output incidence angle raster maps")
else:
@@ -416,15 +424,20 @@
for i, time in enumerate(times):
grass_time = format_grass_time(absolute_time + datetime.timedelta(hours=time))
if beam_rad_basename:
- set_time_stamp(beam_rad_basename + suffixes_all[i], time=grass_time)
+ set_time_stamp(beam_rad_basename + suffixes_all[i],
+ time=grass_time)
if diff_rad_basename:
- set_time_stamp(diff_rad_basename + suffixes_all[i], time=grass_time)
+ set_time_stamp(diff_rad_basename + suffixes_all[i],
+ time=grass_time)
if refl_rad_basename:
- set_time_stamp(refl_rad_basename + suffixes_all[i], time=grass_time)
+ set_time_stamp(refl_rad_basename + suffixes_all[i],
+ time=grass_time)
if glob_rad_basename:
- set_time_stamp(glob_rad_basename + suffixes_all[i], time=grass_time)
+ set_time_stamp(glob_rad_basename + suffixes_all[i],
+ time=grass_time)
if incidout_basename:
- set_time_stamp(incidout_basename + suffixes_all[i], time=grass_time)
+ set_time_stamp(incidout_basename + suffixes_all[i],
+ time=grass_time)
if beam_rad_basename:
maps = [beam_rad_basename + suf for suf in suffixes_all]
More information about the grass-commit
mailing list