SkyImageList

class gammapy.image.SkyImageList(images=None, meta=None)[source]

Bases: collections.UserList

List of SkyImage objects.

This is a simple class that provides

  • FITS I/O
  • Dict-like access by string image name keys in addition to list-like access by integer index.

Examples

Load the image collection from a FITS file:

>>> from gammapy.image import SkyImage, SkyImageList
>>> images = SkyImageList.read('$GAMMAPY_EXTRA/datasets/fermi_survey/all.fits.gz')

Which images are available?

>>> images.names

Access one image by list index or image name string key:

>>> images[0]
>>> images['counts']
>>> images['counts'].show('ds9')

Print some summary info about the images:

>>> print(images)

Remove and append an image:

>>> del images['background']
>>> images.

Attributes Summary

names List of image names.

Methods Summary

append(item) S.append(value) – append value to the end of the sequence
assert_allclose(images2[, check_wcs]) Assert all-close for SkyImageList.
check_required(required_images) Check if required images are present in the sky image list.
clear()
copy()
count(value)
extend(other) S.extend(iterable) – extend sequence by appending elements from the iterable
from_hdu_list(hdu_list) Construct from HDUList.
index(value, [start, [stop]]) Raises ValueError if the value is not present.
insert(i, item) S.insert(index, value) – insert value before index
pop([index]) Raise IndexError if list is empty or index is out of range.
read(filename) Read from FITS file.
remove(item) S.remove(value) – remove first occurrence of value.
reverse() S.reverse() – reverse IN PLACE
sort(*args, **kwds)
to_hdu_list() Convert to HDUList.
write(filename, **kwargs) Write to FITS file.

Attributes Documentation

names

List of image names.

Methods Documentation

append(item)

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

static assert_allclose(images2, check_wcs=True)[source]

Assert all-close for SkyImageList.

A useful helper function to implement tests.

check_required(required_images)[source]

Check if required images are present in the sky image list.

Parameters:

required_images : list

List of names of required sky images.

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

classmethod from_hdu_list(hdu_list)[source]

Construct from HDUList.

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

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(filename)[source]

Read from FITS 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

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

Convert to HDUList.

write(filename, **kwargs)[source]

Write to FITS file.

kwargs are passed to astropy.io.fits.HDUList.writeto.