shamfi_plotting

shamfi_plotting.add_colourbar(fig=None, ax=None, im=None, label=False, top=False)[source]

Adds a colourbar (colorbar, fine) in a nice way to a subplot

Parameters:
  • fig (matplotlib.pyplot.figure instance) – The figure that the plot lives on
  • ax (matplotlib.pyplot.figure.add_subplot instance) – The axis to append a colorbar to
  • im (ax.imshow output) – The output of imshow to base the colourbar on
  • label (string) – Optional - add a label to the colorbar
  • top (Bool) – Optional - put the colorbar above the axis instead of to the right
shamfi_plotting.do_subplot(fig, ax, data, label, vmin, vmax)[source]

Plots a 2D numpy array (data) with a colorbar. Optionally can set vlim and vmin to control the colour scale

Parameters:
  • fig (matplotlib.pyplot.figure instance) – The figure that the plot lives on
  • ax (matplotlib.pyplot.figure.add_subplot instance) – The axis to plot on
  • data (2D numpy array) – The data to plot
  • label (string) – The title for the subplot
  • vmin (float) – Optional - lower value for the colour scale, passed to imshow
  • vmax (float) – Optional - upper value for the colour scale, passed to imshow
shamfi_plotting.make_masked_image(flat_data, shapelet_fitter)[source]

Create a 2D array for plotting purposes, where all the pixels that were originally masked in the fit are set to NaN so they don’t show during imshow

Parameters:
  • flat_data (array) – numpy array of data to mask
  • shapelet_fitter (shamfi.shapelets.FitShapelets instance) – The FitShapelets used to run the shapelet fitting
Returns:

masked_data – A 2D array in the original shape of the image to be fitted, with the cuts that were applied during fitted set to NaNs for plotting

Return type:

2D array

shamfi_plotting.plot_full_shamfi_fit(shapelet_fitter, save_tag, plot_edge_pad=False)[source]

Take a FitShapelets class that has been run, and plot the results. Plots the data with top left, fit top right, and residuals bottom left. Optionally, plot an edge padded version of the final fit bottom right - useful to check that unconstrained areas outside of the fitting region haven’t ended up with crazy modelled flux.

Parameters:
  • shapelet_fitter (shamfi.shapelets.FitShapelets instance) – The FitShapelets used to run the shapelet fitting
  • save_tag (string) – A tag to add into the file name to save the plot to
  • plot_edge_pad (bool) – If True, plot a version of the model using edge padded coords, to check for run away modelling outside the fitting area
shamfi_plotting.plot_gaussian_fit(shpcoord, save_tag)[source]

Plot a contour of an intial gaussian fit over an image, using the results of a ShapeletCoords

Parameters:
  • shpcoord (shamfi.shapelet_coords.ShapeletCoords instance) – The FitShapelets used to run the shapelet fitting
  • save_tag (string) – A tag to add into the file name to save the plot to

Plot a matrix of the image based residuals as a function of b1, b2

Parameters:
  • shapelet_fitter (shamfi.shapelets.FitShapelets instance) – The FitShapelets used to run the shapelet fitting
  • save_tag (string) – A tag to add into the file name to save the plot to