Coverage for src/swiift/lib/att.py: 81%
21 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-09-11 16:23 +0200
« prev ^ index » next coverage.py v7.9.1, created at 2025-09-11 16:23 +0200
1"""Attenuation parameterisations."""
3import enum
4import typing
6import attrs
7import numpy as np
10def no_attenuation():
11 """No attenuation.
13 Waves propagate indifinitely, as if the ice cover is perfectly elastic and
14 the fluid perfectly inviscid.
16 Returns
17 -------
18 typing.Literal[0]
19 Amplitude attenuation, in m^-1
21 Notes
22 -----
23 The attenuation is defined as:
25 .. math::
27 \alpha_j = 0 \forall j.
29 """
30 return 0
33def parameterisation_01(thickness: float, wavenumbers: np.ndarray) -> np.ndarray:
34 """Parameterised attenuation for individual wave modes.
36 Parameters
37 ----------
38 thickness : float
39 Ice thickness, in m
40 wavenumbers : np.ndarray
41 Propagating wavenumbers, in rad m^-1
43 Returns
44 -------
45 np.ndarray
46 Amplitude attenuation, in m^-1
48 Notes
49 -----
50 The attenuation is defined as:
52 .. math::
54 \alpha_j = \frac{1}{4} {k_j}^2 h.
56 """
57 return wavenumbers**2 * thickness / 4
60def parameterisation_yu2022(
61 thickness: float, gravity: float, angular_frequencies: np.ndarray
62) -> np.ndarray:
63 r"""Parameterised attenuation for individual wave modes.
65 This parameterisation is issued from Yu et al. (2022) [1]_.
67 .. versionadded:: 0.16.0
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.
78 Returns
79 -------
80 np.ndarray
81 Amplitude attenuation rates, in m**-1.
83 Notes
84 -----
85 The attenuation is defined as:
87 .. math::
89 \alpha_j h = 0.108 {(\omega\sqrt{\frac{h}{g}})}^4.46
91 where the prefactor and exponents were obtained by a best fit to
92 available data [1]_.
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.
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 )
111class AttenuationParameterisation(enum.Enum):
112 NO = 0
113 PARAM_01 = 1
114 PARAM_YU_2022 = 20
117@attrs.frozen
118class AttenuationSpecification:
119 function: typing.Callable
120 args: str | None = None
121 kwargs: dict[str, typing.Any] = attrs.field(factory=dict)
124Attenuation: typing.TypeAlias = AttenuationParameterisation | AttenuationSpecification