def plot_doc(): """ """ img = xFITSImage(os.path.join(XIMPOL_DATA, 'crab_complex_cmap.fits')) fig = img.plot(show=False) xFITSImage.add_label(fig, 'XIPE %d ks' %DURATION/1000.) plt.show()
def plot_doc(): """ """ img = xFITSImage(os.path.join(XIMPOL_DATA, 'tycho_cmap.fits')) fig = img.plot(show=False) xFITSImage.add_label(fig, 'XIPE 300 ks') plt.show()
def test_vignetting(self): """ """ from ximpol import XIMPOL_CONFIG file_path = os.path.join(XIMPOL_CONFIG, 'fits', 'casa_1p5_3p0_keV.fits') aeff = load_arf(DEFAULT_IRF_NAME) image = xFITSImage(file_path)
def plot_ymap(self, overlay=True): """Plot the y polarization map. """ if self.y_img is None: self.y_img = xFITSImage(self.ymap_file_path, build_cdf=False) fig = self.y_img.plot(show=False) if overlay: self.overlay_arrows(fig) return fig
def plot_ymap(self, overlay=True, show=False): """Plot the y polarization map. """ if self.y_img is None: self.y_img = xFITSImage(self.ymap_file_path, build_cdf=False) fig = self.y_img.plot(show=False, zlabel="Polarization degree (y)") if overlay: self.overlay_arrows(fig) if show: plt.show() return fig
def plot_doc(): """ """ img = xFITSImage(os.path.join(XIMPOL_DATA, 'casa_cmap.fits')) fig = img.plot(show=False) #Option to draw the psf circle on the count map RAD_PSF = 11/60. fig.show_circles(350.769, 58.873, RAD_PSF/60., lw=2, color='white') fig.add_label(0.73,0.90, 'PSF', relative=True, size='x-large', color='white', horizontalalignment='left') xFITSImage.add_label(fig, 'XIPE 250 ks') plt.show()
def __init__(self, name, img_file_path, energy_spectrum, polarization_degree, polarization_angle, column_density=0., redshift=0., min_validity_time=0., max_validity_time=DEFAULT_MAX_VALIDITY_TIME, identifier=None): """Constructor. """ xModelComponentBase.__init__(self, name, energy_spectrum, polarization_degree, polarization_angle, column_density, redshift, min_validity_time, max_validity_time, identifier) self.image = xFITSImage(img_file_path)
def plot_polarization_degree(self, show=True): """ """ import aplpy if self.x_img is None: self.x_img = xFITSImage(self.xmap_file_path, build_cdf=False) if self.y_img is None: self.y_img = xFITSImage(self.ymap_file_path, build_cdf=False) _data = numpy.sqrt(self.x_data ** 2 + self.y_data ** 2) hdu_list = [self.x_img.hdu_list[0].copy()] hdu_list[0].data = _data with context_no_grids(): fig = aplpy.FITSFigure(hdu_list[0], figure=plt.figure()) fig.add_grid() fig.show_colorscale(cmap="afmhot", vmin=None, vmax=None) fig.add_colorbar() fig.colorbar.set_axis_label_text("Polarization degree") if show: plt.show() return fig
def display(): """Display the source model. """ from ximpol.utils.matplotlib_ import pyplot as plt from ximpol.srcmodel.img import xFITSImage print(ROI_MODEL) fig = plt.figure('Energy spectrum') spectral_model_spline.plot(logy=True, show=False, label='Total') img = xFITSImage(img_file_path) img.plot(show=False) plt.show()
def plot(cmap_file): full_map = xBinnedMap(cmap_file) fig = full_map.plot(show=False) # fig.show_circles(RA, DEC, RAD/60., lw=1) fig.show_circles(RA_CORE, DEC_CORE, RAD_PSF / 60.0, lw=1, color="white") fig.show_circles(RA_JET, DEC_JET, RAD_PSF / 60.0, lw=1, color="white") fig.recenter(RA + 0.003, DEC, 1 / 60.0) fig.show_colorscale(stretch="linear", cmap="afmhot", vmin=80, vmax=1500) fig.add_label(0.1, 0.9, "XIPE 2 Ms", relative=True, size="xx-large", color="white", horizontalalignment="left") image = xFITSImage(IMAGE_FITS_PATH, build_cdf=False) fig2 = image.plot(show=False) fig2.recenter(RA + 0.003, DEC, 1 / 60.0) fig2.show_colorscale(stretch="log", cmap="afmhot", vmin=2, vmax=200) fig2.add_label( 0.1, 0.9, "Chandra 39.5 ks", relative=True, size="xx-large", color="white", horizontalalignment="left" ) fig.show_contour(IMAGE_FITS_PATH, levels=[6, 10, 20, 50, 100], colors="green", smooth=3)
def display(): """Display the source model. """ from ximpol.utils.matplotlib_ import pyplot as plt from ximpol.srcmodel.img import xFITSImage print(ROI_MODEL) fig = plt.figure('Energy spectrum') total_spectral_model.plot(logy=True, show=False, label='Total') nonthermal_spectral_model.plot(logy=True, show=False, label='Non-thermal') thermal_spectral_model.plot(logy=True, show=False, label='Thermal') plt.legend(bbox_to_anchor=(0.95, 0.95)) fig = thermal_component.image.plot(show=False) xFITSImage.add_label(fig, 'Chandra 1.5-3.0 keV') fig = nonthermal_component.image.plot(show=False) xFITSImage.add_label(fig, 'Chandra 4.0-6.0 keV') img = xFITSImage(he_img_file_path) fig = img.plot(show=False) polarization_map.build_grid_sample(ROI_MODEL.ra, ROI_MODEL.dec) polarization_map.overlay_arrows(fig) plt.show()
def display(): """Display the source model. """ from ximpol.utils.matplotlib_ import pyplot as plt from ximpol.srcmodel.img import xFITSImage print(ROI_MODEL) #fig = plt.figure('Energy spectrum') #for src in ROI_MODEL.values(): #src.energy_spectrum.plot(logy=True, show=False, label=src.name) #plt.legend(bbox_to_anchor=(0.95, 0.95)) # fig = thermal_component.image.plot(show=False) #xFITSImage.add_label(fig, 'Chandra 1.5-3.0 keV') #fig = nonthermal_component.image.plot(show=False) #xFITSImage.add_label(fig, 'Chandra 4.0-6.0 keV') img = xFITSImage(img_file_path) fig = img.plot(show=False) for polarization_map in polarization_maps: polarization_map.build_grid_sample(ROI_MODEL.ra, ROI_MODEL.dec,num_points=100) polarization_map.overlay_arrows(fig) plt.show()
self.overlay_arrows(fig) return fig def plot_ymap(self, overlay=True): """Plot the y polarization map. """ if self.y_img is None: self.y_img = xFITSImage(self.ymap_file_path, build_cdf=False) fig = self.y_img.plot(show=False) if overlay: self.overlay_arrows(fig) return fig if __name__ == '__main__': import os from ximpol import XIMPOL_CONFIG from ximpol.utils.matplotlib_ import pyplot as plt file_path_x = os.path.join(XIMPOL_CONFIG, 'fits', 'casa_pol_x.fits') file_path_y = os.path.join(XIMPOL_CONFIG, 'fits', 'casa_pol_y.fits') img_file_path = os.path.join(XIMPOL_CONFIG, 'fits', 'casa_1p5_3p0_keV.fits') polarization_map = xPolarizationMap(file_path_x, file_path_y) polarization_map.build_grid_sample(350.863, 58.815) polarization_map.plot_xmap() polarization_map.plot_ymap() img = xFITSImage(img_file_path) fig = img.plot(show=False) polarization_map.overlay_arrows(fig) plt.show()
if degrees: _data = numpy.degrees(_data) hdu_list = [self.x_img.hdu_list[0].copy()] hdu_list[0].data = _data with context_no_grids(): fig = aplpy.FITSFigure(hdu_list[0], figure=plt.figure()) fig.add_grid() fig.show_colorscale(cmap="afmhot", vmin=None, vmax=None) fig.add_colorbar() fig.colorbar.set_axis_label_text("Polarization angle") if show: plt.show() return fig if __name__ == "__main__": import os from ximpol import XIMPOL_CONFIG file_path_x = os.path.join(XIMPOL_CONFIG, "fits", "casa_pol_x.fits") file_path_y = os.path.join(XIMPOL_CONFIG, "fits", "casa_pol_y.fits") img_file_path = os.path.join(XIMPOL_CONFIG, "fits", "casa_1p5_3p0_keV.fits") polarization_map = xPolarizationMap(file_path_x, file_path_y) polarization_map.build_grid_sample(350.863, 58.815) polarization_map.plot_xmap() polarization_map.plot_ymap() img = xFITSImage(img_file_path) fig = img.plot(show=False) polarization_map.overlay_arrows(fig) plt.show()
def __init__(self, file_path): """Constructor. """ self.image = xFITSImage(file_path, build_cdf=False)