Coverage for tests/helpers.py: 0%

1 import typing

2

3 import numpy as np

4

5 from swiift.model.model import FloatingIce, Ice, Ocean, WavesUnderFloe, WavesUnderIce

6

7 wave_params = (

8 (

9 np.array([0.00950574 + 0.13669057j]),

10 np.array([0.02660581 + 0.02685434j]),

11 ), # monochromatic

12 (

13 (

14 np.array([0.00950574 + 0.13669057j, 0.02660581 + 0.0265434j]),

15 np.array([0.03552382 + 0.05215654j, 0.06214718 + 0.1250975j]),

16 ) # polychromatic

17 ),

18)

19 growth_params_bool = (None, True)

20

21

22 def make_growth_params(

23 growth_params_bool: typing.Literal[True] | None,

24 wave_params: tuple[np.ndarray, np.ndarray],

25) -> tuple | None:

26 if growth_params_bool is not None:

27 one_and_maybe_two = np.linspace(1, 2, len(wave_params[0]))

28 # Set arbitrary growth kernel with correct shape. Setting the mean to a

29 # negative number ensures a numerical solution is used.

30 return (-3 * one_and_maybe_two[:, None], 20)

31 return growth_params_bool

32

33

34 def setup_wuf(wave_params: tuple[np.ndarray, np.ndarray]) -> WavesUnderFloe:

35 gravity = 9.8

36 left_edge = -13.2

37 length = 98.3

38

39 amplitudes, c_wavenumbers = wave_params

40 wavenumbers, attenuations = (func(c_wavenumbers) for func in (np.real, np.imag))

41 wui = WavesUnderIce(

42 FloatingIce.from_ice_ocean(Ice(), Ocean(), gravity),

43 wavenumbers,

44 attenuations,

45 )

46 return WavesUnderFloe(

47 left_edge=left_edge, length=length, wui=wui, edge_amplitudes=amplitudes

48 )