def plot(self, show=True, fit=True, analyze=True, xsubplot=0): """Plot the azimuthal distributions for all the energy bins. """ if analyze: fit = True for i, _emean in enumerate(self.emean): if xsubplot == 0: plt.figure() else: plt.subplot(len(self.emean), xsubplot + 1, (xsubplot + 1)*(i + 1)) self.plot_bin(i, False, False) if fit: _res = self.fit_bin(i) _res.plot(color=xpColor(i)) if analyze: fig = plt.figure('Polarization degree vs. energy') self.plot_polarization_degree(show=False) fig = plt.figure('Polarization angle vs. energy') self.plot_polarization_angle(show=False) if show: plt.show()
def plot(self, show=True, fit=True, analyze=True, xsubplot=0): """Plot the azimuthal distributions for all the energy bins. """ if analyze: fit = True for i, _emean in enumerate(self.emean): if xsubplot == 0: plt.figure() else: plt.subplot(len(self.emean), xsubplot + 1, (xsubplot + 1) * (i + 1)) self.plot_bin(i, False, False) if fit: _res = self.fit_bin(i) _res.plot(color=xpColor(i)) if analyze: fig = plt.figure('Polarization degree vs. energy') self.plot_polarization_degree(show=False) fig = plt.figure('Polarization angle vs. energy') self.plot_polarization_angle(show=False) if show: plt.show()
def plot(save=False): logger.info('Plotting stuff...') pipeline.xpbin(evt_file_path, algorithm='CMAP', outfile=map_file_path) regions = pyregion.open(reg_file_path) full_map = xBinnedMap(map_file_path) fig_all = full_map.plot(show=False) for i, region in enumerate(regions): ra, dec, rad = region.coord_list #fig_all.show_circles(ra, dec, rad, lw=1) fig = full_map.plot(show=False, subplot=(1, 2, 1)) plt.subplots_adjust(hspace=0.001) fig.show_circles(ra, dec, rad, lw=1) mcube_file_path = get_mcube_file_path(i) mcube = xBinnedModulationCube(mcube_file_path) mcube.plot(show=False, analyze=False, xsubplot=1) scale_x = rad/numpy.cos(numpy.deg2rad(dec)) # This is to take into account the effect of the projection. scale_y = rad for j,fit in enumerate(mcube.fit_results): angle = fit.phase angle_error = fit.phase_error degree = fit.polarization_degree #nangles=20 #for t in range(nangles): # dx = scale_x*numpy.cos(numpy.pi*2.0*t/float(nangles))#angle) # dy = scale_y*numpy.sin(numpy.pi*2.0*t/float(nangles))#angle) # fig.show_arrows(ra, dec, dx, dy, color='w', alpha=1, width=1,head_width=0, head_length=0) # pass dx = scale_x*numpy.cos(angle) dy = scale_y*numpy.sin(angle) dx1 = scale_x*degree*numpy.cos(angle+angle_error) dy1 = scale_y*degree*numpy.sin(angle+angle_error) dx2 = scale_x*degree*numpy.cos(angle-angle_error) dy2 = scale_y*degree*numpy.sin(angle-angle_error) fig.show_arrows(ra, dec, dx, dy, color=xpColor(j), alpha=1, linestyle='dashed', width=0.2,head_width=0, head_length=0) fig.show_arrows(ra, dec, -dx, -dy, color=xpColor(j), alpha=1, linestyle='dashed', width=0.2,head_width=0, head_length=0) fig.show_arrows(ra, dec, dx1, dy1, color=xpColor(j), alpha=1, width=1,head_width=0, head_length=0) fig.show_arrows(ra, dec, -dx1, -dy1, color=xpColor(j), alpha=1, width=1,head_width=0, head_length=0) fig.show_arrows(ra, dec, dx2, dy2, color=xpColor(j), alpha=1, width=1,head_width=0, head_length=0) fig.show_arrows(ra, dec, -dx2, -dy2, color=xpColor(j), alpha=1, width=1,head_width=0, head_length=0) fig_all.show_arrows(ra, dec, dx, dy, color=xpColor(j), alpha=1, linestyle='dashed', width=0.2,head_width=0, head_length=0) fig_all.show_arrows(ra, dec, -dx, -dy, color=xpColor(j), alpha=1, linestyle='dashed', width=0.2,head_width=0, head_length=0) fig_all.show_arrows(ra, dec, dx1, dy1, color=xpColor(j), alpha=1, width=1,head_width=0, head_length=0) fig_all.show_arrows(ra, dec, -dx1, -dy1, color=xpColor(j), alpha=1, width=1,head_width=0, head_length=0) fig_all.show_arrows(ra, dec, dx2, dy2, color=xpColor(j), alpha=1, width=1,head_width=0, head_length=0) fig_all.show_arrows(ra, dec, -dx2, -dy2, color=xpColor(j), alpha=1, width=1,head_width=0, head_length=0) if save: fig.save(mcube_file_path.replace('.fits', '.png')) plt.clf() else: plt.show() pass fig_all.save(os.path.join(XIMPOL_DATA, 'tycho_reg_all.png'))