Пример #1
0
    def __init__(self, **params):

        for p in self.INPUT_PARAM_NAMES:
            setattr(self, p, params[p])

        self.x_array = np.arange(self.x0, self.x1, self.dx, dtype=float)
        self.y_array = np.arange(self.y0, self.y1, self.dy, dtype=float)
        self.z_array = np.arange(self.z0, self.z1, self.dz, dtype=float)

        self.Nx = len(self.x_array)
        self.Ny = len(self.y_array)
        self.Nz = len(self.z_array)

        self.mcl_axis_translation = xyz_tuple(*self.mcl_axis_translation)

        self.HARDWARE_DEBUG = False

        #HARDWARE
        self.nanodrive = MCLNanoDrive(debug=self.HARDWARE_DEBUG)

        self.mono = ActonSpectrometer(port=SPEC_COMM_PORT,
                                      debug=self.HARDWARE_DEBUG,
                                      dummy=False)
        self.mono_grating = self.mono.read_grating()
        self.mono_wl = self.mono.read_wl()

        self.ccd = AndorCCD(debug=self.HARDWARE_DEBUG)
        print "Andor CCD"
        print "%g x %g" % (self.ccd.Nx, self.ccd.Ny)
        self.spectrum_length = self.ccd.Nx
        self.ccd.set_cooler_on()
        self.ccd.get_temperature()

        if SHOW_GRAPH:
            self.fig = pl.figure(1)
            self.ax = self.fig.add_subplot(111)
            self.spec_plotline, = self.ax.plot(np.ones(self.spectrum_length))
            self.fig.show()

        #DATA ARRAYS
        self.integrated_count_map = np.zeros((
            self.Nz,
            self.Ny,
            self.Nx,
        ),
                                             dtype=int)
        self.spec_map = np.zeros(
            (self.Nz, self.Ny, self.Nx, self.spectrum_length), dtype=np.int32)
Пример #2
0
    def OnInit(self):

        print "OnInit"

        self.HARDWARE_DEBUG = HARDWARE_DEBUG

        self.frame = SpectrumCameraControlFrame(None)

        #self.frame.m_panel_scanarea.Disable()

        # Figure
        self.wxfig = MPLFigureWithToolbarWX(self.frame.m_panel_plot)
        self.fig = self.wxfig.fig
        self.ax = self.fig.add_subplot(111)
        self.ax2 = self.fig.add_subplot(611)
        self.ax2.set_xlim(0, 512)

        #Spectrometer ##########################################################
        self.spec = ActonSpectrometer(port="COM4", debug=self.HARDWARE_DEBUG)

        print self.spec.read_grating_info()

        self.frame.m_choice_spec_grating.Clear()
        for gnum, gname in self.spec.gratings:
            self.frame.m_choice_spec_grating.Append("%i %s" % (gnum, gname))

        print self.spec.gratings_dict

        self.spec.read_grating()

        self.frame.m_choice_spec_grating.SetSelection(self.spec.grating - 1)

        self.spec.read_wl()

        self.frame.m_textCtrl_current_spec_wl.SetValue("%f" % self.spec.wl)

        self.frame.m_textCtrl_set_spec_wl.Bind(wx.EVT_TEXT_ENTER,
                                               self.on_change_spec_wl)
        self.frame.m_choice_spec_grating.Bind(wx.EVT_CHOICE,
                                              self.on_change_spec_grating)
        self.frame.m_button_spec_stop.Bind(wx.EVT_BUTTON,
                                           self.on_spec_stop_motion)
        ########################################################################

        #Andor CCD##############################################################

        self.ccd = AndorCCD(debug=self.HARDWARE_DEBUG)

        print "Andor CCD"
        print "%g x %g" % (self.ccd.Nx, self.ccd.Ny)

        self.ccd.set_ro_image_mode()
        self.ccd.set_trigger_mode('internal')
        self.ccd.set_exposure_time(1.0)
        self.ccd.set_EMCCD_gain(1)
        self.ccd.set_shutter_open()

        self.ccd_img = self.ax.imshow(np.zeros((self.ccd.Nx, self.ccd.Ny),
                                               dtype=np.int32),
                                      origin='lower',
                                      interpolation='nearest')
        self.spec_line, = self.ax2.plot(np.zeros(self.ccd.Nx, dtype=np.int32),
                                        'k-')
        self.spec_line2, = self.ax2.plot(np.zeros(self.ccd.Nx, dtype=np.int32),
                                         'g-')
        self.video_mode = False

        self.frame.m_button_video_mode_start.Bind(wx.EVT_BUTTON,
                                                  self.on_start_video_mode)
        self.frame.m_button_video_mode_stop.Bind(wx.EVT_BUTTON,
                                                 self.on_stop_video_mode)

        # A/D rate

        choice_adc = self.frame.m_choice_andor_adc
        choice_adc.Clear()
        for speed in self.ccd.HSSpeeds[AD_CHAN]:
            choice_adc.Append("%g MHz" % (speed))

        choice_adc.SetSelection(0)
        self.ccd.set_hs_speed(0)

        choice_adc.Bind(wx.EVT_CHOICE, self.on_change_andor_adc)

        ########################################################################

        self.timer = wx.Timer(id=2001)
        self.timer.Bind(wx.EVT_TIMER, self.on_timer)

        self.timer.Start(2000)

        self.fast_timer = wx.Timer(id=2002)
        self.fast_timer.Bind(wx.EVT_TIMER, self.on_fast_timer)

        #self.frame.m_checkBox_picoharp_fastreadout.Bind(
        #                            wx.EVT_CHECKBOX, self.on_fast_timer_checkbox)

        #self.update_display()
        self.frame.Show()
        return True
Пример #3
0
    def OnInit(self):

        print "OnInit"

        self.HARDWARE_DEBUG = HARDWARE_DEBUG

        self.frame = ScanningSpectrumControlFrame(None)

        # Logged Quantities
        self.x_position = LoggedQuantity(
            name='x_position',
            dtype=np.float,
            display_textctrl=self.frame.m_textCtrl_current_x,
            input_textctrl=self.frame.m_textCtrl_set_current_x)
        self.y_position = LoggedQuantity(
            name='y_position',
            dtype=np.float,
            display_textctrl=self.frame.m_textCtrl_current_y,
            input_textctrl=self.frame.m_textCtrl_set_current_y)

        # Figure ###############################################################
        self.wxfig = MPLFigureWithToolbarWX(self.frame.m_panel_plot)
        self.fig = self.wxfig.fig
        self.ax = self.fig.add_subplot(111)

        # Spectrum Fig
        self.fig2 = pl.figure(2)
        self.ax_speclive = self.fig2.add_subplot(111)
        #self.c0_hist_line, = self.ax2.plot(np.zeros(HIST_LEN,dtype=float))
        #self.c1_hist_line, = self.ax2.plot(np.zeros(HIST_LEN,dtype=float))
        #self.hist_vline = self.ax2.axvline(0)
        #self.c0_hist = np.zeros(HIST_LEN,dtype=float)
        #self.c1_hist = np.zeros(HIST_LEN,dtype=float)
        self.fig2.show()
        #self.history_i = 0

        self.spec_plotline, = self.ax_speclive.plot(range(0, 512),
                                                    range(0, 512))

        ##################### hardware #########################################

        self.scanning = False

        ######## MCL NanoDrive Stage ###########################################
        self.nanodrive = MCLNanoDrive(debug=self.HARDWARE_DEBUG)
        try:
            self.frame.m_staticText_maxdim.SetLabel(
                "max: %g x %g um" %
                (self.nanodrive.cal[XAXIS_ID], self.nanodrive.cal[YAXIS_ID]))
        except Exception as e:
            print e
            self.frame.m_staticText_maxdim.SetLabel("max: ? x ? um")

        self.read_from_hardware()

        self.x_position.hardware_set_func = lambda x: self.nanodrive.set_pos_ax(
            x, XAXIS_ID)
        self.y_position.hardware_set_func = lambda y: self.nanodrive.set_pos_ax(
            y, YAXIS_ID)

        #Spectrometer ##########################################################
        self.spec = ActonSpectrometer(port=SPEC_COMM_PORT,
                                      debug=self.HARDWARE_DEBUG,
                                      dummy=False)

        print self.spec.read_grating_info()

        self.frame.m_choice_spec_grating.Clear()
        for gnum, gname in self.spec.gratings:
            self.frame.m_choice_spec_grating.Append("%i %s" % (gnum, gname))

        print self.spec.gratings_dict

        self.spec.read_grating()

        self.frame.m_choice_spec_grating.SetSelection(self.spec.grating - 1)

        self.spec.read_wl()

        self.frame.m_textCtrl_current_spec_wl.SetValue("%f" % self.spec.wl)

        self.frame.m_textCtrl_set_spec_wl.Bind(wx.EVT_TEXT_ENTER,
                                               self.on_change_spec_wl)
        self.frame.m_choice_spec_grating.Bind(wx.EVT_CHOICE,
                                              self.on_change_spec_grating)
        #self.frame.m_button_spec_stop.Bind(wx.EVT_BUTTON, self.on_spec_stop_motion)
        ########################################################################

        #Andor CCD##############################################################

        self.ccd = AndorCCD(debug=self.HARDWARE_DEBUG)

        print "Andor CCD"
        print "%g x %g" % (self.ccd.Nx, self.ccd.Ny)

        self.spectrum_length = self.ccd.Nx

        self.ccd.set_ro_image_mode()
        self.ccd.set_trigger_mode('internal')
        self.ccd.set_image_flip(ANDOR_HFLIP, ANDOR_VFLIP)
        print "flip", self.ccd.get_image_flip()
        self.ccd.set_ad_channel(ANDOR_AD_CHAN)
        self.ccd.set_exposure_time(1.0)
        self.ccd.set_EMCCD_gain(1)
        self.ccd.set_cooler_on()
        self.ccd.get_temperature()
        self.ccd.set_shutter_open()

        self.spec_fig = pl.figure(3)
        self.specimg_ax = self.spec_fig.add_subplot(111)
        self.spec_ax = self.spec_fig.add_subplot(611)
        self.spec_ax.set_xlim(0, 512)
        self.spec_fig.show()

        self.ccd_img = self.specimg_ax.imshow(np.zeros(
            (self.ccd.Nx, self.ccd.Ny), dtype=np.int32),
                                              origin='lower',
                                              interpolation='nearest')
        self.specimg_ax.axhline(ROW0, color='w')
        self.specimg_ax.axhline(ROW1, color='w')
        self.specimg_ax.axvline(256, color='w')

        self.spec_line, = self.spec_ax.plot(
            np.zeros(self.ccd.Nx, dtype=np.int32), 'k-')
        self.spec_line2, = self.spec_ax.plot(
            np.zeros(self.ccd.Nx, dtype=np.int32), 'g-')

        self.video_mode = False
        self.frame.m_button_video_mode_start.Bind(wx.EVT_BUTTON,
                                                  self.on_start_video_mode)
        self.frame.m_button_video_mode_stop.Bind(wx.EVT_BUTTON,
                                                 self.on_stop_video_mode)

        self.frame.m_textCtrl_andor_exposure.SetValue(
            str(ANDOR_DEFAULT_EXPOSURE))
        self.frame.m_textCtrl_andor_em.SetValue(str(ANDOR_DEFAULT_EMGAIN))

        # A/D rate

        choice_adc = self.frame.m_choice_andor_adc
        choice_adc.Clear()
        for speed in self.ccd.HSSpeeds[ANDOR_AD_CHAN]:
            choice_adc.Append("%g MHz" % (speed))

        choice_adc.SetSelection(0)
        self.ccd.set_hs_speed(0)

        choice_adc.Bind(wx.EVT_CHOICE, self.on_change_andor_adc)

        ########################################################################

        # update figure
        self.ax.set_xlim(0, self.nanodrive.cal[XAXIS_ID])
        self.ax.set_ylim(0, self.nanodrive.cal[YAXIS_ID])

        # events
        self.frame.Bind(wx.EVT_BUTTON, self.on_start_scan,
                        self.frame.m_button_start)
        self.frame.Bind(wx.EVT_BUTTON, self.on_stop_scan,
                        self.frame.m_button_stop)

        self.timer = wx.Timer(id=2001)
        self.timer.Bind(wx.EVT_TIMER, self.on_timer)

        self.timer.Start(2000)

        #self.fast_timer = wx.Timer(id=2002)
        #self.fast_timer.Bind(wx.EVT_TIMER, self.on_fast_timer)

        #self.frame.m_checkBox_picoharp_fastreadout.Bind(
        #                            wx.EVT_CHECKBOX, self.on_fast_timer_checkbox)

        self.update_display()
        self.frame.Show()
        return True
Пример #4
0
    def connect(self):
        if self.debug: print "Connecting to Andor EMCCD Counter"

        # Open connection to hardware
        self.andor_ccd = AndorCCD(debug=self.debug)

        # connect logged quantities
        self.status.hardware_read_func = self.andor_ccd.get_status
        self.temperature.hardware_read_func = self.andor_ccd.get_temperature
        self.exposure_time.hardware_set_func = self.andor_ccd.set_exposure_time
        self.exposure_time.hardware_read_func = self.andor_ccd.get_exposure_time
        self.em_gain.hardware_read_func = self.andor_ccd.get_EMCCD_gain
        self.em_gain.hardware_set_func = self.andor_ccd.set_EMCCD_gain
        self.output_amp.hardware_read_func = self.andor_ccd.get_output_amp
        self.output_amp.hardware_set_func = self.andor_ccd.set_output_amp
        self.ad_chan.hardware_set_func = self.andor_ccd.set_ad_channel
        self.hs_speed_em.hardware_set_func = self.andor_ccd.set_hs_speed_em
        self.hs_speed_conventional.hardware_set_func = self.andor_ccd.set_hs_speed_conventional
        self.shutter_open.hardware_set_func = self.andor_ccd.set_shutter_open
        self.trigger_mode.hardware_set_func = self.andor_ccd.set_trigger_mode
        self.hflip.hardware_read_func = self.andor_ccd.get_image_hflip
        self.hflip.hardware_set_func = self.andor_ccd.set_image_hflip
        self.vflip.hardware_read_func = self.andor_ccd.get_image_vflip
        self.vflip.hardware_set_func = self.andor_ccd.set_image_vflip

        # Update the ROI min and max values to the CCD dimensions
        width = self.andor_ccd.Nx
        height = self.andor_ccd.Ny
        self.roi_fvb_hbin.change_min_max(1, width)
        self.roi_img_hbin.change_min_max(1, width)
        self.roi_img_hend.change_min_max(1, width)
        self.roi_img_hstart.change_min_max(1, width)
        self.roi_img_vbin.change_min_max(1, height)
        self.roi_img_vend.change_min_max(1, height)
        self.roi_img_vstart.change_min_max(1, height)
        self.roi_st_center.change_min_max(1, height)
        self.roi_st_hbin.change_min_max(1, width)
        self.roi_st_width.change_min_max(1, height)

        #Choics for Readout mode
        choices = [("FullVerticalBinning",
                    AndorReadMode.FullVerticalBinning.value),
                   ("SingleTrack", AndorReadMode.SingleTrack.value),
                   ("Image", AndorReadMode.Image.value)]
        self.readout_mode.change_choice_list(choices)

        # Choices for the horizontal shift speeds in EMCCD mode
        choices = []
        for chan_i in range(self.andor_ccd.numADChan):
            for speed in enumerate(self.andor_ccd.HSSpeeds_EM[chan_i]):
                choices.append((str.format("Chan {} - {:.2f} MHz", chan_i,
                                           speed[1]), speed[0]))
        self.hs_speed_em.change_choice_list(choices)

        # Choices for the horizontal shift speeds in conventional mode
        choices = []
        for chan_i in range(self.andor_ccd.numADChan):
            for speed in enumerate(
                    self.andor_ccd.HSSpeeds_Conventional[chan_i]):
                choices.append((str.format("Chan {} - {:.2f} MHz", chan_i,
                                           speed[1]), speed[0]))
        self.hs_speed_conventional.change_choice_list(choices)

        # Choices for the AD channels
        choices = []
        for chan_i in range(self.andor_ccd.numADChan):
            choices.append((str.format("Channel {}", chan_i), chan_i))
        self.ad_chan.change_choice_list(choices)

        # For all of the logged quantities, call read from hardware to make sync
        # everything.
        for name, lq in self.logged_quantities.items():
            lq.read_from_hardware()

        # Set some default values that are useful
        self.andor_ccd.set_temperature(DEFAULT_TEMPERATURE)

        if not self.has_been_connected_once:
            # initialize the readout parameters
            self.output_amp.update_value(0)  #EMCCD mode
            self.ad_chan.update_value(0)  #14-bit AD Chan
            self.hs_speed_em.update_value(0)  #10 MHz readout speed
            self.hflip.update_value(True)  #Default to true horizontal flip
            self.exposure_time.update_value(1)  #Default to a 1 s integration
            self.shutter_open.update_value(False)  #Close the shutter.
            self.em_gain.update_value(10)
            self.cooler_on.update_value(True)

            # Readout and ROI parameters
            self.readout_mode.update_value(
                AndorReadMode.Image.value)  #Full image readout mode
            self.roi_img_hstart.update_value(1)
            self.roi_img_hend.update_value(width)
            self.roi_img_hbin.update_value(1)
            self.roi_img_vstart.update_value(1)
            self.roi_img_vend.update_value(height)
            self.roi_img_vbin.update_value(1)
            self.roi_st_center.update_value(height / 2)
            self.roi_st_width.update_value(height / 10)
            self.roi_st_hbin.update_value(1)
            self.roi_fvb_hbin.update_value(1)

        self.set_readout()

        self.is_connected = True