def _loop_differential_spectrum(self): """ This loop toggles the modulation and iteratively records a differential spectrum. """ # If the loop should not continue, then return immediately without # emitting any signal to repeat. if not self._continue_differential: return # Otherwise, we make a measurement and then emit a signal to repeat this loop. # Toggle on, take spectrum and add data to the mod_on data self.toggle_modulation(on=True) these_data = netobtain(self._spectrometer_device.recordSpectrum()) self.diff_spec_data_mod_on[1, :] += these_data[1, :] # Toggle off, take spectrum and add data to the mod_off data self.toggle_modulation(on=False) these_data = netobtain(self._spectrometer_device.recordSpectrum()) self.diff_spec_data_mod_off[1, :] += these_data[1, :] self.repetition_count += 1 # increment the loop count # Calculate the differential spectrum self._spectrum_data[1, :] = self.diff_spec_data_mod_on[ 1, :] - self.diff_spec_data_mod_off[1, :] self.sig_specdata_updated.emit() self.sig_next_diff_loop.emit()
def _loop_differential_spectrum(self): """ This loop toggles the modulation and iteratively records a differential spectrum. """ # If the loop should not continue, then return immediately without # emitting any signal to repeat. if not self._continue_differential: return # Otherwise, we make a measurement and then emit a signal to repeat this loop. # Toggle on, take spectrum and add data to the mod_on data self.toggle_modulation(on=True) these_data = netobtain(self._spectrometer_device.recordSpectrum()) self.diff_spec_data_mod_on[1, :] += these_data[1, :] # Toggle off, take spectrum and add data to the mod_off data self.toggle_modulation(on=False) these_data = netobtain(self._spectrometer_device.recordSpectrum()) self.diff_spec_data_mod_off[1, :] += these_data[1, :] self.repetition_count += 1 # increment the loop count # Calculate the differential spectrum self.spectrum_data[1, :] = self.diff_spec_data_mod_on[ 1, :] - self.diff_spec_data_mod_off[1, :] self.sig_specdata_updated.emit() self.sig_next_diff_loop.emit()
def startKernel(self, config, external=None): """Start a qudi inprocess jupyter kernel. @param dict config: connection information for kernel @param callable external: function to call on exit of kernel @return str: uuid of the started kernel """ realconfig = netobtain(config) self.log.debug('Start {0}'.format(realconfig)) kernel = QZMQKernel(realconfig) kernelthread = self._manager.tm.newThread('kernel-{0}'.format(kernel.engine_id)) kernel.moveToThread(kernelthread) kernel.user_global_ns.update({ 'pg': pg, 'np': np, 'config': self._manager.tree['defined'], 'manager': self._manager }) kernel.sigShutdownFinished.connect(self.cleanupKernel) self.log.debug('Kernel is {0}'.format(kernel.engine_id)) kernelthread.start() QtCore.QMetaObject.invokeMethod(kernel, 'connect_kernel', QtCore.Qt.BlockingQueuedConnection) self.kernellist[kernel.engine_id] = kernel self.log.info('Finished starting Kernel {0}'.format(kernel.engine_id)) self.sigStartKernel.emit(kernel.engine_id) return kernel.engine_id
def get_acquired_data(self): """ Return an array of last acquired data. @return: Data in the format depending on the read mode. Depending on the read mode, the format is : 'FVB' : 1d array 'MULTIPLE_TRACKS' : list of 1d arrays 'IMAGE' 2d array of shape (width, height) 'IMAGE_ADVANCED' 2d array of shape (width, height) Each value might be a float or an integer. """ if self._reverse_data_with_side_output and self.output_port == "OUTPUT_SIDE": return netobtain(self.camera().get_acquired_data()[:, ::-1]) return netobtain(self.camera().get_acquired_data())
def stopKernel(self, kernelid): """Tell kernel to close all sockets and stop hearteat thread. @param str kernelid: uuid of kernel to be stopped """ realkernelid = netobtain(kernelid) self.log.info('Stopping kernel {0}'.format(realkernelid)) kernel = self.kernellist[realkernelid] QtCore.QMetaObject.invokeMethod(kernel, 'shutdown')
def get_single_spectrum(self, background=False): """ Record a single spectrum from the spectrometer. """ # Clear any previous fit self.fc.clear_result() if background: self._spectrum_background = netobtain(self._spectrometer_device.recordSpectrum()) else: self._spectrum_data = netobtain(self._spectrometer_device.recordSpectrum()) self._calculate_corrected_spectrum() # Clearing the differential spectra data arrays so that they do not get # saved with this single spectrum. self.diff_spec_data_mod_on = np.array([]) self.diff_spec_data_mod_off = np.array([]) self.sig_specdata_updated.emit()
def get_single_spectrum(self): self.spectrum_data = netobtain( self._spectrometer_device.recordSpectrum()) # Clearing the differential spectra data arrays so that they do not get # saved with this single spectrum. self.diff_spec_data_mod_on = np.array([]) self.diff_spec_data_mod_off = np.array([]) self.sig_specdata_updated.emit()
def get_single_spectrum(self): """ Record a single spectrum from the spectrometer. """ self.spectrum_data = netobtain(self._spectrometer_device.recordSpectrum()) # Clearing the differential spectra data arrays so that they do not get # saved with this single spectrum. self.diff_spec_data_mod_on = np.array([]) self.diff_spec_data_mod_off = np.array([]) self.sig_specdata_updated.emit()
def get_data(self, fastcounter='fastcomtec'): """ get the singleshot data from the fastcounter along with its shape @param: optional string fastcounter: Determines how the data is extracted from the fastcounter @return: dictionary containing shape of the data as well as the raw data coming from fastcounter and possible additional data to calculate dt ( the time between two singleshot measurements ) later. """ return_dict = OrderedDict() if not self._fast_counter_device.is_gated(): if fastcounter == 'fastcomtec': settings = self._fast_counter_device.get_settings() # check if settings object is coming from a remote connection settings = netobtain(settings) n_rows = settings.cycles # looks like this is in ns, but I'm not completely sure n_columns = settings.range reps_per_row = settings.swpreset raw_data = netobtain( self._fast_counter_device.get_data_trace(sweep_reset=True)) return_dict['n_rows'] = n_rows return_dict['n_columns'] = n_columns return_dict['reps_per_row'] = reps_per_row return_dict['raw_data'] = raw_data # needed to internally calculate the measurement time, unless the columns are # always in ns ? return_dict[ 'bin_width'] = self._fast_counter_device.get_binwidth() else: self.log.warning( 'other ungated counters are not implemented at the moment') else: self.log.warning('using gated counter not implemented yet') self.data_dict = return_dict return 0
def get_data(self, fastcounter='fastcomtec'): """ get the singleshot data from the fastcounter along with its shape @param: optional string fastcounter: Determines how the data is extracted from the fastcounter @return: dictionary containing shape of the data as well as the raw data coming from fastcounter and possible additional data to calculate dt ( the time between two singleshot measurements ) later. """ return_dict = OrderedDict() if not self._fast_counter_device.is_gated(): if fastcounter == 'fastcomtec': settings = self._fast_counter_device.get_settings() # check if settings object is coming from a remote connection settings = netobtain(settings) n_rows = settings.cycles # looks like this is in ns, but I'm not completely sure n_columns = settings.range reps_per_row = settings.swpreset raw_data = netobtain(self._fast_counter_device.get_data_trace(sweep_reset=True)) return_dict['n_rows'] = n_rows return_dict['n_columns'] = n_columns return_dict['reps_per_row'] = reps_per_row return_dict['raw_data'] = raw_data # needed to internally calculate the measurement time, unless the columns are # always in ns ? return_dict['bin_width'] = self._fast_counter_device.get_binwidth() else: self.log.warning('other ungated counters are not implemented at the moment') else: self.log.warning('using gated counter not implemented yet') self.data_dict = return_dict return 0
def start_differential_spectrum(self): """Start a differential spectrum acquisition. An initial spectrum is recorded to initialise the data arrays to the right size. """ self._continue_differential = True # Taking a demo spectrum gives us the wavelength values and the length of the spectrum data. demo_data = netobtain(self._spectrometer_device.recordSpectrum()) wavelengths = demo_data[0, :] empty_signal = np.zeros(len(wavelengths)) # Using this information to initialise the differential spectrum data arrays. self.spectrum_data = np.array([wavelengths, empty_signal]) self.diff_spec_data_mod_on = np.array([wavelengths, empty_signal]) self.diff_spec_data_mod_off = np.array([wavelengths, empty_signal]) self.repetition_count = 0 # Starting the measurement loop self._loop_differential_spectrum()
def start_differential_spectrum(self): """Start a differential spectrum acquisition. An initial spectrum is recorded to initialise the data arrays to the right size. """ self._continue_differential = True # Taking a demo spectrum gives us the wavelength values and the length of the spectrum data. demo_data = netobtain(self._spectrometer_device.recordSpectrum()) wavelengths = demo_data[0, :] empty_signal = np.zeros(len(wavelengths)) # Using this information to initialise the differential spectrum data arrays. self._spectrum_data = np.array([wavelengths, empty_signal]) self.diff_spec_data_mod_on = np.array([wavelengths, empty_signal]) self.diff_spec_data_mod_off = np.array([wavelengths, empty_signal]) self.repetition_count = 0 # Starting the measurement loop self._loop_differential_spectrum()
def update_additional_parameters(self, *args, **kwargs): """ Method to update one or multiple additional parameters @param dict args: Optional single positional argument holding parameters in a dict to update additional parameters from. @param kwargs: Optional keyword arguments to be added to additional parameters """ if len(args) == 0: param_dict = kwargs elif len(args) == 1 and isinstance(args[0], dict): param_dict = args[0] param_dict.update(kwargs) else: raise TypeError('"update_additional_parameters" takes exactly 0 or 1 positional ' 'argument of type dict.') for key in param_dict.keys(): param_dict[key] = netobtain(param_dict[key]) self._additional_parameters.update(param_dict) return
def update_additional_parameters(self, **new_pairs): """ Method to update one or multiple additional parameters """ dic = {} for key in new_pairs.keys(): dic[key] = netobtain(new_pairs[key]) self._additional_parameters = {**self._additional_parameters, **dic}