mascado.utility.plotting module

Provide some plotting functions useful for distortion solutions.

mascado.utility.plotting.make_grid_analysis(fig, positions, distortions, posscale, maxorder, minorder=0, name='distortions', poly=<class 'mascado.distortions.polynomials.Legendre'>, maxcondition=100.0)[source]

Run analysis of distortion pattern and display in four panels.

The four panels are:

  1. Arrow plot of distortion pattern itself.
  2. Arrow plot with marginalized distributions of residuals of fit at maxorder.
  3. RMS residuals over maximum order of polynomials. Maximum order from 1 to maxorder.
  4. RMS power in each degree of polynomial of fit at maxorder.

Since an affine transformation was applied to calculate the distortions, the zeroth and first order terms of the polynomial solution are incomplete and are plotted with gray data points.

Some information is printed to the console.

  • fig (matplotlib.figure.Figure) – Target figure.
  • positions ((N,2)-shaped array) – Position grid in normalized coordinates, i.e. [-1, 1].
  • distortions ((N,2)-shaped array) – Distortions in arcseconds.
  • posscale (float) – Scale of normalized positions to arcseconds.
  • maxorder (int) – Maximum order for fits.
  • name (str) – Name of distortions in plots (eg. "drift" for distortions difference).

vf – Fitted 2D vector field of maxorder.

Return type:


mascado.utility.plotting.make_psd_analysis(fig, vf, posscale, name='distortions')[source]

Run analysis of power spectrum of distortion pattern.

The figure is filled with four panels and one colorbar. The upper two panels contain the unbinned 2D power spectrum for the x- and y-components of the vector field with logarithmic colorbar.

The lower left panel shows the binned power spectra and the lower right panel the cumulative version of the lower left panel.

Units on the power are unituitive and not clear. At least to the present me.

  • fig (matplotlib.figure.Figure) – Target figure.
  • vf (mascado.distortions.polynomials.PolyVectorField) – Vector field to analyze.
  • posscale (float) – Scale to convert from normalized coordinates to arcseconds.
  • name (str) – Meta-name of data.
mascado.utility.plotting.plot_distortions(ax, positions, distortions, inliers=None, limits=(-1.1, 1.1), positionunits=(1, 'normalized'), positionunits2=None, arrowunits='arcsec', keylen=None, keypos=(0.5, 1.04), dotsize=2)[source]

Make arrow plot of distortions.

  • ax (matplotlib.Axes) – The target axes used for plotting.
  • positions ((N, 2)-shaped array) – The grid of positions in normalised coordinates.
  • distortions ((N, 2)-shaped array) – The distortions.
  • inliers ((N,)-shaped bool array or None) – Optional array that masks outliers. True for inliers.
  • limits (2-tuple) – Lower and upper limit for plot axes in normalised coordinates. Same in x and y direction.
  • positionunits (2-tuple of (float, str)) – Scale of normalised units to another unit and the other unit’s name. Use e.g. the plate scale and “arcsec”.
  • positionunits2 (2-tuple of (float, str)) – Like positionunits for a second scale, currently unsupported.
  • arrowunits (str) – The unit name for distortion data, e.g. “uas”.
  • keylen (float) – Length of key for arrows. If set to None the RMS value is used.
  • keypos (2-tuple of floats) – The position of the key in axes coordinates. If the keylen is not given and the x component of keypos inside the axes (0 to 1), a note about the RMS is appended to the key label.
  • dotsize (float) – Diameter of outlier dots in pt.
mascado.utility.plotting.plot_residuals(fig, positions, residuals, inliers=None, limits=(-1.1, 1.1), positionunits=(1, 'normalized'), arrowunits='arcsec', keylen=None, keypos=(1.2, 1.2), dotsize=1, **kwgridspec)[source]

Plot residual map with marginalized distributions.

You pass a figure and keyword arguments to matplotlib.GridSpec to define where all five subplots should go.

  • fig (matplotlib.Figure) – Target figure for plotting.
  • positions ((N, 2)-shaped array) – See plot_distortions() for doc.
  • residuals ((N, 2)-shaped array)
  • inliers ((N,)-shaped bool array)
  • limits (2-tuple of floats)
  • positionunits (2-tuple of (floats, str))
  • arrowunits (str)
  • keylen (float or None)
  • keypos (2-tuple of floats)
  • dotsize (float)
  • kwgridspec (keyword arguments) – Use keywords left, right, bottom, top, wspace, hspace to define the position of the subplots.


>>> plot_residuals(
...     fig, positions, residuals * 1e6,
...     positionunits=(posscale, "arcsec"),
...     arrowunits="uas",
...     left=0.52, right=0.9, bottom=0.52, top=0.9,
...     wspace=0.05, hspace=0.05)
mascado.utility.plotting.plot_spectrum(ax, spectrum, smin, smax, caption)[source]

Plot power spectrum as image with correct frequency scale.

  • ax (matplotlib.Axes) – Target axes for plotting
  • spectrum ((N, N)-shaped float array) – Power spectrum
  • smin, smax (float) – Minimum and maximum values for color map.
  • caption (str) – Plot title

matplotlib imshow result

Return type:


mascado.utility.plotting.set_fontsize(small=8, medium=10, bigger=12)[source]

Set font size of ticks, axes labels and titles.