def __init__(self): super(Experiment, self).__init__() # Experiment name self.name = None # Sweep control self.sweeper = Sweeper() # This holds the experiment graph self.graph = None # This holds a reference to a matplotlib server instance # for plotting, if there is one. self.matplot_server_thread = None # If this is True, don't close the plot server thread so that # we might push additional plots after run_sweeps is complete. self.leave_plot_server_open = False # Also keep references to all of the plot filters self.plotters = [] # Standard pipeline plotters using streams self.extra_plotters = [ ] # Plotters using streams, but not the pipeline self.manual_plotters = [ ] # Plotters using neither streams nor the pipeline self.manual_plotter_callbacks = [ ] # These are called at the end of run self._extra_plots_to_streams = {} # Furthermore, keep references to all of the file writers. # If multiple writers request acces to the same filename, they # should share the same file object and write in separate # hdf5 groups. self.writers = [] self.buffers = [] # ExpProgressBar object to display progress bars self.progressbar = None # indicates whether the instruments are already connected self.instrs_connected = False # Things we can't metaclass self.output_connectors = {} for oc in self._output_connectors.keys(): a = OutputConnector(name=oc, data_name=oc, unit=self._output_connectors[oc].data_unit, parent=self) a.parent = self self.output_connectors[oc] = a setattr(self, oc, a) # Some instruments don't clean up well after themselves, reconstruct them on a # per instance basis for n in self._instruments.keys(): new_cls = type(self._instruments[n]) new_inst = new_cls( resource_name=self._instruments[n].resource_name, name=self._instruments[n].name) setattr(self, n, new_inst) self._instruments[n] = new_inst # Create the asyncio measurement loop self.loop = asyncio.get_event_loop() # Based on the logging level, infer whether we want asyncio debug do_debug = logger.getEffectiveLevel() <= logging.DEBUG self.loop.set_debug(do_debug) # Run the stream init self.init_streams()
def __init__(self): super(Experiment, self).__init__() # Experiment name self.name = None # Sweep control self.sweeper = Sweeper() # This holds the experiment graph self.graph = None # Should we show the dashboard? self.dashboard = False # Create and use plots? self.do_plotting = False # Unique ID for this experiment self.uuid = str(uuid.uuid4()) # Disconnect at the end of experiment? self.keep_instruments_connected = False # Also keep references to all of the plot filters self.plotters = [] # Standard pipeline plotters using streams self.extra_plotters = [ ] # Plotters using streams, but not the pipeline self.manual_plotters = [ ] # Plotters using neither streams nor the pipeline self.manual_plotter_callbacks = [ ] # These are called at the end of run self._extra_plots_to_streams = {} # Keep track of additional DataStreams created for manual plotters, etc. self.extra_streams = [] # Furthermore, keep references to all of the file writers and buffers. self.writers = [] self.buffers = [] # ExpProgressBar object to display progress bars self.progressbar = None # indicates whether the instruments are already connected self.instrs_connected = False # indicates whether this is the first (or only) experiment in a series (e.g. for pulse calibrations) self.first_exp = True # add date to data files? self.add_date = False # save channel library self.save_chanddb = False # Things we can't metaclass self.output_connectors = {} for oc in self._output_connectors.keys(): a = OutputConnector( name=oc, data_name=oc, unit=self._output_connectors[oc].data_unit, dtype=self._output_connectors[oc].descriptor.dtype, parent=self) a.parent = self self.output_connectors[oc] = a setattr(self, oc, a) # Some instruments don't clean up well after themselves, reconstruct them on a # per instance basis. These instruments contain a wide variety of complex behaviors # and rely on other classes and data structures, so we avoid copying them and # run through the constructor instead. self._instruments_instance = {} for n in self._instruments.keys(): new_cls = type(self._instruments[n]) new_inst = new_cls( resource_name=self._instruments[n].resource_name, name=self._instruments[n].name) setattr(self, n, new_inst) self._instruments_instance[n] = new_inst self._instruments = self._instruments_instance # We don't want to add parameters to the base class, so do the same here. # These aren't very complicated objects, so we'll throw caution to the wind and # try copying them directly. self._parameters_instance = {} for n, v in self._parameters.items(): new_inst = copy.deepcopy(v) setattr(self, n, new_inst) self._parameters_instance[n] = new_inst self._parameters = self._parameters_instance # Based on the logging level, infer whether we want asyncio debug do_debug = logger.getEffectiveLevel() <= logging.DEBUG # Run the stream init self.init_streams()