Coverage for C:\src\imod-python\imod\mf6\cnc.py: 100%

1 import numpy as np

2

3 from imod.logging import init_log_decorator

4 from imod.mf6.boundary_condition import BoundaryCondition

5 from imod.mf6.interfaces.iregridpackage import IRegridPackage

6 from imod.mf6.validation import BOUNDARY_DIMS_SCHEMA

7 from imod.schemata import (

8 AllInsideNoDataSchema,

9 AllNoDataSchema,

10 AllValueSchema,

11 CoordsSchema,

12 DTypeSchema,

13 IndexesSchema,

14 OtherCoordsSchema,

15)

16

17

18 class ConstantConcentration(BoundaryCondition, IRegridPackage):

19 """

20 Constant Concentration package.

21

22 Parameters

23 ----------

24 concentration: array of floats (xr.DataArray)

25 Concentration of the boundary.

26 print_input: ({True, False}, optional)

27 keyword to indicate that the list of constant head information will

28 be written to the listing file immediately after it is read. Default is

29 False.

30 print_flows: ({True, False}, optional)

31 Indicates that the list of constant head flow rates will be printed to

32 the listing file for every stress period time step in which "BUDGET

33 PRINT" is specified in Output Control. If there is no Output Control

34 option and PRINT FLOWS is specified, then flow rates are printed for the

35 last time step of each stress period.

36 Default is False.

37 save_flows: ({True, False}, optional)

38 Indicates that constant head flow terms will be written to the file

39 specified with "BUDGET FILEOUT" in Output Control. Default is False.

40 observations: [Not yet supported.]

41 Default is None.

42 validate: {True, False}

43 Flag to indicate whether the package should be validated upon

44 initialization. This raises a ValidationError if package input is

45 provided in the wrong manner. Defaults to True.

46 """

47

48 _pkg_id = "cnc"

49 _keyword_map = {}

50 _period_data = ("concentration",)

51 _template = BoundaryCondition._initialize_template(_pkg_id)

52

53 _init_schemata = {

54 "concentration": [

55 DTypeSchema(np.floating),

56 IndexesSchema(),

57 CoordsSchema(("layer",)),

58 BOUNDARY_DIMS_SCHEMA,

59 ],

60 }

61 _write_schemata = {

62 "concentration": [

63 OtherCoordsSchema("idomain"),

64 AllNoDataSchema(), # Check for all nan, can occur while clipping

65 AllInsideNoDataSchema(other="idomain", is_other_notnull=(">", 0)),

66 AllValueSchema(">=", 0.0),

67 ]

68 }

69

70 @init_log_decorator()

71 def __init__(

72 self,

73 concentration,

74 print_input=False,

75 print_flows=False,

76 save_flows=False,

77 observations=None,

78 validate: bool = True,

79 ):

80 dict_dataset = {

81 "concentration": concentration,

82 "print_input": print_input,

83 "print_flows": print_flows,

84 "save_flows": save_flows,

85 "observations": observations,

86 }

87 super().__init__(dict_dataset)

88 self._validate_init_schemata(validate)