Skip to content

grass.jupyter: Use grass.temporal API directly in TimeSeriesMap#7344

Open
ninsbl wants to merge 9 commits intoOSGeo:mainfrom
ninsbl:gj_timeseries
Open

grass.jupyter: Use grass.temporal API directly in TimeSeriesMap#7344
ninsbl wants to merge 9 commits intoOSGeo:mainfrom
ninsbl:gj_timeseries

Conversation

@ninsbl
Copy link
Copy Markdown
Member

@ninsbl ninsbl commented Apr 27, 2026

This PR changes TimeSeriesMap in grass.jupyter to use the temporal API directly, instead of through tools.

This change

Things to discuss:

@ninsbl ninsbl added this to the 8.6.0 milestone Apr 27, 2026
@ninsbl ninsbl requested review from chaedri and petrasovaa April 27, 2026 12:41
@ninsbl ninsbl added Python Related code is in Python libraries labels Apr 27, 2026
@ninsbl
Copy link
Copy Markdown
Member Author

ninsbl commented Apr 28, 2026

The failing windows test seems to be due to issues with ctypes in Jupyter. I comes up because of the TGIS import, but in principle that should work also on Windows (and seems to work in the temporal modules). Not sure how to debug / fix this? Is it a glitch in grass jupyter init?

@petrasovaa
Copy link
Copy Markdown
Contributor

Could you clarify why this is even needed? I briefly read the linked issues, but is there a reason why these issues can't be solved in the tools? We have always had issues with ctypes on Windows, so I am not sure the tests fail, although I didn't check what's wrong. So that's my main hesitation with this. Does this solution have any advantage, e.g. speed?

@ninsbl
Copy link
Copy Markdown
Member Author

ninsbl commented Apr 29, 2026

Could you clarify why this is even needed?

Sure. I understand your concerns.

Yes, going through the commandline tools adds for temporal modules quite a bit of overhead. t.list, t.info, t.rast.list all have to import the relatively heavy temporal library, and initialize tgis. t.list for example is quite slow from my experience, esp. with more mapsets on the search_path. Yet, this overhead / performance impact would not be a show stopper for going through tools. That overhead will most likely not be very significant when rendering a large number of maps. And if using tools is prefered, I can change the approach.

Currently however, t.rast.list cannot be used with a where clause and the gran method (this should probably be addressed there anyway). Also the warning message about the number of granules to return with the gran method should probably be included in t.rast.list too. Using the temporal API made that possible and rather simple.

The issues with ctypes is probably due to how jupyter session is initialized? Given that the cli-tools work (and require ctypes as well)? Should not libraries be available in Jupyter as well? Maybe something we should look into anyway, no? Unless, -and I think the case can be reasonably be made - the Jupyter API is aiming at less in-depth coding and thus deliberately more focused on a higher level of programing (mostly using tools and not library functions)...

Again, I can go either route: try to dig into the ctypes issue or rather revert to tools, as you prefer...

@chaedri
Copy link
Copy Markdown
Contributor

chaedri commented Apr 29, 2026

I see why this is advantageous -- #2688 caused difficulties when creating sliders/GIFs of STDS with satellite imagery. The workaround was to use SeriesMap but that made the step between each image equal, making them appear evenly distributed through time.

However, I remember from GSoC that we decided to use the CLI tool because of the ctypes issue. This is unfortunately all I know...

So, I can see why this would improve functionality but I don't know anything about solving the ctypes issue.

@petrasovaa
Copy link
Copy Markdown
Contributor

Given we need to better understand the ctypes issues first, I suggest to start addressing the issues in the tools themselves (because we want that anyway, right?) and perhaps making a smaller PR allowing to use these additions in TimeSeriesMap. Depending on the GSoC selection results, we could task the student with this.

Regarding the ctypes issue, my understanding was something like this is needed:
https://github.com/zarch/grass-session/blob/master/grass_session/session.py#L338
@wenzeslaus has probably better understanding.

But I am not sure whether the ctypes usage is even needed in the temporal API.

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

Labels

libraries notebook Python Related code is in Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants