SpectrumObservationList

class gammapy.spectrum.SpectrumObservationList(initlist=None)[source]

Bases: collections.UserList

List of SpectrumObservation objects.

Attributes Summary

obs_id List of observations ids
off_vector_list Off PHACountsSpectrumList
on_vector_list On PHACountsSpectrumList
total_livetime Summed livetime

Methods Summary

append(item) S.append(value) – append value to the end of the sequence
clear()
copy()
count(value)
extend(other) S.extend(iterable) – extend sequence by appending elements from the iterable
index(value, [start, [stop]]) Raises ValueError if the value is not present.
insert(i, item) S.insert(index, value) – insert value before index
obs(obs_id) Return one observation.
peek() Quickly look at observations
pop([index]) Raise IndexError if list is empty or index is out of range.
read(directory[, pha_typeII]) Read multiple observations
remove(item) S.remove(value) – remove first occurrence of value.
reverse() S.reverse() – reverse IN PLACE
safe_range([method]) Safe energy range
sort(*args, **kwds)
stack() Return stacked SpectrumObservation
write([outdir, pha_typeII]) Create OGIP files

Attributes Documentation

obs_id

List of observations ids

off_vector_list

Off PHACountsSpectrumList

on_vector_list

On PHACountsSpectrumList

total_livetime

Summed livetime

Methods Documentation

append(item)

S.append(value) – append value to the end of the sequence

clear() → None -- remove all items from S
copy()
count(value) → integer -- return number of occurrences of value
extend(other)

S.extend(iterable) – extend sequence by appending elements from the iterable

index(value[, start[, stop]]) → integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(i, item)

S.insert(index, value) – insert value before index

obs(obs_id)[source]

Return one observation.

Parameters:

obs_id : int

Identifier

peek()[source]

Quickly look at observations

Uses IPython widgets. TODO: Change to bokeh

pop([index]) → item -- remove and return item at index (default last).

Raise IndexError if list is empty or index is out of range.

classmethod read(directory, pha_typeII=False)[source]

Read multiple observations

This methods reads all PHA files contained in a given directory. Enable pha_typeII to read a PHA type II file.

see https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/spectra/ogip_92_007/node8.html

TODO: Replace with more sophisticated file managment system

Parameters:

directory : Path

Directory holding the observations

pha_typeII : bool, default: False

Read PHA typeII file

remove(item)

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()

S.reverse() – reverse IN PLACE

safe_range(method='inclusive')[source]

Safe energy range

This is the energy range in with any / all observations have their safe threshold

Parameters:

method : str, {‘inclusive’, ‘exclusive’}

Maximum or minimum range

sort(*args, **kwds)
stack()[source]

Return stacked SpectrumObservation

write(outdir=None, pha_typeII=False, **kwargs)[source]

Create OGIP files

Each observation will be written as seperate set of FITS files by default. If the option pha_typeII is enabled all on and off counts spectra will be collected into one PHACountsSpectrumList and written to one FITS file. All datasets will be associated to the same response files. see https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/spectra/ogip_92_007/node8.html

TODO: File written with the pha_typeII option are not read properly with sherpa. This could be a sherpa issue. Investigate and file issue.

Parameters:

outdir : str, Path, optional

Output directory, default: pwd

pha_typeII : bool, default: False

Collect PHA datasets into one file