solprop.plotting.spectrograms#

Time-frequency maps of a saved plane, through a Gaussian-gated short-time transform.

Built on scipy.signal.ShortTimeFFT rather than on a hand-rolled Gabor transform. The gate width and the number of gate positions have defaults, taken from the time range asked for; and a multimode run must say which mode it means, rather than silently taking the first.

Module Attributes

DEFAULT_GATE_POSITIONS

How many gate positions a spectrogram uses when it is not told.

Functions

spectrogram(output[, z, axis, modes, ...])

Return the time-frequency map of one saved plane.

solprop.plotting.spectrograms.DEFAULT_GATE_POSITIONS = 256#

How many gate positions a spectrogram uses when it is not told.

solprop.plotting.spectrograms.spectrogram(output, z=None, axis='wavelength', *, modes=None, trange=(-5e-14, 5e-14), gate_fwhm=None, positions=256, wavelength_range=(1.5e-07, 2e-06), log=False, db_min=-40.0, cmap=None, ax=None, transfer=None)[source]#

Return the time-frequency map of one saved plane.

The real field is gated by a Gaussian of the given full width at half maximum and transformed at evenly spaced positions, which trades time resolution against frequency resolution in the usual way: a gate of duration tau resolves frequencies no better than 1/tau.

Parameters:
outputsolprop.output.schema.Output

An opened output handler.

zfloat or None

Position of the plane, m; the end of the run by default.

axis{‘wavelength’, ‘f’, ‘omega’}

Spectral abscissa of the ordinate.

modesint, sequence of int, ‘sum’ or None

Which mode to draw. A multimode run must name one: a spectrogram is of a field, and modal fields do not add away from a point in space.

trangetuple of float

Time range to gate over, s.

gate_fwhmfloat or None

Width of the gate, s; a twentieth of the time range by default.

positionsint

How many gate positions to place across the time range.

wavelength_rangetuple of float

Spectral limits, m.

logbool

Whether to show decibels below the peak rather than a linear scale.

db_minfloat

Bottom of a logarithmic colour scale, dB.

cmapstr, matplotlib.colors.Colormap or None

Colour map.

axmatplotlib.axes.Axes or None

Axis to draw into; a new figure is made when none is given.

transferTransferFunction or None

A linear optical element of solprop.optics applied to the field first, so that the map is of the pulse after a compressor.

Returns:
matplotlib.figure.Figure

The figure the map was drawn on.

Raises:
solprop.exceptions.ModeError

If a multimode run does not name a single mode.

Examples

>>> import matplotlib.pyplot as plt
>>> from solprop.plotting.spectrograms import spectrogram
>>> from solprop.processing._examples import example_output
>>> figure = spectrogram(example_output(), 0.0)
>>> figure.axes[0].get_xlabel()
'Time (fs)'
>>> plt.close(figure)