def _getYValueFromTraceNum(self,ds,num): y_ds = _get_ds(ds, ds.attrs.get('y_ds_url')) if ds.attrs.get('ds_type') == ds_types['box']: y_data = np.array(y_ds)[:ds.attrs.get('fill')[1]] else: y_data = np.array(y_ds)[:ds.shape[1]] yunit = _get_unit(y_ds) yval = y_data[num] return str(yval)+" "+str(yunit)
def _getXValueFromTraceNum(self, ds, num): x_ds = _get_ds(ds, ds.attrs.get('x_ds_url')) if ds.attrs.get('ds_type') == ds_types['box']: x_data = np.array(x_ds)[:ds.attrs.get('fill')[0]] else: x_data = np.array(x_ds)[:ds.shape[0]] xunit = _get_unit(x_ds) xval = x_data[num] return str(xval) + " " + str(xunit)
def update_plots(self): """Checks the signal slots and changes the plotting attributes to be evaluated by PlotWindow_lib. This function coordinates the changing input from the signal slots and updates the attributes that are parsed to the plotting lib functions. update_plots() is either periodically called e.g. by the timer or once on startup. Args: self: Object of the PlotWindow class. Returns: No return variable. The function operates on the given object. """ #print "PWL update_plots:", self.obj_parent.h5file try: self.ds = self.obj_parent.h5file[self.dataset_url] except ValueError as e: print(str(self.dataset_url)+": "+str(e)) return self.ds_type = self.ds.attrs.get('ds_type', -1) # The axis names are parsed to plot_view's Ui_Form class to label the UI selectors x_ds_name = _get_name(_get_ds(self.ds, self.ds.attrs.get('x_ds_url', ''))) y_ds_name = _get_name(_get_ds(self.ds, self.ds.attrs.get('y_ds_url', ''))) z_ds_name = _get_name(_get_ds(self.ds, self.ds.attrs.get('z_ds_url', ''))) try: if self.ds.attrs.get('xy_0', ''): x_ds_name_view = _get_name(_get_ds(self.ds,_get_ds(self.ds, self.ds.attrs.get('xy_0', '').decode().split(':')[1]).attrs.get('x_ds_url', ''))) y_ds_name_view = _get_name(_get_ds(self.ds,_get_ds(self.ds, self.ds.attrs.get('xy_0', '').decode().split(':')[1]).attrs.get('y_ds_url', ''))) else: raise AttributeError except AttributeError: x_ds_name_view = '_none_' y_ds_name_view = '_none_' selector_label = [x_ds_name, y_ds_name, z_ds_name, x_ds_name_view, y_ds_name_view] ## At first window creation the attributes are set to state zero. if self._windowJustCreated: # A few state variables: self._onPlotTypeChanged = True self._windowJustCreated = False self.graphicsView = None self.TraceValueChanged = False self.TraceZValueChanged = False self.TraceXValueChanged = False self.TraceYValueChanged = False self.VTraceZValueChanged = False self.VTraceXValueChanged = False self.VTraceYValueChanged = False # the following calls rely on ds_type and setup the layout of the plot window. self.setupUi(self,self.ds_type, selector_label) window_title = str(self.dataset_url.split('/')[-1]) +" "+ str(self.DATA.filename) self.setWindowTitle(window_title) self._setDefaultView() self._setup_signal_slots() ## We check here for the view type given by either default setting or ## user input. Creates the canvas and calls the associated plot ## function from the lib. For code constistence the variable names are ## the same in all view types. try: if self.view_type == view_types['1D-V']: if not self.graphicsView or self._onPlotTypeChanged: self._onPlotTypeChanged = False self.graphicsView = pg.PlotWidget(name=self.dataset_url) self.graphicsView.setObjectName(self.dataset_url) self.addQvkMenu() self.graphicsView.sceneObj.contextMenu[:0] = [self.qvkMenu] self.gridLayout.addWidget(self.graphicsView,0,0) _display_1D_view(self,self.graphicsView) elif self.view_type == view_types['1D']: if not self.graphicsView or self._onPlotTypeChanged: self._onPlotTypeChanged = False self.graphicsView = pg.PlotWidget(name=self.dataset_url) self.graphicsView.setObjectName(self.dataset_url) self.addQvkMenu() self.graphicsView.sceneObj.contextMenu[:0] = [self.qvkMenu] self.gridLayout.addWidget(self.graphicsView,0,0) _display_1D_data(self,self.graphicsView) elif self.view_type == view_types['2D']: if not self.graphicsView or self._onPlotTypeChanged: self._onPlotTypeChanged = False self.graphicsView = ImageViewMplColorMaps(self.obj_parent, view = pg.PlotItem()) self.graphicsView.setObjectName(self.dataset_url) self.addQvkMenu() self.graphicsView.scene.contextMenu[:0] = [self.qvkMenu] self.graphicsView.view.setAspectLocked(False) self.gridLayout.addWidget(self.graphicsView,0,0) self.linestyle_selector.setDisabled(True) _display_2D_data(self,self.graphicsView) elif self.view_type == view_types['table']: if not self.graphicsView or self._onPlotTypeChanged: self._onPlotTypeChanged = False self.graphicsView = pg.TableWidget(sortable=False) self.graphicsView.setWindowTitle(self.dataset_url+'_table') self.graphicsView.setObjectName(self.dataset_url) self.graphicsView.setFormat("%.6g") self.gridLayout.addWidget(self.graphicsView,0,0) _display_table(self,self.graphicsView) elif self.view_type == view_types['txt']: if not self.graphicsView or self._onPlotTypeChangeBox: self._onPlotTypeChangeBox = False self.graphicsView = QPlainTextEdit() self.graphicsView.setObjectName(self.dataset_url) self.gridLayout.addWidget(self.graphicsView,0,0) self.graphicsView.clear() _display_text(self,self.graphicsView) else: print("This should not be here: View Type:"+str(self.view_type)) except ValueError as e: print("PlotWindow: Value Error; Dataset not yet available", self.dataset_url) print(e)
def _getZValueFromTraceNum(self,ds,num): z_ds = _get_ds(ds, ds.attrs.get('z_ds_url')) z_data = np.array(z_ds)[:ds.shape[2]] zunit = _get_unit(z_ds) zval = z_data[num] return str(zval)+" "+str(zunit)