def test_colormap_hess(): transition = 0.5 cmap = colormap_hess(transition=transition) vals = [ (0, (0.0, 0.0, 0.0)), (0.25, (0.0, 0.0, 0.50196078)), (0.5, (1.0, 0.0058823529411764722, 0.0)), (0.75, (1.0, 0.75882352941176501, 0.0)), (1, (1.0, 1.0, 1.0)), ] _check_cmap_rgb_vals(vals, cmap)
""" import numpy as np import matplotlib.pyplot as plt from astropy.visualization.mpl_normalize import ImageNormalize from astropy.visualization import LinearStretch from gammapy.image import colormap_hess, colormap_milagro from gammapy.maps import Map filename = '$GAMMAPY_EXTRA/test_datasets/unbundled/poisson_stats_image/expected_ts_0.000.fits.gz' image = Map.read(filename, hdu='SQRT_TS') # Plot with the HESS and Milagro colormap vmin, vmax, vtransition = -5, 15, 5 fig = plt.figure(figsize=(15.5, 6)) normalize = ImageNormalize(vmin=vmin, vmax=vmax, stretch=LinearStretch()) transition = normalize(vtransition) ax = fig.add_subplot(121, projection=image.geom.wcs) cmap = colormap_hess(transition=transition) image.plot(ax=ax, cmap=cmap, norm=normalize, add_cbar=True) plt.title('HESS-style colormap') ax = fig.add_subplot(122, projection=image.geom.wcs) cmap = colormap_milagro(transition=transition) image.plot(ax=ax, cmap=cmap, norm=normalize, add_cbar=True) plt.title('MILAGRO-style colormap') plt.tight_layout() plt.show()
from astropy.visualization import LinearStretch # Compute an example significance image counts = load_poisson_stats_image() counts = disk_correlate(counts, radius=5, mode='reflect') background = np.median(counts) * np.ones_like(counts) image = significance(counts, background) # Plot with the HESS and Milagro colormap vmin, vmax, vtransition = -5, 15, 5 plt.figure(figsize=(8, 4)) normalize = ImageNormalize(vmin=vmin, vmax=vmax, stretch=LinearStretch()) transition = normalize(vtransition) plt.subplot(121) cmap = colormap_hess(transition=transition) plt.imshow(image, cmap=cmap, norm=normalize) plt.axis('off') plt.colorbar() plt.title('HESS-style colormap') plt.subplot(122) cmap = colormap_milagro(transition=transition) plt.imshow(image, cmap=cmap, norm=normalize) plt.axis('off') plt.colorbar() plt.title('MILAGRO-style colormap') plt.show()
from gammapy.datasets import load_poisson_stats_image from gammapy.image import disk_correlate from gammapy.stats import significance from gammapy.image import colormap_hess, colormap_milagro # Compute an example significance image counts = load_poisson_stats_image() counts = disk_correlate(counts, radius=5, mode='reflect') background = np.median(counts) * np.ones_like(counts) image = significance(counts, background) # Plot with the HESS and Milagro colormap vmin, vmax, vtransition = -5, 15, 5 plt.figure(figsize=(8, 4)) plt.subplot(121) cmap = colormap_hess(vtransition=vtransition, vmin=vmin, vmax=vmax) plt.imshow(image, cmap=cmap, vmin=vmin, vmax=vmax) plt.axis('off') plt.colorbar() plt.title('HESS-style colormap') plt.subplot(122) cmap = colormap_milagro(vtransition=vtransition, vmin=vmin, vmax=vmax) plt.imshow(image, cmap=cmap, vmin=vmin, vmax=vmax) plt.axis('off') plt.colorbar() plt.title('MILAGRO-style colormap') plt.show()
from gammapy.image import colormap_hess, illustrate_colormap import matplotlib.pyplot as plt cmap = colormap_hess() illustrate_colormap(cmap) plt.show()