Observation#
- class gammapy.data.Observation(obs_id=None, obs_info=None, gti=None, aeff=None, edisp=None, psf=None, bkg=None, rad_max=None, events=None, obs_filter=None)[source]#
Bases:
object
In-memory observation.
- Parameters
- obs_idint
Observation id
- obs_infodict
Observation info dict
- aeff
EffectiveAreaTable2D
Effective area
- edisp
EnergyDispersion2D
Energy dispersion
- psf
PSF3D
Point spread function
- bkg
Background3D
Background rate model
- rad_max: `~gammapy.irf.RadMax2D`
Only for point-like IRFs: RAD_MAX table (energy dependent RAD_MAX) For a fixed RAD_MAX, create a RadMax2D with a single bin.
- gti
GTI
Table with GTI start and stop time
- events
EventList
Event list
- obs_filter
ObservationFilter
Observation filter.
Attributes Summary
A lazy FITS data descriptor.
Which HDUs are available
Which IRFs are available
A lazy FITS data descriptor.
A lazy FITS data descriptor.
Fixed pointing info for this observation (
FixedPointingInfo
).Observation muon efficiency.
Observation info dictionary.
Dead-time fraction (float).
Live-time duration in seconds (
Quantity
).Observation time duration in seconds (
Quantity
).Observatory location (
EarthLocation
).Pointing RA / DEC sky coordinates (
SkyCoord
).Pointing zenith angle sky (
Quantity
).A lazy FITS data descriptor.
Target RA / DEC sky coordinates (
SkyCoord
).Observation start time (
Time
).Observation stop time (
Time
).Methods Summary
check
([checks])Run checks.
copy
([in_memory])Copy observation
create
(pointing[, location, obs_id, ...])Create an observation.
peek
([figsize])Quick-look plots in a few panels.
read
(event_file[, irf_file])Create an Observation from a Event List and an (optional) IRF file.
select_time
(time_interval)Select a time interval of the observation.
write
(path[, overwrite, format, include_irfs])Write this observation into
path
using the specified formatAttributes Documentation
- aeff#
A lazy FITS data descriptor.
- Parameters
- cachebool
Whether to cache the data.
- available_hdus#
Which HDUs are available
- available_irfs#
Which IRFs are available
- bkg#
A lazy FITS data descriptor.
- Parameters
- cachebool
Whether to cache the data.
- edisp#
A lazy FITS data descriptor.
- Parameters
- cachebool
Whether to cache the data.
- events#
- fixed_pointing_info#
Fixed pointing info for this observation (
FixedPointingInfo
).
- gti#
- muoneff#
Observation muon efficiency.
- obs_info#
Observation info dictionary.
- observation_dead_time_fraction#
Dead-time fraction (float).
Defined as dead-time over observation time.
Dead-time is defined as the time during the observation where the detector didn’t record events: https://en.wikipedia.org/wiki/Dead_time https://ui.adsabs.harvard.edu/abs/2004APh….22..285F
The dead-time fraction is used in the live-time computation, which in turn is used in the exposure and flux computation.
- observation_live_time_duration#
Live-time duration in seconds (
Quantity
).The dead-time-corrected observation time.
Computed as
t_live = t_observation * (1 - f_dead)
wheref_dead
is the dead-time fraction.
- observation_time_duration#
Observation time duration in seconds (
Quantity
).The wall time, including dead-time.
- observatory_earth_location#
Observatory location (
EarthLocation
).
- pointing_altaz#
- psf#
A lazy FITS data descriptor.
- Parameters
- cachebool
Whether to cache the data.
- rad_max#
Methods Documentation
- copy(in_memory=False, **kwargs)[source]#
Copy observation
Overwriting arguments requires the ‘in_memory` argument to be true.
- Parameters
- in_memorybool
Copy observation in memory.
- **kwargsdict
Keyword arguments passed to
Observation
- Returns
- obs
Observation
Copied observation
- obs
Examples
from gammapy.data import Observation obs = Observation.read( "$GAMMAPY_DATA/hess-dl3-dr1/data/hess_dl3_dr1_obs_id_020136.fits.gz" ) obs_copy = obs.copy(obs_id=1234) print(obs_copy)
- classmethod create(pointing, location=None, obs_id=0, livetime=None, tstart=None, tstop=None, irfs=None, deadtime_fraction=0.0, reference_time=<Time object: scale='utc' format='iso' value=2000-01-01 00:00:00.000>)[source]#
Create an observation.
User must either provide the livetime, or the start and stop times.
- Parameters
- pointing
SkyCoord
Pointing position
- obs_idint
Observation ID as identifier
- livetime~astropy.units.Quantity`
Livetime exposure of the simulated observation
- tstart: `~astropy.time.Time` or `~astropy.units.Quantity`
Start time of observation as
Time
or duration relative toreference_time
- tstop: `astropy.time.Time` or `~astropy.units.Quantity`
Stop time of observation as
Time
or duration relative toreference_time
- irfs: dict
IRFs used for simulating the observation:
bkg
,aeff
,psf
,edisp
,rad_max
- deadtime_fractionfloat, optional
Deadtime fraction, defaults to 0
- reference_time
Time
the reference time to use in GTI definition
- pointing
- Returns
- obs
gammapy.data.MemoryObservation
- obs
- peek(figsize=(15, 10))[source]#
Quick-look plots in a few panels.
- Parameters
- figsizetuple
Figure size
- classmethod read(event_file, irf_file=None)[source]#
Create an Observation from a Event List and an (optional) IRF file.
- Parameters
- event_filestr, Path
path to the .fits file containing the event list and the GTI
- irf_filestr, Path
(optional) path to the .fits file containing the IRF components, if not provided the IRF will be read from the event file
- Returns
- observation
Observation
observation with the events and the irf read from the file
- observation
- select_time(time_interval)[source]#
Select a time interval of the observation.
- Parameters
- time_interval
astropy.time.Time
Start and stop time of the selected time interval. For now we only support a single time interval.
- time_interval
- Returns
- new_obs
Observation
A new observation instance of the specified time interval
- new_obs
- write(path, overwrite=False, format='gadf', include_irfs=True)[source]#
Write this observation into
path
using the specified format- Parameters
- path: str or `~pathlib.Path`
Path for the output file
- overwrite: bool
If true, existing files are overwritten.
- format: str
Output format, currently only “gadf” is supported
- include_irfs: bool
Whether to include irf components in the output file