def get_trace(self, mode='lin'): ''' Send trigger to device, wait for aquiring the data, and read back the data from the device. ''' qt.mstart() startfreq = self.get_start_freq(query=False) stopfreq = self.get_stop_freq(query=False) numpoints = self.get_numpoints(query=False) if mode=='lin': freqs = numpy.linspace(startfreq,stopfreq,numpoints) elif mode=='log': freqs = numpy.logspace(numpy.log10(startfreq),numpy.log10(stopfreq),numpoints) else: print 'mode needs to be either "lin" or "log"!' return False sweep_time = self.get_sweep_time(query=False) print 'sending trigger to network analyzer, and wait to finish' print 'estimated waiting time: %.2f s' % sweep_time self.send_trigger() qt.msleep(sweep_time) print 'readout network analyzer' reply = self.read() reply = numpy.array(reply) qt.mend() return (freqs, reply)
def get_trace(self, mode='lin'): ''' Send trigger to device, wait for aquiring the data, and read back the data from the device. ''' qt.mstart() startfreq = self.get_start_freq(query=False) stopfreq = self.get_stop_freq(query=False) numpoints = self.get_numpoints(query=False) if mode == 'lin': freqs = numpy.linspace(startfreq, stopfreq, numpoints) elif mode == 'log': freqs = numpy.logspace(numpy.log10(startfreq), numpy.log10(stopfreq), numpoints) else: print 'mode needs to be either "lin" or "log"!' return False sweep_time = self.get_sweep_time(query=False) print 'sending trigger to network analyzer, and wait to finish' print 'estimated waiting time: %.2f s' % sweep_time self.send_trigger() qt.msleep(sweep_time) print 'readout network analyzer' reply = self.read() reply = numpy.array(reply) qt.mend() return (freqs, reply)
def run(self): qt.mstart() self.Fire() qt.msleep(0.1) while not self.buttons[8]: print "==============================" self.Fire() qt.msleep(0.1) qt.mend() print "So long, and thanks for all the fish!"
def start(self): from qtlab.source import qt tstart = exact_time() i = 0 while i < self._n: self._cb(i, *self._args, **self._kwargs) i += 1 if i == self._n: break # delay tn = exact_time() req_delay = tstart + float(i) * self._delay / 1000.0 - tn if req_delay > 0: qt.msleep(req_delay)
def get_trace(self): ''' This function performs a full measurement. First a trigger is sent to initiate a sweep. An estimate is made of the time the sweep takes. After the estimated time the data is queried from the device. Usually the estimated time is a bit lower then the actual time, the device will respond as soon as it is finished. It is assumed that the instrument is already on 'trigger hold'-mode. Input: None Ouptput: freqs (array of floats): The frequencies at which the reflection / transmission was measured reply (arrray of foats): Measured data ''' qt.mstart() startfreq = self.get_start_freq(query=False) stopfreq = self.get_stop_freq(query=False) numpoints = self.get_numpoints(query=False) IF_Bandwidth = self.get_IF_Bandwidth(query=False) freqs = numpy.linspace(startfreq,stopfreq,numpoints) sweep_time = numpoints / IF_Bandwidth print 'sending trigger to network analyzer, and wait to finish' print 'estimated waiting time: %.2f s' % sweep_time self.send_trigger() qt.msleep(sweep_time) print 'reading out network analyzer' reply = self.read() reply = numpy.array(reply) qt.mend() return (freqs, reply)
def get_trace(self): ''' This function performs a full measurement. First a trigger is sent to initiate a sweep. An estimate is made of the time the sweep takes. After the estimated time the data is queried from the device. Usually the estimated time is a bit lower then the actual time, the device will respond as soon as it is finished. It is assumed that the instrument is already on 'trigger hold'-mode. Input: None Ouptput: freqs (array of floats): The frequencies at which the reflection / transmission was measured reply (arrray of foats): Measured data ''' qt.mstart() startfreq = self.get_start_freq(query=False) stopfreq = self.get_stop_freq(query=False) numpoints = self.get_numpoints(query=False) IF_Bandwidth = self.get_IF_Bandwidth(query=False) freqs = numpy.linspace(startfreq, stopfreq, numpoints) sweep_time = numpoints / IF_Bandwidth print 'sending trigger to network analyzer, and wait to finish' print 'estimated waiting time: %.2f s' % sweep_time self.send_trigger() qt.msleep(sweep_time) print 'reading out network analyzer' reply = self.read() reply = numpy.array(reply) qt.mend() return (freqs, reply)
def start(self): ''' Start measurement loop. ''' if len(self._coords) == 0: logging.info('Not starting measurement without loop') self.emit('finished', 'ok') return False # determine loop delay last_coord = self._coords[len(self._coords) - 1] if 'delay' in self._options: self._delay = self._options['delay'] elif 'delay' in last_coord: self._delay = last_coord['delay'] else: logging.warning('measurement delay undefined') return False # determine loop steps self._ntotal = 1 for coord in self._coords: self._ntotal *= coord['steps'] # Create file self._data.create_file(self._name) # Set starting values and sleep self._last_index = [-1 for i in xrange(len(self._coords))] self._do_set_values(-1) time.sleep(self._delay / 1000.0) for i in range(self._ntotal): self._measure() try: qt.msleep(self._delay / 1000.0) except: self.emit('finished', 'Interrupted') self.emit('finished', 'Ok')
def take_spectra(self, n=100): return for i in range(n): self.take_spectrum() qt.msleep(0.05) return
import numpy as np from qtlab.source import qt d = qt.Data() d.add_coordinate('X') d.add_value('Y') d.create_file() p = plot(d) # Inform wrapper that a measurement has started qt.mstart() for x in arange(0, 40, 0.1): y = np.sin(x) + np.random.rand() / 10 d.add_data_point(x, y) # Sleep for 100msec and allow UI interaction qt.msleep(0.1) # Inform wrapper that the measurement has ended qt.mend() d.close_file()
import numpy as np from qtlab.source import qt d = qt.Data() d.add_coordinate('X') d.add_value('Y') d.create_file() p = plot(d) # Inform wrapper that a measurement has started qt.mstart() for x in arange(0, 40, 0.1): y = np.sin(x) + np.random.rand()/10 d.add_data_point(x, y) # Sleep for 100msec and allow UI interaction qt.msleep(0.1) # Inform wrapper that the measurement has ended qt.mend() d.close_file()