Implement Wigner Transform in `get_spectrogram`
The current implementation of get_spectrogram seems to return wrong results.
.
The white plots in the spectrogram show the projections of the spectrogram and should give the pulse spectrum and envelope.
For comparison the spectrum is calculated with
numpy.fft.fft() and the envelope with get_envelope. These plots definitely fit to the input data of the simulation. As you can see they don't really agree with the spectrogram.
I'm not yet sure what's causing this discrepancy, as this could either be an error in the algorithm or some other issue. One idea I had is that the frog method just doesn't work well with the given pulse. In that case one could try to use a different gating function. Or maybe you have some other idea what might be the cause of this.
I just wanted to warn you about this issue and will look further into this. You can assign this issue to me.
Hi Soeren,
I think that the problem is due to the fact that the mathematical operation that is implemented in get_spectrogram is not a Wigner transform:
- The Wigner transform does have the property that integrating along the
toromegaaxis retrieves the spectrum and the time envelope respectively. (See https://en.wikipedia.org/wiki/Wigner_distribution_function). But it can also be negative in some points, which makes it difficult to interpret. - On the other hand, the spectrogram transform that we use is basically a gated fourier transform, and it does not have the property that the integral retrieves the spectrum/envelope. But it is always positive, which is easier to interpret.
Does the above make sense? If needed/useful, we can also implement a get_wigner_transform method, which return the true Wigner transform.
Ok this somewhat makes sense to me. So for a correct Wigner transform one would need more information about the field than given by the simulation (i.e the complex field), right?
Actually I think the formula in https://en.wikipedia.org/wiki/Wigner_distribution_function was written for the case where x is intrinsically a complex number (e.g. a wavefunction in quantum mechanics). But I think that it applies equally well to the case where x is real (e.g. in our case, x would represent an electric field, which is intrinsically a real quantity - although it is often represented as the real part of a complex quantity). In the case of a real quantity, one would just ignore the * in the formula for the Wigner transform. For more clarity, I attach the formula which I think we should apply here:

Thanks for the explanation. This should be fairly easy to implement. For the sake of curiosity I will write a method. Then we can see how it performs and decide if we want to implement it.
Great! That sounds good! Depending on what you prefer, you could:
- Implement a separate method
get_wigner_transform - or simply add an optional
methodargument toget_spectrogram, for instancemethod='frog'for the current calculation andmethod='wigner'for the true wigner transform.