Coverage for src/swiift/lib/att.py: 81%

1"""Attenuation parameterisations."""

2

3 import enum (empty)

4 import typing (empty)

5

6 import attrs (empty)

7 import numpy as np (empty)

8

9

10 def no_attenuation(): (empty)

11 """No attenuation.

12

13 Waves propagate indifinitely, as if the ice cover is perfectly elastic and

14 the fluid perfectly inviscid.

15

16 Returns

17 -------

18 typing.Literal[0]

19 Amplitude attenuation, in m^-1

20

21 Notes

22 -----

23 The attenuation is defined as:

24

25 .. math::

26

27 \alpha_j = 0 \forall j.

28

29 """

30 return 0

31

32

33 def parameterisation_01(thickness: float, wavenumbers: np.ndarray) -> np.ndarray: (empty)

34 """Parameterised attenuation for individual wave modes.

35

36 Parameters

37 ----------

38 thickness : float

39 Ice thickness, in m

40 wavenumbers : np.ndarray

41 Propagating wavenumbers, in rad m^-1

42

43 Returns

44 -------

45 np.ndarray

46 Amplitude attenuation, in m^-1

47

48 Notes

49 -----

50 The attenuation is defined as:

51

52 .. math::

53

54 \alpha_j = \frac{1}{4} {k_j}^2 h.

55

56 """

57 return wavenumbers**2 * thickness / 4

58

59

60 def parameterisation_yu2022( (empty)

61 thickness: float, gravity: float, angular_frequencies: np.ndarray

62) -> np.ndarray:

63 r"""Parameterised attenuation for individual wave modes.

64

65 This parameterisation is issued from Yu et al. (2022) [1]_.

66

67 .. versionadded:: 0.16.0

68

69 Parameters

70 ----------

71 thickness : float

72 Ice thickness, in m.

73 gravity : float

74 Acceleration of gravity, in m s**-2.

75 angular_frequencies : np.ndarray

76 Angular frequencies, in rad s**-1.

77

78 Returns

79 -------

80 np.ndarray

81 Amplitude attenuation rates, in m**-1.

82

83 Notes

84 -----

85 The attenuation is defined as:

86

87 .. math::

88

89 \alpha_j h = 0.108 {(\omega\sqrt{\frac{h}{g}})}^4.46

90

91 where the prefactor and exponents were obtained by a best fit to

92 available data [1]_.

93

94 References

95 ----------

96 .. [1] Yu, J., W. E. Rogers, and D. W. Wang (2022). A new method for

97 parameterization of wave dissipation by sea ice. Cold Regions Science and

98 Technology 199, p. 103582.

99 DOI: https://doi.org/10.1016/j.coldregions.2022.103582.

100

101 """

102 prefactor, exponent = 0.108, 4.46

103 return (

104 prefactor

105 * angular_frequencies**exponent

106 * thickness ** (exponent / 2 - 1)

107 / gravity ** (exponent / 2)

108 )

109

110

111 class AttenuationParameterisation(enum.Enum): (empty)

112 NO = 0 (empty)

113 PARAM_01 = 1 (empty)

114 PARAM_YU_2022 = 20 (empty)

115

116

117@attrs.frozen (empty)

118 class AttenuationSpecification: (empty)

119 function: typing.Callable (empty)

120 args: str | None = None (empty)

121 kwargs: dict[str, typing.Any] = attrs.field(factory=dict) (empty)

122

123

124 Attenuation: typing.TypeAlias = AttenuationParameterisation | AttenuationSpecification (empty)