Plots#

astrophot.plots.covariance_matrix(covariance_matrix, mean, labels=None, figsize=(10, 10), reference_values=None, ellipse_colors='tab:blue', showticks=True, **kwargs)[source]#

Create a covariance matrix plot. Creates a corner plot with ellipses representing the covariance between parameters.

Parameters:
  • covariance_matrix (np.ndarray) – Covariance matrix of shape (n_params, n_params).

  • mean (np.ndarray) – Mean values of the parameters, shape (n_params,).

  • labels (list, optional) – Labels for the parameters.

  • figsize (tuple, optional) – Size of the figure. Default is (10, 10).

  • reference_values (np.ndarray, optional) – Reference values for the parameters, used to draw vertical and horizontal lines. Typically these are the true values of the parameters.

  • ellipse_colors (str or list, optional) – Color for the ellipses. Default is main_pallet[“primary1”].

  • showticks (bool, optional) – Whether to show ticks on the axes. Default is True.

returns the fig and ax objects created to allow further customization by the user.

astrophot.plots.model_image(fig, ax, model, sample_image=None, window=None, target=None, showcbar: bool = True, target_mask: bool = False, cmap_levels: int | None = None, magunits: bool = True, vmin: float | None = None, vmax: float | None = None, **kwargs)[source]#

This function is used to generate a model image and display it using the provided figure and axes.

Parameters:
  • fig (matplotlib.figure.Figure) – The figure object in which the image will be displayed.

  • ax (matplotlib.axes.Axes) – The axes object on which the image will be plotted.

  • model (Model) – The model object used to generate a model image if sample_image is not provided.

  • sample_image (Image or Image_List, optional) – The image or list of images to be displayed. If None, a model image is generated using the provided model. Defaults to None.

  • window (Window, optional) – The window through which the image is viewed. If None, the window of the provided model is used. Defaults to None.

  • target (Target, optional) – The target or list of targets for the image or image list. If None, the target of the model is used. Defaults to None.

  • showcbar (bool, optional) – Whether to show the color bar. Defaults to True.

  • target_mask (bool, optional) – Whether to apply the mask of the target. If True and if the target has a mask, the mask is applied to the image. Defaults to False.

  • cmap_levels (int, optional) – The number of discrete levels to convert the continuous color map to. If not None, the color map is converted to a ListedColormap with the specified number of levels. Defaults to None.

  • magunits (bool, optional) – Whether to convert the image to surface brightness units. If True, the zeropoint of the target is used to convert the image to surface brightness units. Defaults to True.

  • vmin (float, optional) – The minimum value for the color scale. Defaults to None.

  • vmax (float, optional) – The maximum value for the color scale. Defaults to None.

  • kwargs – Arbitrary keyword arguments. These are used to override the default imshow_kwargs.

Note:

If the sample_image is an Image_List, this function will recursively call itself for each image in the list, with the corresponding target and window. The showcbar parameter and kwargs are passed unchanged to each recursive call.

astrophot.plots.model_window(fig, ax, model, target=None, rectangle_linewidth=2, **kwargs)[source]#

Used for plotting the window(s) of a model on a target image. These windows bound the region that a model will be evaluated/fit to.

Parameters:
  • fig (matplotlib.figure.Figure) – The figure object in which the model window will be displayed.

  • ax (matplotlib.axes.Axes) – The axes object on which the model window will be plotted.

  • model (Model) – The model object whose window will be displayed.

  • target (Target or Image_List, optional) – The target or list of targets for the image or image list. If None, the target of the model is used. Defaults to None.

  • rectangle_linewidth (int, optional) – The linewidth of the rectangle drawn around the model window. Defaults to 2.

  • kwargs – Arbitrary keyword arguments. These are used to override the default rectangle properties.

astrophot.plots.psf_image(fig, ax, psf: PSFImage | PSFModel | PSFGroupModel, cmap_levels: int | None = None, vmin: float | None = None, vmax: float | None = None, **kwargs)[source]#

For plotting PSF images, or the output of a PSF model.

Parameters:
  • fig (matplotlib.figure.Figure) – The figure object in which the PSF image will be displayed.

  • ax (matplotlib.axes.Axes) – The axes object on which the PSF image will be plotted.

  • psf (PSFImage or PSFModel or PSFGroupModel) – The PSF model or group model to be displayed.

  • cmap_levels (int, optional) – The number of discrete levels to convert the continuous color map to. If not None, the color map is converted to a ListedColormap with the specified number of levels. Defaults to None.

  • vmin (float, optional) – The minimum value for the color scale. Defaults to None.

  • vmax (float, optional) – The maximum value for the color scale. Defaults to None.

astrophot.plots.radial_light_profile(fig, ax, model: Model, rad_unit='arcsec', extend_profile=1.0, R0=0.0, resolution=1000, plot_kwargs={})[source]#

Used to plot the brightness profile as a function of radius for models which define a radial_model.

Parameters:
  • fig – matplotlib figure object

  • ax – matplotlib axis object

  • model (Model) – Model object from which to plot the radial profile.

  • rad_unit (str) – The name of the radius units to plot. If you select “pixel” then the plot will work in pixel units (physical radii divided by pixelscale) if you choose any other string then it will remain in the physical units of the image and the axis label will be whatever you set the value to. Default: “arcsec”. Options: “arcsec”, “pixel”

  • extend_profile (float) – The factor by which to extend the profile beyond the maximum radius of the model’s window. Default: 1.0

  • R0 (float) – The starting radius for the profile. Default: 0.0

  • resolution (int) – The number of points to use in the profile. Default: 1000

  • plot_kwargs (dict) – Additional keyword arguments to pass to the plot function, such as linewidth, color, etc.

astrophot.plots.radial_median_profile(fig, ax, model: Model, count_limit: int = 10, return_profile: bool = False, rad_unit: str = 'arcsec', plot_kwargs: dict = {})[source]#

Plot an SB profile by taking flux median at each radius.

Using the coordinate transforms defined by the model object, assigns a radius to each pixel then bins the pixel-radii and computes the median in each bin. This gives a simple representation of the image data if one were to simply average the pixels along isophotes.

Parameters:
  • fig – matplotlib figure object

  • ax – matplotlib axis object

  • model (AstroPhot_Model) – Model object from which to determine the radial binning. Also provides the target image to extract the data

  • count_limit (int) – The limit of pixels in a bin, below which uncertainties are not computed. Default: 10

  • return_profile (bool) – Instead of just returning the fig and ax object, will return the extracted profile formatted as: Rbins (the radial bin edges), medians (the median in each bin), scatter (the 16-84 quartile range / 2), count (the number of pixels in each bin). Default: False

  • rad_unit (str) – The name of the radius units to plot. If you select “pixel” then the plot will work in pixel units (physical radii divided by pixelscale) if you choose any other string then it will remain in the physical units of the image and the axis label will be whatever you set the value to. Default: “arcsec”. Options: “arcsec”, “pixel”

  • plot_kwargs (dict) – Additional keyword arguments to pass to the plot function, such as linewidth, color, etc.

astrophot.plots.ray_light_profile(fig, ax, model: Model, rad_unit='arcsec', extend_profile=1.0, resolution=1000)[source]#

Used for plotting ray (wedge) type models which define a iradial_model method. These have multiple radial profiles.

Parameters:
  • fig – matplotlib figure object

  • ax – matplotlib axis object

  • model (Model) – Model object from which to plot the radial profile.

  • rad_unit (str) – The name of the radius units to plot.

  • extend_profile (float) – The factor by which to extend the profile beyond the maximum radius of the model’s window. Default: 1.0

  • resolution (int) – The number of points to use in the profile. Default: 1000

astrophot.plots.residual_image(fig, ax, model, target=None, sample_image=None, showcbar=True, window=None, clb_label=None, normalize_residuals=False, scaling: Literal['arctan', 'clip', 'none'] = 'arctan', **kwargs)[source]#

This function is used to calculate and display the residuals of a model image with respect to a target image. The residuals are calculated as the difference between the target image and the sample image and may be normalized by the standard deviation.

Parameters:
  • fig (matplotlib.figure.Figure) – The figure object in which the residuals will be displayed.

  • ax (matplotlib.axes.Axes) – The axes object on which the residuals will be plotted.

  • model (Model) – The model object used to generate a model image if sample_image is not provided.

  • target (Target or Image_List, optional) – The target or list of targets for the image or image list. If None, the target of the model is used. Defaults to None.

  • sample_image (Image or Image_List, optional) – The image or list of images from which residuals will be calculated. If None, a model image is generated using the provided model. Defaults to None.

  • showcbar (bool, optional) – Whether to show the color bar. Defaults to True.

  • window (Window or Window_List, optional) – The window through which the image is viewed. If None, the window of the provided model is used. Defaults to None.

  • clb_label (str, optional) – The label for the colorbar. If None, a default label is used based on the normalization of the residuals. Defaults to None.

  • normalize_residuals (bool, optional) – Whether to normalize the residuals. If True, residuals are divided by the square root of the variance of the target. Defaults to False.

  • scaling (str, optional) – The scaling method for the residuals. Options are “arctan”, “clip”, or “none”. arctan will show all residuals, though squish high values to make the fainter residuals more visible, clip will show the residuals in linear space but remove any values above/below 5 sigma, none does no scaling and simply shows the residuals in linear space. Defaults to “arctan”.

  • kwargs – Arbitrary keyword arguments. These are used to override the default imshow_kwargs.

Note:

If the window, target, or sample_image are lists, this function will recursively call itself for each element in the list, with the corresponding window, target, and sample image. The showcbar, center_residuals, and kwargs are passed unchanged to each recursive call.

astrophot.plots.target_image(fig, ax, target, window=None, **kwargs)[source]#

This function is used to display a target image using the provided figure and axes. The target is plotted using histogram equalization for better visibility of the image data for the faint areas of the image, while it uses log scale normalization for the bright areas.

Parameters:
  • fig (matplotlib.figure.Figure) – The figure object in which the target image will be displayed.

  • ax (matplotlib.axes.Axes) – The axes object on which the target image will be plotted.

  • target (Image or Image_List) – The image or list of images to be displayed.

  • window (Window, optional) – The window through which the image is viewed. If None, the window of the provided target is used. Defaults to None.

  • kwargs – Arbitrary keyword arguments.

Note:

If the target is an Image_List, this function will recursively call itself for each image in the list. The window parameter and kwargs are passed unchanged to each recursive call.

astrophot.plots.warp_phase_profile(fig, ax, model: Model, rad_unit='arcsec')[source]#

Used to plot the phase profile of a warp model. This gives the axis ratio and position angle as a function of radius.