AvsFiberSpectrograph¶
- class lsst.ts.fiberspectrograph.AvsFiberSpectrograph(serial_number=None, log=None, log_to_stdout=False)¶
Bases:
object
Interface for the Avantes fiber spectrograph AvaSpec library.
This class follows Resource acquisition is initialization (RAII): when instantiated, it opens a connection; if it cannot open a connection, it raises an exception. To reconnect, delete the object and create a new one.
This class requires that
libavs.so
be installed in/usr/local/lib
. It is compatible with libavs version 0.2.0.- Parameters:
- serial_number
str
, optional The serial number of the USB device to connect to. If
None
, then connect to the only available USB device, or raise RuntimeError if multiple devices are connected.- log
logging.Logger
, optional A Logger instance to send log messages to.
- log_to_stdout
bool
Send all log info from DEBUG up to stdout. Useful when debugging the spectrograph in a python terminal.
- serial_number
- Raises:
- LookupError
Raised if there is no device with the specified serial number.
- RuntimeError
Raised if multiple devices are connected and no serial number was specified.
Raised if there is an error connecting to the requested device.
Attributes Summary
AvsIdentityType
of the connected spectrograph.The handle of the connected spectrograph.
Methods Summary
check_expose_ok
(duration)Check that an expose command would be allowed to succeed.
Close the connection with the connected USB spectrograph.
expose
(duration)Take an exposure with the currently connected spectrograph.
get_status
([full])Get the status of the currently connected spectrograph.
Cancel a currently running exposure and reset the spectrograph.
Attributes Documentation
- device = None¶
AvsIdentityType
of the connected spectrograph.
- handle = None¶
The handle of the connected spectrograph.
Methods Documentation
- check_expose_ok(duration)¶
Check that an expose command would be allowed to succeed.
Checks that parameters are in a valid range, and that no exposures are currently ongoing, returning a message describing the failure state if there would be one, or
None
otherwise.- Parameters:
- duration
float
Integration time of the exposure in seconds.
- duration
- Returns:
Notes
The
Parameters
of this method should match that ofexpose
, as its purpose is to check the validity of those parameters.
- disconnect()¶
Close the connection with the connected USB spectrograph.
If the attempt to disconnect fails, log an error message but still try to release the AVS library port.
Notes
This method should not raise.
- async expose(duration)¶
Take an exposure with the currently connected spectrograph.
- Parameters:
- duration
float
Integration time of the exposure in seconds.
- duration
- Returns:
- wavelength
astropy.units.Quantity
The 1-d wavelength solution provided by the instrument.
- spectrum
numpy.ndarray
The 1-d spectrum measured by the instrument.
- wavelength
- Raises:
- RuntimeError
Raised if we cannot start the exposure for whatever reason (e.g. invalid duration, ongoing exposure).
- AvsReturnError
Raised if there is an error in preparation, measurement, or readout from the device.
- asyncio.CancelledError
Raised if the exposure is stopped before it is read out.
- get_status(full=False)¶
Get the status of the currently connected spectrograph.
- Parameters:
- full
bool
Include the full
AvsDeviceConfig
structure in the output. This can be useful for understanding what other information is available from the spectrograph, but requires having the Avantes manual on hand to decode it.
- full
- Returns:
- status
SpectrographStatus
The current status of the spectrograph, including temperature, exposure status, etc.
- status
- Raises:
- AvsReturnError
Raised if there is an error querying the device.
- stop_exposure()¶
Cancel a currently running exposure and reset the spectrograph.
If there is no currently active exposure, this does nothing.
- Raises:
- AvsReturnError
Raised if there is an error stopping the exposure on the device.