Performing multiple measurements

Sometimes it may be desired to perform multiple measurements at each scan point.

Multiple measurements without models

When models are not being used, the scan framework is instructed to perform multiple measurements by setting the measurements attribute of the scan to a list of strings containing the name of each measurement, as in the following example.

def build(self, **kwargs):
    # define two separate measurements
    self.measurements = ['rsb', 'bsb']

def measure(self, time):

    # perform a blue side-band measurement
    if self.measurement == 'bsb':

    # perform a red side-band measurement
    if self.measurement == 'rsb':

    # rsb or bsb counts
    counts = self.detection.detect()
    return counts

When self.measurements is set, the framework sets self.measurement to the name of the current measurement prior to calling measure() and measure() is called separately for each defined measurement. In the example above, the measure method is called 2 * nrepeats times at each scan point: nrepeats times for each measurement. Measurements are executed in the order that they appear in self.measurements and are interleaved such that each successive call to measure will have self.measurement set to the name of a different measurement.

Multiple measurements when using models

When using models, measurements are defined by simply setting the measurement attribute of register_model

def register_models(self):
    # create models to store data for each measurement
    self.bsb_model = BsbModel(self)
    self.rsb_model = RsbModel(self)

    # register each model with it's associated measurement
    self.register_model(self.bsb_model, measurement='bsb')
    self.register_model(self.rsb_model, measurement='rsb')

The framework will automatically append the measurement name to self.measurements and all data generated by that measurement will be processed and saved by the scan model instance that is registered for the nammed measurement.