def _init_data(self, *args, **kwargs):
	
        print("Initializing Andor Camera .... ")
        #self.cam = andorsdk.Andor()
        self.cam = andor.Andor()

        print("Cooling down the detector...")
        self.cam.SetTemperature(core.CAMERATEMP)
        self.cam.CoolerON()
        #self.cam.GetStatus()



        self._txtlog = {}
        self.auto_cmap_adjust = True
        self.log = False
        self.camsize = (self.cam.width, self.cam.height)
        self.lastimg = np.zeros(self.camsize).astype(np.int16)
        self._dark = np.zeros(self.camsize).astype(np.int16)

        #self.cam.exposure = core.DEFAULTEXPOSURETIME  # ms
	self.cam.exposure = 100  # ms
        self.cam.SetVideoScan()
        self.cam.StartAcquisition()

        # needed for boxcal show_boxes
        self._boxcal._szratio = self.camsize[0]*1./self.camsize[1]

        # init the sub img
        self._nsub = [int(np.ceil(np.sqrt(len(core.FIRSTSEGS)))), 0]
        self._nsub[1] = int(np.ceil(len(core.FIRSTSEGS)/self._nsub[0]))

        self._do_boxes()
        
        l = self.boxes_list(ret=True)
        if len(l) > 0:
            self.boxes_load(l[-1])
        self._txtlog = {'dark': False, 'log': self._log,
                        'auto': self.auto_cmap_adjust}
      if stamp != 1:
         pass

      stamp = 0
      try:
         server2 = SimpleXMLRPCServer((conf.serverhost, conf.abort_port), requestHandler=RequestHandler, logRequests=False)
      except Exception, e:
         print 'error: ', e
         stamp = 1
      if stamp != 1:
         pass

      # Makes the CCD camera handle global. This is essential.
      try:
         global cam
         cam = andor.Andor()
      except Exception, e:
	 print e
         sys.exit("Camera handle could not be made!")

      #register functions
      server.register_function(Spool)
      server.register_function(acquire_an_image)
      server.register_function(acquire_an_image_thread)
      server.register_function(acquire_an_or_image)
      server.register_function(shutdown_camera)
      server.register_function(stop_server)
      server.register_function(initialize_cam)
      server.register_function(set_temp)
      server.register_function(get_settings)
      server.register_function(get_values)
Esempio n. 3
0
    def __init__(self):
        super(AQuA, self).__init__()

        # instruments
        self.functional_waveforms = functional_waveforms.FunctionalWaveforms('functional_waveforms', self, 'Waveforms for HSDIO, DAQmx DIO, and DAQmx AO; defined as functions')
        self.picomotors = picomotors.Picomotors('picomotors', self, 'Newport Picomotors')
        self.noise_eaters = noise_eaters.Noise_Eaters('noise_eaters', self,'rotating wave-plate noise eaters')
        self.BILT = BILT.BILTcards('BILT',self, 'BILT DC Voltage sources')
        self.Andor = andor.Andor('Andor', self, 'Andor Luca Camera')
        self.PICam = picam.PICam('PICam', self, 'Princeton Instruments Camera')
        self.LabView = LabView.LabView(self)
        self.DDS = DDS.DDS('DDS', self, 'server for homemade DDS boxes')
        self.DC_noise_eaters = DCNoiseEater.DCNoiseEaters('DC_noise_eaters', self)
        self.box_temperature = Laird_temperature.LairdTemperature('box_temperature', self)
        # do not include functional_waveforms in self.instruments because it need not start/stop
        self.instruments += [self.box_temperature, self.picomotors, self.noise_eaters, self.Andor, self.PICam, self.DC_noise_eaters, self.BILT,
                             self.LabView, self.DDS]

        # analyses
        self.functional_waveforms_graph = functional_waveforms.FunctionalWaveformGraph('functional_waveform_graph', self, 'Graph the HSDIO, DAQmx DO, and DAQmx AO settings')
        self.TTL_filters = TTL.TTL_filters('TTL_filters', self)
        self.AI_graph = AnalogInput.AI_Graph('AI_graph', self, 'Analog Input Graph')
        self.AI_filter = AnalogInput.AI_Filter('AI_filter', self, 'Analog Input filter')
        self.loading_filters = analysis.LoadingFilters('loading_filters', self, 'drop measurements with no atom loaded')
        self.first_measurements_filter = analysis.DropFirstMeasurementsFilter('first_measurements_filter', self, 'drop the first N measurements')
        self.squareROIAnalysis = analysis.SquareROIAnalysis(self, ROI_rows=self.ROI_rows, ROI_columns=self.ROI_columns)
        self.gaussian_roi = roi_fitting.GaussianROI('gaussian_roi', self, rows=self.ROI_rows, columns=self.ROI_columns)
        self.text_analysis = analysis.TextAnalysis('text_analysis', self, 'text results from the measurement')
        self.imageSumAnalysis = analysis.ImageSumAnalysis(self)
        self.recent_shot_analysis = analysis.RecentShotAnalysis('recent_shot_analysis', self, description='just show the most recent shot')
        self.shotBrowserAnalysis = analysis.ShotsBrowserAnalysis(self)
        self.histogramAnalysis = analysis.HistogramAnalysis('histogramAnalysis', self, 'plot the histogram of any shot and roi')
        self.histogram_grid = analysis.HistogramGrid('histogram_grid', self, 'all 49 histograms for shot 0 at the same time')
        self.measurements_graph = analysis.MeasurementsGraph('measurements_graph', self, 'plot the ROI sum vs all measurements')
        self.iterations_graph = analysis.IterationsGraph('iterations_graph', self, 'plot the average of ROI sums vs iterations')
        self.retention_graph = analysis.RetentionGraph('retention_graph', self, 'plot occurence of binary result (i.e. whether or not atoms are there in the 2nd shot)')
        self.andor_viewer = andor.AndorViewer('andor_viewer', self, 'show the most recent Andor image')
        self.picam_viewer = picam.PICamViewer('picam_viewer', self, 'show the most recent PICam image')
        self.DC_noise_eater_graph = DCNoiseEater.DCNoiseEaterGraph('DC_noise_eater_graph', self, 'DC Noise Eater graph')
        self.DC_noise_eater_filter = DCNoiseEater.DCNoiseEaterFilter('DC_noise_eater_filter', self, 'DC Noise Eater Filter')
        self.Noise_EatersGraph = noise_eaters.Noise_EatersGraph('Noise_EatersGraph', self, 'Graph of new DC Noise eater output')
        self.Ramsey = analysis.Ramsey('Ramsey', self, 'Fit a cosine to retention results')
        self.retention_analysis = analysis.RetentionAnalysis('retention_analysis', self, 'calculate the loading and retention')
        self.save_notes = save2013style.SaveNotes('save_notes', self, 'save a separate notes.txt')
        self.save2013Analysis = save2013style.Save2013Analysis(self)
        # do not include functional_waveforms_graph in self.analyses because it need not update on iterations, etc.
        self.analyses += [self.TTL_filters, self.AI_graph, self.AI_filter, self.squareROIAnalysis, self.gaussian_roi,
                          self.loading_filters, self.first_measurements_filter, self.text_analysis,
                          self.imageSumAnalysis, self.recent_shot_analysis, self.shotBrowserAnalysis,
                          self.histogramAnalysis, self.histogram_grid, self.measurements_graph, self.iterations_graph,
                          self.andor_viewer, self.picam_viewer, self.DC_noise_eater_graph, self.DC_noise_eater_filter,self.Noise_EatersGraph,
                          self.Ramsey, self.retention_analysis, self.retention_graph, self.save_notes,
                          self.save2013Analysis]
        
        self.properties += ['functional_waveforms', 'LabView', 'functional_waveforms_graph', 'DDS', 'picomotors', 'noise_eaters', 'BILT',
                            'Andor', 'PICam', 'DC_noise_eaters', 'box_temperature', 'squareROIAnalysis', 'gaussian_roi',
                            'TTL_filters', 'AI_graph', 'AI_filter', 'loading_filters', 'first_measurements_filter',
                            'imageSumAnalysis', 'recent_shot_analysis', 'shotBrowserAnalysis', 'histogramAnalysis',
                            'histogram_grid', 'retention_analysis', 'measurements_graph', 'iterations_graph',
                            'retention_graph', 'andor_viewer', 'picam_viewer', 'DC_noise_eater_filter',
                            'DC_noise_eater_graph','Noise_EatersGraph', 'Ramsey']

        try:
            self.allow_evaluation = False
            self.loadDefaultSettings()

            #update variables
            self.allow_evaluation = True
            self.evaluateAll()
        except PauseError:
            logger.warning('Loading default settings aborted in AQuA.__init__().  PauseError')
        except Exception as e:
            logger.warning('Loading default settings aborted in AQuA.__init__().\n{}\n{}\n'.format(e, traceback.format_exc()))

        #make sure evaluation is allowed now
        self.allow_evaluation = True