def test_chain_list(self): param = ['a', 'b'] X2_list = [1, 1, 2] pos_list = [[1, 0], [2, 0], [3, 0]] vel_list = [[-1, 0], [0, 0], [1, 0]] chain = X2_list, pos_list, vel_list, None samples_mcmc = np.random.random((10, 1000)) dist_mcmc = np.random.random(1000) chain_list = [['PSO', chain, param], ['COSMOHAMMER', samples_mcmc, param, dist_mcmc], ['EMCEE', samples_mcmc, param], ['MULTINEST', samples_mcmc, param, dist_mcmc]] output_plots.plot_chain_list(chain_list, index=0) plt.close() output_plots.plot_chain_list(chain_list, index=1, num_average=10) plt.close() output_plots.plot_chain_list(chain_list, index=2, num_average=10) plt.close() output_plots.plot_chain_list(chain_list, index=3, num_average=10) plt.close()
mcmc_new_list = np.asarray(mcmc_new_list) idx = 1 #The translated flux for the host v_l = np.percentile(mcmc_new_list[:, idx], 16, axis=0) v_m = np.percentile(mcmc_new_list[:, idx], 50, axis=0) v_h = np.percentile(mcmc_new_list[:, idx], 84, axis=0) #print labels_new[idx], ":", v_l, v_m, v_h print "The inferred", labels_new[idx], "mag:" print "lower limit:", -2.5 * np.log10(v_h) + zp print "The mid fit:", -2.5 * np.log10(v_m) + zp print "upper limit", -2.5 * np.log10(v_l) + zp #%% print "Check the convergency of the PSO chains:" import lenstronomy.Plots.output_plots as out_plot for i in range(len(chain_list)): f, axes = out_plot.plot_chain_list(chain_list, 0) plt.show() #%%test the MCMC chain convergency # #import lenstronomy.Plots.output_plots as plot_mcmc_behaviour fig = plt.figure(figsize=(20, 15)) ax = fig.add_subplot(111) out_plot.plot_mcmc_behaviour(ax, samples_mcmc, param_mcmc, dist_mcmc) plt.show() #%% Plot the image again: band_seq = ['G', 'R', 'I', 'Z', 'Y'] filename = galaxy_ID + '_HSC-{0}.fits'.format(band) sub_bkg = True from flux_profile import galaxy_total_compare
def test_raise(self): with self.assertRaises(ValueError): kwargs_data = sim_util.data_configure_simple(numPix=10, deltaPix=1, sigma_bkg=1) #kwargs_data['image_data'] = np.zeros((10, 10)) kwargs_model = {'source_light_model_list': ['GAUSSIAN']} kwargs_params = { 'kwargs_lens': [], 'kwargs_source': [{ 'amp': 1, 'sigma_x': 1, 'sigma_y': 1, 'center_x': 0, 'center_y': 0 }], 'kwargs_ps': [], 'kwargs_lens_light': [] } lensPlot = ModelPlot( multi_band_list=[[kwargs_data, { 'psf_type': 'NONE' }, {}]], kwargs_model=kwargs_model, kwargs_params=kwargs_params, arrow_size=0.02, cmap_string="gist_heat") f, ax = plt.subplots(1, 1, figsize=(4, 4)) ax = lensPlot.source_plot(ax=ax, numPix=10, deltaPix_source=0.1, v_min=None, v_max=None, with_caustics=False, caustic_color='yellow', fsize=15, plot_scale='bad') plt.close() with self.assertRaises(ValueError): kwargs_data = sim_util.data_configure_simple(numPix=10, deltaPix=1, sigma_bkg=1) # kwargs_data['image_data'] = np.zeros((10, 10)) kwargs_model = {'source_light_model_list': ['GAUSSIAN']} kwargs_params = { 'kwargs_lens': [], 'kwargs_source': [{ 'amp': 1, 'sigma_x': 1, 'sigma_y': 1, 'center_x': 0, 'center_y': 0 }], 'kwargs_ps': [], 'kwargs_lens_light': [] } lensPlot = ModelPlot( multi_band_list=[[kwargs_data, { 'psf_type': 'NONE' }, {}]], kwargs_model=kwargs_model, kwargs_params=kwargs_params, bands_compute=[False], arrow_size=0.02, cmap_string="gist_heat") lensPlot._select_band(band_index=0) with self.assertRaises(ValueError): output_plots.plot_chain_list(chain_list=[['WRONG']], index=0)