PlasmaWaves.jl
PlasmaWaves — Module
References
Santolík et al. [1] Samson and Olson [2] Means [3]
Installation
using Pkg
Pkg.add("PlasmaWaves")API Reference
PlasmaWaves.PlasmaWaves — Module
PlasmaWaves.Means — Type
Means()Polarization method for wavpol reading the polarization ellipse off the rows of the spectral matrix S, as SPEDAS wavpol does. Returns degpol, waveangle, ellipticity and ellipticity_perp.
The wave normal follows Means [3]: $𝐤 ∥ (Im S_{23}, -Im S_{13}, Im S_{12})$.
Row c gives the field vector $𝐮 ∝ S_{c,:}^*$ up to a phase. The polarization ellipse traced by $Re(𝐮 e^{iφ})$ has semi-axes $\sqrt{(|𝐮|^2 ± |𝐮^T 𝐮|)/2}$ and area $π |Re 𝐮 × Im 𝐮|$, so its axial ratio is
\[\frac{2 |Re 𝐮 × Im 𝐮|}{|𝐮|^2 + |𝐮^T 𝐮|}.\]
ellipticity_perp applies the same to the (x, y) components. Both are signed by $Im S_{12}$. Each ratio is formed from numerator and denominator summed over rows, so row c counts ∝ $S_{cc}$ for a pure wave.
Differences from SPEDAS, whose helicity is abs(ellipticity) and whose ellipticity is ellipticity_perp:
- SPEDAS averages the rows equally; for a parallel wave over white noise the δB_z row then holds only noise, and helicity tends to 2/3 of its true value however high the SNR.
- SPEDAS drops a factor 2 in the rotation angle of the (x, y) projection, so its ellipticity differs for tilted ellipses.
PlasmaWaves.Samson — Type
Samson()Polarization method for wavpol reading the polarization ellipse off the principal eigenvector $𝐯$ of the spectral matrix, its pure-state part [2]. Returns the same fields as Means, with the wave normal $𝐤 ∥ Re 𝐯 × Im 𝐯$.
Isotropic noise $σ^2 I$ leaves $𝐯$ unchanged, so in the ensemble limit ellipticity is unbiased at any SNR. On finite samples it stays closer to the truth than Means below degpol ≈ 0.5; above that the two agree, and Samson takes about 1.4× as long.
PlasmaWaves.Santolik — Type
Santolik()Polarization method for wavpol from the singular value decomposition of the real 6×3 matrix $[Re S; Im S]$ [1]. Returns degpol, planarity, waveangle and ellipticity.
The wave normal is the right singular vector of the smallest singular value $W_3$, and ellipticity is $W_2 / W_1$ signed by $Im S_{12}$. planarity comes from the squared singular values $W_i^2$, so near 1 it is resolved only to about $ε^{1/4}$ ($10^{-4}$ in Float64).
PlasmaWaves.degree_of_polarization — Method
degree_of_polarization(S0, S1, S2, S3)Degree of polarization $p^2 = (S_1^2 + S_2^2 + S_3^2) / S_0^2$ from the Stokes parameters, equal to degree_of_polarization(S) of the corresponding 2×2 spectral matrix.
PlasmaWaves.degree_of_polarization — Method
degree_of_polarization(S)Degree of polarization $p^2$ of the $n×n$ Hermitian spectral matrix S [2]: 1 for a pure state, 0 for $S ∝ I$.
\[\begin{aligned} p^2 &= 1-\frac{(tr 𝐒)^2-(tr 𝐒^2)}{(tr 𝐒)^2-n^{-1}(tr 𝐒)^2} \\ &= \frac{n(tr 𝐒^2)-(tr 𝐒)^2}{(n-1)(tr 𝐒)^2} \end{aligned}\]
PlasmaWaves.spectral_matrix — Function
spectral_matrix(X, dim = 1)Compute the spectral matrix $S(f)$ given the time series data X along dimension dim.
Returns a 3-D array of size $n × n × (\lfloor N/2 \rfloor + 1)$ for n components of length N.
PlasmaWaves.spectral_matrix — Method
spectral_matrix(Xf)Compute the spectral matrix $S$ defined by
\[S_{ij}(f) = X_i(f) X_j^*(f),\]
where $X_i(f)$=Xf[f, i] is the FFT of the $i$-th component and $*$ denotes complex conjugation.
PlasmaWaves.twavpol — Method
twavpol(X; fs, kw...)wavpol on time series X, with fs inferred from the times dimension of X if not given. Adds the window centre times to the result.
PlasmaWaves.wavpol — Method
wavpol(X, fs = 1; method = Means(), nfft = 256, noverlap = div(nfft, 2), smooth_t, smooth_f, dim = 1)Polarization analysis of 3-component time series X (components along dimension 2, or 1 with dim = 2) sampled at fs.
For each FFT window, the spectral matrix $S(f)$ of the windowed data is smoothed over frequency, scaled to unit trace and passed to method, which turns it into wave parameters. Methods: Means (SPEDAS wavpol), Samson (principal eigenvector) and Santolik (SVD); any callable mapping the 3×3 $S$ to a NamedTuple of reals also works.
The data are assumed to be in a right-handed, field-aligned coordinate system with z along the ambient magnetic field.
Keywords
noverlap: Number of samples shared by consecutive windowssmooth_t: Time-domain window of lengthnfft(default: Hamming)smooth_f: Frequency-domain smoothing weights of odd length (default: 3-point Hamming)
Returns
A named tuple with indices (centre sample of each window), freqs, power (one-sided power spectral density, input units² / Hz), and the fields of method, each a (window × frequency) matrix. A field name means the same quantity whichever method returns it:
degpol: Degree of polarization $p^2$ in [0, 1]; seedegree_of_polarizationwaveangle: Angle between the wave normal and z, in [0, π/2]ellipticity: Minor-to-major axis ratio of the polarization ellipse in its own plane, in [-1, 1], negative for left-hand rotation about zellipticity_perp: The same for the ellipse projected onto the (x, y) planeplanarity: $1 - \sqrt{W_3 / W_1}$ from the singular values $W_1 ≥ W_2 ≥ W_3$ of $[Re S; Im S]$
Notes
smooth_f is needed because otherwise the rank of the spectral matrix $S̃(f)$ is 1, yielding a constant (fully polarized) result $degpol(f) = 1$. Frequency smoothing introduces ensemble averaging, corresponding to different realizations, so $S̃(f)$ gains fuller rank. The length(smooth_f) ÷ 2 bins at each end, where the smoothing window does not fit, report only power; the other outputs are NaN there.
- [1]
- O. Santolík, M. Parrot and F. Lefeuvre. Singular Value Decomposition Methods for Wave Propagation Analysis. Radio Science 38 (2003). ↩1 ↩2
- [2]
- J. C. Samson and J. V. Olson. Some Comments on the Descriptions of the Polarization States of Waves. Geophysical Journal International 61, 115–129 (1980). ↩1 ↩2 ↩3
- [3]
- J. D. Means. Use of the Three-Dimensional Covariance Matrix in Analyzing the Polarization Properties of Plane Waves. Journal of Geophysical Research (1896-1977) 77, 5551–5559 (1972). ↩1 ↩2