Plotting

Plotting functions for radar data.

impdar.lib.plot.plot(fns, tr=None, s=False, ftype='png', dpi=300, xd=False, yd=False, dualy=False, x_range=(0, -1), power=None, spectra=None, freq_limit=None, window=None, scaling='spectrum', filetype='mat', pick_colors=None, ft=False, hft=False, clims=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>, flatten_layer=None, *args, **kwargs)

Wrap a number of plot types.

This should really only be used by the exectuables. If you are plotting yourself, just use the individual plotting functions that are described below.

Parameters
  • fns (list of strs) – A list of filenames to plot individually.

  • tr (tuple or int, optional) – Plot traces tr[1] to tr[2] (or trace tr) rather than the radargram. Default is None (plot radargram).

  • power (int, optional) – If not None, then plot power returned from this layer

  • filetype (str, optional) – Type of input file. Default mat.

  • x_range (tuple, optional) – The range of traces to plot in the radargram. Default is (0, -1) (plot all traces)

  • flatten_layer (int, optional) – Distort the radargram so this layer is flat. Default is None (do not distort).

impdar.lib.plot.plot_ft(dat, fig=None, ax=None, **line_kwargs)

Plot the Fourier spectrum of the data in the vertical.

This will give the power spectral density in terms of the frequency (in MHz). We first fft, then average the fft.

Parameters
  • dat (impdar.lib.RadarData.Radardata) – The RadarData object to plot.

  • fig (matplotlib.pyplot.Figure) – Figure canvas that should be plotted upon

  • ax (matplotlib.pyplot.Axes) – Axes that should be plotted upon

  • **line_kwargs – Arguments passed to the plotting call (e.g. color, linewidth)

Returns

  • fig (matplotlib.pyplot.Figure) – Figure canvas that was plotted upon

  • ax (matplotlib.pyplot.Axes) – Axes that were plotted upon

impdar.lib.plot.plot_hft(dat, fig=None, ax=None)

Plot the Fourier spectrum of the data in the horizontal.

This will give the power spectral density as a function of the horizontal wavelength (in meters). We first fft, then average the fft

Parameters
  • dat (impdar.lib.RadarData.Radardata) – The RadarData object to plot.

  • fig (matplotlib.pyplot.Figure) – Figure canvas that should be plotted upon

  • ax (matplotlib.pyplot.Axes) – Axes that should be plotted upon

Returns

  • fig (matplotlib.pyplot.Figure) – Figure canvas that was plotted upon

  • ax (matplotlib.pyplot.Axes) – Axes that were plotted upon

impdar.lib.plot.plot_picks(rd, xd, yd, colors=None, flatten_layer=None, fig=None, ax=None, just_middle=False, picknums=None, x_range=None, **plotting_kwargs)

Update the plotting of the current pick.

Parameters
  • colors (str) – You have choices here. This can be a npicksx3 list, an npicks list of 3-letter strings, a 3 letter string, a single string, or a npicks list. Any of the x3 options are interpretted as top, middle, bottom colors. If it is a string, the lines are all plotted in this color. If it is a list, the different values are used for the different lines.

  • flatten_layer (int, optional) – Make this layer flat in the plot. Distorts all layers. Default is no distortion.

impdar.lib.plot.plot_power(dats, idx, fig=None, ax=None, clims=None)

Make a plot of the reflected power along a given pick.

Parameters
  • dat (impdar.lib.RadarData.Radardata) – The RadarData object to plot.

  • idx (int) – A picknum in the dat.picks.picknum array

  • fig (matplotlib.pyplot.Figure) – Figure canvas that should be plotted upon

  • ax (matplotlib.pyplot.Axes) – Axes that should be plotted upon

Returns

  • fig (matplotlib.pyplot.Figure) – Figure canvas that was plotted upon

  • ax (matplotlib.pyplot.Axes) – Axes that were plotted upon

impdar.lib.plot.plot_radargram(dat, xdat='tnum', ydat='twtt', x_range=(0, -1), y_range=(0, -1), cmap=<matplotlib.colors.LinearSegmentedColormap object>, fig=None, ax=None, return_plotinfo=False, pick_colors=None, clims=None, data_name='data', flatten_layer=None, middle_picks_only=False)

Plot a radio echogram.

This function is a little weird since I want to be able to plot on top of existing figures/axes or on new figures an axes. There is therefore an argument return_plotinfo that funnels between these options and changes the return types.

Parameters
  • dat (impdar.lib.RadarData.Radardata) – The RadarData object to plot.

  • xdat (str, optional) – The horizontal axis units. Either tnum or dist(ance).

  • ydat (str, optional) – The vertical axis units. Either twtt or or depth. Default twtt.

  • x_range (2-tuple, optional) – The range of values to plot, in tnum space. Default is plot everything (0, -1)

  • y_range (2-tuple, optional) – The range of values to plot, in snum space. Default is plot everything (0, -1)

  • cmap (matplotlib.pyplot.cm, optional) – The colormap to use

  • fig (matplotlib.pyplot.Figure) – Figure canvas that should be plotted upon

  • ax (matplotlib.pyplot.Axes) – Axes that should be plotted upon

  • data_name (str, optional) – The name of the data attribute. Default ‘data’. Must exist.

  • flatten_layer (int, optional) – Distort so this layer is flat

  • middle_picks_only (bool, optional) – Allows you to specify color triples for plotting picks and not have them misinterptreted.

Returns

  • If not return_plotinfo

    fig: matplotlib.pyplot.Figure

    Figure canvas that was plotted upon

    ax: matplotlib.pyplot.Axes

    Axes that were plotted upon

  • else

    im: pyplot.imshow

    The image object plotted

    xd: np.ndarray

    The x values of the plot

    yd: np.ndarray

    The y values of the plot

    x_range: 2-tuple

    The limits of the x range, after modification to remove negative indices

    clims: 2-tuple

    The limits of the colorbar

impdar.lib.plot.plot_spectrogram(dat, freq_limit=None, window=None, scaling='spectrum', fig=None, ax=None, **kwargs)

Make a plot of power spectral density across all traces of a radar profile.

Parameters
  • dat (impdar.lib.RadarData.Radardata) – The RadarData object to plot.

  • freq_limit (tuple) – The minimum and maximum frequency (in MHz) to limit the y-axis to

  • window (str, optional) –

    Type of window to be used for the signal.periodogram() method.

    Default hamming. Further information

  • scaling (str, optional) –

    Whether to plot power spectral density or power spectrum ‘density’ or ‘spectrum’, the default being ‘spectrum’. Further information

  • fig (matplotlib.pyplot.Figure, optional) – Figure canvas that should be plotted upon

  • ax (matplotlib.pyplot.Axes, optional) – Axes that should be plotted upon

Returns

  • fig (matplotlib.pyplot.Figure) – Figure canvas that was plotted upon

  • ax (matplotlib.pyplot.Axes) – Axes that were plotted upon

impdar.lib.plot.plot_traces(dat, tr, ydat='twtt', fig=None, ax=None, linewidth=1.0, linestyle='solid')

Plot power vs depth or twtt in a trace.

Parameters
  • dat (impdar.lib.RadarData.Radardata) – The RadarData object to plot.

  • tr (int or 2-tuple) – Either a single trace or a range of traces to plot

  • ydat (str, optional) – The vertical axis units. Either twtt or or depth. Default twtt.

  • fig (matplotlib.pyplot.Figure) – Figure canvas that should be plotted upon

  • ax (matplotlib.pyplot.Axes) – Axes that should be plotted upon

Returns

  • fig (matplotlib.pyplot.Figure) – Figure canvas that was plotted upon

  • ax (matplotlib.pyplot.Axes) – Axes that were plotted upon