AbstractSensitivityFit.__init__(self=self, tracer_normal=tracer_normal, tracer_sensitive=tracer_sensitive)<EOL>self.fit_normal = lens_fit.LensInversionFit(lens_data=lens_data, tracer=tracer_normal)<EOL>self.fit_sensitive = lens_fit.LensInversionFit(lens_data=lens_data, tracer=tracer_sensitive)<EOL>

Evaluate the sensitivity of an invesion fit to a specific component of a lens model and tracer. This is \
        performed by evaluating the likelihood of a fit to an image using two tracers:

        1) A 'normal tracer', which uses the same lens model as a the simulated lens data. This gives a baseline \
           value of the likelihood we can expect when we fit the model to itself.

        2) A 'sensitive tracer', which uses the same lens model as the simulated lens data, but also includes the \
           additional model components (e.g. a mass clump 'subhalo') which we are testing our sensitivity to.

        The difference in likelihood of these two fits informs us of how sensitive we are to the component in the \
        second tracer. For example, if the difference in likelihood is neglible, it means the model component had no \
        impact on our fit, meaning we are not sensitive to its properties.

        Parameters
        ----------
        lens_data: lens_data.LensData
            A simulated lens data which is used to determine our sensitiivity to specific model components.
        tracer_normal : ray_tracing.AbstractTracer
            A tracer whose galaxies have the same model components (e.g. light profiles, mass profiles) as the \
            lens data that we are fitting.
       tracer_sensitive : ray_tracing.AbstractTracerNonStack
            A tracer whose galaxies have the same model components (e.g. light profiles, mass profiles) as the \
            lens data that we are fitting, but also addition components (e.g. mass clumps) which we measure \
            how sensitive we are too.


@classmethod<EOL><INDENT>def for_data_and_tracer(cls, lens_data, tracer, padded_tracer=None):<DEDENT>

if tracer.has_light_profile and not tracer.has_pixelization:<EOL><INDENT>return LensProfileFit(lens_data=lens_data, tracer=tracer, padded_tracer=padded_tracer)<EOL><DEDENT>elif not tracer.has_light_profile and tracer.has_pixelization:<EOL><INDENT>return LensInversionFit(lens_data=lens_data, tracer=tracer, padded_tracer=None)<EOL><DEDENT>elif tracer.has_light_profile and tracer.has_pixelization:<EOL><INDENT>return LensProfileInversionFit(lens_data=lens_data, tracer=tracer, padded_tracer=None)<EOL><DEDENT>else:<EOL><INDENT>raise exc.FittingException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>

Fit lens data with a model tracer, automatically determining the type of fit based on the \
        properties of the galaxies in the tracer.

        Parameters
        -----------
        lens_data : lens_data.LensData or lens_data.LensDataHyper
            The lens-images that is fitted.
        tracer : ray_tracing.TracerNonStack
            The tracer, which describes the ray-tracing and strong lens configuration.
        padded_tracer : ray_tracing.Tracer or None
            A tracer with an identical strong lens configuration to the tracer above, but using the lens data's \
            padded grid_stack such that unmasked model-images can be computed.


def __init__(self, image, noise_map, mask, model_image, tracer, psf, map_to_scaled_array, padded_tracer=None):

<EOL>if padded_tracer is not None:<EOL><INDENT>original_noise_map = noise_map.copy()<EOL>unmasked_model_image = padded_tracer.image_plane.grid_stack.unmasked_blurred_image_from_psf_and_unmasked_image(psf=psf,<EOL>unmasked_image_1d=padded_tracer.<EOL>image_plane_image_1d)<EOL>for galaxy in tracer.galaxies:<EOL><INDENT>if galaxy.hyper_galaxy is not None:<EOL><INDENT>plane = padded_tracer.plane_with_galaxy(galaxy)<EOL>unmasked_galaxy_image = plane.unmasked_blurred_image_of_galaxy_with_grid_stack_psf(<EOL>galaxy,<EOL>padded_tracer.image_plane.grid_stack,<EOL>psf)<EOL>hyper_galaxy = galaxy.hyper_galaxy<EOL>hyper_noise = hyper_galaxy.hyper_noise_from_model_image_galaxy_image_and_noise_map(<EOL>unmasked_model_image,<EOL>unmasked_galaxy_image,<EOL>original_noise_map)<EOL>noise_map += hyper_noise<EOL><DEDENT><DEDENT><DEDENT>super().__init__(image=image, noise_map=noise_map, mask=mask, model_image=model_image)<EOL>self.tracer = tracer<EOL>self.padded_tracer = padded_tracer<EOL>self.psf = psf<EOL>self.map_to_scaled_array = map_to_scaled_array<EOL>

An  lens fitter, which contains the tracer's used to perform the fit and functions to manipulate \
        the lens data's hyper.

        Parameters
        -----------
        tracer : ray_tracing.Tracer
            The tracer, which describes the ray-tracing and strong lens configuration.
        padded_tracer : ray_tracing.TracerNonStack or None
            A tracer with an identical strong lens configuration to the tracer above, but using the lens data's \
            padded grid_stack such that unmasked model-images can be computed.
        map_to_scaled_array : func
            A function which maps the 1D lens hyper to its unmasked 2D array.


def __init__(self, lens_data, tracer, padded_tracer=None):

An  lens profile fitter, which generates the image-plane image of all galaxies (with light \
        profiles) in the tracer and blurs it with the lens data's PSF.

        If a padded tracer is supplied, the blurred profile image's can be generated over the entire image and thus \
        without the mask.

        Parameters
        -----------
        lens_data : lens_data.LensData
            The lens-image that is fitted.
        tracer : ray_tracing.TracerNonStack
            The tracer, which describes the ray-tracing and strong lens configuration.
        padded_tracer : ray_tracing.Tracer or None
            A tracer with an identical strong lens configuration to the tracer above, but using the lens data's \
            padded grid_stack such that unmasked model-images can be computed.


An  lens inversion fitter, which fits the lens data an inversion using the mapper(s) and \
        regularization(s) in the galaxies of the tracer.

        This inversion use's the lens-image, its PSF and an input noise-map.

        Parameters
        -----------
        lens_data : lens_data.LensData
            The lens-image that is fitted.
        tracer : ray_tracing.Tracer
            The tracer, which describes the ray-tracing and strong lens configuration.


blurred_profile_image_1d = util.blurred_image_1d_from_1d_unblurred_and_blurring_images(<EOL>unblurred_image_1d=tracer.image_plane_image_1d, blurring_image_1d=tracer.image_plane_blurring_image_1d,<EOL>convolver=lens_data.convolver_image)<EOL>blurred_profile_image = lens_data.map_to_scaled_array(array_1d=blurred_profile_image_1d)<EOL>profile_subtracted_image_1d = lens_data.image_1d - blurred_profile_image_1d<EOL>inversion = inversions.inversion_from_image_mapper_and_regularization(<EOL>image_1d=profile_subtracted_image_1d, noise_map_1d=lens_data.noise_map_1d,<EOL>convolver=lens_data.convolver_mapping_matrix, mapper=tracer.mappers_of_planes[-<NUM_LIT:1>],<EOL>regularization=tracer.regularizations_of_planes[-<NUM_LIT:1>])<EOL>model_image = blurred_profile_image + inversion.reconstructed_data<EOL>super(LensProfileInversionFit, self).__init__(tracer=tracer,<EOL>padded_tracer=padded_tracer,<EOL>lens_data=lens_data,<EOL>model_image=model_image,<EOL>inversion=inversion)<EOL>self.convolver_image = lens_data.convolver_image<EOL>self.blurred_profile_image = blurred_profile_image<EOL>self.profile_subtracted_image = lens_data.image - self.blurred_profile_image<EOL>

An  lens profile and inversion fitter, which first generates and subtracts the image-plane \
        image of all galaxies (with light profiles) in the tracer, blurs it with the PSF and fits the residual image \
        with an inversion using the mapper(s) and regularization(s) in the galaxy's of the tracer.

        This inversion use's the lens-image, its PSF and an input noise-map.

        If a padded tracer is supplied, the blurred profile image's can be generated over the entire image and thus \
        without the mask.

        Parameters
        -----------
        lens_data : lens_data.LensData
            The lens-image that is fitted.
        tracer : ray_tracing.Tracer
            The tracer, which describes the ray-tracing and strong lens configuration.
        padded_tracer : ray_tracing.TracerNonStack or None
            A tracer with an identical strong lens configuration to the tracer above, but using the lens data's \
            padded grid_stack such that unmasked model-images can be computed.


def __init__(self, positions, noise_map):

self.positions = positions<EOL>self.noise_map = noise_map<EOL>

A lens position fitter, which takes a set of positions (e.g. from a plane in the tracer) and computes \
        their maximum separation, such that points which tracer closer to one another have a higher likelihood.

        Parameters
        -----------
        positions : [[]]
            The (y,x) arc-second coordinates of positions which the maximum distance and likelihood is computed using.
        noise_map : ndarray | float
            The noise-value assumed when computing the likelihood.


if number_subplots <= <NUM_LIT:2>:<EOL><INDENT>return <NUM_LIT:1>, <NUM_LIT:2>, (<NUM_LIT>, <NUM_LIT:8>)<EOL><DEDENT>elif number_subplots <= <NUM_LIT:4>:<EOL><INDENT>return <NUM_LIT:2>, <NUM_LIT:2>, (<NUM_LIT>, <NUM_LIT:10>)<EOL><DEDENT>elif number_subplots <= <NUM_LIT:6>:<EOL><INDENT>return <NUM_LIT:2>, <NUM_LIT:3>, (<NUM_LIT>, <NUM_LIT:12>)<EOL><DEDENT>elif number_subplots <= <NUM_LIT:9>:<EOL><INDENT>return <NUM_LIT:3>, <NUM_LIT:3>, (<NUM_LIT>, <NUM_LIT:20>)<EOL><DEDENT>elif number_subplots <= <NUM_LIT:12>:<EOL><INDENT>return <NUM_LIT:3>, <NUM_LIT:4>, (<NUM_LIT>, <NUM_LIT:20>)<EOL><DEDENT>elif number_subplots <= <NUM_LIT:16>:<EOL><INDENT>return <NUM_LIT:4>, <NUM_LIT:4>, (<NUM_LIT>, <NUM_LIT:20>)<EOL><DEDENT>elif number_subplots <= <NUM_LIT:20>:<EOL><INDENT>return <NUM_LIT:4>, <NUM_LIT:5>, (<NUM_LIT>, <NUM_LIT:20>)<EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:6>, <NUM_LIT:6>, (<NUM_LIT>, <NUM_LIT:20>)<EOL><DEDENT>

Get the size of a sub plot in (rows, columns), based on the number of subplots that are going to be plotted.

    Parameters
    -----------
    number_subplots : int
        The number of subplots that are to be plotted in the figure.


if not as_subplot:<EOL><INDENT>fig = plt.figure(figsize=figsize)<EOL>return fig<EOL><DEDENT>

Setup a figure for plotting an image.

    Parameters
    -----------
    figsize : (int, int)
        The size of the figure in (rows, columns).
    as_subplot : bool
        If the figure is a subplot, the setup_figure function is omitted to ensure that each subplot does not create a \
        new figure and so that it can be output using the *output_subplot_array* function.


plt.title(title, fontsize=titlesize)<EOL>

Set the title and title size of the figure.

    Parameters
    -----------
    title : str
        The text of the title.
    titlesize : int
        The size of of the title of the figure.


def output_figure(array, as_subplot, output_path, output_filename, output_format):

if not as_subplot:<EOL><INDENT>if output_format is '<STR_LIT>':<EOL><INDENT>plt.show()<EOL><DEDENT>elif output_format is '<STR_LIT>':<EOL><INDENT>plt.savefig(output_path + output_filename + '<STR_LIT>', bbox_inches='<STR_LIT>')<EOL><DEDENT>elif output_format is '<STR_LIT>':<EOL><INDENT>array_util.numpy_array_2d_to_fits(array_2d=array, file_path=output_path + output_filename + '<STR_LIT>',<EOL>overwrite=True)<EOL><DEDENT><DEDENT>

Output the figure, either as an image on the screen or to the hard-disk as a .png or .fits file.

    Parameters
    -----------
    array : ndarray
        The 2D array of image to be output, required for outputting the image as a fits file.
    as_subplot : bool
        Whether the figure is part of subplot, in which case the figure is not output so that the entire subplot can \
        be output instead using the *output_subplot_array* function.
    output_path : str
        The path on the hard-disk where the figure is output.
    output_filename : str
        The filename of the figure that is output.
    output_format : str
        The format the figue is output:
        'show' - display on computer screen.
        'png' - output to hard-disk as a png.
        'fits' - output to hard-disk as a fits file.'


def output_subplot_array(output_path, output_filename, output_format):

if output_format is '<STR_LIT>':<EOL><INDENT>plt.show()<EOL><DEDENT>elif output_format is '<STR_LIT>':<EOL><INDENT>plt.savefig(output_path + output_filename + '<STR_LIT>', bbox_inches='<STR_LIT>')<EOL><DEDENT>elif output_format is '<STR_LIT>':<EOL><INDENT>raise exc.PlottingException('<STR_LIT>')<EOL><DEDENT>

Output a figure which consists of a set of subplot,, either as an image on the screen or to the hard-disk as a \
    .png file.

    Parameters
    -----------
    output_path : str
        The path on the hard-disk where the figure is output.
    output_filename : str
        The filename of the figure that is output.
    output_format : str
        The format the figue is output:
        'show' - display on computer screen.
        'png' - output to hard-disk as a png.


if not as_subplot:<EOL><INDENT>plt.close()<EOL><DEDENT>

After plotting and outputting a figure, close the matplotlib figure instance (omit if a subplot).

    Parameters
    -----------
    as_subplot : bool
        Whether the figure is part of subplot, in which case the figure is not closed so that the entire figure can \
        be closed later after output.


def plot_array(array, origin=None, mask=None, extract_array_from_mask=False, zoom_around_mask=False,<EOL>should_plot_border=False, positions=None, centres=None, axis_ratios=None, phis=None, grid=None,<EOL>as_subplot=False,<EOL>units='<STR_LIT>', kpc_per_arcsec=None, figsize=(<NUM_LIT:7>, <NUM_LIT:7>), aspect='<STR_LIT>',<EOL>cmap='<STR_LIT>', norm='<STR_LIT>', norm_min=None, norm_max=None, linthresh=<NUM_LIT>, linscale=<NUM_LIT>,<EOL>cb_ticksize=<NUM_LIT:10>, cb_fraction=<NUM_LIT>, cb_pad=<NUM_LIT>, cb_tick_values=None, cb_tick_labels=None,<EOL>title='<STR_LIT>', titlesize=<NUM_LIT:16>, xlabelsize=<NUM_LIT:16>, ylabelsize=<NUM_LIT:16>, xyticksize=<NUM_LIT:16>,<EOL>mask_pointsize=<NUM_LIT:10>, border_pointsize=<NUM_LIT:2>, position_pointsize=<NUM_LIT:30>, grid_pointsize=<NUM_LIT:1>,<EOL>xticks_manual=None, yticks_manual=None,<EOL>output_path=None, output_format='<STR_LIT>', output_filename='<STR_LIT>'):

if array is None:<EOL><INDENT>return<EOL><DEDENT>if extract_array_from_mask and mask is not None:<EOL><INDENT>array = np.add(array, <NUM_LIT:0.0>, out=np.zeros_like(array), where=np.asarray(mask) == <NUM_LIT:0>)<EOL><DEDENT>if zoom_around_mask and mask is not None:<EOL><INDENT>array = array.zoomed_scaled_array_around_mask(mask=mask, buffer=<NUM_LIT:2>)<EOL>zoom_offset_pixels = np.asarray(mask.zoom_offset_pixels)<EOL>zoom_offset_arcsec = np.asarray(mask.zoom_offset_arcsec)<EOL><DEDENT>else:<EOL><INDENT>zoom_offset_pixels = None<EOL>zoom_offset_arcsec = None<EOL><DEDENT>if aspect is '<STR_LIT>':<EOL><INDENT>aspect = float(array.shape_arcsec[<NUM_LIT:1>]) / float(array.shape_arcsec[<NUM_LIT:0>])<EOL><DEDENT>fig = plot_figure(array=array, as_subplot=as_subplot, units=units, kpc_per_arcsec=kpc_per_arcsec,<EOL>figsize=figsize, aspect=aspect, cmap=cmap, norm=norm,<EOL>norm_min=norm_min, norm_max=norm_max, linthresh=linthresh, linscale=linscale,<EOL>xticks_manual=xticks_manual, yticks_manual=yticks_manual)<EOL>plotter_util.set_title(title=title, titlesize=titlesize)<EOL>set_xy_labels_and_ticksize(units=units, kpc_per_arcsec=kpc_per_arcsec, xlabelsize=xlabelsize, ylabelsize=ylabelsize,<EOL>xyticksize=xyticksize)<EOL>set_colorbar(cb_ticksize=cb_ticksize, cb_fraction=cb_fraction, cb_pad=cb_pad,<EOL>cb_tick_values=cb_tick_values, cb_tick_labels=cb_tick_labels)<EOL>plot_origin(array=array, origin=origin, units=units, kpc_per_arcsec=kpc_per_arcsec,<EOL>zoom_offset_arcsec=zoom_offset_arcsec)<EOL>plot_mask(mask=mask, units=units, kpc_per_arcsec=kpc_per_arcsec, pointsize=mask_pointsize,<EOL>zoom_offset_pixels=zoom_offset_pixels)<EOL>plot_border(mask=mask, should_plot_border=should_plot_border, units=units, kpc_per_arcsec=kpc_per_arcsec,<EOL>pointsize=border_pointsize, zoom_offset_pixels=zoom_offset_pixels)<EOL>plot_points(points_arcsec=positions, array=array, units=units, kpc_per_arcsec=kpc_per_arcsec,<EOL>pointsize=position_pointsize, zoom_offset_arcsec=zoom_offset_arcsec)<EOL>plot_grid(grid_arcsec=grid, array=array, units=units, kpc_per_arcsec=kpc_per_arcsec, pointsize=grid_pointsize,<EOL>zoom_offset_arcsec=zoom_offset_arcsec)<EOL>plot_centres(array=array, centres=centres, units=units, kpc_per_arcsec=kpc_per_arcsec,<EOL>zoom_offset_arcsec=zoom_offset_arcsec)<EOL>plot_ellipses(fig=fig, array=array, centres=centres, axis_ratios=axis_ratios, phis=phis, units=units,<EOL>kpc_per_arcsec=kpc_per_arcsec, zoom_offset_arcsec=zoom_offset_arcsec)<EOL>plotter_util.output_figure(array, as_subplot=as_subplot, output_path=output_path, output_filename=output_filename,<EOL>output_format=output_format)<EOL>plotter_util.close_figure(as_subplot=as_subplot)<EOL>

Plot an array of data as a figure.

    Parameters
    -----------
    array : data.array.scaled_array.ScaledArray
        The 2D array of data which is plotted.
    origin : (float, float).
        The origin of the coordinate system of the array, which is plotted as an 'x' on the image if input.
    mask : data.array.mask.Mask
        The mask applied to the array, the edge of which is plotted as a set of points over the plotted array.
    extract_array_from_mask : bool
        The plotter array is extracted using the mask, such that masked values are plotted as zeros. This ensures \
        bright features outside the mask do not impact the color map of the plot.
    zoom_around_mask : bool
        If True, the 2D region of the array corresponding to the rectangle encompassing all unmasked values is \
        plotted, thereby zooming into the region of interest.
    should_plot_border : bool
        If a mask is supplied, its borders pixels (e.g. the exterior edge) is plotted if this is *True*.
    positions : [[]]
        Lists of (y,x) coordinates on the image which are plotted as colored dots, to highlight specific pixels.
    grid : data.array.grids.RegularGrid
        A grid of (y,x) coordinates which may be plotted over the plotted array.
    as_subplot : bool
        Whether the array is plotted as part of a subplot, in which case the grid figure is not opened / closed.
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float or None
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
    figsize : (int, int)
        The size of the figure in (rows, columns).
    aspect : str
        The aspect ratio of the array, specifically whether it is forced to be square ('equal') or adapts its size to \
        the figure size ('auto').
    cmap : str
        The colormap the array is plotted using, which may be chosen from the standard matplotlib colormaps.
    norm : str
        The normalization of the colormap used to plot the image, specifically whether it is linear ('linear'), log \
        ('log') or a symmetric log normalization ('symmetric_log').
    norm_min : float or None
        The minimum array value the colormap map spans (all values below this value are plotted the same color).
    norm_max : float or None
        The maximum array value the colormap map spans (all values above this value are plotted the same color).
    linthresh : float
        For the 'symmetric_log' colormap normalization ,this specifies the range of values within which the colormap \
        is linear.
    linscale : float
        For the 'symmetric_log' colormap normalization, this allowws the linear range set by linthresh to be stretched \
        relative to the logarithmic range.
    cb_ticksize : int
        The size of the tick labels on the colorbar.
    cb_fraction : float
        The fraction of the figure that the colorbar takes up, which resizes the colorbar relative to the figure.
    cb_pad : float
        Pads the color bar in the figure, which resizes the colorbar relative to the figure.
    xlabelsize : int
        The fontsize of the x axes label.
    ylabelsize : int
        The fontsize of the y axes label.
    xyticksize : int
        The font size of the x and y ticks on the figure axes.
    mask_pointsize : int
        The size of the points plotted to show the mask.
    border_pointsize : int
        The size of the points plotted to show the borders.
    positions_pointsize : int
        The size of the points plotted to show the input positions.
    grid_pointsize : int
        The size of the points plotted to show the grid.
    xticks_manual :  [] or None
        If input, the xticks do not use the array's default xticks but instead overwrite them as these values.
    yticks_manual :  [] or None
        If input, the yticks do not use the array's default yticks but instead overwrite them as these values.
    output_path : str
        The path on the hard-disk where the figure is output.
    output_filename : str
        The filename of the figure that is output.
    output_format : str
        The format the figue is output:
        'show' - display on computer screen.
        'png' - output to hard-disk as a png.
        'fits' - output to hard-disk as a fits file.'

    Returns
    --------
    None

    Examples
    --------
        array_plotters.plot_array(
        array=image, origin=(0.0, 0.0), mask=circular_mask, extract_array_from_mask=True, zoom_around_mask=True,
        should_plot_border=False, positions=[[1.0, 1.0], [2.0, 2.0]], grid=None, as_subplot=False,
        units='arcsec', kpc_per_arcsec=None, figsize=(7,7), aspect='auto',
        cmap='jet', norm='linear, norm_min=None, norm_max=None, linthresh=None, linscale=None,
        cb_ticksize=10, cb_fraction=0.047, cb_pad=0.01, cb_tick_values=None, cb_tick_labels=None,
        title='Image', titlesize=16, xlabelsize=16, ylabelsize=16, xyticksize=16,
        mask_pointsize=10, border_pointsize=2, position_pointsize=10, grid_pointsize=10,
        xticks_manual=None, yticks_manual=None,
        output_path='/path/to/output', output_format='png', output_filename='image')


def plot_figure(array, as_subplot, units, kpc_per_arcsec, figsize, aspect, cmap, norm, norm_min, norm_max,<EOL>linthresh, linscale, xticks_manual, yticks_manual):

fig = plotter_util.setup_figure(figsize=figsize, as_subplot=as_subplot)<EOL>norm_min, norm_max = get_normalization_min_max(array=array, norm_min=norm_min, norm_max=norm_max)<EOL>norm_scale = get_normalization_scale(norm=norm, norm_min=norm_min, norm_max=norm_max,<EOL>linthresh=linthresh, linscale=linscale)<EOL>extent = get_extent(array=array, units=units, kpc_per_arcsec=kpc_per_arcsec,<EOL>xticks_manual=xticks_manual, yticks_manual=yticks_manual)<EOL>plt.imshow(array, aspect=aspect, cmap=cmap, norm=norm_scale, extent=extent)<EOL>return fig<EOL>

Open a matplotlib figure and plot the array of data on it.

    Parameters
    -----------
    array : data.array.scaled_array.ScaledArray
        The 2D array of data which is plotted.
    as_subplot : bool
        Whether the array is plotted as part of a subplot, in which case the grid figure is not opened / closed.
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float or None
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
    figsize : (int, int)
        The size of the figure in (rows, columns).
    aspect : str
        The aspect ratio of the array, specifically whether it is forced to be square ('equal') or adapts its size to \
        the figure size ('auto').
    cmap : str
        The colormap the array is plotted using, which may be chosen from the standard matplotlib colormaps.
    norm : str
        The normalization of the colormap used to plot the image, specifically whether it is linear ('linear'), log \
        ('log') or a symmetric log normalization ('symmetric_log').
    norm_min : float or None
        The minimum array value the colormap map spans (all values below this value are plotted the same color).
    norm_max : float or None
        The maximum array value the colormap map spans (all values above this value are plotted the same color).
    linthresh : float
        For the 'symmetric_log' colormap normalization ,this specifies the range of values within which the colormap \
        is linear.
    linscale : float
        For the 'symmetric_log' colormap normalization, this allowws the linear range set by linthresh to be stretched \
        relative to the logarithmic range.
    xticks_manual :  [] or None
        If input, the xticks do not use the array's default xticks but instead overwrite them as these values.
    yticks_manual :  [] or None
        If input, the yticks do not use the array's default yticks but instead overwrite them as these values.


def get_extent(array, units, kpc_per_arcsec, xticks_manual, yticks_manual):

if xticks_manual is not None and yticks_manual is not None:<EOL><INDENT>return np.asarray([xticks_manual[<NUM_LIT:0>], xticks_manual[<NUM_LIT:3>], yticks_manual[<NUM_LIT:0>], yticks_manual[<NUM_LIT:3>]])<EOL><DEDENT>if units in '<STR_LIT>':<EOL><INDENT>return np.asarray([<NUM_LIT:0>, array.shape[<NUM_LIT:1>], <NUM_LIT:0>, array.shape[<NUM_LIT:0>]])<EOL><DEDENT>elif units in '<STR_LIT>' or kpc_per_arcsec is None:<EOL><INDENT>return np.asarray([array.arc_second_minima[<NUM_LIT:1>], array.arc_second_maxima[<NUM_LIT:1>],<EOL>array.arc_second_minima[<NUM_LIT:0>], array.arc_second_maxima[<NUM_LIT:0>]])<EOL><DEDENT>elif units in '<STR_LIT>':<EOL><INDENT>return list(map(lambda tick : tick*kpc_per_arcsec,<EOL>np.asarray([array.arc_second_minima[<NUM_LIT:1>], array.arc_second_maxima[<NUM_LIT:1>],<EOL>array.arc_second_minima[<NUM_LIT:0>], array.arc_second_maxima[<NUM_LIT:0>]])))<EOL><DEDENT>else:<EOL><INDENT>raise exc.PlottingException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>

Get the extent of the dimensions of the array in the units of the figure (e.g. arc-seconds or kpc).

    This is used to set the extent of the array and thus the y / x axis limits.

    Parameters
    -----------
    array : data.array.scaled_array.ScaledArray
        The 2D array of data which is plotted.
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
    xticks_manual :  [] or None
        If input, the xticks do not use the array's default xticks but instead overwrite them as these values.
    yticks_manual :  [] or None
        If input, the yticks do not use the array's default yticks but instead overwrite them as these values.


def get_normalization_min_max(array, norm_min, norm_max):

if norm_min is None:<EOL><INDENT>norm_min = array.min()<EOL><DEDENT>if norm_max is None:<EOL><INDENT>norm_max = array.max()<EOL><DEDENT>return norm_min, norm_max<EOL>

Get the minimum and maximum of the normalization of the array, which sets the lower and upper limits of the \
    colormap.

    If norm_min / norm_max are not supplied, the minimum / maximum values of the array of data are used.

    Parameters
    -----------
    array : data.array.scaled_array.ScaledArray
        The 2D array of data which is plotted.
    norm_min : float or None
        The minimum array value the colormap map spans (all values below this value are plotted the same color).
    norm_max : float or None
        The maximum array value the colormap map spans (all values above this value are plotted the same color).


def get_normalization_scale(norm, norm_min, norm_max, linthresh, linscale):

if norm is '<STR_LIT>':<EOL><INDENT>return colors.Normalize(vmin=norm_min, vmax=norm_max)<EOL><DEDENT>elif norm is '<STR_LIT>':<EOL><INDENT>if norm_min == <NUM_LIT:0.0>:<EOL><INDENT>norm_min = <NUM_LIT><EOL><DEDENT>return colors.LogNorm(vmin=norm_min, vmax=norm_max)<EOL><DEDENT>elif norm is '<STR_LIT>':<EOL><INDENT>return colors.SymLogNorm(linthresh=linthresh, linscale=linscale, vmin=norm_min, vmax=norm_max)<EOL><DEDENT>else:<EOL><INDENT>raise exc.PlottingException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>

Get the normalization scale of the colormap. This will be scaled based on the input min / max normalization \
    values.

    For a 'symmetric_log' colormap, linthesh and linscale also change the colormap.

    If norm_min / norm_max are not supplied, the minimum / maximum values of the array of data are used.

    Parameters
    -----------
    array : data.array.scaled_array.ScaledArray
        The 2D array of data which is plotted.
    norm_min : float or None
        The minimum array value the colormap map spans (all values below this value are plotted the same color).
    norm_max : float or None
        The maximum array value the colormap map spans (all values above this value are plotted the same color).
    linthresh : float
        For the 'symmetric_log' colormap normalization ,this specifies the range of values within which the colormap \
        is linear.
    linscale : float
        For the 'symmetric_log' colormap normalization, this allowws the linear range set by linthresh to be stretched \
        relative to the logarithmic range.


def set_xy_labels_and_ticksize(units, kpc_per_arcsec, xlabelsize, ylabelsize, xyticksize):

if units in '<STR_LIT>':<EOL><INDENT>plt.xlabel('<STR_LIT>', fontsize=xlabelsize)<EOL>plt.ylabel('<STR_LIT>', fontsize=ylabelsize)<EOL><DEDENT>elif units in '<STR_LIT>' or kpc_per_arcsec is None:<EOL><INDENT>plt.xlabel('<STR_LIT>', fontsize=xlabelsize)<EOL>plt.ylabel('<STR_LIT>', fontsize=ylabelsize)<EOL><DEDENT>elif units in '<STR_LIT>':<EOL><INDENT>plt.xlabel('<STR_LIT>', fontsize=xlabelsize)<EOL>plt.ylabel('<STR_LIT>', fontsize=ylabelsize)<EOL><DEDENT>else:<EOL><INDENT>raise exc.PlottingException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>plt.tick_params(labelsize=xyticksize)<EOL>

Set the x and y labels of the figure, and set the fontsize of those labels.

    The x and y labels are always the distance scales, thus the labels are either arc-seconds or kpc and depend on the \
    units the figure is plotted in.

    Parameters
    -----------
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
    xlabelsize : int
        The fontsize of the x axes label.
    ylabelsize : int
        The fontsize of the y axes label.
    xyticksize : int
        The font size of the x and y ticks on the figure axes.


def set_colorbar(cb_ticksize, cb_fraction, cb_pad, cb_tick_values, cb_tick_labels):

if cb_tick_values is None and cb_tick_labels is None:<EOL><INDENT>cb = plt.colorbar(fraction=cb_fraction, pad=cb_pad)<EOL><DEDENT>elif cb_tick_values is not None and cb_tick_labels is not None:<EOL><INDENT>cb = plt.colorbar(fraction=cb_fraction, pad=cb_pad, ticks=cb_tick_values)<EOL>cb.ax.set_yticklabels(cb_tick_labels)<EOL><DEDENT>else:<EOL><INDENT>raise exc.PlottingException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>cb.ax.tick_params(labelsize=cb_ticksize)<EOL>

Setup the colorbar of the figure, specifically its ticksize and the size is appears relative to the figure.

    Parameters
    -----------
    cb_ticksize : int
        The size of the tick labels on the colorbar.
    cb_fraction : float
        The fraction of the figure that the colorbar takes up, which resizes the colorbar relative to the figure.
    cb_pad : float
        Pads the color bar in the figure, which resizes the colorbar relative to the figure.
    cb_tick_values : [float]
        Manually specified values of where the colorbar tick labels appear on the colorbar.
    cb_tick_labels : [float]
        Manually specified labels of the color bar tick labels, which appear where specified by cb_tick_values.


def convert_grid_units(array, grid_arcsec, units, kpc_per_arcsec):

if units in '<STR_LIT>':<EOL><INDENT>return array.grid_arcsec_to_grid_pixels(grid_arcsec=grid_arcsec)<EOL><DEDENT>elif units in '<STR_LIT>' or kpc_per_arcsec is None:<EOL><INDENT>return grid_arcsec<EOL><DEDENT>elif units in '<STR_LIT>':<EOL><INDENT>return grid_arcsec * kpc_per_arcsec<EOL><DEDENT>else:<EOL><INDENT>raise exc.PlottingException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>

Convert the grid from its input units (arc-seconds) to the input unit (e.g. retain arc-seconds) or convert to \
    another set of units (pixels or kilo parsecs).

    Parameters
    -----------
    array : data.array.scaled_array.ScaledArray
        The 2D array of data which is plotted, the shape of which is used for converting the grid to units of pixels.
    grid_arcsec : ndarray or data.array.grids.RegularGrid
        The (y,x) coordinates of the grid in arc-seconds, in an array of shape (total_coordinates, 2).
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.


def plot_origin(array, origin, units, kpc_per_arcsec, zoom_offset_arcsec):

if origin is not None:<EOL><INDENT>origin_grid = np.asarray(origin)<EOL>if zoom_offset_arcsec is not None:<EOL><INDENT>origin_grid -= zoom_offset_arcsec<EOL><DEDENT>origin_units = convert_grid_units(array=array, grid_arcsec=origin_grid, units=units,<EOL>kpc_per_arcsec=kpc_per_arcsec)<EOL>plt.scatter(y=origin_units[<NUM_LIT:0>], x=origin_units[<NUM_LIT:1>], s=<NUM_LIT>, c='<STR_LIT:k>', marker='<STR_LIT:x>')<EOL><DEDENT>

Plot the (y,x) origin ofo the array's coordinates as a 'x'.

    Parameters
    -----------
    array : data.array.scaled_array.ScaledArray
        The 2D array of data which is plotted.
    origin : (float, float).
        The origin of the coordinate system of the array, which is plotted as an 'x' on the image if input.
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float or None
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.


def plot_centres(array, centres, units, kpc_per_arcsec, zoom_offset_arcsec):

if centres is not None:<EOL><INDENT>colors = itertools.cycle(["<STR_LIT:m>", "<STR_LIT:y>", "<STR_LIT:r>", "<STR_LIT:w>", "<STR_LIT:c>", "<STR_LIT:b>", "<STR_LIT:g>", "<STR_LIT:k>"])<EOL>for centres_of_galaxy in centres:<EOL><INDENT>color = next(colors)<EOL>for centre in centres_of_galaxy:<EOL><INDENT>if zoom_offset_arcsec is not None:<EOL><INDENT>centre -= zoom_offset_arcsec<EOL><DEDENT>centre_units = convert_grid_units(array=array, grid_arcsec=centre, units=units,<EOL>kpc_per_arcsec=kpc_per_arcsec)<EOL>plt.scatter(y=centre_units[<NUM_LIT:0>], x=centre_units[<NUM_LIT:1>], s=<NUM_LIT>, c=color, marker='<STR_LIT:x>')<EOL><DEDENT><DEDENT><DEDENT>

Plot the (y,x) centres (e.g. of a mass profile) on the array as an 'x'.

    Parameters
    -----------
    array : data.array.scaled_array.ScaledArray
        The 2D array of data which is plotted.
    centres : [[tuple]]
        The list of centres; centres in the same list entry are colored the same.
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float or None
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.


def plot_ellipses(fig, array, centres, axis_ratios, phis, units, kpc_per_arcsec, zoom_offset_arcsec):

if centres is not None and axis_ratios is not None and phis is not None:<EOL><INDENT>colors = itertools.cycle(["<STR_LIT:m>", "<STR_LIT:y>", "<STR_LIT:r>", "<STR_LIT:w>", "<STR_LIT:c>", "<STR_LIT:b>", "<STR_LIT:g>", "<STR_LIT:k>"])<EOL>for set_index in range(len(centres)):<EOL><INDENT>color = next(colors)<EOL>for geometry_index in range(len(centres[set_index])):<EOL><INDENT>centre = centres[set_index][geometry_index]<EOL>axis_ratio = axis_ratios[set_index][geometry_index]<EOL>phi = phis[set_index][geometry_index]<EOL>if zoom_offset_arcsec is not None:<EOL><INDENT>centre -= zoom_offset_arcsec<EOL><DEDENT>centre_units = convert_grid_units(array=array, grid_arcsec=centre, units=units,<EOL>kpc_per_arcsec=kpc_per_arcsec)<EOL>y = <NUM_LIT:1.0><EOL>x = <NUM_LIT:1.0>*axis_ratio<EOL>t = np.linspace(<NUM_LIT:0>, <NUM_LIT:2>*np.pi, <NUM_LIT:100>)<EOL>plt.plot(centre_units[<NUM_LIT:0>] + y*np.cos(t), centre_units[<NUM_LIT:1>] + x*np.sin(t), color=color)<EOL><DEDENT><DEDENT><DEDENT>


def plot_mask(mask, units, kpc_per_arcsec, pointsize, zoom_offset_pixels):

if mask is not None:<EOL><INDENT>plt.gca()<EOL>edge_pixels = mask.masked_grid_index_to_pixel[mask.edge_pixels] + <NUM_LIT:0.5><EOL>if zoom_offset_pixels is not None:<EOL><INDENT>edge_pixels -= zoom_offset_pixels<EOL><DEDENT>edge_arcsec = mask.grid_pixels_to_grid_arcsec(grid_pixels=edge_pixels)<EOL>edge_units = convert_grid_units(array=mask, grid_arcsec=edge_arcsec, units=units,<EOL>kpc_per_arcsec=kpc_per_arcsec)<EOL>plt.scatter(y=edge_units[:,<NUM_LIT:0>], x=edge_units[:,<NUM_LIT:1>], s=pointsize, c='<STR_LIT:k>')<EOL><DEDENT>

Plot the mask of the array on the figure.

    Parameters
    -----------
    mask : ndarray of data.array.mask.Mask
        The mask applied to the array, the edge of which is plotted as a set of points over the plotted array.
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float or None
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
    pointsize : int
        The size of the points plotted to show the mask.


def plot_border(mask, should_plot_border, units, kpc_per_arcsec, pointsize, zoom_offset_pixels):

if should_plot_border and mask is not None:<EOL><INDENT>plt.gca()<EOL>border_pixels = mask.masked_grid_index_to_pixel[mask.border_pixels]<EOL>if zoom_offset_pixels is not None:<EOL><INDENT>border_pixels -= zoom_offset_pixels<EOL><DEDENT>border_arcsec = mask.grid_pixels_to_grid_arcsec(grid_pixels=border_pixels)<EOL>border_units = convert_grid_units(array=mask, grid_arcsec=border_arcsec, units=units,<EOL>kpc_per_arcsec=kpc_per_arcsec)<EOL>plt.scatter(y=border_units[:,<NUM_LIT:0>], x=border_units[:,<NUM_LIT:1>], s=pointsize, c='<STR_LIT:y>')<EOL><DEDENT>

Plot the borders of the mask or the array on the figure.

    Parameters
    -----------t.
    mask : ndarray of data.array.mask.Mask
        The mask applied to the array, the edge of which is plotted as a set of points over the plotted array.
    should_plot_border : bool
        If a mask is supplied, its borders pixels (e.g. the exterior edge) is plotted if this is *True*.
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float or None
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
    border_pointsize : int
        The size of the points plotted to show the borders.


def plot_points(points_arcsec, array, units, kpc_per_arcsec, pointsize, zoom_offset_arcsec):

if points_arcsec is not None:<EOL><INDENT>points_arcsec = list(map(lambda position_set: np.asarray(position_set), points_arcsec))<EOL>point_colors = itertools.cycle(["<STR_LIT:m>", "<STR_LIT:y>", "<STR_LIT:r>", "<STR_LIT:w>", "<STR_LIT:c>", "<STR_LIT:b>", "<STR_LIT:g>", "<STR_LIT:k>"])<EOL>for point_set_arcsec in points_arcsec:<EOL><INDENT>if zoom_offset_arcsec is not None:<EOL><INDENT>point_set_arcsec -= zoom_offset_arcsec<EOL><DEDENT>point_set_units = convert_grid_units(array=array, grid_arcsec=point_set_arcsec, units=units,<EOL>kpc_per_arcsec=kpc_per_arcsec)<EOL>plt.scatter(y=point_set_units[:,<NUM_LIT:0>], x=point_set_units[:,<NUM_LIT:1>], color=next(point_colors), s=pointsize)<EOL><DEDENT><DEDENT>

Plot a set of points over the array of data on the figure.

    Parameters
    -----------
    positions : [[]]
        Lists of (y,x) coordinates on the image which are plotted as colored dots, to highlight specific pixels.
    array : data.array.scaled_array.ScaledArray
        The 2D array of data which is plotted.
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float or None
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
    pointsize : int
        The size of the points plotted to show the input positions.


def plot_grid(grid_arcsec, array, units, kpc_per_arcsec, pointsize, zoom_offset_arcsec):

if grid_arcsec is not None:<EOL><INDENT>if zoom_offset_arcsec is not None:<EOL><INDENT>grid_arcsec -= zoom_offset_arcsec<EOL><DEDENT>grid_units = convert_grid_units(grid_arcsec=grid_arcsec, array=array, units=units,<EOL>kpc_per_arcsec=kpc_per_arcsec)<EOL>plt.scatter(y=np.asarray(grid_units[:, <NUM_LIT:0>]), x=np.asarray(grid_units[:, <NUM_LIT:1>]), s=pointsize, c='<STR_LIT:k>')<EOL><DEDENT>

Plot a grid of points over the array of data on the figure.

     Parameters
     -----------.
     grid_arcsec : ndarray or data.array.grids.RegularGrid
         A grid of (y,x) coordinates in arc-seconds which may be plotted over the array.
     array : data.array.scaled_array.ScaledArray
        The 2D array of data which is plotted.
     units : str
         The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
     kpc_per_arcsec : float or None
         The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
     grid_pointsize : int
         The size of the points plotted to show the grid.


def set_xy_labels_and_ticksize(units, kpc_per_arcsec, ylabel, xlabelsize, ylabelsize, xyticksize):

plt.ylabel(ylabel=ylabel, fontsize=ylabelsize)<EOL>if units in '<STR_LIT>' or kpc_per_arcsec is None:<EOL><INDENT>plt.xlabel('<STR_LIT>', fontsize=xlabelsize)<EOL><DEDENT>elif units in '<STR_LIT>':<EOL><INDENT>plt.xlabel('<STR_LIT>', fontsize=xlabelsize)<EOL><DEDENT>else:<EOL><INDENT>raise exc.PlottingException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>plt.tick_params(labelsize=xyticksize)<EOL>

Set the x and y labels of the figure, and set the fontsize of those labels.

    The x label is always the distance scale / radius, thus the x-label is either arc-seconds or kpc and depending \
    on the units the figure is plotted in.

    The ylabel is the physical quantity being plotted and is passed as an input parameter.

    Parameters
    -----------
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
    ylabel : str
        The y-label of the figure, which is the physical quantitiy being plotted.
    xlabelsize : int
        The fontsize of the x axes label.
    ylabelsize : int
        The fontsize of the y axes label.
    xyticksize : int
        The font size of the x and y ticks on the figure axes.


def plot_grid(grid, axis_limits=None, points=None, as_subplot=False,<EOL>units='<STR_LIT>', kpc_per_arcsec=None,<EOL>figsize=(<NUM_LIT:12>, <NUM_LIT:8>), pointsize=<NUM_LIT:5>, pointcolor='<STR_LIT:k>', xyticksize=<NUM_LIT:16>,<EOL>title='<STR_LIT>', titlesize=<NUM_LIT:16>, xlabelsize=<NUM_LIT:16>, ylabelsize=<NUM_LIT:16>,<EOL>output_path=None, output_format='<STR_LIT>', output_filename='<STR_LIT>'):

plotter_util.setup_figure(figsize=figsize, as_subplot=as_subplot)<EOL>grid = convert_grid_units(grid_arcsec=grid, units=units, kpc_per_arcsec=kpc_per_arcsec)<EOL>plt.scatter(y=np.asarray(grid[:, <NUM_LIT:0>]), x=np.asarray(grid[:, <NUM_LIT:1>]), s=pointsize, marker='<STR_LIT:.>')<EOL>plotter_util.set_title(title=title, titlesize=titlesize)<EOL>set_xy_labels(units, kpc_per_arcsec, xlabelsize, ylabelsize, xyticksize)<EOL>set_axis_limits(axis_limits)<EOL>plot_points(grid, points, pointcolor)<EOL>plt.tick_params(labelsize=xyticksize)<EOL>plotter_util.output_figure(None, as_subplot, output_path, output_filename, output_format)<EOL>plotter_util.close_figure(as_subplot=as_subplot)<EOL>

Plot a grid of (y,x) Cartesian coordinates as a scatter plot of points.

    Parameters
    -----------
    grid : data.array.grids.RegularGrid
        The (y,x) coordinates of the grid, in an array of shape (total_coordinates, 2).
    axis_limits : []
        The axis limits of the figure on which the grid is plotted, following [xmin, xmax, ymin, ymax].
    points : []
        A set of points that are plotted in a different colour for emphasis (e.g. to show the mappings between \
        different planes).
    as_subplot : bool
        Whether the grid is plotted as part of a subplot, in which case the grid figure is not opened / closed.
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
    figsize : (int, int)
        The size of the figure in (rows, columns).
    pointsize : int
        The size of the points plotted on the grid.
    xyticksize : int
        The font size of the x and y ticks on the figure axes.
    title : str
        The text of the title.
    titlesize : int
        The size of of the title of the figure.
    xlabelsize : int
        The fontsize of the x axes label.
    ylabelsize : int
        The fontsize of the y axes label.
    output_path : str
        The path on the hard-disk where the figure is output.
    output_filename : str
        The filename of the figure that is output.
    output_format : str
        The format the figue is output:
        'show' - display on computer screen.
        'png' - output to hard-disk as a png.


def convert_grid_units(grid_arcsec, units, kpc_per_arcsec):

if units in '<STR_LIT>' or kpc_per_arcsec is None:<EOL><INDENT>return grid_arcsec<EOL><DEDENT>elif units in '<STR_LIT>':<EOL><INDENT>return grid_arcsec * kpc_per_arcsec<EOL><DEDENT>

Convert the grid from its input units (arc-seconds) to the input unit (e.g. retain arc-seconds) or convert to \
    another set of units (kiloparsecs).

    Parameters
    -----------
    grid_arcsec : ndarray or data.array.grids.RegularGrid
        The (y,x) coordinates of the grid in arc-seconds, in an array of shape (total_coordinates, 2).
    units : str
        The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
    kpc_per_arcsec : float
        The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.


def set_xy_labels(units, kpc_per_arcsec, xlabelsize, ylabelsize, xyticksize):

if units in '<STR_LIT>' or kpc_per_arcsec is None:<EOL><INDENT>plt.xlabel('<STR_LIT>', fontsize=xlabelsize)<EOL>plt.ylabel('<STR_LIT>', fontsize=ylabelsize)<EOL><DEDENT>elif units in '<STR_LIT>':<EOL><INDENT>plt.xlabel('<STR_LIT>', fontsize=xlabelsize)<EOL>plt.ylabel('<STR_LIT>', fontsize=ylabelsize)<EOL><DEDENT>else:<EOL><INDENT>raise exc.PlottingException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>plt.tick_params(labelsize=xyticksize)<EOL>


if axis_limits is not None:<EOL><INDENT>plt.axis(axis_limits)<EOL><DEDENT>

Set the axis limits of the figure the grid is plotted on.

    Parameters
    -----------
    axis_limits : []
        The axis limits of the figure on which the grid is plotted, following [xmin, xmax, ymin, ymax].


def plot_points(grid, points, pointcolor):

if points is not None:<EOL><INDENT>if pointcolor is None:<EOL><INDENT>point_colors = itertools.cycle(["<STR_LIT:y>", "<STR_LIT:r>", "<STR_LIT:k>", "<STR_LIT:g>", "<STR_LIT:m>"])<EOL>for point_set in points:<EOL><INDENT>plt.scatter(y=np.asarray(grid[point_set, <NUM_LIT:0>]),<EOL>x=np.asarray(grid[point_set, <NUM_LIT:1>]), s=<NUM_LIT:8>, color=next(point_colors))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for point_set in points:<EOL><INDENT>plt.scatter(y=np.asarray(grid[point_set, <NUM_LIT:0>]),<EOL>x=np.asarray(grid[point_set, <NUM_LIT:1>]), s=<NUM_LIT:8>, color=pointcolor)<EOL><DEDENT><DEDENT><DEDENT>

Plot a subset of points in a different color, to highlight a specifc region of the grid (e.g. how certain \
    pixels map between different planes).

    Parameters
    -----------
    grid : ndarray or data.array.grids.RegularGrid
        The (y,x) coordinates of the grid, in an array of shape (total_coordinates, 2).
    points : []
        A set of points that are plotted in a different colour for emphasis (e.g. to show the mappings between \
        different planes).
    pointcolor : str or None
        The color the points should be plotted. If None, the points are iterated through a cycle of colors.


if seed == -<NUM_LIT:1>:<EOL><INDENT>seed = np.random.randint(<NUM_LIT:0>,<EOL>int(<NUM_LIT>))  <EOL><DEDENT>np.random.seed(seed)<EOL>

Setup the random seed. If the input seed is -1, the code will use a random seed for every run. If it is \
    positive, that seed is used for all runs, thereby giving reproducible results.

    Parameters
    ----------
    seed : int
        The seed of the random number generator.


def generate_poisson_noise(image, exposure_time_map, seed=-<NUM_LIT:1>):

setup_random_seed(seed)<EOL>image_counts = np.multiply(image, exposure_time_map)<EOL>return image - np.divide(np.random.poisson(image_counts, image.shape), exposure_time_map)<EOL>

Generate a two-dimensional poisson noise_maps-mappers from an image.

Values are computed from a Poisson distribution using the image's input values in units of counts.

Parameters
----------
image : ndarray
    The 2D image, whose values in counts are used to draw Poisson noise_maps values.
exposure_time_map : Union(ndarray, int)
    2D array of the exposure time in each pixel used to convert to / from counts and electrons per second.
seed : int
    The seed of the random number generator, used for the random noise_maps maps.

Returns
-------
poisson_noise_map: ndarray
    An array describing simulated poisson noise_maps


Factory for loading the ccd data from .fits files, as well as computing properties like the noise-map,
    exposure-time map, etc. from the ccd-data.

    This factory also includes a number of routines for converting the ccd-data from units not supported by PyAutoLens \
    (e.g. adus, electrons) to electrons per second.

    Parameters
    ----------
    lens_name
    image_path : str
        The path to the image .fits file containing the image (e.g. '/path/to/image.fits')
    pixel_scale : float
        The size of each pixel in arc seconds.
    image_hdu : int
        The hdu the image is contained in the .fits file specified by *image_path*.
    image_hdu : int
        The hdu the image is contained in the .fits file that *image_path* points too.
    resized_ccd_shape : (int, int) | None
        If input, the ccd arrays that are image sized, e.g. the image, noise-maps) are resized to these dimensions.
    resized_ccd_origin_pixels : (int, int) | None
        If the ccd arrays are resized, this defines a new origin (in pixels) around which recentering occurs.
    resized_ccd_origin_arcsec : (float, float) | None
        If the ccd arrays are resized, this defines a new origin (in arc-seconds) around which recentering occurs.
    psf_path : str
        The path to the psf .fits file containing the psf (e.g. '/path/to/psf.fits')
    psf_hdu : int
        The hdu the psf is contained in the .fits file specified by *psf_path*.
    resized_psf_shape : (int, int) | None
        If input, the psf is resized to these dimensions.
    renormalize_psf : bool
        If True, the PSF is renoralized such that all elements sum to 1.0.
    noise_map_path : str
        The path to the noise_map .fits file containing the noise_map (e.g. '/path/to/noise_map.fits')
    noise_map_hdu : int
        The hdu the noise_map is contained in the .fits file specified by *noise_map_path*.
    noise_map_from_image_and_background_noise_map : bool
        If True, the noise-map is computed from the observed image and background noise-map \
        (see NoiseMap.from_image_and_background_noise_map).
    convert_noise_map_from_weight_map : bool
        If True, the noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
        *NoiseMap.from_weight_map).
    convert_noise_map_from_inverse_noise_map : bool
        If True, the noise-map loaded from the .fits file is converted from an inverse noise-map to a noise-map (see \
        *NoiseMap.from_inverse_noise_map).
    background_noise_map_path : str
        The path to the background_noise_map .fits file containing the background noise-map \
        (e.g. '/path/to/background_noise_map.fits')
    background_noise_map_hdu : int
        The hdu the background_noise_map is contained in the .fits file specified by *background_noise_map_path*.
    convert_background_noise_map_from_weight_map : bool
        If True, the bacground noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
        *NoiseMap.from_weight_map).
    convert_background_noise_map_from_inverse_noise_map : bool
        If True, the background noise-map loaded from the .fits file is converted from an inverse noise-map to a \
        noise-map (see *NoiseMap.from_inverse_noise_map).
    poisson_noise_map_path : str
        The path to the poisson_noise_map .fits file containing the Poisson noise-map \
         (e.g. '/path/to/poisson_noise_map.fits')
    poisson_noise_map_hdu : int
        The hdu the poisson_noise_map is contained in the .fits file specified by *poisson_noise_map_path*.
    poisson_noise_map_from_image : bool
        If True, the Poisson noise-map is estimated using the image.
    convert_poisson_noise_map_from_weight_map : bool
        If True, the Poisson noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
        *NoiseMap.from_weight_map).
    convert_poisson_noise_map_from_inverse_noise_map : bool
        If True, the Poisson noise-map loaded from the .fits file is converted from an inverse noise-map to a \
        noise-map (see *NoiseMap.from_inverse_noise_map).
    exposure_time_map_path : str
        The path to the exposure_time_map .fits file containing the exposure time map \
        (e.g. '/path/to/exposure_time_map.fits')
    exposure_time_map_hdu : int
        The hdu the exposure_time_map is contained in the .fits file specified by *exposure_time_map_path*.
    exposure_time_map_from_single_value : float
        The exposure time of the ccd imaging, which is used to compute the exposure-time map as a single value \
        (see *ExposureTimeMap.from_single_value*).
    exposure_time_map_from_inverse_noise_map : bool
        If True, the exposure-time map is computed from the background noise_map map \
        (see *ExposureTimeMap.from_background_noise_map*)
    background_sky_map_path : str
        The path to the background_sky_map .fits file containing the background sky map \
        (e.g. '/path/to/background_sky_map.fits').
    background_sky_map_hdu : int
        The hdu the background_sky_map is contained in the .fits file specified by *background_sky_map_path*.
    convert_from_electrons : bool
        If True, the input unblurred_image_1d are in units of electrons and all converted to electrons / second using the exposure \
        time map.
    gain : float
        The image gain, used for convert from ADUs.
    convert_from_adus : bool
        If True, the input unblurred_image_1d are in units of adus and all converted to electrons / second using the exposure \
        time map and gain.


def load_image(image_path, image_hdu, pixel_scale):

return ScaledSquarePixelArray.from_fits_with_pixel_scale(file_path=image_path, hdu=image_hdu,<EOL>pixel_scale=pixel_scale)<EOL>

Factory for loading the image from a .fits file

    Parameters
    ----------
    image_path : str
        The path to the image .fits file containing the image (e.g. '/path/to/image.fits')
    image_hdu : int
        The hdu the image is contained in the .fits file specified by *image_path*.
    pixel_scale : float
        The size of each pixel in arc seconds..


def load_noise_map(noise_map_path, noise_map_hdu, pixel_scale, image, background_noise_map, exposure_time_map,<EOL>convert_noise_map_from_weight_map, convert_noise_map_from_inverse_noise_map,<EOL>noise_map_from_image_and_background_noise_map, convert_from_electrons, gain, convert_from_adus):

noise_map_options = sum([convert_noise_map_from_weight_map,<EOL>convert_noise_map_from_inverse_noise_map,<EOL>noise_map_from_image_and_background_noise_map])<EOL>if noise_map_options > <NUM_LIT:1>:<EOL><INDENT>raise exc.DataException('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if noise_map_options == <NUM_LIT:0> and noise_map_path is not None:<EOL><INDENT>return NoiseMap.from_fits_with_pixel_scale(file_path=noise_map_path, hdu=noise_map_hdu, pixel_scale=pixel_scale)<EOL><DEDENT>elif convert_noise_map_from_weight_map and noise_map_path is not None:<EOL><INDENT>weight_map = Array.from_fits(file_path=noise_map_path, hdu=noise_map_hdu)<EOL>return NoiseMap.from_weight_map(weight_map=weight_map, pixel_scale=pixel_scale)<EOL><DEDENT>elif convert_noise_map_from_inverse_noise_map and noise_map_path is not None:<EOL><INDENT>inverse_noise_map = Array.from_fits(file_path=noise_map_path, hdu=noise_map_hdu)<EOL>return NoiseMap.from_inverse_noise_map(inverse_noise_map=inverse_noise_map, pixel_scale=pixel_scale)<EOL><DEDENT>elif noise_map_from_image_and_background_noise_map:<EOL><INDENT>if background_noise_map is None:<EOL><INDENT>raise exc.DataException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if not (convert_from_electrons or convert_from_adus) and exposure_time_map is None:<EOL><INDENT>raise exc.DataException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if convert_from_adus and gain is None:<EOL><INDENT>raise exc.DataException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>return NoiseMap.from_image_and_background_noise_map(pixel_scale=pixel_scale, image=image,<EOL>background_noise_map=background_noise_map,<EOL>exposure_time_map=exposure_time_map,<EOL>convert_from_electrons=convert_from_electrons,<EOL>gain=gain, convert_from_adus=convert_from_adus)<EOL><DEDENT>else:<EOL><INDENT>raise exc.DataException(<EOL>'<STR_LIT>')<EOL><DEDENT>

Factory for loading the noise-map from a .fits file.

    This factory also includes a number of routines for converting the noise-map from from other units (e.g. \
    a weight map) or computing the noise-map from other unblurred_image_1d (e.g. the ccd image and background noise-map).

    Parameters
    ----------
    noise_map_path : str
        The path to the noise_map .fits file containing the noise_map (e.g. '/path/to/noise_map.fits')
    noise_map_hdu : int
        The hdu the noise_map is contained in the .fits file specified by *noise_map_path*.
    pixel_scale : float
        The size of each pixel in arc seconds.
    image : ndarray
        The image-image, which the noise-map can be calculated using.
    background_noise_map : ndarray
        The background noise-map, which the noise-map can be calculated using.
    exposure_time_map : ndarray
        The exposure-time map, which the noise-map can be calculated using.
    convert_noise_map_from_weight_map : bool
        If True, the noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
        *NoiseMap.from_weight_map).
    convert_noise_map_from_inverse_noise_map : bool
        If True, the noise-map loaded from the .fits file is converted from an inverse noise-map to a noise-map (see \
        *NoiseMap.from_inverse_noise_map).
    background_noise_map_path : str
        The path and filename of the .fits image containing the background noise-map.
    background_noise_map_hdu : int
        The hdu the background noise-map is contained in the .fits file that *background_noise_map_path* points too.
    convert_background_noise_map_from_weight_map : bool
        If True, the bacground noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
        *NoiseMap.from_weight_map).
    convert_background_noise_map_from_inverse_noise_map : bool
        If True, the background noise-map loaded from the .fits file is converted from an inverse noise-map to a \
        noise-map (see *NoiseMap.from_inverse_noise_map).
    noise_map_from_image_and_background_noise_map : bool
        If True, the noise-map is computed from the observed image and background noise-map \
        (see NoiseMap.from_image_and_background_noise_map).
    convert_from_electrons : bool
        If True, the input unblurred_image_1d are in units of electrons and all converted to electrons / second using the exposure \
        time map.
    gain : float
        The image gain, used for convert from ADUs.
    convert_from_adus : bool
        If True, the input unblurred_image_1d are in units of adus and all converted to electrons / second using the exposure \
        time map and gain.


background_noise_map_options = sum([convert_background_noise_map_from_weight_map,<EOL>convert_background_noise_map_from_inverse_noise_map])<EOL>if background_noise_map_options == <NUM_LIT:0> and background_noise_map_path is not None:<EOL><INDENT>return NoiseMap.from_fits_with_pixel_scale(file_path=background_noise_map_path, hdu=background_noise_map_hdu,<EOL>pixel_scale=pixel_scale)<EOL><DEDENT>elif convert_background_noise_map_from_weight_map and background_noise_map_path is not None:<EOL><INDENT>weight_map = Array.from_fits(file_path=background_noise_map_path, hdu=background_noise_map_hdu)<EOL>return NoiseMap.from_weight_map(weight_map=weight_map, pixel_scale=pixel_scale)<EOL><DEDENT>elif convert_background_noise_map_from_inverse_noise_map and background_noise_map_path is not None:<EOL><INDENT>inverse_noise_map = Array.from_fits(file_path=background_noise_map_path, hdu=background_noise_map_hdu)<EOL>return NoiseMap.from_inverse_noise_map(inverse_noise_map=inverse_noise_map, pixel_scale=pixel_scale)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

Factory for loading the background noise-map from a .fits file.

    This factory also includes a number of routines for converting the background noise-map from from other units (e.g. \
    a weight map).

    Parameters
    ----------
    background_noise_map_path : str
        The path to the background_noise_map .fits file containing the background noise-map \
        (e.g. '/path/to/background_noise_map.fits')
    background_noise_map_hdu : int
        The hdu the background_noise_map is contained in the .fits file specified by *background_noise_map_path*.
    pixel_scale : float
        The size of each pixel in arc seconds.
    convert_background_noise_map_from_weight_map : bool
        If True, the bacground noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
        *NoiseMap.from_weight_map).
    convert_background_noise_map_from_inverse_noise_map : bool
        If True, the background noise-map loaded from the .fits file is converted from an inverse noise-map to a \
        noise-map (see *NoiseMap.from_inverse_noise_map).


poisson_noise_map_options = sum([convert_poisson_noise_map_from_weight_map,<EOL>convert_poisson_noise_map_from_inverse_noise_map,<EOL>poisson_noise_map_from_image])<EOL>if poisson_noise_map_options == <NUM_LIT:0> and poisson_noise_map_path is not None:<EOL><INDENT>return PoissonNoiseMap.from_fits_with_pixel_scale(file_path=poisson_noise_map_path, hdu=poisson_noise_map_hdu,<EOL>pixel_scale=pixel_scale)<EOL><DEDENT>elif poisson_noise_map_from_image:<EOL><INDENT>if not (convert_from_electrons or convert_from_adus) and exposure_time_map is None:<EOL><INDENT>raise exc.DataException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if convert_from_adus and gain is None:<EOL><INDENT>raise exc.DataException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>return PoissonNoiseMap.from_image_and_exposure_time_map(pixel_scale=pixel_scale, image=image,<EOL>exposure_time_map=exposure_time_map,<EOL>convert_from_electrons=convert_from_electrons,<EOL>gain=gain,<EOL>convert_from_adus=convert_from_adus)<EOL><DEDENT>elif convert_poisson_noise_map_from_weight_map and poisson_noise_map_path is not None:<EOL><INDENT>weight_map = Array.from_fits(file_path=poisson_noise_map_path, hdu=poisson_noise_map_hdu)<EOL>return PoissonNoiseMap.from_weight_map(weight_map=weight_map, pixel_scale=pixel_scale)<EOL><DEDENT>elif convert_poisson_noise_map_from_inverse_noise_map and poisson_noise_map_path is not None:<EOL><INDENT>inverse_noise_map = Array.from_fits(file_path=poisson_noise_map_path, hdu=poisson_noise_map_hdu)<EOL>return PoissonNoiseMap.from_inverse_noise_map(inverse_noise_map=inverse_noise_map, pixel_scale=pixel_scale)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

Factory for loading the Poisson noise-map from a .fits file.

    This factory also includes a number of routines for converting the Poisson noise-map from from other units (e.g. \
    a weight map) or computing the Poisson noise_map from other unblurred_image_1d (e.g. the ccd image).

    Parameters
    ----------
    poisson_noise_map_path : str
        The path to the poisson_noise_map .fits file containing the Poisson noise-map \
         (e.g. '/path/to/poisson_noise_map.fits')
    poisson_noise_map_hdu : int
        The hdu the poisson_noise_map is contained in the .fits file specified by *poisson_noise_map_path*.
    pixel_scale : float
        The size of each pixel in arc seconds.
    convert_poisson_noise_map_from_weight_map : bool
        If True, the Poisson noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
        *NoiseMap.from_weight_map).
    convert_poisson_noise_map_from_inverse_noise_map : bool
        If True, the Poisson noise-map loaded from the .fits file is converted from an inverse noise-map to a \
        noise-map (see *NoiseMap.from_inverse_noise_map).
    poisson_noise_map_from_image : bool
        If True, the Poisson noise-map is estimated using the image.
    image : ndarray
        The image, which the Poisson noise-map can be calculated using.
    background_noise_map : ndarray
        The background noise-map, which the Poisson noise-map can be calculated using.
    exposure_time_map : ndarray
        The exposure-time map, which the Poisson noise-map can be calculated using.
    convert_from_electrons : bool
        If True, the input unblurred_image_1d are in units of electrons and all converted to electrons / second using the exposure \
        time map.
    gain : float
        The image gain, used for convert from ADUs.
    convert_from_adus : bool
        If True, the input unblurred_image_1d are in units of adus and all converted to electrons / second using the exposure \
        time map and gain.


def load_psf(psf_path, psf_hdu, pixel_scale, renormalize=False):

if renormalize:<EOL><INDENT>return PSF.from_fits_renormalized(file_path=psf_path, hdu=psf_hdu, pixel_scale=pixel_scale)<EOL><DEDENT>if not renormalize:<EOL><INDENT>return PSF.from_fits_with_scale(file_path=psf_path, hdu=psf_hdu, pixel_scale=pixel_scale)<EOL><DEDENT>

Factory for loading the psf from a .fits file.

    Parameters
    ----------
    psf_path : str
        The path to the psf .fits file containing the psf (e.g. '/path/to/psf.fits')
    psf_hdu : int
        The hdu the psf is contained in the .fits file specified by *psf_path*.
    pixel_scale : float
        The size of each pixel in arc seconds.
    renormalize : bool
        If True, the PSF is renoralized such that all elements sum to 1.0.


def load_exposure_time_map(exposure_time_map_path, exposure_time_map_hdu, pixel_scale, shape, exposure_time,<EOL>exposure_time_map_from_inverse_noise_map, inverse_noise_map):

exposure_time_map_options = sum([exposure_time_map_from_inverse_noise_map])<EOL>if exposure_time is not None and exposure_time_map_path is not None:<EOL><INDENT>raise exc.DataException(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if exposure_time_map_options == <NUM_LIT:0>:<EOL><INDENT>if exposure_time is not None and exposure_time_map_path is None:<EOL><INDENT>return ExposureTimeMap.single_value(value=exposure_time, pixel_scale=pixel_scale, shape=shape)<EOL><DEDENT>elif exposure_time is None and exposure_time_map_path is not None:<EOL><INDENT>return ExposureTimeMap.from_fits_with_pixel_scale(file_path=exposure_time_map_path,<EOL>hdu=exposure_time_map_hdu, pixel_scale=pixel_scale)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if exposure_time_map_from_inverse_noise_map:<EOL><INDENT>return ExposureTimeMap.from_exposure_time_and_inverse_noise_map(pixel_scale=pixel_scale,<EOL>exposure_time=exposure_time,<EOL>inverse_noise_map=inverse_noise_map)<EOL><DEDENT><DEDENT>

Factory for loading the exposure time map from a .fits file.

    This factory also includes a number of routines for computing the exposure-time map from other unblurred_image_1d \
    (e.g. the background noise-map).

    Parameters
    ----------
    exposure_time_map_path : str
        The path to the exposure_time_map .fits file containing the exposure time map \
        (e.g. '/path/to/exposure_time_map.fits')
    exposure_time_map_hdu : int
        The hdu the exposure_time_map is contained in the .fits file specified by *exposure_time_map_path*.
    pixel_scale : float
        The size of each pixel in arc seconds.
    shape : (int, int)
        The shape of the image, required if a single value is used to calculate the exposure time map.
    exposure_time : float
        The exposure-time used to compute the expsure-time map if only a single value is used.
    exposure_time_map_from_inverse_noise_map : bool
        If True, the exposure-time map is computed from the background noise_map map \
        (see *ExposureTimeMap.from_background_noise_map*)
    inverse_noise_map : ndarray
        The background noise-map, which the Poisson noise-map can be calculated using.


def load_background_sky_map(background_sky_map_path, background_sky_map_hdu, pixel_scale):

if background_sky_map_path is not None:<EOL><INDENT>return ScaledSquarePixelArray.from_fits_with_pixel_scale(file_path=background_sky_map_path,<EOL>hdu=background_sky_map_hdu, pixel_scale=pixel_scale)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

Factory for loading the background sky from a .fits file.

    Parameters
    ----------
    background_sky_map_path : str
        The path to the background_sky_map .fits file containing the background sky map \
        (e.g. '/path/to/background_sky_map.fits').
    background_sky_map_hdu : int
        The hdu the background_sky_map is contained in the .fits file specified by *background_sky_map_path*.
    pixel_scale : float
        The size of each pixel in arc seconds.


with open(positions_path) as f:<EOL><INDENT>position_string = f.readlines()<EOL><DEDENT>positions = []<EOL>for line in position_string:<EOL><INDENT>position_list = ast.literal_eval(line)<EOL>positions.append(position_list)<EOL><DEDENT>return positions<EOL>

Load the positions of an image.

    Positions correspond to a set of pixels in the lensed source galaxy that are anticipated to come from the same \
    multiply-imaged region of the source-plane. Mass models which do not trace the pixels within a threshold value of \
    one another are resampled during the non-linear search.

    Positions are stored in a .dat file, where each line of the file gives a list of list of (y,x) positions which \
    correspond to the same region of the source-plane. Thus, multiple source-plane regions can be input over multiple \
    lines of the same positions file.

    Parameters
    ----------
    positions_path : str
        The path to the positions .dat file containing the positions (e.g. '/path/to/positions.dat')


with open(positions_path, '<STR_LIT:w>') as f:<EOL><INDENT>for position in positions:<EOL><INDENT>f.write("<STR_LIT>" % position)<EOL><DEDENT><DEDENT>

Output the positions of an image to a positions.dat file.

    Positions correspond to a set of pixels in the lensed source galaxy that are anticipated to come from the same \
    multiply-imaged region of the source-plane. Mass models which do not trace the pixels within a threshold value of \
    one another are resampled during the non-linear search.

    Positions are stored in a .dat file, where each line of the file gives a list of list of (y,x) positions which \
    correspond to the same region of the source-plane. Thus, multiple source-plane regions can be input over multiple \
    lines of the same positions file.

    Parameters
    ----------
    positions : [[[]]]
        The lists of positions (e.g. [[[1.0, 1.0], [2.0, 2.0]], [[3.0, 3.0], [4.0, 4.0]]])
    positions_path : str
        The path to the positions .dat file containing the positions (e.g. '/path/to/positions.dat')


def __init__(self, image, pixel_scale, psf, noise_map=None, background_noise_map=None, poisson_noise_map=None,<EOL>exposure_time_map=None, background_sky_map=None, name=None, **kwargs):

self.name = name<EOL>self.image = image<EOL>self.pixel_scale = pixel_scale<EOL>self.psf = psf<EOL>self.noise_map = noise_map<EOL>self.background_noise_map = background_noise_map<EOL>self.poisson_noise_map = poisson_noise_map<EOL>self.exposure_time_map = exposure_time_map<EOL>self.background_sky_map = background_sky_map<EOL>self.origin = (<NUM_LIT:0.0>, <NUM_LIT:0.0>)<EOL>

A collection of 2D CCD data (an image, noise-map, psf, etc.)

        Parameters
        ----------
        image : scaled_array.ScaledArraySquarePixels
            The array of the image data, in units of electrons per second.
        pixel_scale : float
            The size of each pixel in arc seconds.
        psf : PSF
            An array describing the PSF kernel of the image.
        noise_map : NoiseMap | float | ndarray
            An array describing the RMS standard deviation error in each pixel, preferably in units of electrons per
            second.
        background_noise_map : NoiseMap
            An array describing the RMS standard deviation error in each pixel due to the background sky noise_map,
            preferably in units of electrons per second.
        poisson_noise_map : NoiseMap
            An array describing the RMS standard deviation error in each pixel due to the Poisson counts of the source,
            preferably in units of electrons per second.
        exposure_time_map : scaled_array.ScaledSquarePixelArray
            An array describing the effective exposure time in each ccd pixel.
        background_sky_map : scaled_array.ScaledSquarePixelArray
            An array describing the background sky.


@classmethod<EOL><INDENT>def simulate_variable_arrays(cls, array, pixel_scale, exposure_time_map, psf=None, background_sky_map=None,<EOL>add_noise=True, noise_if_add_noise_false=<NUM_LIT:0.1>, noise_seed=-<NUM_LIT:1>, name=None):<DEDENT>

if background_sky_map is not None:<EOL><INDENT>array += background_sky_map<EOL><DEDENT>if psf is not None:<EOL><INDENT>array = psf.convolve(array)<EOL>array = cls.trim_psf_edges(array, psf)<EOL>exposure_time_map = cls.trim_psf_edges(exposure_time_map, psf)<EOL>if background_sky_map is not None:<EOL><INDENT>background_sky_map = cls.trim_psf_edges(background_sky_map, psf)<EOL><DEDENT><DEDENT>if add_noise is True:<EOL><INDENT>array += generate_poisson_noise(array, exposure_time_map, noise_seed)<EOL>array_counts = np.multiply(array, exposure_time_map)<EOL>noise_map = np.divide(np.sqrt(array_counts), exposure_time_map)<EOL><DEDENT>else:<EOL><INDENT>noise_map = noise_if_add_noise_false * np.ones(array.shape)<EOL><DEDENT>if np.isnan(noise_map).any():<EOL><INDENT>raise exc.DataException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if background_sky_map is not None:<EOL><INDENT>array -= background_sky_map<EOL><DEDENT>if background_sky_map is not None:<EOL><INDENT>background_noise_map_counts = np.sqrt(np.multiply(background_sky_map, exposure_time_map))<EOL>background_noise_map = np.divide(background_noise_map_counts, exposure_time_map)<EOL><DEDENT>else:<EOL><INDENT>background_noise_map = None<EOL><DEDENT>array_counts = np.multiply(array, exposure_time_map)<EOL>poisson_noise_map = np.divide(np.sqrt(np.abs(array_counts)), exposure_time_map)<EOL>array = ScaledSquarePixelArray(array=array, pixel_scale=pixel_scale)<EOL>noise_map = NoiseMap(array=noise_map, pixel_scale=pixel_scale)<EOL>if background_noise_map is not None:<EOL><INDENT>background_noise_map = NoiseMap(array=background_noise_map, pixel_scale=pixel_scale)<EOL><DEDENT>if poisson_noise_map is not None:<EOL><INDENT>poisson_noise_map = PoissonNoiseMap(array=poisson_noise_map, pixel_scale=pixel_scale)<EOL><DEDENT>return CCDData(array, pixel_scale=pixel_scale, psf=psf, noise_map=noise_map,<EOL>background_noise_map=background_noise_map, poisson_noise_map=poisson_noise_map,<EOL>exposure_time_map=exposure_time_map, background_sky_map=background_sky_map, name=name)<EOL>

Create a realistic simulated image by applying effects to a plain simulated image.

Parameters
----------
name
array : ndarray
    The image before simulating (e.g. the lens and source galaxies before optics blurring and CCD read-out).
pixel_scale: float
    The scale of each pixel in arc seconds
exposure_time_map : ndarray
    An array representing the effective exposure time of each pixel.
psf: PSF
    An array describing the PSF the simulated image is blurred with.
background_sky_map : ndarray
    The value of background sky in every image pixel (electrons per second).
add_noise: Bool
    If True poisson noise_maps is simulated and added to the image, based on the total counts in each image
    pixel
noise_seed: int
    A seed for random noise_maps generation


@classmethod<EOL><INDENT>def simulate_to_target_signal_to_noise(cls, array, pixel_scale, target_signal_to_noise, exposure_time_map,<EOL>psf=None, background_sky_map=None, seed=-<NUM_LIT:1>):<DEDENT>

max_index = np.unravel_index(array.argmax(), array.shape)<EOL>max_image = array[max_index]<EOL>max_effective_exposure_time = exposure_time_map[max_index]<EOL>max_array_counts = np.multiply(max_image, max_effective_exposure_time)<EOL>if background_sky_map is not None:<EOL><INDENT>max_background_sky_map = background_sky_map[max_index]<EOL>max_background_sky_map_counts = np.multiply(max_background_sky_map, max_effective_exposure_time)<EOL><DEDENT>else:<EOL><INDENT>max_background_sky_map_counts = None<EOL><DEDENT>scale_factor = <NUM_LIT:1.><EOL>if background_sky_map is None:<EOL><INDENT>scale_factor = target_signal_to_noise ** <NUM_LIT> / max_array_counts<EOL><DEDENT>elif background_sky_map is not None:<EOL><INDENT>scale_factor = (max_array_counts + max_background_sky_map_counts) * target_signal_to_noise ** <NUM_LIT>/ max_array_counts ** <NUM_LIT><EOL><DEDENT>scaled_effective_exposure_time = np.multiply(scale_factor, exposure_time_map)<EOL>return cls.simulate_variable_arrays(array=array, pixel_scale=pixel_scale,<EOL>exposure_time_map=scaled_effective_exposure_time,<EOL>psf=psf, background_sky_map=background_sky_map,<EOL>add_noise=True, noise_seed=seed)<EOL>

Create a realistic simulated image by applying effects to a plain simulated image.

Parameters
----------
target_signal_to_noise
array : ndarray
    The image before simulating (e.g. the lens and source galaxies before optics blurring and CCD read-out).
pixel_scale: float
    The scale of each pixel in arc seconds
exposure_time_map : ndarray
    An array representing the effective exposure time of each pixel.
psf: PSF
    An array describing the PSF the simulated image is blurred with.
background_sky_map : ndarray
    The value of background sky in every image pixel (electrons per second).
seed: int
    A seed for random noise_maps generation


signal_to_noise_map = np.divide(self.image, self.noise_map)<EOL>signal_to_noise_map[signal_to_noise_map < <NUM_LIT:0>] = <NUM_LIT:0><EOL>return signal_to_noise_map<EOL>

The estimated signal-to-noise_maps mappers of the image.


return np.max(self.signal_to_noise_map)<EOL>

The maximum value of signal-to-noise_maps in an image pixel in the image's signal-to-noise_maps mappers


return np.divide(np.abs(self.image), self.noise_map)<EOL>

The estimated absolute_signal-to-noise_maps mappers of the image.


return np.max(self.absolute_signal_to_noise_map)<EOL>

The maximum value of absolute signal-to-noise_map in an image pixel in the image's signal-to-noise_maps mappers


return np.square(self.absolute_signal_to_noise_map)<EOL>

The potential chi-squared map of the ccd data. This represents how much each pixel can contribute to \
        the chi-squared map, assuming the model fails to fit it at all (e.g. model value = 0.0).


return np.max(self.potential_chi_squared_map)<EOL>

The maximum value of the potential chi-squared map


return np.multiply(array, self.exposure_time_map)<EOL>

For an array (in electrons per second) and an exposure time mappers, return an array in units counts.

Parameters
----------
array : ndarray
    The array the values are to be converted from electrons per seconds to counts.


if array is not None:<EOL><INDENT>return np.divide(array, self.exposure_time_map)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

For an array (in counts) and an exposure time mappers, convert the array to units electrons per second

Parameters
----------
array : ndarray
    The array the values are to be converted from counts to electrons per second.


def array_from_adus_to_electrons_per_second(self, array, gain):

if array is not None:<EOL><INDENT>return np.divide(gain * array, self.exposure_time_map)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>


return self.array_from_electrons_per_second_to_counts(self.image)<EOL>


return self.array_from_electrons_per_second_to_counts(self.background_noise_map)<EOL>

The background noise_maps mappers in units of counts.


return np.sqrt((np.abs(self.image_counts) + np.square(self.background_noise_map_counts)))<EOL>

The estimated noise_maps mappers of the image (using its background noise_maps mappers and image values
        in counts) in counts.


return self.array_from_counts_to_electrons_per_second(self.estimated_noise_map_counts)<EOL>

The estimated noise_maps mappers of the image (using its background noise_maps mappers and image values
        in counts) in electrons per second.


edges = []<EOL>for edge_no in range(no_edges):<EOL><INDENT>top_edge = self.image[edge_no, edge_no:self.image.shape[<NUM_LIT:1>] - edge_no]<EOL>bottom_edge = self.image[self.image.shape[<NUM_LIT:0>] - <NUM_LIT:1> - edge_no, edge_no:self.image.shape[<NUM_LIT:1>] - edge_no]<EOL>left_edge = self.image[edge_no + <NUM_LIT:1>:self.image.shape[<NUM_LIT:0>] - <NUM_LIT:1> - edge_no, edge_no]<EOL>right_edge = self.image[edge_no + <NUM_LIT:1>:self.image.shape[<NUM_LIT:0>] - <NUM_LIT:1> - edge_no, self.image.shape[<NUM_LIT:1>] - <NUM_LIT:1> - edge_no]<EOL>edges = np.concatenate((edges, top_edge, bottom_edge, right_edge, left_edge))<EOL><DEDENT>return norm.fit(edges)[<NUM_LIT:1>]<EOL>

Estimate the background signal_to_noise_ratio by binning data_to_image located at the edge(s) of an image
        into a histogram and fitting a Gaussian profiles to this histogram. The standard deviation (sigma) of this
        Gaussian gives a signal_to_noise_ratio estimate.

        Parameters
        ----------
        no_edges : int
            Number of edges used to estimate the background signal_to_noise_ratio.


@classmethod<EOL><INDENT>def from_weight_map(cls, pixel_scale, weight_map):<DEDENT>

np.seterr(divide='<STR_LIT:ignore>')<EOL>noise_map = <NUM_LIT:1.0> / np.sqrt(weight_map)<EOL>noise_map[noise_map == np.inf] = <NUM_LIT><EOL>return NoiseMap(array=noise_map, pixel_scale=pixel_scale)<EOL>

Setup the noise-map from a weight map, which is a form of noise-map that comes via HST image-reduction and \
        the software package MultiDrizzle.

        The variance in each pixel is computed as:

        Variance = 1.0 / sqrt(weight_map).

        The weight map may contain zeros, in which cause the variances are converted to large values to omit them from \
        the analysis.

        Parameters
        -----------
        pixel_scale : float
            The size of each pixel in arc seconds.
        weight_map : ndarray
            The weight-value of each pixel which is converted to a variance.


@classmethod<EOL><INDENT>def from_inverse_noise_map(cls, pixel_scale, inverse_noise_map):<DEDENT>

noise_map = <NUM_LIT:1.0> / inverse_noise_map<EOL>return NoiseMap(array=noise_map, pixel_scale=pixel_scale)<EOL>

Setup the noise-map from an root-mean square standard deviation map, which is a form of noise-map that \
        comes via HST image-reduction and the software package MultiDrizzle.

        The variance in each pixel is computed as:

        Variance = 1.0 / inverse_std_map.

        The weight map may contain zeros, in which cause the variances are converted to large values to omit them from \
        the analysis.

        Parameters
        -----------
        pixel_scale : float
            The size of each pixel in arc seconds.
        inverse_noise_map : ndarray
            The inverse noise_map value of each pixel which is converted to a variance.


def __init__(self, array, pixel_scale, renormalize=False, **kwargs):

<EOL>super().__init__(array=array, pixel_scale=pixel_scale)<EOL>if renormalize:<EOL><INDENT>self[:, :] = np.divide(self, np.sum(self))<EOL><DEDENT>

Class storing a 2D Point Spread Function (PSF), including its blurring kernel.

Parameters
----------
array : ndarray
    The 2d PSF blurring kernel.
renormalize : bool
    Renormalize the PSF such that he sum of kernel values total 1.0?


@classmethod<EOL><INDENT>def simulate_as_gaussian(cls, shape, pixel_scale, sigma, centre=(<NUM_LIT:0.0>, <NUM_LIT:0.0>), axis_ratio=<NUM_LIT:1.0>, phi=<NUM_LIT:0.0>):<DEDENT>

from autolens.model.profiles.light_profiles import EllipticalGaussian<EOL>gaussian = EllipticalGaussian(centre=centre, axis_ratio=axis_ratio, phi=phi, intensity=<NUM_LIT:1.0>, sigma=sigma)<EOL>grid_1d = grid_util.regular_grid_1d_masked_from_mask_pixel_scales_and_origin(mask=np.full(shape, False),<EOL>pixel_scales=(<EOL>pixel_scale, pixel_scale))<EOL>gaussian_1d = gaussian.intensities_from_grid(grid=grid_1d)<EOL>gaussian_2d = mapping_util.map_unmasked_1d_array_to_2d_array_from_array_1d_and_shape(array_1d=gaussian_1d,<EOL>shape=shape)<EOL>return PSF(array=gaussian_2d, pixel_scale=pixel_scale, renormalize=True)<EOL>

Simulate the PSF as an elliptical Gaussian profile.


@classmethod<EOL><INDENT>def from_fits_renormalized(cls, file_path, hdu, pixel_scale):<DEDENT>

psf = PSF.from_fits_with_scale(file_path, hdu, pixel_scale)<EOL>psf[:, :] = np.divide(psf, np.sum(psf))<EOL>return psf<EOL>

Loads a PSF from fits and renormalizes it

        Parameters
        ----------
        pixel_scale
        file_path: String
            The path to the file containing the PSF
        hdu : int
            The HDU the PSF is stored in the .fits file.

        Returns
        -------
        psf: PSF
            A renormalized PSF instance


@classmethod<EOL><INDENT>def from_fits_with_scale(cls, file_path, hdu, pixel_scale):<DEDENT>

return cls(array=array_util.numpy_array_2d_from_fits(file_path, hdu), pixel_scale=pixel_scale)<EOL>

Loads the PSF from a .fits file.

Parameters
----------
pixel_scale
file_path: String
    The path to the file containing the PSF
hdu : int
    The HDU the PSF is stored in the .fits file.


return PSF(array=self, pixel_scale=self.pixel_scale, renormalize=True)<EOL>

Renormalize the PSF such that its data_vector values sum to unity.


if self.shape[<NUM_LIT:0>] % <NUM_LIT:2> == <NUM_LIT:0> or self.shape[<NUM_LIT:1>] % <NUM_LIT:2> == <NUM_LIT:0>:<EOL><INDENT>raise exc.KernelException("<STR_LIT>")<EOL><DEDENT>return scipy.signal.convolve2d(array, self, mode='<STR_LIT>')<EOL>

Convolve an array with this PSF

Parameters
----------
image : ndarray
    An array representing the image the PSF is convolved with.

Returns
-------
convolved_image : ndarray
    An array representing the image after convolution.

Raises
------
KernelException if either PSF psf dimension is odd


@wraps(func)<EOL>def wrapper(grid, galaxies, *args, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>result = func(grid, galaxies, *args, *kwargs)<EOL>if isinstance(grid, SubGrid):<EOL><INDENT>return grid.regular_data_1d_from_sub_data_1d(result)<EOL><DEDENT>else:<EOL><INDENT>return result<EOL><DEDENT><DEDENT>return wrapper<EOL>

Wrap the function in a function that, if the grid is a sub-grid (grids.SubGrid), rebins the computed \
values to the sub-grids corresponding regular-grid by taking the mean of each set of sub-gridded values.

Parameters
----------
func : (profiles, *args, **kwargs) -> Object
    A function that requires the sub-grid and galaxies.


@wraps(func)<EOL>def wrapper(profile, grid, grid_radial_minimum=None, *args, **kwargs):<EOL><INDENT>if hasattr(grid, "<STR_LIT>"):<EOL><INDENT>interpolator = grid.interpolator<EOL>if grid.interpolator is not None:<EOL><INDENT>values = func(profile, interpolator.interp_grid, grid_radial_minimum, *args, **kwargs)<EOL>if values.ndim == <NUM_LIT:1>:<EOL><INDENT>return interpolator.interpolated_values_from_values(values=values)<EOL><DEDENT>elif values.ndim == <NUM_LIT:2>:<EOL><INDENT>y_values = interpolator.interpolated_values_from_values(values=values[:, <NUM_LIT:0>])<EOL>x_values = interpolator.interpolated_values_from_values(values=values[:, <NUM_LIT:1>])<EOL>return np.asarray([y_values, x_values]).T<EOL><DEDENT><DEDENT><DEDENT>return func(profile, grid, grid_radial_minimum, *args, **kwargs)<EOL><DEDENT>return wrapper<EOL>

Decorate a profile method that accepts a coordinate grid and returns a data grid.

If an interpolator attribute is associated with the input grid then that interpolator is used to down sample the
coordinate grid prior to calling the function and up sample the result of the function.

If no interpolator attribute is associated with the input grid then the function is called as normal.

Parameters
----------
func
    Some method that accepts a grid

Returns
-------
decorated_function
    The function with optional interpolation


def __init__(self, regular, sub, blurring, pix=None):

self.regular = regular<EOL>self.sub = sub<EOL>self.blurring = blurring<EOL>if pix is None:<EOL><INDENT>self.pix = np.array([[<NUM_LIT:0.0>, <NUM_LIT:0.0>]])<EOL><DEDENT>else:<EOL><INDENT>self.pix = pix<EOL><DEDENT>

A 'stack' of grid_stack which contain the (y,x) arc-second coordinates of pixels in a mask. The stack \
        contains at least 3 grid_stack:

        regular - the (y,x) coordinate at the center of every unmasked pixel.

        sub - the (y,x) coordinates of every sub-pixel in every unmasked pixel, each using a grid of size \
        (sub_grid_size x sub_grid_size).

        blurring - the (y,x) coordinates of all blurring pixels, which are masked pixels whose light is \
        blurred into unmasked pixels during PSF convolution.

        There are also optional grid_stack, used if specific PyAutoLens functionality is required:

        pix - the (y,x) coordinates of the grid which is used to form the pixels of a \
        *pixelizations.AdaptivePixelization* pixelization.

        The grid_stack are stored as 2D arrays, where each entry corresponds to the (y,x) coordinates of a pixel. The
        positive y-axis is upwards and poitive x-axis to the right. The array is ordered such pixels begin from the \
        top-row of the mask and go rightwards and then downwards.

        Parameters
        -----------
        regular : RegularGrid
            The grid of (y,x) arc-second coordinates at the centre of every unmasked pixel.
        sub : SubGrid | np.ndarray
            The grid of (y,x) arc-second coordinates at the centre of every unmasked pixel's sub-pixels.
        blurring : RegularGrid | ndarray | None
            The grid of (y,x) arc-second coordinates at the centre of every blurring-mask pixel.
        pix : PixGrid | ndarray | None
            The grid of (y,x) arc-second coordinates of every image-plane pixelization grid used for adaptive source \
            -plane pixelizations.


def unmasked_blurred_image_from_psf_and_unmasked_image(self, psf, unmasked_image_1d):

blurred_image_1d = self.regular.convolve_array_1d_with_psf(padded_array_1d=unmasked_image_1d,<EOL>psf=psf)<EOL>return self.regular.scaled_array_2d_from_array_1d(array_1d=blurred_image_1d)<EOL>

For a padded grid-stack and psf, compute an unmasked blurred image from an unmasked unblurred image.

        This relies on using the lens data's padded-grid, which is a grid of (y,x) coordinates which extends over the \
        entire image as opposed to just the masked region.

        Parameters
        ----------
        psf : ccd.PSF
            The PSF of the image used for convolution.
        unmasked_image_1d : ndarray
            The 1D unmasked image which is blurred.


@classmethod<EOL><INDENT>def grid_stack_from_mask_sub_grid_size_and_psf_shape(cls, mask, sub_grid_size, psf_shape):<DEDENT>

regular_grid = RegularGrid.from_mask(mask)<EOL>sub_grid = SubGrid.from_mask_and_sub_grid_size(mask, sub_grid_size)<EOL>blurring_grid = RegularGrid.blurring_grid_from_mask_and_psf_shape(mask, psf_shape)<EOL>return GridStack(regular_grid, sub_grid, blurring_grid)<EOL>

Setup a grid-stack of grid_stack from a mask, sub-grid size and psf-shape.

        Parameters
        -----------
        mask : Mask
            The mask whose unmasked pixels (*False*) are used to generate the grid-stack's grid_stack.
        sub_grid_size : int
            The size of a sub-pixel's sub-grid (sub_grid_size x sub_grid_size).
        psf_shape : (int, int)
            the shape of the PSF used in the analysis, which defines the mask's blurring-region.


@classmethod<EOL><INDENT>def from_shape_pixel_scale_and_sub_grid_size(cls, shape, pixel_scale, sub_grid_size=<NUM_LIT:2>):<DEDENT>

regular_grid = RegularGrid.from_shape_and_pixel_scale(shape=shape, pixel_scale=pixel_scale)<EOL>sub_grid = SubGrid.from_shape_pixel_scale_and_sub_grid_size(shape=shape, pixel_scale=pixel_scale,<EOL>sub_grid_size=sub_grid_size)<EOL>blurring_grid = np.array([[<NUM_LIT:0.0>, <NUM_LIT:0.0>]])<EOL>return GridStack(regular_grid, sub_grid, blurring_grid)<EOL>

Setup a grid-stack of grid_stack from a 2D array shape, a pixel scale and a sub-grid size.

        This grid corresponds to a fully unmasked 2D array.

        Parameters
        -----------
        shape : (int, int)
            The 2D shape of the array, where all pixels are used to generate the grid-stack's grid_stack.
        pixel_scale : float
            The size of each pixel in arc seconds.
        sub_grid_size : int
            The size of a sub-pixel's sub-grid (sub_grid_size x sub_grid_size).


@classmethod<EOL><INDENT>def padded_grid_stack_from_mask_sub_grid_size_and_psf_shape(cls, mask, sub_grid_size, psf_shape):<DEDENT>

regular_padded_grid = PaddedRegularGrid.padded_grid_from_shape_psf_shape_and_pixel_scale(<EOL>shape=mask.shape,<EOL>psf_shape=psf_shape,<EOL>pixel_scale=mask.pixel_scale)<EOL>sub_padded_grid = PaddedSubGrid.padded_grid_from_mask_sub_grid_size_and_psf_shape(mask=mask,<EOL>sub_grid_size=sub_grid_size,<EOL>psf_shape=psf_shape)<EOL>return GridStack(regular=regular_padded_grid, sub=sub_padded_grid, blurring=np.array([[<NUM_LIT:0.0>, <NUM_LIT:0.0>]]))<EOL>

Setup a grid-stack of masked grid_stack from a mask,  sub-grid size and psf-shape.

        Parameters
        -----------
        mask : Mask
            The mask whose masked pixels the grid-stack are setup using.
        sub_grid_size : int
            The size of a sub-pixels sub-grid (sub_grid_size x sub_grid_size).
        psf_shape : (int, int)
            The shape of the PSF used in the analysis, which defines the mask's blurring-region.


@classmethod<EOL><INDENT>def grid_stack_for_simulation(cls, shape, pixel_scale, psf_shape, sub_grid_size=<NUM_LIT:2>):<DEDENT>

Setup a grid-stack of grid_stack for simulating an image of a strong lens, whereby the grid's use \
        padded-grid_stack to ensure that the PSF blurring in the simulation routine (*ccd.PrepatoryImage.simulate*) \
        is not degraded due to edge effects.

        Parameters
        -----------
        shape : (int, int)
            The 2D shape of the array, where all pixels are used to generate the grid-stack's grid_stack.
        pixel_scale : float
            The size of each pixel in arc seconds.
        psf_shape : (int, int)
            The shape of the PSF used in the analysis, which defines how much the grid's must be masked to mitigate \
            edge effects.
        sub_grid_size : int
            The size of a sub-pixel's sub-grid (sub_grid_size x sub_grid_size).


def new_grid_stack_with_pix_grid_added(self, pix_grid, regular_to_nearest_pix):

pix = PixGrid(arr=pix_grid, regular_to_nearest_pix=regular_to_nearest_pix)<EOL>return GridStack(regular=self.regular, sub=self.sub, blurring=self.blurring, pix=pix)<EOL>

Setup a grid-stack of grid_stack using an existing grid-stack.

        The new grid-stack has the same grid_stack (regular, sub, blurring, etc.) as before, but adds a pix-grid as a \
        new attribute.

        Parameters
        -----------
        pix_grid : ndarray
            The grid of (y,x) arc-second coordinates of every image-plane pixelization grid used for adaptive \
             pixelizations.
        regular_to_nearest_pix : ndarray
            A 1D array that maps every regular-grid pixel to its nearest pix-grid pixel.


if self.blurring is not None and self.pix is not None:<EOL><INDENT>return GridStack(func(self.regular), func(self.sub), func(self.blurring), func(self.pix))<EOL><DEDENT>elif self.blurring is None and self.pix is not None:<EOL><INDENT>return GridStack(func(self.regular), func(self.sub), self.blurring, func(self.pix))<EOL><DEDENT>elif self.blurring is not None and self.pix is None:<EOL><INDENT>return GridStack(func(self.regular), func(self.sub), func(self.blurring), self.pix)<EOL><DEDENT>else:<EOL><INDENT>return GridStack(func(self.regular), func(self.sub), self.blurring, self.pix)<EOL><DEDENT>

Apply a function to all grid_stack in the grid-stack.

        This is used by the *ray-tracing* module to easily apply tracing operations to all grid_stack.


def map_function(self, func, *arg_lists):

return GridStack(*[func(*args) for args in zip(self, *arg_lists)])<EOL>

Map a function to all grid_stack in a grid-stack