Return an instance of a named instrument.
If the instrument name not is qualified (does not contain a '.') and a
butler registry is provided, this will attempt to load the instrument using
Instrument.fromName. Otherwise the instrument will be imported and
instantiated.
Parameters
----------
instrumentName : string
The name or fully-qualified class name of an instrument.
registry : `lsst.daf.butler.Registry`, optional
Butler registry to query to find information about the instrument, by
default None
Returns
-------
Instrument subclass instance
The instantiated instrument.
Raises
------
RuntimeError
If the instrument can not be imported, instantiated, or obtained from
the registry.
TypeError
If the instrument is not a subclass of lsst.obs.base.Instrument.
Definition at line 100 of file utils.py.
101 """Return an instance of a named instrument.
103 If the instrument name not is qualified (does not contain a '.') and a
104 butler registry is provided, this will attempt to load the instrument using
105 Instrument.fromName. Otherwise the instrument will be imported and
110 instrumentName : string
111 The name or fully-qualified class name of an instrument.
112 registry : `lsst.daf.butler.Registry`, optional
113 Butler registry to query to find information about the instrument, by
118 Instrument subclass instance
119 The instantiated instrument.
124 If the instrument can not be imported, instantiated, or obtained from
127 If the instrument is not a subclass of lsst.obs.base.Instrument.
129 if "." not in instrumentName
and registry
is not None:
131 instr = Instrument.fromName(instrumentName, registry)
132 except Exception
as err:
134 f
"Could not get instrument from name: {instrumentName}. Failed with exception: {err}")
138 except Exception
as err:
139 raise RuntimeError(f
"Could not import instrument: {instrumentName}. Failed with exception: {err}")
141 if not isinstance(instr, Instrument):
142 raise TypeError(f
"{instrumentName} is not an Instrument subclass.")