synthesizer.instruments.instrument_collection¶
Container for one or more instrument objects.
An InstrumentCollection behaves like a lightweight labelled registry
for instrument instances. It supports dictionary-style lookup by instrument
label, iteration over stored instruments, and HDF5
serialisation/deserialisation.
Classes
- class synthesizer.instruments.instrument_collection.InstrumentCollection(filepath=None)[source]¶
Container for a set of labelled instruments.
The collection is primarily used when workflows need to combine multiple instruments while preserving their labels and serialised form.
- instruments¶
Mapping from instrument label to instrument instance.
- Type:
dict
- instrument_labels¶
Labels stored in insertion order.
- Type:
list
- ninstruments¶
Number of instruments currently stored.
- Type:
int
- all_filters¶
Combined filters from all photometric instruments in the collection.
- Type:
FilterCollection or None
- add_instruments(*instruments)[source]¶
Add instruments to the collection.
- Parameters:
*instruments (InstrumentBase) – Instruments to add to the collection. Each instrument must have a unique label so it can be stored unambiguously in the collection mapping.
- Raises:
InconsistentArguments – If an object is not an instrument or an instrument label is duplicated.
- items()[source]¶
Get the items in the InstrumentCollection.
- Returns:
- Label-instrument pairs stored in the collection. This
mirrors the behaviour of
dict.items()on the underlying mapping.
- Return type:
dict_items
- load_instruments(filepath)[source]¶
Load instruments from a file.
- Parameters:
filepath (str) – Path to the file containing serialised instruments. Each top-level group in the file, apart from the header group, is interpreted as one serialised instrument.