示例#1
0
    def test_lensModelPlot(self):
        multi_band_list = [[
            self.kwargs_data, self.kwargs_psf, self.kwargs_numerics
        ]]
        lensPlot = ModelPlot(multi_band_list,
                             self.kwargs_model,
                             self.kwargs_params,
                             arrow_size=0.02,
                             cmap_string="gist_heat",
                             multi_band_type='single-band')

        lensPlot.plot_main(with_caustics=True)
        plt.close()
        cmap = plt.get_cmap('gist_heat')

        lensPlot = ModelPlot(multi_band_list,
                             self.kwargs_model,
                             self.kwargs_params,
                             arrow_size=0.02,
                             cmap_string=cmap)

        lensPlot.plot_separate()
        plt.close()
        lensPlot.plot_subtract_from_data_all()
        plt.close()
        f, ax = plt.subplots(1, 1, figsize=(4, 4))
        lensPlot.deflection_plot(ax=ax, with_caustics=True, axis=1)
        plt.close()

        f, ax = plt.subplots(1, 1, figsize=(4, 4))
        lensPlot.subtract_from_data_plot(ax=ax)
        plt.close()

        f, ax = plt.subplots(1, 1, figsize=(4, 4))
        lensPlot.deflection_plot(ax=ax, with_caustics=True, axis=0)
        plt.close()

        numPix = 100
        deltaPix_source = 0.01
        f, ax = plt.subplots(1, 1, figsize=(4, 4))
        lensPlot.error_map_source_plot(ax=ax,
                                       numPix=numPix,
                                       deltaPix_source=deltaPix_source,
                                       with_caustics=True)
        plt.close()

        f, ax = plt.subplots(1, 1, figsize=(4, 4))
        lensPlot.absolute_residual_plot(ax=ax)
        plt.close()

        f, ax = plt.subplots(1, 1, figsize=(4, 4))
        lensPlot.plot_extinction_map(ax=ax)
        plt.close()
            mcmc_new_list.append([gamma, D_dt, cal_h0(z_l, z_s, D_dt)])
        pickle.dump([
            multi_band_list, kwargs_model, kwargs_result, chain_list,
            fix_setting, mcmc_new_list
        ], open(folder + savename, 'wb'))
    #%%Print fitting result:
    multi_band_list, kwargs_model, kwargs_result, chain_list, fix_setting, mcmc_new_list = pickle.load(
        open(folder + savename, 'rb'))
    fixed_lens, fixed_source, fixed_lens_light, fixed_ps, fixed_cosmo = fix_setting
    labels_new = [r"$\gamma$", r"$D_{\Delta t}$", "H$_0$"]
    modelPlot = ModelPlot(multi_band_list,
                          kwargs_model,
                          kwargs_result,
                          arrow_size=0.02,
                          cmap_string="gist_heat")
    f, axes = modelPlot.plot_main()
    f.show()
    # f, axes = modelPlot.plot_separate()
    # f.show()
    # f, axes = modelPlot.plot_subtract_from_data_all()
    # f.show()

    for i in range(len(chain_list)):
        chain_plot.plot_chain_list(chain_list, i)
    plt.show()

    truths = [para_s[0][0]['gamma'], TD_distance, 73.907]
    plot = corner.corner(
        mcmc_new_list,
        labels=labels_new,
        show_titles=