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.

to_set()[source]

Return a set containing the stored instruments.

Returns:

Set of instrument instances in the collection. This is a

convenience helper for APIs that expect an unordered collection of instruments.

Return type:

set

write_instruments(filepath)[source]

Save the instruments in the collection to a file.

Parameters:

filepath (str) – Path to the file in which to save the instruments. The output file will contain a header group followed by one group per stored instrument.