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

23 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-16 11:25 +0200

1from typing import Optional, Tuple 

2 

3import numpy as np 

4 

5from imod.logging import init_log_decorator 

6from imod.mf6.boundary_condition import BoundaryCondition 

7from imod.mf6.interfaces.iregridpackage import IRegridPackage 

8from imod.mf6.utilities.regridding_types import RegridderType 

9from imod.mf6.validation import BOUNDARY_DIMS_SCHEMA 

10from imod.schemata import ( 

11 AllInsideNoDataSchema, 

12 AllNoDataSchema, 

13 AllValueSchema, 

14 CoordsSchema, 

15 DTypeSchema, 

16 IndexesSchema, 

17 OtherCoordsSchema, 

18) 

19 

20 

21class ConstantConcentration(BoundaryCondition, IRegridPackage): 

22 """ 

23 Constant Concentration package. 

24 

25 Parameters 

26 ---------- 

27 concentration: array of floats (xr.DataArray) 

28 Concentration of the boundary. 

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

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

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

32 False. 

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

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

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

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

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

38 last time step of each stress period. 

39 Default is False. 

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

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

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

43 observations: [Not yet supported.] 

44 Default is None. 

45 validate: {True, False} 

46 Flag to indicate whether the package should be validated upon 

47 initialization. This raises a ValidationError if package input is 

48 provided in the wrong manner. Defaults to True. 

49 """ 

50 

51 _pkg_id = "cnc" 

52 _keyword_map = {} 

53 _period_data = ("concentration",) 

54 _template = BoundaryCondition._initialize_template(_pkg_id) 

55 

56 _regrid_method: dict[str, tuple[RegridderType, str]] = {} 

57 

58 _init_schemata = { 

59 "concentration": [ 

60 DTypeSchema(np.floating), 

61 IndexesSchema(), 

62 CoordsSchema(("layer",)), 

63 BOUNDARY_DIMS_SCHEMA, 

64 ], 

65 } 

66 _write_schemata = { 

67 "concentration": [ 

68 OtherCoordsSchema("idomain"), 

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

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

71 AllValueSchema(">=", 0.0), 

72 ] 

73 } 

74 

75 @init_log_decorator() 

76 def __init__( 

77 self, 

78 concentration, 

79 print_input=False, 

80 print_flows=False, 

81 save_flows=False, 

82 observations=None, 

83 validate: bool = True, 

84 ): 

85 dict_dataset = { 

86 "concentration": concentration, 

87 "print_input": print_input, 

88 "print_flows": print_flows, 

89 "save_flows": save_flows, 

90 "observations": observations, 

91 } 

92 super().__init__(dict_dataset) 

93 self._validate_init_schemata(validate) 

94 

95 def get_regrid_methods(self) -> Optional[dict[str, Tuple[RegridderType, str]]]: 

96 return self._regrid_method