GbmDetectorCollection¶
- class gdt.missions.fermi.gbm.collection.GbmDetectorCollection[source]¶
Bases:
DataCollectionA container for a collection of GBM-specific data objects, such as a collection of
GbmPhaiiobjects from different detectors.The special behavior of this class is to provide a way to interact with a collection of detector data that may contain a mix of different types of detectors. For example, many times we want a collection of GBM NaI and GBM BGO detectors. These detectors have very different energy ranges, and so may require different inputs for a variety of functions. This collection allows one to specify the different arguments for NaI and BGO data without having to implement many ugly and space-wasting loops and
if...elseblocks.In addition to the GbmDetectorCollection methods, all of the individual object attributes and methods are exposed, and they become methods of the DataCollection. Note that individual object attributes become methods i.e. if you have an item attribute called item.name, then the corresponding DataCollection method would be item.name().
Attributes Summary
The names of the items in the DataCollection
The type of the objects in the DataCollection
Methods Summary
from_list(data_list[, names, dets])Given a list of objects and optionally a list of corresponding names and corresponding detector names, create a new GbmDetectorCollection.
get_item(item_name)Retrieve an object from the DataCollection by name
include(data_item, det[, name])Insert an object into the GbmDetectorCollection.
remove(item_name)Remove an object from the collection given the name
to_list()Return the objects contained in the DataCollection as a list.
Attributes Documentation
- items¶
The names of the items in the DataCollection
- Type:
(list)
- types¶
The type of the objects in the DataCollection
- Type:
(str)
Methods Documentation
- classmethod from_list(data_list, names=None, dets=None)[source]¶
Given a list of objects and optionally a list of corresponding names and corresponding detector names, create a new GbmDetectorCollection.
- Parameters:
data_list (list of
objects) – The list of objects to be in the collectionnames (list of
str, optional) – The list of corresponding names to the objects. If not set, will try to retrieve a name from object.filename (assuming it’s a data object). If that fails, each item will be named ambiguously ‘item1’, ‘item2’, etc.dets (list of
str, optional) – The detector names for each object. If not set, will try to retrieve from the object.detector attribute. If that attribute doesn’t exist, an error will be raised, and the user will need to specify this list.
- Returns
GbmDetectorCollection: The newly created collection
- get_item(item_name)¶
Retrieve an object from the DataCollection by name
- Parameters:
item_name (str) – The name of the item to retrieve
- Returns:
(
object)
- include(data_item, det, name=None)[source]¶
Insert an object into the GbmDetectorCollection. The first item inserted will set the immutable type.
- Parameters:
data_item (
object) – A data object to includedet (str) – The corresponding detector for the item
name (str, optional) – An optional corresponding name. If not set, will try to retrieve a name from object.filename (assuming it’s a data object). If that fails, each item will be named ambiguously ‘item1’, ‘item2’, etc.
- remove(item_name)[source]¶
Remove an object from the collection given the name
- Parameters:
item_name (str) – The name of the item to remove
- to_list()¶
Return the objects contained in the DataCollection as a list.
- Returns:
(list of
objects)