Observation#

class gammapy.data.Observation(obs_id=None, meta=None, obs_info=None, gti=None, aeff=None, edisp=None, psf=None, bkg=None, rad_max=None, events=None, obs_filter=None, pointing=None, location=None)[source]#

Bases: object

In-memory observation.

Parameters
obs_idint, optional

Observation id. Default is None

obs_infodict, optional

Observation info dict. Default is None.

aeffEffectiveAreaTable2D, optional

Effective area. Default is None.

edispEnergyDispersion2D, optional

Energy dispersion. Default is None.

psfPSF3D, optional

Point spread function. Default is None.

bkgBackground3D, optional

Background rate model. Default is None.

rad_maxRadMax2D, optional

Only for point-like IRFs: RAD_MAX table (energy dependent RAD_MAX) For a fixed RAD_MAX, create a RadMax2D with a single bin. Default is None.

gtiGTI, optional

Table with GTI start and stop time. Default is None.

eventsEventList, optional

Event list. Default is None.

obs_filterObservationFilter, optional

Observation filter. Default is None.

pointingFixedPointingInfo, optional

Pointing information. Default is None.

locationEarthLocation, optional

Earth location of the observatory. Default is None.

Attributes Summary

aeff

A lazy FITS data descriptor.

available_hdus

Which HDUs are available.

available_irfs

Which IRFs are available.

bkg

A lazy FITS data descriptor.

edisp

A lazy FITS data descriptor.

events

Event list of the observation as an EventList.

gti

GTI of the observation as a GTI.

meta

Return metadata container.

muoneff

Deprecated since version v1.2.

obs_info

Observation information dictionary.

observation_dead_time_fraction

Dead-time fraction (float).

observation_live_time_duration

Live-time duration in seconds as a Quantity.

observation_time_duration

Observation time duration in seconds as a Quantity.

observatory_earth_location

Observatory location as an EarthLocation object.

pointing

Get the pointing for the observation as a FixedPointingInfo object.

psf

A lazy FITS data descriptor.

rad_max

Rad max IRF.

target_radec

Target RA / DEC sky coordinates as a SkyCoord object.

tmid

Midpoint between start and stop time as a Time object.

tstart

Observation start time as a Time object.

tstop

Observation stop time as a Time object.

Methods Summary

check([checks])

Run checks.

copy([in_memory])

Copy observation.

create(pointing[, location, obs_id, ...])

Create an observation.

get_pointing_altaz(time)

Get the pointing in alt-az for given time.

get_pointing_icrs(time)

Get the pointing in ICRS for given time.

peek([figsize])

Quick-look plots in a few panels.

read(event_file[, irf_file, checksum])

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, ...])

Write this observation into Path using the specified format.

Attributes 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#

Event list of the observation as an EventList.

gti#

GTI of the observation as a GTI.

meta#

Return metadata container.

muoneff#

Deprecated since version v1.2: Access additional metadata directly in obs.meta.opt.

Observation muon efficiency.

obs_info#

Observation information 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 as a Quantity.

The dead-time-corrected observation time.

Computed as t_live = t_observation * (1 - f_dead) where f_dead is the dead-time fraction.

observation_time_duration#

Observation time duration in seconds as a Quantity.

The wall time, including dead-time.

observatory_earth_location#

Observatory location as an EarthLocation object.

pointing#

Get the pointing for the observation as a FixedPointingInfo object.

psf#

A lazy FITS data descriptor.

Parameters
cachebool

Whether to cache the data.

rad_max#

Rad max IRF. None if not available.

target_radec#

Target RA / DEC sky coordinates as a SkyCoord object.

tmid#

Midpoint between start and stop time as a Time object.

tstart#

Observation start time as a Time object.

tstop#

Observation stop time as a Time object.

Methods Documentation

check(checks='all')[source]#

Run checks.

This is a generator that yields a list of dictionary.

copy(in_memory=False, **kwargs)[source]#

Copy observation.

Overwriting Observation arguments requires the in_memory argument to be true.

Parameters
in_memorybool, optional

Copy observation in memory. Default is False.

**kwargsdict, optional

Keyword arguments passed to Observation.

Returns
obsObservation

Copied observation.

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(in_memory=True, 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
pointingFixedPointingInfo or SkyCoord

Pointing information.

locationEarthLocation, optional

Earth location of the observatory. Default is None.

obs_idint, optional

Observation ID as identifier. Default is 0.

livetime~astropy.units.Quantity`, optional

Livetime exposure of the simulated observation. Default is None.

tstartTime or Quantity, optional

Start time of observation as Time or duration relative to reference_time. Default is None.

tstopastropy.time.Time or Quantity, optional

Stop time of observation as Time or duration relative to reference_time. Default is None.

irfsdict, optional

IRFs used for simulating the observation: bkg, aeff, psf, edisp, rad_max. Default is None.

deadtime_fractionfloat, optional

Deadtime fraction. Default is 0.

reference_timeTime, optional

the reference time to use in GTI definition. Default is Time("2000-01-01 00:00:00").

Returns
obsgammapy.data.MemoryObservation

Observation.

get_pointing_altaz(time)[source]#

Get the pointing in alt-az for given time.

get_pointing_icrs(time)[source]#

Get the pointing in ICRS for given time.

peek(figsize=(15, 10))[source]#

Quick-look plots in a few panels.

Parameters
figsizetuple, optional

Figure size. Default is (15, 10).

classmethod read(event_file, irf_file=None, checksum=False)[source]#

Create an Observation from a Event List and an (optional) IRF file.

Parameters
event_filestr or Path

Path to the FITS file containing the event list and the GTI.

irf_filestr or Path, optional

Path to the FITS file containing the IRF components. Default is None. If None, the IRFs will be read from the event file.

checksumbool

If True checks both DATASUM and CHECKSUM cards in the file headers. Default is False.

Returns
observationObservation

Observation with the events and the IRF read from the file.

select_time(time_interval)[source]#

Select a time interval of the observation.

Parameters
time_intervalastropy.time.Time

Start and stop time of the selected time interval. For now, we only support a single time interval.

Returns
new_obsObservation

A new observation instance of the specified time interval.

write(path, overwrite=False, format='gadf', include_irfs=True, checksum=False)[source]#

Write this observation into Path using the specified format.

Parameters
pathstr or Path

Path for the output file.

overwritebool, optional

Overwrite existing file. Default is False.

format{“gadf”}

Output format, currently only “gadf” is supported. Default is “gadf”.

include_irfsbool, optional

Whether to include irf components in the output file. Default is True.

checksumbool, optional

When True adds both DATASUM and CHECKSUM cards to the headers written to the file. Default is False.