Skip to content

temporal: add granularity and start options to t.rast.univar #3042#7244

Open
selma-Bentaiba wants to merge 1 commit intoOSGeo:mainfrom
selma-Bentaiba:feat-temporal-univar
Open

temporal: add granularity and start options to t.rast.univar #3042#7244
selma-Bentaiba wants to merge 1 commit intoOSGeo:mainfrom
selma-Bentaiba:feat-temporal-univar

Conversation

@selma-Bentaiba
Copy link
Copy Markdown
Contributor

We're trying to solve #3042 by adding native temporal aggregation support to t.rast.univar. This implementation allows users to compute univariate statistics over grouped time windows (granules) without the overhead of creating intermediate raster data via t.rast.aggregate.

Implementation Details
Parameter Addition: Added granularity and start options to the t.rast.univar CLI.

Library Logic: Updated the grass.temporal library (specifically print_gridded_dataset_univar_statistics) to handle map grouping based on the provided granularity.

Efficiency: The module now identifies all maps within a temporal granule and passes them as a comma-separated list to the r.univar backend, leveraging its native multi-map support.

Verification:
Screenshot from 2026-03-31 18-42-50

Added a comprehensive test class TestRasterUnivarGranularity to the existing testsuite.

Manually verified (see screenshot) that a 4-map STRDS correctly aggregates into 2-month granules with accurate mathematical results (Means of 15 and 35) and no additional raster creation.

@github-actions github-actions bot added temporal Related to temporal data processing Python Related code is in Python libraries module tests Related to Test Suite labels Mar 31, 2026
Copy link
Copy Markdown
Member

@ninsbl ninsbl left a comment

Choose a reason for hiding this comment

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

I did not go through everything in detail yet. Here are some comments...


# When the user asks for granularity, we group maps into time windows
# and later feed each group as a comma-joined list to r.univar.
# No new rasters written to disk — that's the whole point of this feature.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
# No new rasters written to disk — that's the whole point of this feature.

granule_groups = None
if granularity and rows:
# Snap the start of the first window to the requested granularity
# unless the user gave an explicit start time
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would argue against adding a start option.
When the granularity option is added, a sampling option would make sense, but start less so. Start can be picked up from first map in series selected by temporal where...
See

# Build the granularity list
for inspiration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libraries module Python Related code is in Python temporal Related to temporal data processing tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants