Import libraries

The data is read from ISF files, using the isfreader library. (Can be installed by "!pip3 install isfreader" command.)

Data loading

Spectral analysis of the signal

The mixer signal is a base sine wave (the envelope of the mixing) at a frequency close to 500 kHz. The reference saw-tooth frequency sweeping wave has the same base frequency, but with a trail of harmonics forming the sharp saw-tooth shape.

Extract the baseband from the signal

The instantaneous phase and amplitude of the base signal can be inferred only for the baseband, i.e. by removing higher and lower frequencies (i.e. extracting the base sine wave from the reference saw-tooth signal).

cut 0.1 ms from the beginning and from the end for better signal processing

Define signal processing functions

func find_peaks - finds peaks with optimal output array

func initial_phase_shift - mixer and ref_saw signals are in general a bit phase shifted from each other -> it calculates "initial" phase shift and removes it

func cut_edges - cut first and last data point, which is distorted from the spectral filter

func smooth - classic func for signal smoothing

func without_correction - a sum of basic operations

func find_nearest - finds the nearest peak of the given one

func calc_dphase_unchanged - calculates dphase from unrepaired data

func calc_lost_phase - calculates lost phase in the signal - to define how much the signal was damaged

func optimizing_cycle - defines the most probable parts of the data, where the signal was damaged and deletes the corresponding waveforms from the reference signal, because these waveforms did not travelled properly through the plasma

func repair - creates the most plausible repair of the given damaged interferometer data (probably caused by the scatter of the probing wave from the plasma, plasma instability, ...)

func calc_dphase - calculates dphase

func calc_curve_length - calculates the length of the dphase curve as a key parameter to decide, whether the repair is good enough

Final signal processing cycle

Estimation of the electron density

The ordinary wave (O-mode) with a carrier frequency $\omega$ traveling through a collisionless plasma with the plasma frequency $\omega_{p} = \sqrt{\frac{n_e e^2}{\epsilon_0 m_e}}$ has a refractive index $$N_O=\sqrt{1-\frac{\omega_p^2}{\omega^2}}$$ Under the assumption that the carrier wave frequency is much larger than the plasma frequency $\omega>>\omega_p$ this formula can be expanded into a Taylor series as $$N_O\approx 1-\frac{\omega_p^2}{2\omega^2}$$ A wave traveling through a medium with a refractive index $N(l)$ accumulates a total phase shift $\varphi = \frac{\omega}{c} \int N(l) \mathrm{d}l$. Therefore, in comparison to a wave traveling in vacuum (or clear air) with $N\approx 1$, the wave traveling through the plasma over a chord with length $L$ accumulates a relative phase shift of $$\Delta \varphi = \frac{e^2}{2\omega c\epsilon_0 m_e}\int\limits_L n_e(l) \mathrm{d}l$$ Therefore, it is possible to estimate the line-averaged density $\bar n_e = \frac{1}{L} \int\limits_L n_e(l) \mathrm{d}l$ from the detected phase shift between the reference and mixer signals.

ne_lav - final line-averaged electron density

ne_lav_zero - final line-averaged electron density without any correction

ne_lav_zero_raw - final line-averaged electron density without any correction and without any smoothing - used to see more clearly, where the data was damaged and repaired in the last figure

Comparison of the final line-averaged electron density between the damaged and repaired signal

Final figure of the temporal evolution of the line-averaged electron density

FOR TESTING (orange lines are repaired locations)

Save data

file ne_lav.csv - the final line-averaged electron density data file ne_lav_max.txt - max value of the line-averaged electron density file ne_lav_mean.txt - mean value of the line-averaged electron density