Plotting Utilities (dataval.plots)

Plotting utilities.

Code author: Rasmus Handberg <>

dataval.plots.plot_image(image, scale='log', origin='lower', xlabel='Pixel Column Number', ylabel='Pixel Row Number', make_cbar=False, clabel='Flux ($e^{-}s^{-1}$)', title=None, percentile=95.0, ax=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>, offset_axes=None, **kwargs)[source]

Utility function to plot a 2D image.

  • image (2d array) – Image data.
  • scale (str or astropy.visualization.ImageNormalize object, optional) – Normalization used to stretch the colormap. Options: 'linear', 'sqrt', or 'log'. Can also be a astropy.visualization.ImageNormalize object. Default is 'log'.
  • origin (str, optional) – The origin of the coordinate system.
  • xlabel (str, optional) – Label for the x-axis.
  • ylabel (str, optional) – Label for the y-axis.
  • make_cbar (boolean, optional) – Create colorbar? Default is False.
  • clabel (str, optional) – Label for the color bar.
  • title (str or None, optional) – Title for the plot.
  • percentile (float, optional) – The fraction of pixels to keep in color-trim. The same fraction of pixels is eliminated from both ends. Default=95.
  • ax (matplotlib.pyplot.axes, optional) – Axes in which to plot. Default (None) is to use current active axes.
  • cmap (matplotlib colormap, optional) – Colormap to use. Default is the Blues colormap.
  • kwargs (dict, optional) – Keyword arguments to be passed to matplotlib.pyplot.imshow.
dataval.plots.plot_image_fit_residuals(fig, image, fit, residuals)[source]

Make a figure with three subplots showing the image, the fit and the residuals. The image and the fit are shown with logarithmic scaling and a common colorbar. The residuals are shown with linear scaling and a separate colorbar.

  • fig (fig object) – Figure object in which to make the subplots.
  • image (2D array) – Image numpy array.
  • fit (2D array) – Fitted image numpy array.
  • residuals (2D array) – Fitted image subtracted from image numpy array.
  • positions (list of arrays) – List with the catalog and PSF fitted
  • positions. Format is (centroid) –
  • plot the positions. (not) –

List with Matplotlib subplot axes objects for each subplot.

Return type:

axes (list)

dataval.plots.save_figure(path, format='png', **kwargs)[source]

Write current figure to file. Creates directory to place it in if needed.

  • path (string) – Path where to save figure. If no file extension is provided, the extension of the format is automatically appended.
  • format (string) – Figure file type. Default is 'png'.
  • kwargs (dict, optional) – Keyword arguments to be passed to matplotlib.pyplot.savefig.