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

1 import pathlib

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

3

4 import numpy as np

5

6# Type annotations

7 IntArray = np.ndarray

8 FloatArray = np.ndarray

9 FilePath = Union[str, pathlib.Path]

10

11

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

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

14

15

16 def _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

24 def 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