threedi-modelchecker 2.14.0.dev0__tar.gz → 2.14.0.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. {threedi_modelchecker-2.14.0.dev0/threedi_modelchecker.egg-info → threedi_modelchecker-2.14.0.dev1}/PKG-INFO +2 -2
  2. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/pyproject.toml +1 -1
  3. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/__init__.py +1 -1
  4. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/checks/cross_section_definitions.py +34 -1
  5. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/config.py +74 -23
  6. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1/threedi_modelchecker.egg-info}/PKG-INFO +2 -2
  7. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker.egg-info/requires.txt +1 -1
  8. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/CHANGES.rst +0 -0
  9. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/LICENSE +0 -0
  10. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/MANIFEST.in +0 -0
  11. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/README.rst +0 -0
  12. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/setup.cfg +0 -0
  13. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/checks/__init__.py +0 -0
  14. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/checks/base.py +0 -0
  15. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/checks/factories.py +0 -0
  16. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/checks/geo_query.py +0 -0
  17. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/checks/other.py +0 -0
  18. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/checks/raster.py +0 -0
  19. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/checks/timeseries.py +0 -0
  20. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/exporters.py +0 -0
  21. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/interfaces/__init__.py +0 -0
  22. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/interfaces/raster_interface.py +0 -0
  23. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/interfaces/raster_interface_gdal.py +0 -0
  24. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/interfaces/raster_interface_rasterio.py +0 -0
  25. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/model_checks.py +0 -0
  26. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/scripts.py +0 -0
  27. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/__init__.py +0 -0
  28. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/conftest.py +0 -0
  29. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/data/__init__.py +0 -0
  30. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/data/empty.gpkg +0 -0
  31. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/data/empty.sqlite +0 -0
  32. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/factories.py +0 -0
  33. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/test_checks_base.py +0 -0
  34. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/test_checks_cross_section_definitions.py +0 -0
  35. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/test_checks_factories.py +0 -0
  36. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/test_checks_other.py +0 -0
  37. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/test_checks_raster.py +0 -0
  38. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/test_checks_timeseries.py +0 -0
  39. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/test_exporters.py +0 -0
  40. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker/tests/test_model_checks.py +0 -0
  41. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker.egg-info/SOURCES.txt +0 -0
  42. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker.egg-info/dependency_links.txt +0 -0
  43. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker.egg-info/entry_points.txt +0 -0
  44. {threedi_modelchecker-2.14.0.dev0 → threedi_modelchecker-2.14.0.dev1}/threedi_modelchecker.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: threedi-modelchecker
3
- Version: 2.14.0.dev0
3
+ Version: 2.14.0.dev1
4
4
  Summary: Checks validity of a 3Di schematisation
5
5
  Author-email: Nelen & Schuurmans <info@nelen-schuurmans.nl>
6
6
  License: MIT
@@ -15,7 +15,7 @@ License-File: LICENSE
15
15
  Requires-Dist: Click
16
16
  Requires-Dist: GeoAlchemy2!=0.11.*,>=0.9
17
17
  Requires-Dist: SQLAlchemy>=1.4
18
- Requires-Dist: threedi-schema==0.228.0.dev1
18
+ Requires-Dist: threedi-schema==0.228.0.dev2
19
19
  Provides-Extra: rasterio
20
20
  Requires-Dist: rasterio>=1.3.10; extra == "rasterio"
21
21
  Provides-Extra: test
@@ -19,7 +19,7 @@ dependencies = [
19
19
  "Click",
20
20
  "GeoAlchemy2>=0.9,!=0.11.*",
21
21
  "SQLAlchemy>=1.4",
22
- "threedi-schema==0.228.0.dev1"
22
+ "threedi-schema==0.228.0.dev2"
23
23
  # "threedi-schema @ git+https://github.com/nens/threedi-schema.git@margriet_89_schema_300_1D"
24
24
 
25
25
  ]
@@ -1,5 +1,5 @@
1
1
  from .model_checks import * # NOQA
2
2
 
3
3
  # fmt: off
4
- __version__ = '2.14.0.dev0'
4
+ __version__ = '2.14.0.dev1'
5
5
  # fmt: on
@@ -2,6 +2,7 @@ from abc import ABC, abstractmethod
2
2
  from enum import IntEnum
3
3
  from typing import Union
4
4
 
5
+ from sqlalchemy import func
5
6
  from threedi_schema import constants, models
6
7
 
7
8
  from .base import BaseCheck
@@ -487,12 +488,13 @@ class OpenIncreasingCrossSectionConveyanceFrictionCheck(
487
488
  super()
488
489
  .to_check(session)
489
490
  .where(
491
+ self.table.c.cross_section_shape.isnot(None),
490
492
  self.table.c.friction_type.in_(
491
493
  [
492
494
  constants.FrictionType.CHEZY_CONVEYANCE,
493
495
  constants.FrictionType.MANNING_CONVEYANCE,
494
496
  ]
495
- )
497
+ ),
496
498
  )
497
499
  )
498
500
 
@@ -544,6 +546,37 @@ class CrossSectionVariableCorrectLengthCheck(CrossSectionBaseCheck, ABC):
544
546
  return f"{self.column_name} should contain 1 value for each element; len({self.column_name}) = len(width)-1"
545
547
 
546
548
 
549
+ class OpenIncreasingCrossSectionConveyanceFrictionCheckWithMaterial(
550
+ OpenIncreasingCrossSectionCheck
551
+ ):
552
+ """
553
+ Check if cross sections used with friction with conveyance
554
+ are open and monotonically increasing in width
555
+ """
556
+
557
+ def to_check(self, session):
558
+ return (
559
+ super()
560
+ .to_check(session)
561
+ .outerjoin(models.Material, self.table.c.material_id == models.Material.id)
562
+ .where(
563
+ self.table.c.cross_section_shape.isnot(None),
564
+ # take value from table if present, otherwise value from Material
565
+ func.coalesce(
566
+ self.table.c.friction_type, models.Material.friction_type
567
+ ).in_(
568
+ [
569
+ constants.FrictionType.CHEZY_CONVEYANCE,
570
+ constants.FrictionType.MANNING_CONVEYANCE,
571
+ ]
572
+ ),
573
+ )
574
+ )
575
+
576
+ def description(self):
577
+ return f"{self.column_name} should contain 1 value for each element; len({self.column_name}) = len(width)-1"
578
+
579
+
547
580
  class CrossSectionFrictionCorrectLengthCheck(CrossSectionVariableCorrectLengthCheck):
548
581
  def parse_str_value(self, str_value):
549
582
  return [float(item) for item in str_value.split(",")]
@@ -1,6 +1,6 @@
1
1
  from typing import List
2
2
 
3
- from sqlalchemy import func, or_, select, true
3
+ from sqlalchemy import and_, func, or_, true
4
4
  from sqlalchemy.orm import Query
5
5
  from threedi_schema import constants, models
6
6
  from threedi_schema.beta_features import BETA_COLUMNS, BETA_VALUES
@@ -35,6 +35,7 @@ from .checks.cross_section_definitions import (
35
35
  CrossSectionYZHeightCheck,
36
36
  CrossSectionYZIncreasingWidthIfOpenCheck,
37
37
  OpenIncreasingCrossSectionConveyanceFrictionCheck,
38
+ OpenIncreasingCrossSectionConveyanceFrictionCheckWithMaterial,
38
39
  OpenIncreasingCrossSectionVariableCheck,
39
40
  )
40
41
  from .checks.factories import (
@@ -149,7 +150,6 @@ cross_section_tables = [
149
150
  CHECKS: List[BaseCheck] = []
150
151
 
151
152
  ## 002x: FRICTION
152
- ## Use same error code as other null checks
153
153
  CHECKS += [
154
154
  QueryCheck(
155
155
  error_code=20,
@@ -225,31 +225,69 @@ CHECKS += [
225
225
  NotNullCheck(
226
226
  error_code=24,
227
227
  column=table.friction_value,
228
- filters=table.crest_type == constants.CrestType.BROAD_CRESTED.value,
228
+ filters=(
229
+ (table.crest_type == constants.CrestType.BROAD_CRESTED.value)
230
+ & ((table.material_id.is_(None)) | (table.friction_type.isnot(None)))
231
+ ),
229
232
  )
230
233
  for table in [models.Orifice, models.Weir]
231
234
  ]
235
+ CHECKS += [
236
+ NotNullCheck(
237
+ error_code=24,
238
+ column=table.friction_value,
239
+ filters=((table.material_id.is_(None)) | (table.friction_type.isnot(None))),
240
+ )
241
+ for table in [models.Culvert, models.Pipe]
242
+ ]
232
243
  CHECKS += [
233
244
  NotNullCheck(
234
245
  error_code=25,
235
246
  column=table.friction_type,
236
- filters=table.crest_type == constants.CrestType.BROAD_CRESTED.value,
247
+ filters=(
248
+ (table.crest_type == constants.CrestType.BROAD_CRESTED.value)
249
+ & ((table.material_id.is_(None)) | (table.friction_value.isnot(None)))
250
+ ),
237
251
  )
238
252
  for table in [models.Orifice, models.Weir]
239
253
  ]
254
+ CHECKS += [
255
+ NotNullCheck(
256
+ error_code=25,
257
+ column=table.friction_type,
258
+ filters=((table.material_id.is_(None)) | (table.friction_value.isnot(None))),
259
+ )
260
+ for table in [models.Culvert, models.Pipe]
261
+ ]
262
+
263
+
240
264
  # Friction with conveyance should raise an error when used
241
265
  # on a column other than models.CrossSectionLocation
266
+
242
267
  CHECKS += [
243
268
  QueryCheck(
244
269
  error_code=26,
245
270
  column=table.friction_type,
246
- invalid=Query(table).filter(
247
- table.friction_type.in_(
248
- [
249
- constants.FrictionType.CHEZY_CONVEYANCE,
250
- constants.FrictionType.MANNING_CONVEYANCE,
251
- ]
252
- ),
271
+ invalid=Query(table)
272
+ .outerjoin(models.Material, table.material_id == models.Material.id)
273
+ .filter(
274
+ or_(
275
+ table.friction_type.in_(
276
+ [
277
+ constants.FrictionType.CHEZY_CONVEYANCE,
278
+ constants.FrictionType.MANNING_CONVEYANCE,
279
+ ]
280
+ ),
281
+ and_(
282
+ table.friction_type == None,
283
+ models.Material.friction_type.in_(
284
+ [
285
+ constants.FrictionType.CHEZY_CONVEYANCE,
286
+ constants.FrictionType.MANNING_CONVEYANCE,
287
+ ]
288
+ ),
289
+ ),
290
+ )
253
291
  ),
254
292
  message=(
255
293
  "Friction with conveyance, such as chezy_conveyance and "
@@ -258,6 +296,8 @@ CHECKS += [
258
296
  )
259
297
  for table in [models.Pipe, models.Culvert, models.Weir, models.Orifice]
260
298
  ]
299
+
300
+
261
301
  # Friction with conveyance should only be used on
262
302
  # tabulated rectangle, tabulated trapezium, or tabulated yz shapes
263
303
  CHECKS += [
@@ -293,10 +333,17 @@ CHECKS += [
293
333
  )
294
334
  ]
295
335
  CHECKS += [
296
- OpenIncreasingCrossSectionConveyanceFrictionCheck(error_code=28, column=table.id)
297
- for table in cross_section_tables
336
+ OpenIncreasingCrossSectionConveyanceFrictionCheckWithMaterial(
337
+ error_code=28, column=table.id
338
+ )
339
+ for table in [models.Pipe, models.Weir, models.Orifice, models.Culvert]
340
+ ] + [
341
+ OpenIncreasingCrossSectionConveyanceFrictionCheck(
342
+ error_code=28, column=models.CrossSectionLocation.id
343
+ )
298
344
  ]
299
345
 
346
+
300
347
  ## 003x: CALCULATION TYPE
301
348
 
302
349
  CHECKS += [
@@ -861,7 +908,7 @@ for table in cross_section_tables:
861
908
  CrossSectionExpectEmptyCheck(
862
909
  error_code=94,
863
910
  level=CheckLevel.WARNING,
864
- column=models.CrossSectionLocation.cross_section_height,
911
+ column=table.cross_section_height,
865
912
  shapes=(
866
913
  constants.CrossSectionShape.CIRCLE,
867
914
  constants.CrossSectionShape.EGG,
@@ -870,23 +917,24 @@ for table in cross_section_tables:
870
917
  ),
871
918
  CrossSectionYZHeightCheck(
872
919
  error_code=95,
873
- column=models.CrossSectionLocation.cross_section_table,
920
+ column=table.cross_section_table,
874
921
  shapes=(constants.CrossSectionShape.TABULATED_YZ,),
875
922
  ),
876
923
  CrossSectionYZCoordinateCountCheck(
877
- column=models.CrossSectionLocation.cross_section_table,
924
+ column=table.cross_section_table,
878
925
  error_code=96,
879
926
  shapes=(constants.CrossSectionShape.TABULATED_YZ,),
880
927
  ),
881
928
  CrossSectionYZIncreasingWidthIfOpenCheck(
882
- column=models.CrossSectionLocation.cross_section_table,
929
+ column=table.cross_section_table,
883
930
  error_code=97,
884
931
  shapes=(constants.CrossSectionShape.TABULATED_YZ,),
885
932
  ),
886
933
  CrossSectionMinimumDiameterCheck(
887
- column=models.CrossSectionLocation.id,
934
+ column=table.id,
888
935
  error_code=98,
889
936
  level=CheckLevel.WARNING,
937
+ filters=table.cross_section_shape.isnot(None),
890
938
  ),
891
939
  ]
892
940
 
@@ -3044,6 +3092,7 @@ CHECKS += [
3044
3092
  OpenIncreasingCrossSectionVariableCheck(
3045
3093
  error_code=186,
3046
3094
  column=table.id,
3095
+ filters=table.cross_section_shape.isnot(None),
3047
3096
  )
3048
3097
  for table in cross_section_tables
3049
3098
  ]
@@ -3230,7 +3279,12 @@ CHECKS += [
3230
3279
  ]
3231
3280
 
3232
3281
  conditions = [
3233
- models.Material.id.in_(select(table.material_id)) for table in material_ref_tables
3282
+ and_(
3283
+ table.material_id == models.Material.id,
3284
+ table.friction_value.is_(None),
3285
+ table.friction_type.is_(None),
3286
+ )
3287
+ for table in material_ref_tables
3234
3288
  ]
3235
3289
  CHECKS += [
3236
3290
  NotNullCheck(
@@ -3339,8 +3393,6 @@ not_null_columns = [
3339
3393
  models.CrossSectionLocation.reference_level,
3340
3394
  models.Culvert.connection_node_id_start,
3341
3395
  models.Culvert.connection_node_id_end,
3342
- models.Culvert.friction_type,
3343
- models.Culvert.friction_value,
3344
3396
  models.Culvert.invert_level_start,
3345
3397
  models.Culvert.invert_level_end,
3346
3398
  models.Orifice.connection_node_id_start,
@@ -3350,8 +3402,6 @@ not_null_columns = [
3350
3402
  models.Pipe.connection_node_id_start,
3351
3403
  models.Pipe.connection_node_id_end,
3352
3404
  models.Pipe.exchange_type,
3353
- models.Pipe.friction_type,
3354
- models.Pipe.friction_value,
3355
3405
  models.Pipe.invert_level_end,
3356
3406
  models.Pipe.invert_level_start,
3357
3407
  models.Pump.connection_node_id,
@@ -3366,6 +3416,7 @@ not_null_columns = [
3366
3416
  models.Weir.crest_level,
3367
3417
  models.Weir.crest_type,
3368
3418
  models.Windshielding.channel_id,
3419
+ models.ModelSettings.node_open_water_detection,
3369
3420
  ]
3370
3421
 
3371
3422
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: threedi-modelchecker
3
- Version: 2.14.0.dev0
3
+ Version: 2.14.0.dev1
4
4
  Summary: Checks validity of a 3Di schematisation
5
5
  Author-email: Nelen & Schuurmans <info@nelen-schuurmans.nl>
6
6
  License: MIT
@@ -15,7 +15,7 @@ License-File: LICENSE
15
15
  Requires-Dist: Click
16
16
  Requires-Dist: GeoAlchemy2!=0.11.*,>=0.9
17
17
  Requires-Dist: SQLAlchemy>=1.4
18
- Requires-Dist: threedi-schema==0.228.0.dev1
18
+ Requires-Dist: threedi-schema==0.228.0.dev2
19
19
  Provides-Extra: rasterio
20
20
  Requires-Dist: rasterio>=1.3.10; extra == "rasterio"
21
21
  Provides-Extra: test
@@ -1,7 +1,7 @@
1
1
  Click
2
2
  GeoAlchemy2!=0.11.*,>=0.9
3
3
  SQLAlchemy>=1.4
4
- threedi-schema==0.228.0.dev1
4
+ threedi-schema==0.228.0.dev2
5
5
 
6
6
  [rasterio]
7
7
  rasterio>=1.3.10