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 :code:`measurements` attribute of the scan to a list of strings containing the name of each measurement, as in the following example. .. code-block:: python def build(self, **kwargs): # define two separate measurements self.measurements = ['rsb', 'bsb'] @kernel def measure(self, time): self.cooling.doppler() # perform a blue side-band measurement if self.measurement == 'bsb': self.raman.set_frequency(self.raman.m1_bsb_frequency) self.raman.pulse(self.raman_readout_time) # perform a red side-band measurement if self.measurement == 'rsb': self.raman.set_frequency(self.raman.m1_rsb_frequency) self.raman.pulse(self.raman_readout_time) # rsb or bsb counts counts = self.detection.detect() return counts When :code:`self.measurements` is set, the framework sets :code:`self.measurement` to the name of the current measurement prior to calling :code:`measure()` and :code:`measure()` is called separately for each defined measurement. In the example above, the measure method is called :code:`2 * nrepeats` times at each scan point: :code:`nrepeats` times for each measurement. Measurements are executed in the order that they appear in :code:`self.measurements` and are interleaved such that each successive call to :code:`measure` will have :code:`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 :code:`measurement` attribute of :meth:`register_model ` .. code-block:: python 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 :code:`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.