nens / threedigrid-builder

Generate a 3Di simulation grid from a model schematisation.
Other
1 stars 0 forks source link

make_gridadmin reports ERROR for schematisations without breaches #364

Closed leendertvanwolfswinkel closed 4 weeks ago

leendertvanwolfswinkel commented 1 month ago

We just introduced a feature in the 3Di modeller interface to report logging from threedigrid_builder to users. If the schematisation does not contain any breaches, it reports a TypeError: object of type 'NoneType' has no len(). A threedimodel can still be made, but now that users see this error, they may get confused and think that something is wrong with their schematisation.

{
  "ExceptionDetails": {
    "Type": "TypeError",
    "Message": "object of type 'NoneType' has no len()"
  },
  "Environment": {
    "Qgis Version": "3.28.11-Firenze",
    "Operating System": "windows",
    "Locale": "en"
  },
  "Trace": [
    {
      "Name": "run_model_checks",
      "Filename": "plugins\\threedi_models_and_simulations\\widgets\\upload_wizard.py",
      "LineNo": 137,
      "Variables": {
        "self": "<threedi_models_and_simulations.widgets.upload_wizard.CheckModelWidget object at 0x000002606ED4A0D0>"
      }
    },
    {
      "Name": "check_computational_grid",
      "Filename": "plugins\\threedi_models_and_simulations\\widgets\\upload_wizard.py",
      "LineNo": 249,
      "Variables": {
        "SchematisationError": "<class 'threedigrid_builder.exceptions.SchematisationError'>",
        "make_gridadmin": "<function make_gridadmin at 0x00000260691B1B80>",
        "progress_logger": "<function CheckModelWidget.check_computational_grid.<locals>.progress_logger at 0x000002606E0D19D0>",
        "global_settings_layer": "<QgsVectorLayer: 'v2_global_settings' (spatialite)>",
        "global_settings_feat": "<qgis._core.QgsFeature object at 0x000002606E0D1E50>",
        "dem_file": "rasters\\dem_area_16.tif",
        "spatialite_dir": "C:\\D\\GIS\\3Di\\WORKING_DIRECTORY\\Area 16 (staging)\\work in progress\\schematisation",
        "dem_file_name": "dem_area_16.tif",
        "dem_path": "C:\\D\\GIS\\3Di\\WORKING_DIRECTORY\\Area 16 (staging)\\work in progress\\schematisation\\rasters\\dem_area_16.tif",
        "err": "Checking computational grid failed with the following error: TypeError(\"object of type 'NoneType' has no len()\")",
        "self": "<threedi_models_and_simulations.widgets.upload_wizard.CheckModelWidget object at 0x000002606ED4A0D0>"
      }
    },
    {
      "Name": "make_gridadmin",
      "Filename": "C:\\Users\\lukas\\AppData\\Roaming\\QGIS\\QGIS3\\profiles\\python39\\python\\plugins\\threedi_results_analysis\\deps\\threedigrid_builder\\application.py",
      "LineNo": 279,
      "Variables": {
        "sqlite_path": "C:\\D\\GIS\\3Di\\WORKING_DIRECTORY\\Area 16 (staging)\\work in progress\\schematisation\\Area 16 (staging).sqlite",
        "dem_path": "C:\\D\\GIS\\3Di\\WORKING_DIRECTORY\\Area 16 (staging)\\work in progress\\schematisation\\rasters\\dem_area_16.tif",
        "out_path": "None",
        "meta": "None",
        "progress_callback": "<function CheckModelWidget.check_computational_grid.<locals>.progress_logger at 0x000002606E0D19D0>",
        "upgrade": "False",
        "Writer": "<class 'threedigrid_builder.interface.dict_out.DictOut'>",
        "grid": "<Grid object with 16564 nodes and 34528 lines>",
        "writer": "<threedigrid_builder.interface.dict_out.DictOut object at 0x000002606EA30A90>"
      }
    },
    {
      "Name": "write",
      "Filename": "C:\\Users\\lukas\\AppData\\Roaming\\QGIS\\QGIS3\\profiles\\python39\\python\\plugins\\threedi_results_analysis\\deps\\threedigrid_builder\\interface\\dict_out.py",
      "LineNo": 153,
      "Variables": {
        "self": "<threedigrid_builder.interface.dict_out.DictOut object at 0x000002606EA30A90>",
        "grid": "<Grid object with 16564 nodes and 34528 lines>",
        "geometry_format": "wkb",
        "geom_serializer": "<function to_wkb at 0x0000026058189EE0>",
        "nodes": "{'id': array([    1,     2,     3, ..., 16562, 16563, 16564]), 'node_type': array(['NODE_2D_OPEN_WATER', 'NODE_2D_OPEN_WATER', 'NODE_2D_OPEN_WATER',\n       ..., 'NODE_2D_BOUNDARIES', 'NODE_2D_BOUNDARIES',\n       'NODE_2D_BOUNDARIES'], dtype=object), 'calculation_type': array(['', '', '', ..., '', '', ''], dtype=object), 'content_type': array(['', '', '', ..., '', '', ''], dtype=object), 'content_pk': array([-9999, -9999, -9999, ..., -9999, -9999, -9999]), 'dmax': array([nan, nan, nan, ..., nan, nan, nan]), 'dimp': array([nan, nan, nan, ..., nan, nan, nan]), 'storage_area': array([nan, nan, nan, ..., nan, nan, nan]), 'boundary_id': array([-9999, -9999, -9999, ...,     1,     1,     1]), 'boundary_type': array(['', '', '', ..., 'WATERLEVEL', 'WATERLEVEL', 'WATERLEVEL'],\n      dtype=object), 'manhole_id': array([-9999, -9999, -9999, ..., -9999, -9999, -9999]), 'initial_waterlevel': array([nan, nan, nan, ..., nan, nan, nan]), 'geometry': array([<POINT (258704 159811)>, <POINT (258704 159851)>,\n       <POINT (258704 159891)>, ..., <POINT (260304 162291)>,\n       <POINT (260344 162291)>, <POINT (260384 162291)>], dtype=object)}",
        "cells": "{'id': array([    1,     2,     3, ..., 16562, 16563, 16564]), 'node_type': array(['NODE_2D_OPEN_WATER', 'NODE_2D_OPEN_WATER', 'NODE_2D_OPEN_WATER',\n       ..., 'NODE_2D_BOUNDARIES', 'NODE_2D_BOUNDARIES',\n       'NODE_2D_BOUNDARIES'], dtype=object), 'boundary_id': array([-9999, -9999, -9999, ...,     1,     1,     1]), 'boundary_type': array(['', '', '', ..., 'WATERLEVEL', 'WATERLEVEL', 'WATERLEVEL'],\n      dtype=object), 'has_dem_averaged': array([0, 0, 0, ..., 0, 0, 0]), 'geometry': array([<POLYGON ((258724 159791, 258724 159831, 258684 159831, 258684 159791, 25872...>,\n       <POLYGON ((258724 159831, 258724 159871, 258684 159871, 258684 159831, 25872...>,\n       <POLYGON ((258724 159871, 258724 159911, 258684 159911, 258684 159871, 25872...>,\n       ...,\n       <POLYGON ((260324 162271, 260324 162311, 260284 162311, 260284 162271, 26032...>,\n       <POLYGON ((260364 162271, 260364 162311, 260324 162311, 260324 162271, 26036...>,\n       <POLYGON ((260404 162271, 260404 162311, 260364 162311, 260364 162271, 26040...>],\n      dtype=object)}",
        "nodes_emb": "None",
        "lines": "{'id': array([    1,     2,     3, ..., 34526, 34527, 34528]), 'kcu': array(['LINE_2D_U', 'LINE_2D_U', 'LINE_2D_U', ...,\n       'LINE_2D_BOUNDARY_NORTH', 'LINE_2D_BOUNDARY_NORTH',\n       'LINE_2D_BOUNDARY_NORTH'], dtype=object), 'node_1': array([   1,    2,    3, ..., 2636, 2697, 2750]), 'node_2': array([    6,     7,     8, ..., 16562, 16563, 16564]), 'ds1d': array([40., 40., 40., ..., 40., 40., 40.]), 'ds1d_half': array([20., 20., 20., ..., 20., 20., 20.]), 'content_type': array(['', '', '', ..., '', '', ''], dtype=object), 'content_pk': array([-9999, -9999, -9999, ..., -9999, -9999, -9999]), 'dpumax': array([nan, nan, nan, ..., nan, nan, nan]), 'invert_level_start_point': array([nan, nan, nan, ..., nan, nan, nan]), 'invert_level_end_point': array([nan, nan, nan, ..., nan, nan, nan]), 'flod': array([nan, nan, nan, ..., nan, nan, nan]), 'cross_id1': array([-9999, -9999, -9999, ..., -9999, -9999, -9999]), 'cross_id2': array([-9999, -9999, -9999, ..., -9999, -9999, -9999]), 'cross_weight': array([nan, nan, nan, ..., nan, nan, nan]), 'frict_type1': array([-9999, -9999, -9999, ..., -9999, -9999, -9999]), 'frict_type2': array([-9999, -9999, -9999, ..., -9999, -9999, -9999]), 'frict_value1': array([nan, nan, nan, ..., nan, nan, nan]), 'frict_value2': array([nan, nan, nan, ..., nan, nan, nan]), 'discharge_coefficient_positive': array([1., 1., 1., ..., 1., 1., 1.]), 'discharge_coefficient_negative': array([1., 1., 1., ..., 1., 1., 1.]), 'geometry': array([<LINESTRING (258704 159811, 258744 159811)>,\n       <LINESTRING (258704 159851, 258744 159851)>,\n       <LINESTRING (258704 159891, 258744 159891)>, ...,\n       <LINESTRING (260304 162251, 260304 162291)>,\n       <LINESTRING (260344 162251, 260344 162291)>,\n       <LINESTRING (260384 162251, 260384 162291)>], dtype=object)}"
      }
    },
    {
      "Name": "get_breaches",
      "Filename": "C:\\Users\\lukas\\AppData\\Roaming\\QGIS\\QGIS3\\profiles\\python39\\python\\plugins\\threedi_results_analysis\\deps\\threedigrid_builder\\interface\\dict_out.py",
      "LineNo": 293,
      "Variables": {
        "self": "<threedigrid_builder.interface.dict_out.DictOut object at 0x000002606EA30A90>",
        "breaches": "None"
      }
    }
  ]
}