[GRASS-dev] pyGRASS problem with r.sun

Pietro Zambelli peter.zamb at gmail.com
Sun Jun 23 05:30:48 PDT 2013


Hi Yann,

On Sunday 23 Jun 2013 11:15:46 Yann Chemin wrote:
> Hi,
> 
> (svn trunk)
> 
> r.sun in pyGRASS is somehow confused with data type for time option.
> 
> Time option does work well as a float input directly in the shell.
> from pyGRASS it expects an integer.
> 
> time=10.3321830777
> Traceback (most recent call last):
>   File "./python-pygrass.py", line 293, in <module>
>    
> r.sun(elevin="dem",albedo=b_albedo,glob_rad=b_rnet,lin=3.0,day=b_doy,time=f
> loat(local_time),quiet=QIET,overwrite=OVR) File
> "/usr/local/grass-7.0.svn/etc/python/grass/pygrass/modules/interface/module
> .py", line 183, in __call__
>     self.inputs[key].value = val
>   File
> "/usr/local/grass-7.0.svn/etc/python/grass/pygrass/modules/interface/parame
> ter.py", line 98, in _set_value
>     (self.name, self.values))
> ValueError: The Parameter <time>, must be one of: [0, 1, 2, 3, 4, 5,
> 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
> 24]

Good point! :-)

should be fixed in r56885

{{{
>>> from pygrass.modules.shortcuts import raster as r
>>> sun = r.sun
>>> sun.inputs.time = 10.5   # it's fine
>>> sun.inputs.time = 110.5  # raise an exception
Traceback (most recent call last):
  File "<ipython-input-15-1259aa696035>", line 1, in <module>
    sun.inputs.time = 110.5
  File "pygrass/modules/interface/typedict.py", line 25, in __setattr__
    self[key].value = value
  File "pygrass/modules/interface/parameter.py", line 99, in _set_value
    self.values[-1]))
ValueError: The Parameter <time>, must be: 0<=value<=24

}}}


More information about the grass-dev mailing list