SubarrayDescription

class ctapipe.instrument.SubarrayDescription(name, tel_positions=None, tel_descriptions=None, reference_location=None)[source]

Bases: object

Collects the TelescopeDescription of all telescopes along with their positions on the ground.

Attributes
name: str

name of subarray

tel_coords: astropy.coordinates.SkyCoord

coordinates of all telescopes

tels:

dict of TelescopeDescription for each telescope in the subarray

Attributes Summary

COMPATIBLE_VERSIONS

CURRENT_TAB_VERSION

camera_types

list of camera types in the array

footprint

area of smallest circle containing array on ground

n_tels

number of telescopes in this subarray

optics_types

list of optics types in the array

tel

Dictionary mapping tel_ids to TelescopeDescriptions

tel_coords

returns telescope positions as astropy.coordinates.SkyCoord

tel_ids

telescope IDs as an array

tel_index_array

returns an expanded array that maps tel_id to tel_index.

tel_indices

returns dict mapping tel_id to tel_index, useful for unpacking lists based on tel_ids into fixed-length arrays

telescope_types

list of telescope types in the array

Methods Summary

from_hdf(path[, focal_length_choice])

get_tel_ids(telescopes)

Convert a list of telescope ids and telescope descriptions to a list of unique telescope ids.

get_tel_ids_for_type(tel_type)

return list of tel_ids that have the given tel_type

info([printer])

print descriptive info about subarray

peek()

Draw a quick matplotlib plot of the array

read(path, **kwargs)

Read subarray from path

select_subarray(tel_ids[, name])

return a new SubarrayDescription that is a sub-array of this one

tel_ids_to_indices(tel_ids)

maps a telescope id (or array of them) to flat indices

tel_ids_to_mask(tel_ids)

Convert a list of telescope ids to a boolean mask of length n_tels where the index of the telescope is set to True for each tel_id in tel_ids

tel_mask_to_tel_ids(tel_mask)

Convert a boolean mask of selected telescopes to a list of tel_ids.

to_hdf(h5file[, overwrite, mode])

write the SubarrayDescription

to_table([kind])

export SubarrayDescription information as an astropy.table.Table

Attributes Documentation

COMPATIBLE_VERSIONS = {'2.0'}
CURRENT_TAB_VERSION = '2.0'
camera_types

list of camera types in the array

footprint

area of smallest circle containing array on ground

n_tels

number of telescopes in this subarray

optics_types

list of optics types in the array

tel

Dictionary mapping tel_ids to TelescopeDescriptions

tel_coords

returns telescope positions as astropy.coordinates.SkyCoord

tel_ids

telescope IDs as an array

tel_index_array

returns an expanded array that maps tel_id to tel_index. I.e. for a given telescope, this array maps the tel_id to a flat index starting at 0 for the first telescope. tel_index = tel_id_to_index_array[tel_id] If the tel_ids are not contiguous, gaps will be filled in by -1. For a more compact representation use the tel_indices

tel_indices

returns dict mapping tel_id to tel_index, useful for unpacking lists based on tel_ids into fixed-length arrays

telescope_types

list of telescope types in the array

Methods Documentation

classmethod from_hdf(path, focal_length_choice=<FocalLengthKind.EFFECTIVE: 1>)[source]
get_tel_ids(telescopes: Iterable[Union[int, str, ctapipe.instrument.telescope.TelescopeDescription]])Tuple[int][source]

Convert a list of telescope ids and telescope descriptions to a list of unique telescope ids.

Parameters
telescopes: List[Union[int, str, TelescopeDescription]]

List of Telescope IDs and descriptions. Supported inputs for telescope descriptions are instances of TelescopeDescription as well as their string representation.

Returns
tel_ids: List[int]

List of unique telescope ids matching telescopes

get_tel_ids_for_type(tel_type)Tuple[int][source]

return list of tel_ids that have the given tel_type

Parameters
tel_type: str or TelescopeDescription

telescope type string (e.g. ‘MST_MST_NectarCam’)

info(printer=<built-in function print>)[source]

print descriptive info about subarray

peek()[source]

Draw a quick matplotlib plot of the array

static read(path, **kwargs)[source]

Read subarray from path

This uses the EventSource mechanism, so it should be able to read a subarray from any file supported by ctapipe or an installed io plugin.

kwargs are passed to the event source

select_subarray(tel_ids, name=None)[source]

return a new SubarrayDescription that is a sub-array of this one

Parameters
tel_ids: list(int)

list of telescope IDs to include in the new subarray

name: str

name of new sub-selection

Returns
——-
SubarrayDescription
tel_ids_to_indices(tel_ids)[source]

maps a telescope id (or array of them) to flat indices

Parameters
tel_idsint or List[int]

array of tel IDs

Returns
np.array:

array of corresponding tel indices

tel_ids_to_mask(tel_ids)[source]

Convert a list of telescope ids to a boolean mask of length n_tels where the index of the telescope is set to True for each tel_id in tel_ids

Parameters
tel_idsint or List[int]

array of tel IDs

Returns
np.array[dtype=bool]:

Boolean array of length n_tels with indices of the telescopes in tel_ids set to True.

tel_mask_to_tel_ids(tel_mask)[source]

Convert a boolean mask of selected telescopes to a list of tel_ids.

Parameters
tel_mask: array-like

Boolean array of length n_tels with indices of the telescopes in tel_ids set to True.

Returns
——-
np.array:

Array of selected tel_ids

to_hdf(h5file, overwrite=False, mode='a')[source]

write the SubarrayDescription

Parameters
h5filestr, bytes, path or tables.File

Path or already opened tables.File with write permission

overwriteFalse

If the output path already contains a subarray, by default an error will be raised. Set overwrite=True to overwrite an existing subarray. This does not affect other content of the file. Use mode="w" to completely overwrite the output path.

modestr

If h5file is not an already opened file, the output file will be opened with the given mode. Must be a mode that enables writing.

to_table(kind='subarray')[source]

export SubarrayDescription information as an astropy.table.Table

Parameters
kind: str

which table to generate (subarray or optics)