Coverage for C:\src\imod-python\imod\mf6\out\common.py: 94%

18 statements  

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

1import pathlib 

2from typing import Any, BinaryIO, Dict, List, Union 

3 

4import numpy as np 

5 

6# Type annotations 

7IntArray = np.ndarray 

8FloatArray = np.ndarray 

9FilePath = Union[str, pathlib.Path] 

10 

11 

12def _grb_text(f: BinaryIO, lentxt: int = 50) -> str: 

13 return f.read(lentxt).decode("utf-8").strip().lower() 

14 

15 

16def _to_nan(a: FloatArray, dry_nan: bool) -> FloatArray: 

17 # TODO: this could really use a docstring? 

18 a[a == 1e30] = np.nan 

19 if dry_nan: 

20 a[a == -1e30] = np.nan 

21 return a 

22 

23 

24def get_first_header_advanced_package( 

25 headers: Dict[str, List[Any]], 

26) -> Any: 

27 for key, header_list in headers.items(): 

28 # multimodels have a gwf-gwf budget for flow-ja-face between domains 

29 if "flow-ja-face" not in key and "gwf_" in key: 

30 return header_list[0] 

31 return None