def updatePlots(self, model, reset=False): bulge_flux, disk_flux = create_model_images(model, self.flux.shape, self.psf) model_flux = bulge_flux + disk_flux x0 = model.x0.value - 1.0 y0 = model.y0.value - 1.0 pa, ell = ellipse_params(self.flux, x0, y0) pa = (90.0 + pa) * np.pi / 180.0 ba = 1.0 - ell bins = np.arange(30) r = bins[:-1] + 0.5 obs_r = radialProfile(self.flux, bins, x0, y0, pa, ba, rad_scale=1.0) obs_r = np.log10(obs_r) mod_r = radialProfile(model_flux, bins, x0, y0, pa, ba, rad_scale=1.0) mod_r = np.log10(mod_r) bulge_r = radialProfile(bulge_flux, bins, x0, y0, pa, ba, rad_scale=1.0) bulge_r = np.log10(bulge_r) disk_r = radialProfile(disk_flux, bins, x0, y0, pa, ba, rad_scale=1.0) disk_r = np.log10(disk_r) obs_im = np.log10(self.flux) mod_im = np.log10(model_flux) res_im = obs_im - mod_im if reset: self.plotPanel.reset(self.plotTitle, obs_im, mod_im, res_im, r, obs_r, mod_r, bulge_r, disk_r) else: self.plotPanel.update(obs_im, mod_im, res_im, r, obs_r, mod_r, bulge_r, disk_r)
plt.colorbar(im, ax=ax) ax.set_xticks([]) ax.set_yticks([]) ax.set_title(u'Resíduo') ax = plt.subplot(gs[1,:]) bins = np.arange(0, 32) bins_c = bins[:-1] y0 = initial_model.y0.value - 1 x0 = initial_model.x0.value - 1 pa_i, ell_i = ellipse_params(total_im, x0, y0) pa_i = (90.0 + pa_i) * np.pi / 180.0 ba_i = 1.0 - ell_i tr = radialProfile(np.log10(total_im), bins, x0, y0, pa_i, ba_i) mr = radialProfile(np.log10(model_im), bins, x0, y0, pa_i, ba_i) br = radialProfile(np.log10(bulge_model_im), bins, x0, y0, pa_i, ba_i) dr = radialProfile(np.log10(disk_model_im), bins, x0, y0, pa_i, ba_i) ax.plot(bins_c, tr, 'k-', label='Observado') ax.plot(bins_c, mr, 'k--', label='Modelo') ax.plot(bins_c, br, 'r-', label='Bojo') ax.plot(bins_c, dr, 'b-', label='Disco') ax.set_xlabel(r'Raio $[\mathrm{arcsec}]$') ax.set_ylabel(r'$\log$ Fluxo') ax.set_xlim(0.0, 20.0) ax.set_ylim(-17.5, -15.5) ax.legend(loc='upper right', frameon=False) plt.suptitle(r'Modelo ajustado em $5635\,\mathrm{\AA}$ - %s (%s)' % (galaxyId, galaxyName))
ax = plt.subplot(gs[0,2]) residual = f - model_f #res_max = max(np.abs(np.min(residual)), np.max(residual)) im = ax.imshow(residual[yslice, xslice], vmin=-0.35, vmax=0.35, cmap='RdBu') plt.colorbar(im, ax=ax) ax.set_title('residual') bins = np.arange(0, imradius) bins_c = bins[:-1] pa = _fitmodel.psf.PA.value ell = _fitmodel.psf.ell.value pa, ell = fix_PA_ell(pa, ell) pa = np.pi * (pa + 90) / 180.0 ba = 1.0 - ell f_r = radialProfile(f, bins, _fitmodel.x0.value - 1, _fitmodel.y0.value - 1, pa, ba) err_r = radialProfile(f, bins, _fitmodel.x0.value - 1, _fitmodel.y0.value - 1, pa, ba, mode='std') model_f_r = radialProfile(model_f, bins, _fitmodel.x0.value - 1, _fitmodel.y0.value - 1, pa, ba) residual_r = radialProfile(f - model_f, bins, _fitmodel.x0.value - 1, _fitmodel.y0.value - 1, pa, ba) if func == 'Gaussian': fwhm = sigma2fwhm * _fitmodel.psf.sigma.value else: fwhm = _fitmodel.psf.fwhm.value ax = plt.subplot(gs[1,:]) ax.errorbar(bins_c, f_r, err_r, linestyle='-', color='k', ecolor='k', label='original') ax.plot(bins_c, model_f_r, 'k--', label='model') ax.plot(bins_c, residual_r, 'k:', label='residual') ax.vlines(fwhm / 2, -0.1, 1.2, linestyles='dashdot') ax.text(fwhm / 2 + 0.1, f_r.max() / 2 + 0.1, 'FWHM = %.3f "' % fwhm)
def rad_prof(model, bins): imfit = Imfit(model, quiet=False) image = imfit.getModelImage((model.y0.value * 2, model.x0.value * 2)) return radialProfile(image, bins, x0, y0, pa=0.0, ba=1.0)
ax.set_yticks([]) ax.set_title(r'Bulge') ax = plt.subplot(gs[0,2]) ax.imshow(np.log10(disk_image), vmin=vmin, vmax=vmax) ax.set_xticks([]) ax.set_yticks([]) ax.set_title(r'Disk') ax = plt.subplot(gs[1,:2]) bins = np.arange(0, 32) bins_c = bins[:-1] + 0.5 pa, ell = ellipse_params(full_image, norm_x0, norm_y0) pa = (90.0 + pa) * np.pi / 180.0 ba = 1.0 - ell mr = radialProfile(np.log10(full_image), bins, norm_x0, norm_y0, pa, ba) br = radialProfile(np.log10(bulge_image), bins, norm_x0, norm_y0, pa, ba) dr = radialProfile(np.log10(disk_image), bins, norm_x0, norm_y0, pa, ba) ax.plot(bins_c, mr, 'k-', label='Total') ax.plot(bins_c, br, 'r-', label='Bulge') ax.plot(bins_c, dr, 'b-', label='Disk') ax.set_xlabel(r'Radius [arcsec]') ax.set_ylabel(r'$\log$ flux (relative)') ax.set_xlim(0.0, 30.0) ax.set_ylim(-1.0, 1.1) ax.legend(loc='upper right') ax = plt.subplot(gs[1,2]) im = ax.imshow(tau_image / 1e9) plt.colorbar(im, ax=ax) ax.set_xticks([])
ax.imshow(np.log10(bulge_image[index_norm]), vmin=vmin, vmax=vmax) ax.set_xticks([]) ax.set_yticks([]) ax.set_title(r'Bulge') ax = plt.subplot(gs[0,2]) ax.imshow(np.log10(disk_image[index_norm]), vmin=vmin, vmax=vmax) ax.set_xticks([]) ax.set_yticks([]) ax.set_title(r'Disk') ax = plt.subplot(gs[1,:]) bins = np.arange(0, 32) bins_c = bins[:-1] + 0.5 pa, ba = ellipse_params(model_image[index_norm], norm_x0, norm_y0) mr = radialProfile(np.log10(model_image[index_norm]), bins, norm_x0, norm_y0, pa, ba) br = radialProfile(np.log10(bulge_image[index_norm]), bins, norm_x0, norm_y0, pa, ba) dr = radialProfile(np.log10(disk_image[index_norm]), bins, norm_x0, norm_y0, pa, ba) ax.plot(bins_c, mr, 'k-', label='Total') ax.plot(bins_c, br, 'r-', label='Bulge') ax.plot(bins_c, dr, 'b-', label='Disk') ax.set_xlabel(r'Radius [arcsec]') ax.set_ylabel(r'$\log$ flux (relative)') ax.set_xlim(0.0, 30.0) ax.set_ylim(-1.0, 1.1) ax.legend(loc='upper right') norm_I_e = norm_model.bulge.I_e.value norm_r_e = norm_model.bulge.r_e.value norm_n = norm_model.bulge.n.value norm_I_0 = norm_model.disk.I_0.value
plt.colorbar() plt.show() plt.ioff() plt.clf() plt.imshow(psfflux[i_plot] - psfbg[i_plot]) plt.colorbar() plt.show() bins = np.arange(0, psfradius) bins_c = bins[:-1] + 0.5 y0 = psfradius x0 = psfradius pa = 90.0 ba = 1.0 flux_r = radialProfile(psfflux[i_plot], bins, x0, y0, pa, ba) bg_r = radialProfile(psfbg[i_plot], bins, x0, y0, pa, ba) flux_bg_r = radialProfile(psfflux[i_plot] - psfbg[i_plot], bins, x0, y0, pa, ba) plt.clf() plt.plot(bins_c, flux_r) plt.plot(bins_c, flux_bg_r) plt.plot(bins_c, bg_r) plt.show() psf_func = function_description(func, 'psf') psf_func.PA.setValue(0.0, vmin=-190, vmax=190) psf_func.ell.setValue(0.2, vmin=-1.0, vmax=1.0) psf_func.I_0.setValue(1.0, vmin=1e-20, vmax=10.0) if func == 'Gaussian': psf_func.sigma.setValue(1.0, vmin=1e-20, vmax=20.0)
im = ax.imshow(residual[yslice, xslice] / norm, vmin=-0.35, vmax=0.35, cmap='RdBu') ax.set_xticklabels([]) ax.set_yticklabels([]) plt.colorbar(im, ax=ax) ax.set_title(u'Resíduo') bins = np.arange(0, imradius) bins_c = bins[:-1] pa = fitmodel.psf.PA.value ell = fitmodel.psf.ell.value pa, ell = fix_PA_ell(pa, ell) pa = np.pi * (pa + 90) / 180.0 ba = 1.0 - ell x0 = fitmodel.x0.value - 1 y0 = fitmodel.y0.value - 1 f_r = radialProfile(flux[i] / norm, bins, x0, y0, pa, ba) err_r = radialProfile(flux[i] / norm, bins, x0, y0, pa, ba, mode='std') model_f_r = radialProfile(modelimage / norm, bins, x0, y0, pa, ba) residual_r = radialProfile(residual / norm, bins, x0, y0, pa, ba) if func == 'Gaussian': fwhm = sigma2fwhm * fitmodel.psf.sigma.value else: fwhm = fitmodel.psf.fwhm.value ax = plt.subplot(gs[1,:]) ax.errorbar(bins_c, f_r, err_r, linestyle='-', color='k', ecolor='k', label='Observado') ax.plot(bins_c, model_f_r, 'k--', label='Modelo') ax.plot(bins_c, residual_r, 'k:', label=u'Resíduo') ax.vlines(fwhm / 2, -0.1, 1.2, linestyles='dashdot') ax.text(fwhm / 2 + 0.1, f_r.max() / 2 + 0.1, '$\mathrm{FWHM} = %.3f\,^{\prime\prime}$' % fwhm)