[GRASS-user] Looping r.sun.hourly with Python script fails
Vaclav Petras
wenzeslaus at gmail.com
Wed Apr 1 06:26:12 PDT 2015
On Wed, Apr 1, 2015 at 8:39 AM, Pietro <peter.zamb at gmail.com> wrote:
> Hi Anna,
>
> On Wed, Apr 1, 2015 at 1:49 PM, Anna Petrášová <kratochanna at gmail.com>
> wrote:
> >
> >
> > On Wed, Apr 1, 2015 at 6:46 AM, Pietro <peter.zamb at gmail.com> wrote:
> >>
> >> Dear Umberto,
> >>
> >> On Wed, Apr 1, 2015 at 11:46 AM, umberto.minora <
> umberto.minora at unimi.it>
> >> wrote:
> >> > File "C:\OSGeo4W\apps\grass\grass-7.0.0\etc\python\grass\p
> >> > ygrass\modules\interface\parameter.py", line 150, in
> >> > __init__
> >> > self.values = [self.type(i) for i in diz['values']]
> >> > ValueError: invalid literal for int() with base 10: '1-'
> >>
> >> The problem here is that the r.sun.hourly define the parmeter nprocs as:
> >>
> >> {{{
> >> #%option
> >> #% key: nprocs
> >> #% type: integer
> >> #% description: Number of r.sun processes to run in parallel
> >> #% options: 1-
> >> #% answer: 1
> >> #%end
> >> }}}
> >>
> >> To me this "#% options: 1-" is wrong, and it does not make to much
> >> sense. I'm keen on removing this row.
> >>
> >> Vaclav and Anna, what is it your feeling?
> >
> >
> > I think it makes sense, it means greater or equal to 1. It is supported
> by
> > the parser, so you might find more of these cases in other modules.
>
> The only cases available are in the grass-addons:
>
> {{{
> $ grep --color=auto --exclude-dir={.svn,.git,.OBJ,locale} -IrnE
> "^#%\s+options: 1-$"
>
> grass_addons/grass7/raster/r.lake.series/r.lake.series.py:95:#% options:
> 1-
> grass_addons/grass7/raster/r.shaded.pca/r.shaded.pca.py:85:#% options: 1-
> grass_addons/grass7/raster/r.sun.daily/r.sun.daily.py:129:#% options: 1-
> grass_addons/grass7/raster/r.sun.hourly/r.sun.hourly.py:120:#% options: 1-
> }}}
>
> ...and me or Anna are authors of these modules. There is also nothing like
this in the C modules:
grep --color=auto --exclude-dir={.svn,.git,.OBJ,locale} -IrnE
"options.*=.*1-"
However, the question is what is supported by the parser. There is
unfortunately no documentation and that's probably the source of confusion
but looking to the source code I see that 1- and -100 is allowed:
http://grass.osgeo.org/programming7/parser_8c_source.html#l01144
1162 if (contains(opt, '-')) {
1163 if (sscanf(opt, "%d-%d", &lo, &hi) == 2) {
1164 if (d >= lo && d <= hi)
1165 return 0;
1166 }
1167 else if (sscanf(opt, "-%d", &hi) == 1) {
1168 if (d <= hi)
1169 return 0;
1170 }
1171 else if (sscanf(opt, "%d-", &lo) == 1) {
1172 if (d >= lo)
1173 return 0;
1174 }
1175 else
1176 return BAD_SYNTAX
<http://grass.osgeo.org/programming7/parser_8c.html#a41312e21c216ba49d374e84389fce29aa47fb4e9df6010b10ef18b436004bdc1b>
;
1177 }
I fix this in r64969.
>
> See you soon.
>
> Pietro
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20150401/c7fd997a/attachment.html>
More information about the grass-user
mailing list