EDispMap#
- class gammapy.irf.EDispMap[source]#
Bases:
IRFMapEnergy dispersion map.
- Parameters:
Examples
- ::
# Energy dispersion map for CTAO data import numpy as np from astropy import units as u from astropy.coordinates import EarthLocation, SkyCoord from gammapy.data import FixedPointingInfo, Observation, observatory_locations from gammapy.irf import EffectiveAreaTable2D, EnergyDispersion2D from gammapy.makers import MapDatasetMaker from gammapy.maps import MapAxis, WcsGeom
pointing = SkyCoord(0, 0, unit=”deg”) livetime = 1 * u.hour
# Define energy dispersion map geometry energy_axis_true = MapAxis.from_edges(
np.logspace(-1, 1, 10), unit=”TeV”, name=”energy_true”
) migra_axis = MapAxis.from_edges(np.linspace(0, 3, 100), name=”migra”)
- geom = WcsGeom.create(
binsz=0.25 * u.deg, width=10 * u.deg, skydir=pointing, axes=[migra_axis, energy_axis_true],
)
# Extract EnergyDispersion2D from CTA 1DC IRF filename = (
“$GAMMAPY_DATA/cta-1dc/caldb/data/cta/1dc/bcf/South_z20_50h/irf_file.fits”
) edisp2D = EnergyDispersion2D.read(filename, hdu=”ENERGY DISPERSION”) aeff2d = EffectiveAreaTable2D.read(filename, hdu=”EFFECTIVE AREA”)
obs_loc = observatory_locations.get(“ctao_south”)
- obs = Observation.create(
pointing=FixedPointingInfo(fixed_icrs=pointing), location=obs_loc, livetime=livetime, irfs={“aeff”: aeff2d, “edisp”: edisp2D},
)
# Create the exposure map exposure_geom = geom.squash(axis_name=”migra”) exposure_map = MapDatasetMaker.make_exposure(exposure_geom, obs)
# Create the EDispMap for the specified observation edisp_map = MapDatasetMaker.make_edisp(geom, obs)
# Get an Energy Dispersion (1D) at any position in the image pos = SkyCoord(2.0, 2.5, unit=”deg”) energy_axis = MapAxis.from_energy_bounds(0.1, 10, 5, unit=”TeV”, name=”energy”) edisp = edisp_map.get_edisp_kernel(energy_axis, position=pos)
# Write map to disk edisp_map.write(“edisp_map.fits”)
Attributes Summary
Methods Summary
from_diagonal_response(energy_axis_true[, ...])Create an all-sky EDisp map with diagonal response.
from_geom(geom)Create energy dispersion map from geometry.
get_edisp_kernel(energy_axis[, position])Get energy dispersion at a given position.
Normalize PSF map.
peek([figsize])Quick-look summary plots.
sample_coord(map_coord[, random_state, ...])Apply the energy dispersion corrections on the coordinates of a set of simulated events.
to_edisp_kernel_map(energy_axis[, threshold])Convert to map with energy dispersion kernels.
Attributes Documentation
- downsample_axes = ['energy_true']#
- edisp_map#
- required_axes = ['migra', 'energy_true']#
- tag = 'edisp_map'#
Methods Documentation
- classmethod from_diagonal_response(energy_axis_true, migra_axis=None)[source]#
Create an all-sky EDisp map with diagonal response.
- classmethod from_geom(geom)[source]#
Create energy dispersion map from geometry.
By default, a diagonal energy dispersion matrix is created.
- Parameters:
- geom
Geom Energy dispersion map geometry.
- geom
- Returns:
- edisp_map
EDispMap Energy dispersion map.
- edisp_map
- peek(figsize=(15, 5))[source]#
Quick-look summary plots.
Plots corresponding to the center of the map.
This method creates a figure with two subplots:
Bias plot : reconstruction bias as a function of true energy
Energy dispersion matrix plot : probability density function matrix
- Parameters:
- figsizetuple
Size of figure.
- sample_coord(map_coord, random_state=0, chunk_size=10000)[source]#
Apply the energy dispersion corrections on the coordinates of a set of simulated events.
- Parameters:
- map_coord
MapCoord Sequence of coordinates and energies of sampled events.
- random_state{int, ‘random-seed’, ‘global-rng’,
RandomState}, optional Defines random number generator initialisation. Passed to
get_random_state. Default is 0.- chunk_sizeint
If set, this will slice the input MapCoord into smaller chunks of chunk_size elements. Default is 10000.
- map_coord
- Returns:
MapCoord.Sequence of energy dispersion corrected coordinates of the input map_coord map.
- to_edisp_kernel_map(energy_axis, threshold=1e-08)[source]#
Convert to map with energy dispersion kernels.
- Parameters:
- energy_axis
MapAxis Reconstructed energy axis.
- thresholdfloat, optional
Threshold value to remove numerical artifacts. Default is 1e-8.
- energy_axis
- Returns:
- edisp
EDispKernelMap Energy dispersion kernel map.
- edisp
- classmethod __new__(*args, **kwargs)#