def read_measurements(self, start_channel): try: # No impedance_readings were provided, so run impedance routine to # collect measurements. def on_update(df): gtk.gdk.threads_enter() self.measurements_label.set_label('channel=%d' % df.iloc[0]['channel']) i = int(df.iloc[0]['channel'] % self.channels_per_board) self.measure_progress.set_fraction( float(i + 1) / self.channels_per_board) self.measure_progress.set_text( 'Measurement: %s/%s' % (i + 1, self.channels_per_board)) width, height = self.measure_progress.size_request() self.measure_progress.set_size_request(width, 40) while gtk.events_pending(): gtk.main_iteration(False) gtk.gdk.threads_leave() self.test_loads = TEST_LOADS.copy() self.test_loads.index += start_channel self.readings = sweep_channels(self.control_board, self.test_loads, on_update=on_update) finally: self.restore_settings() gtk.gdk.threads_enter() self.measurements_label.set_label('Done.') self.widget.set_page_complete(self.box1, True) gtk.gdk.threads_leave()
def read_measurements(self, start_channel): try: # No impedance_readings were provided, so run impedance routine to # collect measurements. def on_update(df): gtk.gdk.threads_enter() self.measurements_label.set_label('channel=%d' % df.iloc[0]['channel']) i = int(df.iloc[0]['channel'] % self.channels_per_board) self.measure_progress.set_fraction(float(i + 1) / self.channels_per_board) self.measure_progress.set_text('Measurement: %s/%s' % (i + 1, self.channels_per_board)) width, height = self.measure_progress.size_request() self.measure_progress.set_size_request(width, 40) while gtk.events_pending(): gtk.main_iteration(False) gtk.gdk.threads_leave() self.test_loads = TEST_LOADS.copy() self.test_loads.index += start_channel self.readings = sweep_channels(self.control_board, self.test_loads, on_update=on_update) finally: self.restore_settings() gtk.gdk.threads_enter() self.measurements_label.set_label('Done.') self.widget.set_page_complete(self.box1, True) gtk.gdk.threads_leave()
def plot_channel_sweep(proxy, start_channel): ''' Parameters ---------- proxy : DMFControlBoard start_channel : int Channel number from which to start a channel sweep (should be a multiple of 40, e.g., 0, 40, 80). Returns ------- pandas.DataFrame See description of return of :func:`sweep_channels`. ''' test_loads = TEST_LOADS.copy() test_loads.index += start_channel results = sweep_channels(proxy, test_loads) normalized_measurements = (results['measured capacitance'] / results['expected capacitance']) fig, axis = plt.subplots(figsize=(10, 8)) axis.bar(normalized_measurements.index - 0.3, normalized_measurements, width=0.6, edgecolor='none', facecolor='limegreen') axis.set_xlim(left=test_loads.index.min() - 0.5, right=test_loads.index.max() + 0.5) axis.set_xlabel('channel') axis.set_ylabel(r'$\frac{C_{\tt{measured}}}{C_{\tt{expected}}}$', fontsize=28) return results