OptFROG – Analytic signal spectrograms with optimized timefrequency resolution
Abstract
A Python package for the calculation of spectrograms with optimized time and frequency resolution for application in the analysis of numerical simulations on ultrashort pulse propagation is presented. Gabor’s uncertainty principle prevents both resolutions from being optimal simultaneously for a given window function employed in the underlying shorttime Fourier analysis. Our aim is to yield a timefrequency representation of the input signal with marginals that represent the original intensities per unit time and frequency similarly well. As usecase we demonstrate the implemented functionality for the analysis of simulations on ultrashort pulse propagation in a nonlinear waveguide.
keywords:
Spectrogram, Shorttime Fourier analysis, Analytic signal, Optics, Ultrashort pulse propagation1 Motivation and significance
The spectrogram, providing a particular timefrequency representation of signals that vary in time Cohen:1989 (), represents an inevitable tool in the analysis of the characteristics of ultrashort optical pulses. E.g., allowing to monitor the change in frequency of pulse features as function of time permits to determine quantities that cannot be obtained from either the time or frequency domain representation of the optical pulse alone. The applicability of the spectrogram to both, data retrieved from experiments Trebino:1993 (); Linden:2000 (); Trebino:2000 (); Efimov:2005 () where it is referred to as frequency resolved optical gating (FROG) analysis, as well as from numerical simulations Dudley:2002 (); Skryabin:2005 (); Guo:2013 (), carried out to complement experiments and to provide a basis for the interpretation of the observed effects, highlights the relevance of signal processing in the field of nonlinear optics and demonstrates the need to be able to compute such spectrograms in the first place. Here, we consider the issue of obtaining optimal timefrequency representations of signals for the interpretation of numerical experiments on ultrashort pulse propagation in nonlinear waveguides.
In principle, a spectrogram measures the properties of the signal under scrutiny as well as those of a userspecified window function for localizing parts of the signal during analysis. Exhibiting features of both, the interpretation of the spectrogram is strongly affected by the particular function used for windowing. Different window functions estimate different signal properties, e.g., if a given function achieves a good approximation of the intensities per unit time of the underlying signal, its approximation of the intensities per unit frequency might be bad. Consequently, the spectrogram might suffer from distortion yielding an unreasonable characterization of the timefrequency features of the signal under scrutiny. The usual approach for deciding on a particular window function is by trialanderror and guided by the liking and experience of the individual.
Here we present a software tool that aims at minimizing the mismatch between the intensities per unit time and frequency and their corresponding estimates based on the spectrogram itself, obtained for a usersupplied parameterized window function. The resulting spectrograms are “optimal” in the sense that their visual inspection exhibits a minimal amount of distortion and thus allow for a reliable interpretation of the timefrequency composition of the input signal. Such an approach was previously shown to result in a reasonable characterization of the underlying timefrequency features Cohen:2003 (). It is further independent of the experience of the individual user and thus yields reproducible results.
2 Software description
The presented package facilitates the construction of spectrograms for the analytic signal (AS) Gabor:1947 () of the real field . In the Fourier domain, the angular frequency components of both are related via Marple:1999 (). Due to its onesided spectral definition the timedomain representation of the AS is complex, further satisfying . The construction of an AS spectrogram relies on the repeated calculation of the spectrum of the modified signal at different delay times in terms of the shorttime Fourier transform
(1) 
wherein specifies a narrow window function centered at and decaying to zero for increasing . The latter allows to selectively filter parts of the AS and to estimate its local frequency content. Scanning over a range of delay times then yields the spectrogram as , providing a joint timefrequency distribution of both, the AS and the window function WignerNote (). For assessing the approximation quality of we utilize its time and frequency marginals
(2)  
(3) 
Note that in the limit where approaches a delta function, the time marginal will approach the intensity per unit time but the frequency marginal will represent the intensity per unit frequency only poorly. As a result, time resolution will be good and frequency resolution will be bad, see the discussion in section 3 below. The timefrequency uncertainty principle prevents both resolutions from being optimal simultaneously Cohen:1989 ().
The aim of the presented package is to obtain a timefrequency representation of the input signal for which the integrated absolute error (IAE) between its normalized marginals and the original intensities per unit time and frequency are minimal. We consider a single parameter window function , e.g. a Gaussian function with mean and rootmeansquare (rms) width , and solve for
(4) 
Above, the underlying spectrogram is computed via , indicated by the superscript on the marginals, and we assume normalization to and a total signal energy in terms of the spectrogram. For a good agreement of the marginals and the original intensities, the objective function assumes a small value. The additional parameter might be adjusted to give more weight to frequency resolution () or time resolution () if appropriate. The particular choice yields a balanced timefrequency representation, see the example provided in section 3. The optimized spectrogram is then computed by using for windowing.
2.1 Software Architecture
OptFROG, following the naming convention PEP8 () for Python packages implemented as optfrog, uses the Python programming language Rossum:1995 () and depends on the functionality of numpy and scipy Scipy (). It further follows a procedural programming paradigm.
2.2 Software Functionalities
The current version of optfrog comprises five software units having the subsequent responsibilities:
 vanillaFrog

Compute a standard spectrogram for the normalized timedomain analytic signal for a particular window function .
 optFrog

Compute a timefrequency resolution optimized spectrogram for the normalized timedomain analytic signal using the window function that minimizes the total IAE of both marginals. Note: for the minimization of the scalar function in the variable , the scipy native function scipy.optimize.minimize_scalar is employed in bounded mode.
 timeMarginal

Compute the marginal distribution in time based on the spectrogram.
 frequencyMarginal

Compute the marginal distribution in frequency based on the spectrogram.
 totalEnergy

Compute the total energy provided by the spectrogram approximation of the timefrequency characteristics of the signal.
For a more detailed description of function parameters and return values we refer to the documentation provided within the code optfrog_GitHub:2018 ().
2.3 Sample code snippet
In our research work we use optfrog mainly in script mode. An exemplary data postprocessing script, reproducing Fig. 1(b) discussed in section 3 below, is shown in listing 1. Therein, after importing the functionality of numpy, optfrog, and a custom figure generating routine in lines 1–3, the location of the input data (line 5) and filter options for the spectrogram outputdata (lines 6p) are specified. Note that the user defined window function (lines 9p) does not need to be normalized. After loading the input data (lines 12p) the routine optFrog is used to compute an optimized spectrogram in line 15. Finally, a visual account of the latter is prepared by the routine spectrogramFigure in line 17.
3 Illustrative Examples
So as to demonstrate the functionality of optfrog we consider the numerical propagation of a short and intense fewcycle optical pulse in presence of the refractive index profile of an “endlessly single mode” () photonic crystal fiber Birks:1997 (); Stone:2007 (). The underlying unidirectional propagation model includes the Kerr effect and a delayed Raman response of HollenbeckCantrell type Hollenbeck:2002 (). For the preparation of the initial condition we considered a single soliton with duration , i.e. approximately cycles, and soliton order , prepared at a center frequency . See Refs. Amiranashvili:2010b (); Amiranashvili:2011 () for a detailed account of the propagation model and Ref. Melchert:2018 () for a more thorough discussion of the particular problem setup. In Fig. 1 we illustrate the timefrequency characteristics of the pulse at propagation distance by using a Gaussian window function centered at and having rmswidth . Note that the delay time has to be interpreted as being relative to the origin of a comoving frame of reference in which the soliton is initially at rest.
In Figs. 1(a,c) we demonstrate an inevitable drawback of a trialanderror choice of a window function used for calculating a spectrogram. As discussed earlier, the properties of the window implies a tradeoff in resolution that might be achieved. I.e., if the user opts for a window function that is either too wide or too narrow in comparison to the signal features in the time domain, only one marginal will approximate its underlying original intensity well and, as a result, the spectrogram will appear distorted. This is shown in Fig. 1(a), where a vanillaFrog trace using demonstrates a good frequency resolution and a bad time resolution. Conversely, as evident from Fig. 1(c), a vanillaFrog trace using yields a good time resolution and a bad frequency resolution. In contrast, if the IAEs of both marginals are minimized simultaneously by aid of a numerical algorithm, both marginals of the optimized spectrogram are found to approximate the original intensities per unit time and frequency similarly well. Consequently, the resulting spectrogram provides a most reasonable timefrequency representation of the underlying signal. To demonstrate this, the balanced () optFrog trace for the optimized window function, obtained for with , is shown in Fig. 1(b).
4 Impact
Computing reliable spectrograms represents an integral part in the analysis of the characteristics of ultrashort optical pulses. The publicly available and free Python package optfrog performs the nontrivial task of computing such spectrograms with optimized timefrequency resolution. It is based on a computational approach to parameter optimization in opposition to common trialanderror approaches, helping to save time and effort and yielding reproducible results independent of the skill of the individual user. It addresses researchers in the field of ultrashort pulse propagation and related disciplines where signal analysis in terms of shorttime Fourier transforms is of relevance. As independent software postprocessing tool it is ideally suited for the analysis of output data obtained by existing pulse propagation codes, as, e.g., the open source LaserFOAM (Python) Amorim:2009 () and gnlse (Matlab) Travers:2010 () solver for the generalized nonlinear Schrödinger equation.
5 Conclusions
The optfrog Python package provides easytouse tools that yield a timefrequency representation of a real valued input signal and allow to quantify how well the resulting spectrogram approximates the signal under scrutiny for a user supplied window function.
We have shown how optfrog can be used to calculate analytic signal based spectrograms that are optimal in the sense that their visual inspection exhibits a minimal amount of distortion, allowing for a reliable interpretation of the timefrequency composition of the input signal.
The optfrog software tool, including scripts that implement the exemplary usecases illustrated in section 3, is available for download and installation under Ref. optfrog_GitHub:2018 ().
Acknowledgements
We acknowledge support from the VolkswagenStiftung within the Niedersächsisches Vorab program (HYMNOS; Grant ZN 3061) and Deutsche Forschungsgemeinschaft (Grand MO 850/201).
References
References
 (1) L. Cohen. TimeFrequency Distributions – A Review. Procedings of the IEEE, 77:941–981, 1989.
 (2) D. J. Kane and R. Trebino. Characterization of Arbitrary Fremtosecond Pulses Using FrequencyResolved Optical Gating. IEEE J. Quantum Electron., 29:571, 1993.
 (3) S. Linden, J. Kuhl, and H. Giessen. FrequencyResolved Optical Gating: The Measurement of Ultrashort Laser Pulses, chapter XFROG—Crosscorrelation Frequencyresolved Optical Gating, pages 313–322. In Trebino Trebino:2000 (), 2000.
 (4) R. Trebino, editor. FrequencyResolved Optical Gating: The Measurement of Ultrashort Laser Pulses. Springer US, Boston, MA, 2000.
 (5) A. Efimov, A. V. Yulin, D. V. Skryabin, J. C. Knight, N. Joly, F. G. Omenetto, A. J. Taylor, and P. Russell. Interaction of an Optical Soliton with a Dispersive Wave. Phys. Rev. Lett., 95:213902, 2005.
 (6) J. M. Dudley, X. Gu, L. Xu, M. Kimmel, E. Zeek, P. O’Shea, R. Trebino, S. Coen, and R. S. Windeler. Crosscorrelation frequency resolved optical gating analysis of broadband continuum generation in photonic crystal fiber: simulations and experiments. Opt. Express, 10(21):1215–1221, 2002.
 (7) D. V. Skryabin and A. V. Yulin. Theory of generation of new frequencies by mixing of solitons and dispersive waves in optical fibers. Phys. Rev. E, 72:016619, 2005.
 (8) H. Guo, S. Wang, X. Zeng, and M. Bache. Understanding Soliton Spectral Tunneling as a Spectral Coupling Effect. IEEE Photonics Technology Letters, 25(19):1928, 2013.
 (9) L. Cohen and P. J. Loughlin. The marginals and timefrequency distributions. In Proc. SPIE 5205, Advanced Signal Processing Algorithms, Architectures, and Implementations XIII, page 59, 2003.
 (10) D. Gabor. Acoustical Quanta and the Theory of Hearing. Nature, 159:591 – 594, 1947.
 (11) S. L. Marple. Computing the discretetime ”analytic” signal via FFT. IEEE Trans. Signal Processing, 47:2600–2603, 1999.
 (12) Alternatively, the optical pulse might be expressed in terms of its Wigner distribution Cohen:1989 (), i.e. a quasiprobability distribution having the correct time and frequency marginals already. However, due to its similarity to the XFROGtraces retrieved from experiments in order to analyse optical pulses, our discussion here is focused on the spectrogram.
 (13) G. van Rossum, B. Warsaw, and N. Coghlan. PEP8 – Style Guide for Python Code. https://www.python.org/dev/peps/pep0008, 2001. [Online; accessed 20180627].
 (14) G. Rossum. Python Reference Manual. Technical report, Amsterdam, The Netherlands, The Netherlands, 1995.
 (15) E. Jones, T. Oliphant, P. Peterson, et al. SciPy: Open source scientific tools for Python. http://www.scipy.org/, 2001–2018. [Online; accessed 20180406].
 (16) O. Melchert. optfrog – Analytic signal spectrograms with optimized timefrequency resolution. https://github.com/omelchert/optfrog.git, 2018. [Online; accessed 20180620].
 (17) T. A. Birks, J. C. Knight, and P. St. J. Russell. Endlessly singlemode photonic crystal fiber. Opt. Lett., 13:961–963, 1997.
 (18) J. M. Stone and J. C. Knight. Visibly ’white’ light generation in uniform photonic crystal fiber using a microchip laser. Optics Express, 16:2670, 2007.
 (19) D. Hollenbeck and C. D. Cantrell. Multiplevibrationalmode model for fiberoptic Raman gain spectrum and response function. J. Opt. Soc. Am. B, 19:2886, 2002.
 (20) Sh. Amiranashvili and A. Demircan. Hamiltonian structure of propagation equations for ultrashort optical pulses. Phys. Rev. A, 82:013812, 2010.
 (21) Sh. Amiranashvili and A. Demircan. Ultrashort Optical Pulse Propagation in terms of Analytic Signal. Advances in Optical Technologies, 2011:989515, 2011.
 (22) O. Melchert, U. Morgner, B. Roth, I. Babushkin, and A. Demircan. Accurate propagation of ultrashort pulses in nonlinear waveguides using propagation models for the analytic signal. In Proc. SPIE 10694, Computational Optics II, page 106940M, 2018.
 (23) A. A. Amorim, M. V. Tognetti, P. Oliveira, J. L. Silva, L. M. Bernardo, F. X. Kärtner, and H. M. Crespo. Subtwocycle pulses by soliton selfcompression in highly nonlinear photonic crystal fibers. Opt. Lett., 34(24):3851–3853, 2009.
 (24) J. C. Travers, M. H. Frosz, and J. M. Dudley. Supercontinuum Generation in Optical Fibers, chapter Nonlinear fibre optics overview. Cambridge University Press, 2010.
Required Metadata
Current code version
Ancillary data table required for subversion of the codebase. Kindly replace examples in right column with the correct information about your current code, and leave the left column as it is.
Nr.  Code metadata description  Please fill in this column 

C1  Current code version  1.0.0 
C2  Permanent link to code/repository used for this code version  https://github.com/omelchert/optfrog.git 
C3  Legal Code License  MIT License 
C4  Code versioning system used  none 
C5  Software code languages, tools, and services used  Python, GitHub 
C6  Compilation requirements, operating environments & dependencies  The optfrog package requires Python, numpy and scipy. The installation process requires Pythons setuptool package and the provided usecases need Pythons matplotlib for figure generation. 
C7  If available Link to developer documentation/manual  Documentation provided within code 
C8  Support email for questions  oliver.melchert@hot.unihannover.de 