Example #1
0
def source_model_on_subplot(fit, plane_index, number_subplots, subplot_index,
                            include, sub_plotter):

    if not fit.tracer.planes[plane_index].has_pixelization:

        sub_plotter.setup_subplot(number_subplots=number_subplots,
                                  subplot_index=subplot_index)

        traced_grids = fit.tracer.traced_grids_of_planes_from_grid(
            grid=fit.grid)

        plane_plots.plane_image(
            plane=fit.tracer.planes[plane_index],
            grid=traced_grids[plane_index],
            positions=include.positions_of_plane_from_fit_and_plane_index(
                fit=fit, plane_index=plane_index),
            caustics=include.caustics_from_obj(obj=fit.tracer),
            include=include,
            plotter=sub_plotter,
        )

    elif fit.tracer.planes[plane_index].has_pixelization:

        ratio = float((fit.inversion.mapper.grid.scaled_maxima[1] -
                       fit.inversion.mapper.grid.scaled_minima[1]) /
                      (fit.inversion.mapper.grid.scaled_maxima[0] -
                       fit.inversion.mapper.grid.scaled_minima[0]))

        if sub_plotter.figure.aspect in "square":
            aspect_inv = ratio
        elif sub_plotter.figure.aspect in "auto":
            aspect_inv = 1.0 / ratio
        elif sub_plotter.figure.aspect in "equal":
            aspect_inv = 1.0

        sub_plotter.setup_subplot(
            number_subplots=number_subplots,
            subplot_index=subplot_index,
            aspect=float(aspect_inv),
        )

        inversion_plots.reconstruction(
            inversion=fit.inversion,
            source_positions=include.
            positions_of_plane_from_fit_and_plane_index(
                fit=fit, plane_index=plane_index),
            caustics=include.caustics_from_obj(obj=fit.tracer),
            include=include,
            plotter=sub_plotter,
        )
Example #2
0
def subplot_of_plane(fit, plane_index, include=None, sub_plotter=None):
    """Plot the model datas_ of an analysis, using the *Fitter* class object.

    The visualization and output type can be fully customized.

    Parameters
    -----------
    fit : autolens.lens.fitting.Fitter
        Class containing fit between the model datas_ and observed lens datas_ (including residual_map, chi_squared_map etc.)
    output_path : str
        The path where the datas_ is output if the output_type is a file format (e.g. png, fits)
    output_filename : str
        The name of the file that is output, if the output_type is a file format (e.g. png, fits)
    output_format : str
        How the datas_ is output. File formats (e.g. png, fits) output the datas_ to harddisk. 'show' displays the datas_ \
        in the python interpreter window.
    """

    number_subplots = 4

    sub_plotter = sub_plotter.plotter_with_new_output(
        filename=sub_plotter.output.filename + "_" + str(plane_index))

    sub_plotter.open_subplot_figure(number_subplots=number_subplots)

    sub_plotter.setup_subplot(number_subplots=number_subplots, subplot_index=1)

    image(fit=fit, include=include, plotter=sub_plotter)

    sub_plotter.setup_subplot(number_subplots=number_subplots, subplot_index=2)

    subtracted_image_of_plane(fit=fit,
                              plane_index=plane_index,
                              include=include,
                              plotter=sub_plotter)

    sub_plotter.setup_subplot(number_subplots=number_subplots, subplot_index=3)

    model_image_of_plane(fit=fit,
                         plane_index=plane_index,
                         include=include,
                         plotter=sub_plotter)

    if not fit.tracer.planes[plane_index].has_pixelization:

        sub_plotter.setup_subplot(number_subplots=number_subplots,
                                  subplot_index=4)

        traced_grids = fit.tracer.traced_grids_of_planes_from_grid(
            grid=fit.grid)

        plane_plots.plane_image(
            plane=fit.tracer.planes[plane_index],
            grid=traced_grids[plane_index],
            positions=include.positions_of_plane_from_fit_and_plane_index(
                fit=fit, plane_index=plane_index),
            caustics=include.caustics_from_obj(obj=fit.tracer),
            include=include,
            plotter=sub_plotter,
        )

    elif fit.tracer.planes[plane_index].has_pixelization:

        ratio = float((fit.inversion.mapper.grid.scaled_maxima[1] -
                       fit.inversion.mapper.grid.scaled_minima[1]) /
                      (fit.inversion.mapper.grid.scaled_maxima[0] -
                       fit.inversion.mapper.grid.scaled_minima[0]))

        if sub_plotter.figure.aspect in "square":
            aspect_inv = ratio
        elif sub_plotter.figure.aspect in "auto":
            aspect_inv = 1.0 / ratio
        elif sub_plotter.figure.aspect in "equal":
            aspect_inv = 1.0

        sub_plotter.setup_subplot(number_subplots=number_subplots,
                                  subplot_index=4,
                                  aspect=float(aspect_inv))

        inversion_plots.reconstruction(
            inversion=fit.inversion,
            source_positions=include.
            positions_of_plane_from_fit_and_plane_index(
                fit=fit, plane_index=plane_index),
            caustics=include.caustics_from_obj(obj=fit.tracer),
            include=include,
            plotter=sub_plotter,
        )

    sub_plotter.output.subplot_to_figure()

    sub_plotter.figure.close()
Example #3
0
def individuals(
    fit,
    plot_image=False,
    plot_noise_map=False,
    plot_signal_to_noise_map=False,
    plot_model_image=False,
    plot_residual_map=False,
    plot_normalized_residual_map=False,
    plot_chi_squared_map=False,
    plot_subtracted_images_of_planes=False,
    plot_model_images_of_planes=False,
    plot_plane_images_of_planes=False,
    include=None,
    plotter=None,
):
    """Plot the model datas_ of an analysis, using the *Fitter* class object.

    The visualization and output type can be fully customized.

    Parameters
    -----------
    fit : autolens.lens.fitting.Fitter
        Class containing fit between the model datas_ and observed lens datas_ (including residual_map, chi_squared_map etc.)
    output_path : str
        The path where the datas_ is output if the output_type is a file format (e.g. png, fits)
    output_format : str
        How the datas_ is output. File formats (e.g. png, fits) output the datas_ to harddisk. 'show' displays the datas_ \
        in the python interpreter window.
    """

    if plot_image:

        image(fit=fit, include=include, plotter=plotter)

    if plot_noise_map:

        noise_map(fit=fit, include=include, plotter=plotter)

    if plot_signal_to_noise_map:

        signal_to_noise_map(fit=fit, include=include, plotter=plotter)

    if plot_model_image:

        model_image(fit=fit, include=include, plotter=plotter)

    if plot_residual_map:

        residual_map(fit=fit, include=include, plotter=plotter)

    if plot_normalized_residual_map:

        normalized_residual_map(fit=fit, include=include, plotter=plotter)

    if plot_chi_squared_map:

        chi_squared_map(fit=fit, include=include, plotter=plotter)

    if plot_subtracted_images_of_planes:

        for plane_index in range(fit.tracer.total_planes):

            subtracted_image_of_plane(fit=fit,
                                      plane_index=plane_index,
                                      include=include,
                                      plotter=plotter)

    if plot_model_images_of_planes:

        for plane_index in range(fit.tracer.total_planes):

            model_image_of_plane(fit=fit,
                                 plane_index=plane_index,
                                 include=include,
                                 plotter=plotter)

    if plot_plane_images_of_planes:

        for plane_index in range(fit.tracer.total_planes):

            plotter = plotter.plotter_with_new_output(
                filename="plane_image_of_plane_" + str(plane_index))

            if fit.tracer.planes[plane_index].has_light_profile:

                plane_plots.plane_image(
                    plane=fit.tracer.planes[plane_index],
                    grid=include.traced_grid_of_plane_from_fit_and_plane_index(
                        fit=fit, plane_index=plane_index),
                    positions=include.
                    positions_of_plane_from_fit_and_plane_index(
                        fit=fit, plane_index=plane_index),
                    caustics=include.caustics_from_obj(obj=fit.tracer),
                    include=include,
                    plotter=plotter,
                )

            elif fit.tracer.planes[plane_index].has_pixelization:

                inversion_plots.reconstruction(
                    inversion=fit.inversion,
                    source_positions=include.
                    positions_of_plane_from_fit_and_plane_index(
                        fit=fit, plane_index=plane_index),
                    caustics=include.caustics_from_obj(obj=fit.tracer),
                    include=include,
                    plotter=plotter,
                )