LabJackAccelerometerDataClient#
- class lsst.ts.ess.labjack.LabJackAccelerometerDataClient(config, topics, log, simulation_mode=0)#
Bases:
BaseLabJackDataClientRead 3-axis accelerometer data from a LabJack T7 or similar, and report using the accelerometerPSD topic.
- Parameters:
name (str)
config (types.SimpleNamespace) – The configuration, after validation by the schema returned by
get_config_schemaand conversion to a types.SimpleNamespace.topics (
salobj.Controller) – The telemetry topics this model can write, as a struct with attributes such astel_temperature.log (
logging.Logger) – Logger.simulation_mode (
int, optional) – Simulation mode; 0 for normal operation.
- accelerometers#
List of configuration for each accelerometer.
- Type:
- acquisition_time#
How long it takes to acquire one set of raw data samples*: sampling_interval * (accel_array_len - 1)
- psd_frequencies#
Array of frequences for the computed PSD, starting from 0.
- Type:
np.ndarray
- offsets#
Offset for each accelerometer channel. scaled acceleration = (raw acceleration - offset) * scale
- Type:
ndarray
- scales#
Scale for each accelerometer channel; see
offsetsfor details.- Type:
ndarray
- make_random_mock_raw_1d_data#
In simulation mode controls whether the client generates random mock_raw_1d_data (producing garbage PSDs). By default it is True, so that some output is produced. Set it to False if you would rather generate the raw data yourself, in which case the topic is not written until you set
mock_raw_1d_data.- Type:
- mock_raw_1d_data#
Unit tests may set this to a list of floats with length containing raw acceleration values for: [v0_chan0, v0_chan1, v0_chan2, v1_chan0, v1_chan1, v1_chan2, …, vn_chan0, vn_chan1, vn_chan2]. In simulation mode this will be cycled over to provide the raw acceleration data. If None and if make_random_mock_raw_1d_data is true then it will be set to random data when first needed.
- wrote_psd_event#
An event that unit tests can use to wait for PSD data to be written. A test can clear the event, then wait for it to be set.
- Type:
Notes
In simulation mode the mock LabJack returns unspecified values, and those values may change in future versions of the LabJack software.
Attributes marked with * are set when sampling begins, because the exact values depend on a value returned by the LabJack.
Methods Summary
blocking_data_stream_callback(handle)Called in a thread when a full set of stream data is available.
Disconnect from the LabJack.
Get the config schema as jsonschema dict.
process_data(scaled_data, end_tai, backlogs)Process one set of data.
psd_from_scaled_data(scaled_data)Compute the PSD from scaled data.
Read data.
run()Read and process data from the LabJack.
scaled_data_from_raw(raw_1d_data)Convert a list of 1-D raw readings to 2-d scaled data.
Start the data stream from the LabJack.
Start a mock stream, since ljm demo mode does not stream.
start_processing_data(scaled_data, end_tai, ...)Start process_data as a background task, unless still running.
Methods Documentation
- blocking_data_stream_callback(handle)#
Called in a thread when a full set of stream data is available.
A full set is self.accel_array_len * self.num_channels values.
- classmethod get_config_schema()#
Get the config schema as jsonschema dict.
- async process_data(scaled_data, end_tai, backlogs)#
Process one set of data.
- Parameters:
scaled_data (
np.ndarray) – x, y, z acceleration data of shape (self.num_channels, n) after applying offset and scaleend_tai (
float) – The time (TAI unix seconds) at which data collection ended.backlogs (
tuple) – Two measures of the number of backlogged messages. Both values should be nearly zero if the data client is keeping up with the LabJack.
- Raises:
RuntimeError – If streaming has not yet begun (because self.sampling_interval is None until streaming begins).
- Return type:
- psd_from_scaled_data(scaled_data)#
Compute the PSD from scaled data.
- Parameters:
scaled_data (
ndarray)- Return type:
ndarray
- async read_data()#
Read data.
- Return type:
Notes
This method should never be called because this class overrides the run method which, in the super class, calls this read_data method.
- scaled_data_from_raw(raw_1d_data)#
Convert a list of 1-D raw readings to 2-d scaled data.
- Parameters:
raw_1d_data (list[float]) – Raw voltage data read from the LabJack in the form: [v0_chan0, v0_chan1, v0_chan2, v1_chan0, v1_chan1, v1_chan2, …, vn_chan0, vn_chan1, vn_chan2]
- Returns:
scaled_data – Raw data reshaped to size (self.num_channels, voltages) with offsets and scales applied:
scaled = (raw - offset) * scaled
- Return type:
np.ndarray
- start_processing_data(scaled_data, end_tai, backlogs)#
Start process_data as a background task, unless still running.
- Parameters:
scaled_data (
np.ndarray) – Acceleration data of shape (self.num_channels, self.accel_array_len) after applying offset and scale.end_tai (
float) – The time (TAI unix seconds) at which data collection ended.backlogs (
tuple) – Two measures of the number of backlogged messages. Both values should be nearly zero if the data client is keeping up with the LabJack.
- Return type: