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

A QGIS Ribasim plotting window #790

Open
Huite opened this issue Nov 15, 2023 · 3 comments
Open

A QGIS Ribasim plotting window #790

Huite opened this issue Nov 15, 2023 · 3 comments
Labels
QGIS Ribasim QGIS plugin

Comments

@Huite
Copy link
Contributor

Huite commented Nov 15, 2023

#788 got my noggin' joggin'.

All the Ribasim input is essentially in long table form. This should make it relatively easy to support a general plotting window to help with inspecting model input.

Essentially:

  • Allow spatial selection on the nodes. See e.g. imod plugin timeseries logic.
  • Use a dropdown to select from one of the properties tables. These can be filtered -- at the least -- on NullGeometry tables.
  • Fetch all the associated nodes from the selected table.
  • Group by the node id.
  • General x-y plots can be supported, set a selector for the x-axis variable, and one for the y-axis variable.
  • Some specific logic is required to support e.g. a datetime axis, but this isn't too hard to setup with pyqtgraph.
  • To reduce tedium, a default x and y column could be set for each table. E.g. for tabulated rating curve, it automatically draws the Q-h relationship. For the profile, the area (x) versus level (y). For timeseries, it automatically puts the time on the x-axis.

Performance might be a bit of an issue. Pandas is available, and arrow data can be read efficiently (although it will load all data into memory). Data from the geopackage can be ingested via the PyQGIS API, which would result a list of dicts.

Although if we can get QGIS installed via pixi, we would be able to use pyarrow and pyogrio instead.

@github-project-automation github-project-automation bot moved this to To do in Ribasim Nov 15, 2023
@Huite Huite added enhancement QGIS Ribasim QGIS plugin labels Nov 15, 2023
@Huite
Copy link
Contributor Author

Huite commented Nov 28, 2023

Something that came up today: there's many cases where you probably want to look at more than one state, but which should not be plotted in the same plotting window, such as basin levels / storages and edge flows.

An easy solution is to allow the spawning of separate plotting windows. This allows us to spawn two plotting widgets, one for the levels and one for the flows.

@visr
Copy link
Member

visr commented Dec 24, 2024

As @deltamarnix mentioned in #342 (comment), we looked a bit at https://github.com/ghtmtt/DataPlotly. It looks like it can already do many of the things listed above. Some are still a bit cumbersome, but perhaps we can work around that or contribute upstream.

This is plotting a Basin / profile relation for the currently selected Basin:
Image
This works due to #1756. However if you select multiple nodes ideally you'd want to be able to group by node_id, like described in this feature request: ghtmtt/DataPlotly#83 (comment). Without grouping it will think it is one line: Image

The workaround is to do a manual Feature subset on the first node_id, create plot, change the feature subset, create plot. This will show them both with separate labels.

For showing results, the iMOD plugin picks up metadata on the Node and Edge layers on where to find the Arrow files. These are then loaded with pandas by the plugin. To show results with DataPlotly you have to load the Arrow into an attribute table as far as I know. This could lead to performance issues, so perhaps we can find a way to avoid that. Also the related tables feature won't help us, so we cannot select features on the map. Perhaps it is possible to write some code for this and use the DataPlotly API (beta): https://dataplotly-docs.readthedocs.io/en/latest/from_console.html.

Here is an example of results from flow.arrow where I had to set the feature subset myself:
Image

The interactive features of Plotly make it quite useful to inspect the data.

@Huite
Copy link
Contributor Author

Huite commented Jan 6, 2025

This looks quite promising indeed!

Using from the console suggests that you might be able to use the plugin as a library, which makes sense but I haven't seen it with any other QGIS plugin.

The interactivity is a nice advantage over (default) pyqtgraph.

Performance should be good maybe even better too, since I'm guessing it's serving the plotting pane in a Qt HTML window, and Claude tells me Qt uses Chromium V8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QGIS Ribasim QGIS plugin
Projects
Status: To do
Development

No branches or pull requests

2 participants