def make_fermi_data(): filename = '$GAMMAPY_EXTRA/datasets/fermi_survey/all.fits.gz' image = SkyImage.read(filename, hdu='COUNTS') background = SkyImage.read(filename, hdu='BACKGROUND') return dict(image=image, background=background)
def make_poisson_data(): from gammapy.datasets import load_poisson_stats_image filename = load_poisson_stats_image(return_filenames=True) image = SkyImage.read(filename=filename) background = SkyImage.read(filename=filename) background.data = np.ones_like(image.data, dtype=float) return dict(image=image, background=background)
def make_fermi_data(): import os filename = os.environ['GAMMAPY_EXTRA'] + '/datasets/fermi_survey/all.fits.gz' image = SkyImage.read(filename=filename, extname='COUNTS') background = SkyImage.read(filename=filename, extname='BACKGROUND') return dict(image=image, background=background)
def make_fermi_data(): import os filename = os.environ[ 'GAMMAPY_EXTRA'] + '/datasets/fermi_survey/all.fits.gz' image = SkyImage.read(filename=filename, extname='COUNTS') background = SkyImage.read(filename=filename, extname='BACKGROUND') return dict(image=image, background=background)
def mask_rxj1713(): filename = 'RXJ1713_above2TeV_2016.fits.gz' print('Reading {}'.format(filename)) image = SkyImage.read(filename) # The position from SIMBAD for "RX J1713.7-3946" and "SNR G347.3-00.5" # are offset by ~ 0.2 deg from the TeV shell center position # http://simbad.u-strasbg.fr/simbad/sim-id?Ident=SNR+G347.3-00.5 # SkyCoord.from_name('SNR G347.3-00.5') # Here we put the center position from TeVCat, which was taken from a HESS paper # http://tevcat.uchicago.edu/?mode=1&showsrc=84 region = CircleSkyRegion( center=SkyCoord(ra='17h13m33.6s', dec='-39d45m36s'), radius=Angle(0.7, 'deg'), ) # filename = 'RXJ1713_mask.reg' # print('Writing {}'.format(filename)) # write_ds9([region], filename=filename) # # fig, ax, cbar = image.plot() # filename = 'RXJ1713.png' # print('Writing {}'.format(filename)) # fig.savefig(filename) mask = image.region_mask(region) image.data *= mask.data filename = 'RXJ1713_above2TeV_2016_masked.fits.gz' print('Writing {}'.format(filename)) image.write(filename, overwrite=True)
def make_images_grouped(): images = SkyImageList([ SkyImage.read('counts.fits.gz'), SkyImage.read('background.fits.gz'), SkyImage.read('exposure.fits.gz'), SkyImage.read('exclusion.fits.gz'), SkyImage.read('model.fits.gz'), ]) images[0].name = 'counts' images[1].name = 'background' images[2].name = 'exposure' images[3].name = 'exclusion' images[4].name = 'model' filename = 'input_all.fits.gz' print('Writing {}'.format(filename)) images.write(filename, clobber=True)
def get_image(): filename = '/Users/deil/code/gammapy-extra/datasets/fermi_2fhl/gll_psch_v08.fit.gz' print('Reading {}'.format(filename)) image = SkyImage.read(filename) image.data = image.data.astype(float) sigma_pix = 3 sigma_deg = sigma_pix * image.wcs_pixel_scale()[0] print('Smoothing by sigma = {} pix = {:.3f}'.format(sigma_pix, sigma_deg)) image = image.smooth('gauss', sigma_pix) return image
def estimate_reflected(self, EXCLUSION_FILE, size): #just extracts the reflected background on_size=0.11 * u.deg #0.11 for point source cuts... allsky_mask = SkyImage.read(EXCLUSION_FILE) exclusion_mask = allsky_mask.cutout(position=self.obspos,size=size) on_region=CircleSkyRegion(self.obspos,on_size) background_estimator = ReflectedRegionsBackgroundEstimator(obs_list=self.obslist, on_region=on_region, exclusion_mask = exclusion_mask) background_estimator.run() return background_estimator.result[0]
def make_CS_model(outdir, data_image, ampl_init,ampl_frozen, threshold_zero_value): CS_map = SkyImage.read("CStot.fits") if 'COMMENT' in CS_map.meta: del CS_map.meta['COMMENT'] cs_reproj = CS_map.reproject(data_image) cs_reproj.data[np.where(np.isnan(cs_reproj.data))] = 0 cs_reproj.data[np.where(cs_reproj.data < threshold_zero_value)] = 0 cs_reproj.data = cs_reproj.data / cs_reproj.data.sum() cs_reproj.write(outdir + "/cs_map_reproj.fits", clobber=True) load_table_model("CS", outdir + "/cs_map_reproj.fits") set_par(CS.ampl, val=ampl_init, min=0, max=None, frozen=ampl_frozen) return CS
def summed(): comp_image = image_estimator.run(mylist) comp_image.names print("Total number of counts",images[0].data.sum()) print("Total number of excess events",images[3].data.sum()) fermi=SkyImage.read("FDA16.fits") fermi_rep=fermi.reproject(ref_image) #Make sure that the exclusion mask properly excludes all sources masked_excess = SkyImage.empty_like(images['excess']) masked_excess.data = comp_image['excess'].data * exclusion_mask.data masked_excess.plot(cmap='viridis',stretch='sqrt',add_cbar=True) plt.hist(masked_excess.data.flatten(),bins=100,log=True) #smooth excess_smooth=comp_image.smooth(radius=0.5*u.deg) excess_smooth.show() counts_smooth=comp_image.smooth(radius=0.5*u.deg) counts_smooth.show() #cutout excess_cut=excess_smooth.cutout( position=SkyCoord(src.galactic.l.value, src.galactic.b.value, unit='deg', frame='galactic'), size=(9*u.deg, 9*u.deg)) excess_cut.plot(cmap='viridis',add_cbar=True,stretch='sqrt') counts_cut=counts_smooth.cutout( position=SkyCoord(src.galactic.l.value, src.galactic.b.value, unit='deg', frame='galactic'), size=(9*u.deg, 9*u.deg)) counts_cut.plot(cmap='viridis',add_cbar=True,stretch='sqrt') fermi_cutout=fermi_rep.cutout( position=SkyCoord(src.galactic.l.value, src.galactic.b.value, unit='deg', frame='galactic'), size=(9*u.deg, 9*u.deg)) fig, ax, _ = excess_cut.plot(cmap='viridis',add_cbar=True,stretch='sqrt') ax.contour(fermi_cutout.data, cmap='Blues')
def make_EG_model(outdir, data_image): """ Parameters ---------- outdir: str directory chere are stored the data data_image: SkyImage on map to reproject the psf Returns ------- """ EmGal_map = SkyImage.read("HGPS_large_scale_emission_model.fits", ext=1) emgal_reproj = EmGal_map.reproject(data_image) emgal_reproj.data[np.where(np.isnan(emgal_reproj.data))] = 0 emgal_reproj.write(outdir + "/emgal_reproj.fits", clobber=True) load_table_model("EmGal", outdir + "/emgal_reproj.fits") set_par(EmGal.ampl, val=1e-8, min=0, max=None, frozen=None) return EmGal
def make_image_from_2d_bg(): center = SkyCoord(83.63, 22.01, unit='deg').galactic energy_band = Energy([1, 10], 'TeV') offset_band = Angle([0, 2.49], 'deg') data_store = DataStore.from_dir('/Users/jouvin/Desktop/these/temp/bg_model_image/') # TODO: fix `binarize` implementation # exclusion_mask = exclusion_mask.binarize() image = SkyImage.empty(nxpix=250, nypix=250, binsz=0.02, xref=center.l.deg, yref=center.b.deg, proj='TAN', coordsys='GAL') refheader = image.to_image_hdu().header exclusion_mask = SkyImage.read('$GAMMAPY_EXTRA/datasets/exclusion_masks/tevcat_exclusion.fits') exclusion_mask = exclusion_mask.reproject(reference=refheader) mosaic_images = StackedObsImageMaker(image, energy_band=energy_band, offset_band=offset_band, data_store=data_store, obs_table=data_store.obs_table, exclusion_mask=exclusion_mask) mosaic_images.make_images(make_background_image=True, for_integral_flux=True, radius=10., make_psf = True, region_center=center) filename = 'fov_bg_images.fits' log.info('Writing {}'.format(filename)) mosaic_images.images.write(filename, clobber=True)
model = bkg + 1E-11 * (source_model_SgrA) + 1E-11 * (source_model_SgrA) fit = Fit(data=cube, model=model, stat=Cash(), method=NelderMead(), estmethod=Covariance()) result = fit.fit() err = fit.est_errors() print(err) # Set starting values Gauss*CS spatial_model_central_gauss = NormGauss2DInt('spatial-model_central_Gauss_CS') spectral_model_central_gauss = PowLaw1D('spectral-model_Gauss_CS') CS_cube = SkyCube.empty_like(exposure_3D) CS_map = SkyImage.read("CStot.fits") if 'COMMENT' in CS_map.meta: del CS_map.meta['COMMENT'] cs_reproj = (CS_map.reproject(CS_cube.sky_image_ref)).cutout( center, extraction_size) cs_reproj.data[np.where(np.isnan(cs_reproj.data))] = 0 cs_reproj.data[np.where( cs_reproj.data < input_param["param_fit_3D"]["CS"]["threshold_map"])] = 0 cs_reproj.data = cs_reproj.data / cs_reproj.data.sum() for i in range(len(energy_bins_true)): CS_cube[iE, :, :] = cs_reproj.data CS = TableModel('CS') CS.load(None, CS_cube.data[index_region_selected_3d].value.ravel()) CS.ampl = input_param["param_fit_3D"]["CS"]["ampl_init"] #spectral_model_central_gauss = MyPLExpCutoff('spectral-model_Gauss_CS')
obsid = srcruns['OBS_ID'].data good_obs = np.loadtxt("PKS2155_PA_201801.list.txt", usecols=(0)) obsid1 = np.intersect1d(good_obs, obsid) mylist = datastore.obs_list(obsid1) ref_image = SkyImage.empty( nxpix=400, nypix=400, binsz=0.02, xref=src.ra.deg, yref=src.dec.deg, coordsys='CEL', proj='TAN', ) exclusion_mask_tevcat = SkyImage.read( '$GAMMAPY_EXTRA/datasets/exclusion_masks/tevcat_exclusion.fits') exclusion_mask_tevcat = exclusion_mask_tevcat.reproject(reference=ref_image) energy_band = Energy([0.5, 1.0], 'TeV') #energy_band = Energy([0.5, 50.0], 'TeV') offset_band = Angle([0.0, 1.5], 'deg') backnorm = [] Ncounts = [] list_zen = filter(lambda o1: o1.pointing_zen.value < 34.3, mylist) N = len(list_zen) #print N N = 1 for i in range(N): # if i%10 ==0:
from astropy import units as u from astropy.coordinates import SkyCoord from astropy.convolution import Tophat2DKernel from gammapy.datasets import FermiGalacticCenter from gammapy.image import SkyImageList, SkyImage from gammapy.detect import KernelBackgroundEstimator # Parameters CORRELATION_RADIUS = 10 # Pixels SIGNIFICANCE_THRESHOLD = 5 # Sigma MASK_DILATION_RADIUS = 0.5 * u.deg # Load example images. filename = ('$GAMMAPY_EXTRA/datasets/source_diffuse_separation/' 'galactic_simulations/fermi_counts.fits') counts = SkyImage.read(filename) center = SkyCoord(0, 0, frame='galactic', unit='deg') images = SkyImageList() images['counts'] = counts.cutout(center, (10 * u.deg, 80 * u.deg)) kernel_src = Tophat2DKernel(CORRELATION_RADIUS).array kernel_bkg = np.ones((10, 150)) kbe = KernelBackgroundEstimator( kernel_src=kernel_src, kernel_bkg=kernel_bkg, significance_threshold=SIGNIFICANCE_THRESHOLD, mask_dilation_radius=MASK_DILATION_RADIUS, )
"""Plot significance image with HESS and MILAGRO colormap. """ import numpy as np import matplotlib.pyplot as plt from gammapy.image import colormap_hess, colormap_milagro from astropy.visualization.mpl_normalize import ImageNormalize from astropy.visualization import LinearStretch from gammapy.image import SkyImage filename = '$GAMMAPY_EXTRA/test_datasets/unbundled/poisson_stats_image/expected_ts_0.000.fits.gz' image = SkyImage.read(filename, extname='sqrt_ts') # Plot with the HESS and Milagro colormap vmin, vmax, vtransition = -5, 15, 5 plt.figure(figsize=(12, 6)) 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(shrink=0.7) 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(shrink=0.7)
obs_ids = [23523, 23526] obs_list = data_store.obs_list(obs_ids) # In[3]: # Target definition target_position = SkyCoord(ra=83.63308, dec=22.01450, unit='deg') on_region_radius = Angle('0.2 deg') on_region = CircleSkyRegion(center=target_position, radius=on_region_radius) target = Target(on_region=on_region, name='Crab', tag='ana_crab') # In[4]: # Exclusion regions exclusion_file = '$GAMMAPY_EXTRA/datasets/exclusion_masks/tevcat_exclusion.fits' allsky_mask = SkyImage.read(exclusion_file) exclusion_mask = allsky_mask.cutout( position=target.on_region.center, size=Angle('6 deg'), ) # In[5]: # Estimation of the background bkg_estimator = ReflectedRegionsBackgroundEstimator( on_region=on_region, obs_list=obs_list, exclusion_mask=exclusion_mask, ) bkg_estimator.run()
print('Scipy version: ' + sp.__version__) # ## CWT Algorithm. PlayGround # First of all we import the data which should be analysied. # In[3]: import os from astropy.io import fits from astropy.coordinates import Angle, SkyCoord from gammapy.image import SkyImage filename = '$GAMMAPY_EXTRA/datasets/fermi_survey/all.fits.gz' image = SkyImage.read(filename=filename, hdu='COUNTS') background = SkyImage.read(filename=filename, hdu='BACKGROUND') size = Angle([10, 20], 'deg') image = image.cutout(position=image.center, size=size) background = background.cutout(position=background.center, size=size) data = dict(image=image, background=background) # In[4]: fig = plt.figure(figsize=(15, 3)) ax = fig.add_subplot(121, projection=data['image'].wcs) data['image'].plot(vmax=10, ax=ax, fig=fig)
from astropy.units import Quantity from astropy.coordinates import SkyCoord from gammapy.image import SkyImage filename = '$GAMMAPY_EXTRA/datasets/fermi_2fhl/fermi_2fhl_gc.fits.gz' counts = SkyImage.read(filename, hdu=2) position = SkyCoord(0, 0, frame='galactic', unit='deg') size = Quantity([5, 5], 'deg') cutout = counts.cutout(position, size) cutout.show()
source_name_skycoord=input_param["general"]["sourde_name_skycoord"] else: use_taget_name=False source_name_skycoord=None make_new_directorydataset(nobs, config_directory+"/"+config_name, source_name, center, obsdir, use_taget_name,source_name_skycoord) add_bkgmodel_to_indextable(bkg_model_directory, source_name, obsdir) # Make the images and psf model for different energy bands #Energy binning energy_reco_bins = EnergyBounds.equal_log_spacing(input_param["energy binning"]["Emin"], input_param["energy binning"]["Emax"], input_param["energy binning"]["nbin"], 'TeV') energy_reco=[Energy(input_param["energy binning"]["Emin"],"TeV"),Energy(input_param["energy binning"]["Emax"],"TeV"), input_param["energy binning"]["nbin"]] #offset_band = Angle([0, 2.49], 'deg') offset_band = Angle([0, 2.0], 'deg') data_store = DataStore.from_dir(obsdir) exclusion_mask = SkyImage.read(input_param["general"]["exclusion_mask"]) obs_table_subset = data_store.obs_table[0:nobs] # Cette observetion n est pas utilise par gammapy car cette observation est centre sur le Crab donc ne peut pas trouve de reflected region... if ((source_name=="Crab") | (source_name=="Crab_Test")): i_remove = np.where(obs_table_subset["OBS_ID"] == 18373) if len(i_remove[0]) != 0: obs_table_subset.remove_row(i_remove[0][0]) if use_cube: if use_etrue: energy_true=[Energy(input_param["energy true binning"]["Emin"],"TeV"),Energy(input_param["energy true binning"]["Emax"],"TeV"), input_param["energy true binning"]["nbin"]] outdir = make_outdir(source_name, name_bkg,config_name, image_size,for_integral_flux,energy_reco,etrue=energy_true,use_cube=use_cube, use_etrue=use_etrue) else: energy_true=[Energy(input_param["energy binning"]["Emin"],"TeV"),Energy(input_param["energy binning"]["Emax"],"TeV"), input_param["energy binning"]["nbin"]] outdir = make_outdir(source_name, name_bkg,config_name, image_size,for_integral_flux,energy_reco,etrue=None,use_cube=use_cube, use_etrue=use_etrue) make_cube(image_size, energy_reco, energy_true, offset_band, center, data_store, obs_table_subset, exclusion_mask, outdir,
from gammapy.image import SkyImage filename = '$GAMMAPY_EXTRA/datasets/fermi_2fhl/fermi_2fhl_vela.fits.gz' image = SkyImage.read(filename, hdu=2) image.show()
#crab_pos = SkyCoord.from_name('crab') on_region = CircleSkyRegion(crab_pos, 0.15 * u.deg) model = models.LogParabola( alpha=2.3, beta=0, amplitude=1e-11 * u.Unit('cm-2 s-1 TeV-1'), reference=1 * u.TeV, ) flux_point_binning = EnergyBounds.equal_log_spacing(0.7, 30, 5, u.TeV) # 0.7, 30, 5, u.TeV exclusion_mask = SkyImage.read( '/Users/lucatosti/gammapy-extra/datasets/exclusion_masks/tevcat_exclusion.fits' ) config = dict(outdir=None, background=dict( on_region=on_region, exclusion_mask=exclusion_mask, min_distance=0.1 * u.rad, ), extraction=dict(containment_correction=False), fit=dict(model=model, stat='wstat', forward_folded=True, fit_range=flux_point_binning[[0, -1]]), fp_binning=flux_point_binning)
emin = 0.5 * u.TeV emax = 20 * u.TeV offset_max = 2.3 * u.deg image_estimator = IACTBasicImageEstimator(reference=ref_image, emin=emin, emax=emax, offset_max=offset_max, background_estimator=bkg_estimator, exclusion_mask=exclusion_mask) images = image_estimator.run_indiv(mylist) fermi = "FDA16.fits" diffuse = SkyImage.read(fermi) diffuse_rep = diffuse.reproject(ref_image) #make exclusion and cutouts exc_list = [] diffuse_list = [] for i in range(len(mylist)): exc_list.append( image_estimator._cutout_observation(exclusion_mask, mylist[i])) diffuse_list.append( image_estimator._cutout_observation(diffuse_rep, mylist[i])) backnorm = [] for im in images:
image_estimator = IACTBasicImageEstimator(reference=ref_image, emin=emin, emax=emax, offset_max=offset_max, background_estimator=bkg_estimator, exclusion_mask=exclusion_mask) comp_image = image_estimator.run(mylist) comp_image.names images = comp_image print("Total number of counts", images[0].data.sum()) print("Total number of excess events", images[3].data.sum()) fermi = SkyImage.read("FDA16.fits") fermi_rep = fermi.reproject(ref_image) #Make sure that the exclusion mask properly excludes all sources masked_excess = SkyImage.empty_like(images['excess']) masked_excess.data = comp_image['excess'].data * exclusion_mask.data masked_excess_cutout = masked_excess.cutout(position=SkyCoord( src.galactic.l.value, src.galactic.b.value, unit='deg', frame='galactic'), size=(9 * u.deg, 9 * u.deg)) masked_excess_cutout.show(add_cbar=True) #masked_excess.plot(cmap='viridis',stretch='sqrt',add_cbar=True) #plt.hist(masked_excess.data.flatten(),bins=100,log=True) #smooth
# * Smooth images # * Plot images # * Cutout parts from images # * Reproject images to different WCS # # The `SkyImage` class is part of the [gammapy.image](http://docs.gammapy.org/dev/image/index.html) submodule. So we will start by importing it from there: # In[5]: from gammapy.image import SkyImage # As a first example, we will read a FITS file from a prepared Fermi-LAT 2FHL dataset: # In[6]: vela_2fhl = SkyImage.read( "$GAMMAPY_EXTRA/datasets/fermi_2fhl/fermi_2fhl_vela.fits.gz", hdu='COUNTS') # As the FITS file `fermi_2fhl_vela.fits.gz` contains mutiple image extensions and a `SkyImage` can only represent a single image, we explicitely specify to read the extension called 'Counts'. Let's print the image to get some basic information about it: # In[7]: print(vela_2fhl) # The shape of the image is 320x180 pixel, the data unit is counts ('ct') and it is defined using a cartesian projection in galactic coordinates. # # Let's take a closer look a the `.data` attribute: # In[8]: vela_2fhl.data
sim.obs.peek() print sim.obs plt.show() amplitude model = PowerLaw(index=index, amplitude=amplitude, reference=reference) sim = SpectrumSimulation(aeff=aeff, edisp=edisp, source_model=model, livetime=livetime) sim.simulate_obs(seed=42, obs_id=0) sim.obs.peek() print sim.obs plt.show() get_ipython().magic(u'save 1-40 sim-bkg,py') get_ipython().magic(u'save 1-40 sim-bkg.py') get_ipython().magic(u'save 1-40 sim-bkg.py') get_ipython().magic(u'save sim-bkg.py 1-40') crab allsky_mask = SkyImage.read(EXCLUSION_FILE) exclusion_mask = allsky_mask.cutout( position=crab, size=Angle('6 deg'), ) EXCLUSION_FILE = '$GAMMAPY_EXTRA/datasets/exclusion_masks/tevcat_exclusion.fits' allsky_mask = SkyImage.read(EXCLUSION_FILE) exclusion_mask = allsky_mask.cutout( position=crab, size=Angle('6 deg'), ) from gammapy.background.reflected import ReflectedRegionsBackgroundEstimator get_ipython().magic(u'pinfo ReflectedRegionsBackgroundEstimator') on_region=CircleSkyRegion(crab,0.15 * u.deg) background_estimator = ReflectedRegionsBackgroundEstimator(obs_list=fakerun, on_region=on_region, exclusion_mask = exclusion_mask)
time = (datastore.obs_table["TSTART"]> 55562.0) & (datastore.obs_table["TSTOP"] < 56927) sel=(time) & (sep<2.0*u.deg) sel np.where(sel) crabrun=(datastore.obs_table[sel]) on_region=CircleSkyRegion(crab,0.15 * u.deg) model = models.LogParabola( alpha = 2.3, beta = 0, amplitude = 1e-11 * u.Unit('cm-2 s-1 TeV-1'), reference = 1 * u.TeV, ) flux_point_binning = EnergyBounds.equal_log_spacing(0.7, 30, 5, u.TeV) exclusion_mask = SkyImage.read('$GAMMAPY_EXTRA/datasets/exclusion_masks/tevcat_exclusion.fits') import gammapy import numpy as np import astropy import regions import sherpa import matplotlib.pyplot as plt import astropy.units as u from astropy.coordinates import SkyCoord, Angle from astropy.table import vstack as vstack_table from regions import CircleSkyRegion from gammapy.data import DataStore, ObservationList from gammapy.data import ObservationStats, ObservationSummary from gammapy.background.reflected import ReflectedRegionsBackgroundEstimator from gammapy.utils.energy import EnergyBounds from gammapy.spectrum import SpectrumExtraction, SpectrumObservation, SpectrumFit, SpectrumResult
"""Plot significance image with HESS and MILAGRO colormap. """ import numpy as np import matplotlib.pyplot as plt from gammapy.image import colormap_hess, colormap_milagro from astropy.visualization.mpl_normalize import ImageNormalize from astropy.visualization import LinearStretch from gammapy.image import SkyImage filename = '$GAMMAPY_EXTRA/test_datasets/unbundled/poisson_stats_image/expected_ts_0.000.fits.gz' image = SkyImage.read(filename, hdu='SQRT_TS') # Plot with the HESS and Milagro colormap vmin, vmax, vtransition = -5, 15, 5 plt.figure(figsize=(12, 6)) 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(shrink=0.7) 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(shrink=0.7)