Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t.rast.univar: allow r-flag combined with zones option #4577

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ninsbl
Copy link
Member

@ninsbl ninsbl commented Oct 23, 2024

Fix #4576

The library function actually used already a region environment. So it did not have to be added. But the region env was actualy applied redundant to the r-flag for STRDS...
So, now, the region env is only used if r-flag and zones are combined or for STR3DS. If only the r-flag is used, it is propagated to r.univar (for STRDS).

@ninsbl ninsbl added enhancement New feature or request temporal Related to temporal data processing Python Related code is in Python labels Oct 23, 2024
@ninsbl ninsbl added this to the 8.5.0 milestone Oct 23, 2024
@github-actions github-actions bot added libraries module tests Related to Test Suite labels Oct 23, 2024
@echoix
Copy link
Member

echoix commented Oct 23, 2024

I don't see a problem with the code changed, but I don't think I understand well the issue. What was the exclusivity between the options protecting before?

I think it boils down to the fact that I don't know yet the details of the implementation of an STR3DS vs just a temporal raster STRDS.

@ninsbl
Copy link
Member Author

ninsbl commented Oct 23, 2024

r.univar does not allow to use the r-flag and the zones option, because the region would change while the zones map is open. That limitation was handed down to the temporal application of the module. However, the region can be changed to the input map(s) using a region env for the call to r.univar. That would have the same effect and circumvent the problem in r.univar.

r3.univar does not have an r-flag (see: https://grass.osgeo.org/grass-stable/manuals/r3.univar.html), so space time 3D raster datasets need to use the region env to that effect anyway...

@ninsbl
Copy link
Member Author

ninsbl commented Oct 24, 2024

@neteler or @veroandreo do you have any thoughts on this maybe?

@echoix
Copy link
Member

echoix commented Oct 24, 2024

r.univar does not allow to use the r-flag and the zones option, because the region would change while the zones map is open. That limitation was handed down to the temporal application of the module. However, the region can be changed to the input map(s) using a region env for the call to r.univar. That would have the same effect and circumvent the problem in r.univar.

r3.univar does not have an r-flag (see: https://grass.osgeo.org/grass-stable/manuals/r3.univar.html), so space time 3D raster datasets need to use the region env to that effect anyway...

Thanks, I better understand why the change works now. The biggest missing piece for me was that zones is like map (that is to be opened), and they can have different regions

@ninsbl ninsbl requested a review from neteler October 25, 2024 10:33
Copy link
Member

@echoix echoix left a comment

Choose a reason for hiding this comment

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

I've attentively reviewed (in an IDE this time) in regard to this comment: #4577 (comment).
So if that comment makes sense, then after addressing the docstring review comment, this PR would be good to go.

Sorry for the delay, I didn't touch a computer for the whole week

@@ -57,7 +57,7 @@ def compute_univar_stats(registered_map_info, stats_module, fs, rast_region=Fals
)

stats_module.inputs.map = id
if rast_region:
if rast_region and (stats_module.inputs.zones or stats_module.name == "r3.univar"):
Copy link
Member

Choose a reason for hiding this comment

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

This is coherent with your explanations in #4577 (comment)

But now, the docstring of the rast_region parameter of this function (compute_univar_stats()) should be adjusted to reflect the change.

Currently, it reads:

    :param rast_region: If set True ignore the current region settings
           and use the raster map regions for univar statistical calculation.
           Only available for strds.

Copy link
Member

@echoix echoix left a comment

Choose a reason for hiding this comment

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

There wasn't any other objections and the docstring updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 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.

[Feat] r.univar/t.rast.univar: allow r-flag also with zones input
2 participants