Fourier
coef_conversion(amp_coef=None, phase_coef=None, cos_coef=None, sin_coef=None)
The term for the \(n^{th}\) harmonic of a Fourier expansion can be written in two ways:
- \(F_n\cos(2n\pi ft - \Phi_n)\)
- \(F_{n, cos}\cos(2n\pi ft) + F_{n, sin}\sin(2n\pi ft)\)
Given the coefficients of one form, this returns the coefficients in the other form. Note \(\sin(x) = \cos(x - \pi /2)\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
amp_coef
|
Optional[Union[float, ndarray]]
|
|
None
|
phase_coef
|
Optional[Union[float, ndarray]]
|
|
None
|
cos_coef
|
Optional[Union[float, ndarray]]
|
|
None
|
sin_coef
|
Optional[Union[float, ndarray]]
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
coef1 |
Union[float, ndarray]
|
|
coef2 |
Union[float, ndarray]
|
|
Source code in isca_tools/utils/fourier.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
fourier_series(time, coefs_amp, coefs_phase)
For \(N\) harmonics, the fourier series with frequency \(f\) is:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time
|
ndarray
|
|
required |
coefs_amp
|
Union[List[float], ndarray]
|
|
required |
coefs_phase
|
Union[List[float], ndarray]
|
|
required |
Returns:
Type | Description |
---|---|
ndarray
|
|
Source code in isca_tools/utils/fourier.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
fourier_series_deriv(time, coefs_amp, coefs_phase, day_seconds=86400)
For \(N\) harmonics, the derivative of a fourier series with frequency \(f\) is:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time
|
ndarray
|
|
required |
coefs_amp
|
Union[ndarray, List[float]]
|
|
required |
coefs_phase
|
Union[ndarray, List[float]]
|
|
required |
day_seconds
|
float
|
Duration of a day in seconds. |
86400
|
Returns:
Type | Description |
---|---|
ndarray
|
|
Source code in isca_tools/utils/fourier.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
get_fourier_coef(time, var, n, integ_method='spline')
This calculates the analytic solution for the amplitude and phase coefficients for the n
th harmonic
🔗
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time
|
ndarray
|
|
required |
var
|
ndarray
|
|
required |
n
|
int
|
Harmonic to find coefficients for, if 0, will just return amplitude coefficient. Otherwise, will return an amplitude and phase coefficient. |
required |
integ_method
|
str
|
How to perform the integration.
If |
'spline'
|
Returns:
amp_coef
: The amplitude fourier coefficient \(F_n\).
phase_coef
: The phase fourier coefficient \(\Phi_n\). Will not return if \(n=0\).
Source code in isca_tools/utils/fourier.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
get_fourier_fit(time, var, n_harmonics, integ_method='spline')
Obtains the Fourier series solution for \(F=\)var
, using \(N=\)n_harmonics
:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time
|
ndarray
|
|
required |
var
|
ndarray
|
|
required |
n_harmonics
|
int
|
Number of harmonics to use to fit fourier series, \(N\). |
required |
integ_method
|
str
|
How to perform the integration when obtaining Fourier coefficients.
If |
'spline'
|
Returns:
Type | Description |
---|---|
ndarray
|
|
ndarray
|
|
ndarray
|
|
Source code in isca_tools/utils/fourier.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|