grass-addons
grass-addons copied to clipboard
t.rast.line: new addon to draw trendlines based on raster layers from a strds
New addon to draw trendlines based on the raster layers from a spatio-temporal raster database, showing for each time step the average values of the raster layer. If a zonal map is provided, trend lines are drawn showing for each time step the average value of each of the categories of the zonal raster layer.
Also, what are the atexit, gs and sys empty files?
@veroandreo where do you see these empty files?
Files changed tab within this PR
Also, what are the atexit, gs and sys empty files?
@veroandreo where do you see these empty files?
Files changed tab within this PR
Thanks, result of some previous failed runs. Removed.
Also, what are the atexit, gs and sys empty files?
@veroandreo where do you see these empty files?
Files changed tab within this PR
Thanks, result of some previous failed runs. Removed.
It's still there...
I tested the addon, nice! Some suggestions inline. When I pass an nonexistent strds, I get:
ERROR: Dataset <precip_sum@climate_2000_2012> of type <strds> not found in temporal database Traceback (most recent call last): File "/home/vandreo/.grass8/addons/scripts/t.rast.line", line 673, in <module> sys.exit(main(*gs.parser())) ^^^^^^^^^^^^^^^^^^ File "/home/vandreo/.grass8/addons/scripts/t.rast.line", line 541, in main t_info = gs.parse_command("t.info", flags="g", input=options["input"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/grass83/etc/python/grass/script/core.py", line 573, in parse_command res = read_command(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/grass83/etc/python/grass/script/core.py", line 533, in read_command return handle_errors(returncode, stdout, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/grass83/etc/python/grass/script/core.py", line 345, in handle_errors raise CalledModuleError(module=module, code=code, returncode=returncode) grass.exceptions.CalledModuleError: Module run `t.info -g input=precip_sum@climate_2000_2012` ended with an error.
Perhaps the error can be caught differently? i.e., to get only the message and not the rest? Is that possible?
You can pass errors="fatal"
into run_command, that should do it:
https://grass.osgeo.org/grass83/manuals/libpython/script.html#script.core.handle_errors
Some messages are translatable, some not, so if you could make them all translatable, that would be better.
@petrasovaa I normally do that, but for some reason, if I run it with e.g.,
# Get strds type
gs.message(_("Getting the strds metadata..."))
I'm getting an error message about _ being references before assignment.
GRASS WGS84/VITO_FCover:~ > t.rast.line input=FCOVER300 zones=LUCesri3 nprocs=10
Traceback (most recent call last):
File "/home/paulo/.grass8/addons/scripts/t.rast.line", line 694, in <module>
sys.exit(main(*gs.parser()))
File "/home/paulo/.grass8/addons/scripts/t.rast.line", line 557, in main
gs.message(_("Getting the strds metadata..."))
UnboundLocalError: local variable '_' referenced before assignment
Any idea what I am doing wrong here?
Also, what are the atexit, gs and sys empty files?
@veroandreo where do you see these empty files?
Files changed tab within this PR
Thanks, result of some previous failed runs. Removed.
It's still there...
Ah, in the src folder. I really do not understand how they end up there. But in any case, I'll remove them. Thanks for pointing out.
errors="fatal"
That also results in a double error message. Adding
except CalledModuleEror:
return False
Does the trick, it seems.
errors="fatal"
That also results in a double error message. Adding
Strange, I tested with:
gs.read_command("r.info", map="aa", errors="fatal")
and I get
ERROR: Raster map <aa> not found
ERROR: Module r.info (r.info map=aa) failed with non-zero return code 1
Some messages are translatable, some not, so if you could make them all translatable, that would be better.
@petrasovaa I normally do that, but for some reason, if I run it with e.g.,
# Get strds type gs.message(_("Getting the strds metadata..."))
I'm getting an error message about _ being references before assignment.
GRASS WGS84/VITO_FCover:~ > t.rast.line input=FCOVER300 zones=LUCesri3 nprocs=10 Traceback (most recent call last): File "/home/paulo/.grass8/addons/scripts/t.rast.line", line 694, in <module> sys.exit(main(*gs.parser())) File "/home/paulo/.grass8/addons/scripts/t.rast.line", line 557, in main gs.message(_("Getting the strds metadata...")) UnboundLocalError: local variable '_' referenced before assignment
Any idea what I am doing wrong here?
Remove the _
from for i, _ in enumerate(cats_ids):
(and one other place), that should fix it.