OptFROG - Analytic signal spectrograms with optimized time-frequency resolution
OOptFROG – Analytic signal spectrograms with optimized time-frequencyresolution
O. Melchert a , B. Roth a , U. Morgner b , A. Demircan a,b a Hannover Centre for Optical Technologies (HOT), 30167 Hannover, Germany b Institute of Quantum Optics (IQO), Leibniz Universit¨at Hannover, 30167 Hannover, Germany
Abstract
A Python package for the calculation of spectrograms with optimized time and frequency resolution for applicationin the analysis of numerical simulations on ultrashort pulse propagation is presented. Gabor’s uncertainty principleprevents both resolutions from being optimal simultaneously for a given window function employed in the underlyingshort-time Fourier analysis. Our aim is to yield a time-frequency representation of the input signal with marginalsthat represent the original intensities per unit time and frequency similarly well. As use-case we demonstrate theimplemented functionality for the analysis of simulations on ultrashort pulse propagation in a nonlinear waveguide.
Keywords:
Spectrogram, Short-time Fourier analysis, Analytic signal, Optics, Ultrashort pulse propagation
1. Motivation and significance
The spectrogram, providing a particular time-frequency representation of signals that vary in time[1], represents an inevitable tool in the analysis of thecharacteristics of ultrashort optical pulses. E.g., allowingto monitor the change in frequency of pulse featuresas function of time permits to determine quantities thatcannot be obtained from either the time or frequencydomain representation of the optical pulse alone. Theapplicability of the spectrogram to both, data retrievedfrom experiments [2, 3, 4, 5] where it is referred to asfrequency resolved optical gating (FROG) analysis, aswell as from numerical simulations [6, 7, 8], carried outto complement experiments and to provide a basis for theinterpretation of the observed e ff ects, highlights the rele-vance of signal processing in the field of nonlinear opticsand demonstrates the need to be able to compute suchspectrograms in the first place. Here, we consider the Email address: [email protected] (O.Melchert) issue of obtaining optimal time-frequency representationsof signals for the interpretation of numerical experimentson ultrashort pulse propagation in nonlinear waveguides.In principle, a spectrogram measures the propertiesof the signal under scrutiny as well as those of a user-specified window function for localizing parts of the sig-nal during analysis. Exhibiting features of both, the in-terpretation of the spectrogram is strongly a ff ected by theparticular function used for windowing. Di ff erent win-dow functions estimate di ff erent signal properties, e.g., ifa given function achieves a good approximation of the in-tensities per unit time of the underlying signal, its approx-imation of the intensities per unit frequency might be bad.Consequently, the spectrogram might su ff er from distor-tion yielding an unreasonable characterization of the time-frequency features of the signal under scrutiny. The usualapproach for deciding on a particular window function isby trial-and-error and guided by the liking and experienceof the individual.Here we present a software tool that aims at minimiz-ing the mismatch between the intensities per unit time andfrequency and their corresponding estimates based on thespectrogram itself, obtained for a user-supplied parame- Preprint submitted to SoftwareX September 5, 2018 a r X i v : . [ phy s i c s . c o m p - ph ] S e p erized window function. The resulting spectrograms are“optimal” in the sense that their visual inspection exhibitsa minimal amount of distortion and thus allow for a reli-able interpretation of the time-frequency composition ofthe input signal. Such an approach was previously shownto result in a reasonable characterization of the underly-ing time-frequency features [9]. It is further independentof the experience of the individual user and thus yieldsreproducible results.
2. Software description
The presented package facilitates the construction ofspectrograms for the analytic signal (AS) [10] E ( t ) ofthe real field E ( t ). In the Fourier domain, the angularfrequency components of both are related via ˆ E ( ω ) = [1 + sgn( ω )] ˆ E ( ω ) [11]. Due to its one-sided spectral def-inition the time-domain representation of the AS is com-plex, further satisfying E ( t ) = Re[ E ( t )]. The constructionof an AS spectrogram relies on the repeated calculation ofthe spectrum of the modified signal E ( t ) h ( t − τ ) at di ff erentdelay times τ in terms of the short-time Fourier transform S τ ( ω ) = √ π (cid:90) E ( t ) h ( t − τ ) exp {− i ω t } d t , (1)wherein h ( t ) specifies a narrow window function cen-tered at t = | t | .The latter allows to selectively filter parts of the AS andto estimate its local frequency content. Scanning overa range of delay times then yields the spectrogram as P S ( τ, ω ) = | S τ ( ω ) | , providing a joint time-frequency dis-tribution of both, the AS and the window function [12].For assessing the approximation quality of P S we utilizeits time and frequency marginals P ( τ ) = (cid:90) P S ( τ, ω ) d ω, and (2) P ( ω ) = (cid:90) P S ( τ, ω ) d τ. (3)Note that in the limit where h ( t ) approaches a delta func-tion, the time marginal will approach the intensity per unittime |E ( t ) | but the frequency marginal will represent theintensity per unit frequency | ˆ E ( ω ) | only poorly. As a re-sult, time resolution will be good and frequency resolutionwill be bad, see the discussion in section 3 below. The time-frequency uncertainty principle prevents both reso-lutions from being optimal simultaneously [1].The aim of the presented package is to obtain a time-frequency representation of the input signal for which theintegrated absolute error (IAE) between its normalizedmarginals and the original intensities per unit time andfrequency are minimal. We consider a single parameterwindow function h ( t , σ ), e.g. a Gaussian function withmean t and root-mean-square (rms) width σ , and solvefor σ (cid:63) = arg min σ Q ( σ, α ) ≡ (1 + α )IAE + (1 − α )IAE where IAE ≡ (cid:90) (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) |E ( τ ) | − P ( σ )1 ( τ ) E S (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) d τ, IAE ≡ (cid:90) (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) | ˆ E ( ω ) | − P ( σ )2 ( ω ) E S (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) d ω. (4)Above, the underlying spectrogram is computed via h ( t , σ ), indicated by the superscript σ on the marginals,and we assume normalization to (cid:82) |E ( t ) | d t = E S = (cid:82) (cid:82) P S ( τ, ω ) d τ d ω in terms ofthe spectrogram. For a good agreement of the marginalsand the original intensities, the objective function Q as-sumes a small value. The additional parameter α mightbe adjusted to give more weight to frequency resolution( α <
0) or time resolution ( α >
0) if appropriate. Theparticular choice α = h ( t ) ≡ h ( t , σ (cid:63) ) for windowing. OptFROG, following the naming convention [13] forPython packages implemented as optfrog , uses thePython programming language [14] and depends on thefunctionality of numpy and scipy [15]. It further followsa procedural programming paradigm.
The current version of optfrog comprises five soft-ware units having the subsequent responsibilities:2 anillaFrog
Compute a standard spectrogram P S ( τ, ω )for the normalized time-domain analytic signal fora particular window function h ( t , σ ). optFrog Compute a time-frequency resolution optimizedspectrogram for the normalized time-domain an-alytic signal using the window function h ( t , σ (cid:63) )that minimizes the total IAE of both marginals.Note: for the minimization of the scalar function Q ( σ, α ) in the variable σ , the scipy native function scipy.optimize.minimize scalar is employedin bounded mode. timeMarginal Compute the marginal distribution in time P based on the spectrogram. frequencyMarginal Compute the marginal distributionin frequency P based on the spectrogram. totalEnergy Compute the total energy E S providedby the spectrogram approximation of the time-frequency characteristics of the signal.For a more detailed description of function parametersand return values we refer to the documentation providedwithin the code [16]. In our research work we use optfrog mainly in scriptmode. An exemplary data postprocessing script, repro-ducing Fig. 1(b) discussed in section 3 below, is shownin listing 1. Therein, after importing the functionality of numpy , optfrog , and a custom figure generating routinein lines 1–3, the location of the input data (line 5) andfilter options for the spectrogram output-data (lines 6p)are specified. Note that the user defined window function(lines 9p) does not need to be normalized. After loadingthe input data (lines 12p) the routine optFrog is used tocompute an optimized spectrogram in line 15. Finally,a visual account of the latter is prepared by the routine spectrogramFigure in line 17. Listing 1: Exemplary Python script using optfrog for the calculationof a time-frequency resolution optimized spectrogram. import numpy as np from optfrog import optFrog from figure import spectrogramFigure fName = ’./ data/ exampleData_pulsePropagation .npz ’ A n g u l a r f r e q u e n c y ω ( r a d / f s ) P S (τ,ω) (a) -6 -4 -2 |E| P -4 -2 |ˆE| P -5 -3 -1 A n g u l a r f r e q u e n c y ω ( r a d / f s ) P S (τ,ω) (b) -6 -4 -2 |E| P -4 -2 |ˆE| P -5 -3 -1 A n g u l a r f r e q u e n c y ω ( r a d / f s ) P S (τ,ω) (c) -6 -4 -2 |E| P -4 -2 |ˆE| P -5 -3 -1 Figure 1: Analytic signal spectrograms allowing for the time-frequencycharacterization of a real optical field obtained from the numerical prop-agation of an ultrashort pulse in an
ESM photonic crystal fiber. (a) vanillaFrog -trace for a Gaussian window function with rms-width σ =
140 fs, (b) balanced optFrog -trace for σ (cid:63) = . vanillaFrog -trace for a Gaussian window function at σ =
10 fs. Pars = ( -500.0 , 5800.0 , 10) wPars = ( 0.75 , 3.25 , 3) d e f wFunc(s0): r e t u r n lambda x: np.exp(-x **2/2/ s0/s0) data = np.load(fName) t, Et = data[’t’], data[’Et’] res = optFrog (t,Et ,wFunc ,tLim=tPars ,wLim=wPars) spectrogramFigure ((t,Et),res)
3. Illustrative Examples
So as to demonstrate the functionality of optfrog weconsider the numerical propagation of a short and intensefew-cycle optical pulse in presence of the refractive in-dex profile of an “endlessly single mode” (
ESM ) photoniccrystal fiber [17, 18]. The underlying unidirectional prop-agation model includes the Kerr e ff ect and a delayed Ra-man response of Hollenbeck-Cantrell type [19]. For thepreparation of the initial condition we considered a sin-gle soliton with duration t = . N s =
8, prepared at a center fre-quency ω = . / fs. See Refs. [20, 21] for a detailedaccount of the propagation model and Ref. [22] for a morethorough discussion of the particular problem setup. InFig. 1 we illustrate the time-frequency characteristics ofthe pulse at propagation distance z = .
12 m by using aGaussian window function h ( t , σ ) centered at t = σ . Note that the delay time τ has to beinterpreted as being relative to the origin of a co-movingframe of reference in which the soliton is initially at rest.In Figs. 1(a,c) we demonstrate an inevitable drawbackof a trial-and-error choice of a window function used forcalculating a spectrogram. As discussed earlier, the prop-erties of the window implies a trade-o ff in resolution thatmight be achieved. I.e., if the user opts for a windowfunction that is either too wide or too narrow in compar-ison to the signal features in the time domain, only onemarginal will approximate its underlying original inten-sity well and, as a result, the spectrogram will appear dis-torted. This is shown in Fig. 1(a), where a vanillaFrog trace using σ =
140 fs demonstrates a good frequencyresolution and a bad time resolution. Conversely, as evi-dent from Fig. 1(c), a vanillaFrog trace using σ =
10 fsyields a good time resolution and a bad frequency res-olution. In contrast, if the IAEs of both marginals are minimized simultaneously by aid of a numerical algo-rithm, both marginals of the optimized spectrogram arefound to approximate the original intensities per unit timeand frequency similarly well. Consequently, the resultingspectrogram provides a most reasonable time-frequencyrepresentation of the underlying signal. To demonstratethis, the balanced ( α = optFrog trace for the opti-mized window function, obtained for σ (cid:63) = . Q = .
39, is shown in Fig. 1(b).
4. Impact
Computing reliable spectrograms represents an integralpart in the analysis of the characteristics of ultrashort op-tical pulses. The publicly available and free Python pack-age optfrog performs the nontrivial task of computingsuch spectrograms with optimized time-frequency resolu-tion. It is based on a computational approach to parame-ter optimization in opposition to common trial-and-errorapproaches, helping to save time and e ff ort and yieldingreproducible results independent of the skill of the indi-vidual user. It addresses researchers in the field of ul-trashort pulse propagation and related disciplines wheresignal analysis in terms of short-time Fourier transformsis of relevance. As independent software postprocessingtool it is ideally suited for the analysis of output data ob-tained by existing pulse propagation codes, as, e.g., theopen source LaserFOAM (Python) [23] and gnlse (Mat-lab) [24] solver for the generalized nonlinear Schr¨odingerequation.
5. Conclusions
The optfrog
Python package provides easy-to-usetools that yield a time-frequency representation of areal valued input signal and allow to quantify how wellthe resulting spectrogram approximates the signal underscrutiny for a user supplied window function.We have shown how optfrog can be used to calcu-late analytic signal based spectrograms that are optimal inthe sense that their visual inspection exhibits a minimalamount of distortion, allowing for a reliable interpretationof the time-frequency composition of the input signal.The optfrog software tool, including scripts that im-plement the exemplary use-cases illustrated in section 3,is available for download and installation under Ref. [16].4 cknowledgements
We acknowledge support from the VolkswagenStiftungwithin the Nieders¨achsisches Vorab program (HYMNOS;Grant ZN 3061) and Deutsche Forschungsgemeinschaft(Grand MO 850 / ReferencesReferences [1] L. Cohen. Time-Frequency Distributions – A Re-view.
Procedings of the IEEE , 77:941–981, 1989.[2] D. J. Kane and R. Trebino. Characterization ofArbitrary Fremtosecond Pulses Using Frequency-Resolved Optical Gating.
IEEE J. Quantum Elec-tron. , 29:571, 1993.[3] S. Linden, J. Kuhl, and H. Giessen.
Frequency-Resolved Optical Gating: The Measurementof Ultrashort Laser Pulses , chapter XFROG—Cross-correlation Frequency-resolved Optical Gat-ing, pages 313–322. In Trebino [4], 2000.[4] R. Trebino, editor.
Frequency-Resolved OpticalGating: The Measurement of Ultrashort LaserPulses . 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 DispersiveWave.
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.Cross-correlation frequency resolved optical gatinganalysis of broadband continuum generation in pho-tonic crystal fiber: simulations and experiments.
Opt. Express , 10(21):1215–1221, 2002.[7] D. V. Skryabin and A. V. Yulin. Theory of genera-tion of new frequencies by mixing of solitons anddispersive waves in optical fibers.
Phys. Rev. E ,72:016619, 2005.[8] H. Guo, S. Wang, X. Zeng, and M. Bache. Un-derstanding Soliton Spectral Tunneling as a SpectralCoupling E ff ect. IEEE Photonics Technology Let-ters , 25(19):1928, 2013. [9] L. Cohen and P. J. Loughlin. The marginals andtime-frequency distributions. In
Proc. SPIE 5205,Advanced Signal Processing Algorithms, Architec-tures, and Implementations XIII , page 59, 2003.[10] D. Gabor. Acoustical Quanta and the Theory ofHearing.
Nature , 159:591 – 594, 1947.[11] S. L. Marple. Computing the discrete-time ”ana-lytic” signal via FFT.
IEEE Trans. Signal Process-ing , 47:2600–2603, 1999.[12] Alternatively, the optical pulse might be expressedin terms of its Wigner distribution [1], i.e. a quasi-probability distribution having the correct time andfrequency marginals already. However, due to itssimilarity to the XFROG-traces retrieved from ex-periments in order to analyse optical pulses, our dis-cussion here is focused on the spectrogram.[13] G. van Rossum, B. Warsaw, and N. Cogh-lan. PEP8 – Style Guide for Python Code.https: // / dev / peps / pep-0008, 2001.[Online; accessed 2018-06-27].[14] G. Rossum. Python Reference Manual. Technicalreport, Amsterdam, The Netherlands, The Nether-lands, 1995.[15] E. Jones, T. Oliphant, P. Peterson, et al.SciPy: Open source scientific tools for Python.http: // / , 2001–2018. [Online;accessed 2018-04-06].[16] O. Melchert. optfrog – Analytic signal spec-trograms with optimized time-frequency reso-lution. https: // github.com / omelchert / optfrog.git,2018. [Online; accessed 2018-06-20].[17] T. A. Birks, J. C. Knight, and P. St. J. Russell. End-lessly single-mode photonic crystal fiber. Opt. Lett. ,13:961–963, 1997.[18] J. M. Stone and J. C. Knight. Visibly ’white’ lightgeneration in uniform photonic crystal fiber using amicrochip laser.
Optics Express , 16:2670, 2007.[19] D. Hollenbeck and C. D. Cantrell. Multiple-vibrational-mode model for fiber-optic Raman gain5pectrum and response function.
J. Opt. Soc. Am. B ,19:2886, 2002.[20] Sh. Amiranashvili and A. Demircan. Hamiltonianstructure of propagation equations for ultrashort op-tical pulses.
Phys. Rev. A , 82:013812, 2010.[21] Sh. Amiranashvili and A. Demircan. Ultrashort Op-tical Pulse Propagation in terms of Analytic Signal.
Advances in Optical Technologies , 2011:989515,2011.[22] O. Melchert, U. Morgner, B. Roth, I. Babushkin, andA. Demircan. Accurate propagation of ultrashortpulses in nonlinear waveguides using propagationmodels 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¨artner, and H. M.Crespo. Sub-two-cycle pulses by soliton self-compression in highly nonlinear photonic crystalfibers.
Opt. Lett. , 34(24):3851–3853, 2009.[24] J. C. Travers, M. H. Frosz, and J. M. Dudley.
Su-percontinuum Generation in Optical Fibers , chapterNonlinear fibre optics overview. Cambridge Univer-sity Press, 2010. 6 equired MetadataCurrent code version
Ancillary data table required for subversion of thecodebase. Kindly replace examples in right column withthe correct information about your current code, and leavethe left column as it is.
Nr. Code metadata description Please fill in this column