Skip to content

temporal: restore strds.semantic_label band references for raster tools - #8063

Merged
petrasovaa merged 3 commits into
OSGeo:mainfrom
ecodiv:semantic_label
Oct 15, 2026
Merged

petrasovaa merged 3 commits into
OSGeo:mainfrom
ecodiv:semantic_label

Conversation

@ecodiv

@ecodiv ecodiv commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

PR fixes #8062

t.rast.mapcalc's documented semantic-label band references (inputs=strds.S2_8,strds.S2_4) regressed on main and fail with:

ERROR: Space time dataset <strds.S2_8> of type <raster> not found

The issue was with:

_parse_id() (added in #7670) splits name.semantic_label only when stds_type == "strds". But the call path is
t.rast.mapcalc → dataset_mapcalculator(..., "raster", ...) → open_old_stds(..., "raster") → _parse_id(stds_type="raster"), so the .label is never split off. In 8.4 the split was unconditional, so it worked.

This can hopefully be fixed with:

Accept the raster map element types ("raster"/"rast") alongside "strds", consistent with try_get_stds(), which already maps them to a raster STRDS. 3D-raster and vector STDS stay excluded (no semantic labels).

Added doctests for _parse_id and registered open_stds in the temporal doctest suite. Minimal reproducer (fails before, passes after):

r.mapcalc expression="nir = 100"; r.support map=nir semantic_label=S2_8
r.mapcalc expression="red = 50";  r.support map=red semantic_label=S2_4
t.create type=strds temporaltype=absolute output=test title=t description=t
# register nir,red at 2020-01-01, then:
t.rast.mapcalc inputs=test.S2_8,test.S2_4 output=ndvi basename=ndvi \
  expression="float(test.S2_8 - test.S2_4) / (test.S2_8 + test.S2_4)"

Disclaimer: created with help of Claud
But also tested it manually on my own dataset. With this fix, it works again.

`t.rast.mapcalc`'s documented semantic-label band references
(`inputs=strds.S2_8,strds.S2_4`) regressed on `main` and fail with:

```
ERROR: Space time dataset <strds.S2_8> of type <raster> not found
```

### Why

`_parse_id()` (added in OSGeo#7670) splits `name.semantic_label` only when
`stds_type == "strds"`. But the call path is
`t.rast.mapcalc` → `dataset_mapcalculator(..., "raster", ...)` →
`open_old_stds(..., "raster")` → `_parse_id(stds_type="raster")`, so the
`.label` is never split off. In 8.4 the split was unconditional, so it worked.

### Fix

Accept the raster map element types (`"raster"`/`"rast"`) alongside `"strds"`,
consistent with `try_get_stds()`, which already maps them to a raster STRDS.
3D-raster and vector STDS stay excluded (no semantic labels).

Added doctests for `_parse_id` and registered `open_stds` in the temporal
doctest suite. Minimal reproducer (fails before, passes after):

```sh
r.mapcalc expression="nir = 100"; r.support map=nir semantic_label=S2_8
r.mapcalc expression="red = 50";  r.support map=red semantic_label=S2_4
t.create type=strds temporaltype=absolute output=test title=t description=t
# register nir,red at 2020-01-01, then:
t.rast.mapcalc inputs=test.S2_8,test.S2_4 output=ndvi basename=ndvi \
  expression="float(test.S2_8 - test.S2_4) / (test.S2_8 + test.S2_4)"
```

Disclaimer: created with help of Claud
But also tested it manually on my own dataset. With this fix, it works again.
@ecodiv
ecodiv requested review from echoix and petrasovaa and removed request for petrasovaa October 13, 2026 10:51
@ecodiv ecodiv added the bug Something isn't working label Oct 13, 2026
@github-actions github-actions Bot added Python Related code is in Python libraries tests Related to Test Suite labels Oct 13, 2026
Comment thread python/grass/temporal/open_stds.py Outdated

@petrasovaa petrasovaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caught by AI review - since parse_id is also used in check_new_stds, one more suggestion to restore 8.4 behavior when user outputs a dataset name with a dot:

In check_new_stds, treat a non-None semantic label as an error:

name, mapset, semantic_label = _parse_id(name, stds_type=stds_type)
if semantic_label:
    msgr.fatal(
        _("Illegal dataset name <{}>. Character '.' not allowed.").format(name)
    )

The message should quote the original full name, so capture it before the parse.

follows two suggestions from @petrasovaa

- replaced doctest for pytest. The test file is named grass_temporal_semantic_label_test.py (made with Claud)
- implemented the suggestion to treat a non-None semantic label as an error
@ninsbl

ninsbl commented Oct 14, 2026

Copy link
Copy Markdown
Member

Sorry for breaking it and thanks for fixing.

Comment thread python/grass/temporal/open_stds.py Outdated
@petrasovaa
petrasovaa enabled auto-merge (squash) October 15, 2026 03:44
@petrasovaa
petrasovaa merged commit a04b539 into OSGeo:main Oct 15, 2026
26 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working libraries Python Related code is in Python tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] t.rast.mapcalc with semantic labels does not work anymore

3 participants