Deltares / imod-qgis

🗺️🧭 QGIS plugin for iMOD
GNU General Public License v2.0
7 stars 1 forks source link

Improve error message if as_line not checked and no "top" and "bottom" present in dataset. #65

Open JoerivanEngelen opened 7 months ago

JoerivanEngelen commented 7 months ago

QGIS-Tim outputs datasets without a top and bottom variable. For analytic element models, it is easier to output this data as lines, for which the "as line" checkbox has to be checked. QGIS-Tim users are usually unaware of all the specifics required to plot PColorMeshItem, and forgetting to check the "as line" box causes this message:

ValueError: Missing "top" and "bottom" variables in dataset

iMOD Python's users have got more info about the plugin's requirements for CrossSectionData through iMOD Python's API docstrings.

To help QGIS-Tim users we could either do:

rubencalje commented 5 months ago

Hi @JoerivanEngelen,

The imod plugin performs really well, especially the Time Series and Cross Section widgets, and integrates well in QGIS. I have managed to get my data into the plugin, below is a screenshot of my project. I do have variables named 'toplayer{x}" and "bottomlayer{x}" for x from 1 to 28, and all layered variables are shown by a single checkbox in the variable selection list. However, I cannot uncheck the "As line(s)" checkbox, as it is disabled. Does this have anything to do with this issue?

Another minor issue I have: the documentation states

For time dependent data, when the Temporal Controller Panel is turned on, the cross-section plot is automatically updated when a different moment in time is selected.

This is not my experience. The cross-section plot only updates to a new selected time when I draw another cross-section line using the "Select location"-button. The main map does update when I select a different moment in time. Is this a known issue, or am I doing something wrong?

image

rubencalje commented 5 months ago

I think the plugin checks if the first variable in the variable-list has a layer dimension. If there is no layer dimension, it disables the "As line(s)" button, and it is never enabled again.

If I remove the first variables without a layer dimension from the netcdf-file, I can deselect the "As line(s)" button, until I select a variable without a layer dimension, and the "As line(s)" button is selected and disabled again. I can then enable the "As line(s)" button again by selecting the netcdf-file again (the most left selection button).

rubencalje commented 5 months ago

Sorry for all the messages (this will be my last). I think my (first) issue is relatively easy to solve, by changing the following lines in the method set_variable_layernumbers in cross_section_widget.py:

        if layers == NO_LAYERS:
            self.as_line_checkbox.setChecked(True)
            self.as_line_checkbox.setEnabled(False)

to

        if layers == NO_LAYERS:
            self.as_line_checkbox.setChecked(True)
            self.as_line_checkbox.setEnabled(False)
        else:
            self.as_line_checkbox.setChecked(False)
            self.as_line_checkbox.setEnabled(True)

If you want, I can make a pull request. If so, please let me know to which branch do I need to create this request.

JoerivanEngelen commented 5 months ago

Hi @rubencalje, thanks for reporting the issue you found and coming up with a fix!

I think your first issue you run into is different than this issue (#65): It's a bug in the behavior of the "as line" checkbox, whereas issue #65 is to change default behavior of the check box.

The bug you describe seems very annoying, so good if we can get this fixed soon, so I'm glad if you can make a PR. I'll open up a new issue for the bug you run into, and I'll write instructions on the branch name to push to there.

JoerivanEngelen commented 5 months ago

Regarding your second issue: that's not the intended behavior, so I expect this to be a bug and not faulty use on your end. I'll create a separate issue for it.