def __init__(self, *args, **kwargs): FigureWindow.__init__(self, *args, **kwargs) self.currentData = None # algorithm dict and current data self.algorithms = AlgorithmDict() self.lockAttribute('algorithms') # # The toolbar toolTabs = self.toolTabs figureBook = self.figureBook frmAlgo = Frame(toolTabs) grpAlgoSel = AlgoSelGroup(frmAlgo, topwin=self) grpAlgoSel.pack(side=LEFT, fill=Y) grpParams = ParamsGroup(frmAlgo, topwin=self) grpParams.pack(side=LEFT, fill=Y) grpSolve = OptimizeGroup(frmAlgo, topwin=self) grpSolve.pack(side=LEFT, fill=Y) toolTabs.add(frmAlgo, text='Algorithm') with self.attributeLock: setMultiAttr(self, grpAlgoSel = grpAlgoSel, grpParams = grpParams, grpSolve = grpSolve ) self.makeViewTab() self.makeMarkerTab() self.makeExportTab() # End toolbar figureBook.makeFigures( figureMeta = [ dict(name='Envelope', polar=False), dict(name='Phase', polar=False), dict(name='AutoCorrelation', polar=False), dict(name='PSD', polar=False) ] ) with open(Application.instance.configFileName) as f: config = json.load(f) algorithms = config['SingleWaveformAlgorithms'] for algo in algorithms: self.loadAlgorithm(moduleName=algo['ModuleName'], className=algo['ClassName']) self.grpAlgoSel.algoList.current(len(algorithms)-1) figEnvelope = figureBook[0] figEnvelope.plotFunction = lambda currentData, *args, **kwargs:\ figEnvelope.plot(abs(currentData), *args, **kwargs) figPhase = figureBook[1] figPhase.plotFunction = lambda currentData, *args, **kwargs:\ figPhase.plot(angle(currentData), *args, **kwargs) def plot_acdb(currentData, *args, **kwargs): s = currentData if not isinstance(s, ndarray): s = array(s) N = len(s) ac = convolve(s, conj(s[::-1])) acdb = 20*log10(abs(ac)) acdb = acdb - max(acdb) figAuto.plot(r_[(-N+1):N], acdb, *args, **kwargs) figAuto = figureBook[2] figAuto.plotFunction = plot_acdb figPSD = figureBook[3] figPSD.plotFunction = lambda currentData, *args, **kwargs:\ figPSD.plot(abs(fft.fft(currentData)), *args, **kwargs)
def on_connect(self): # algorithm dict and current data self.algorithms = AlgorithmDict() self.lock_attribute('algorithms') # # The toolbar tool_tabs = self._tool_tabs figure_book = self.figure_book frmAlgo = Frame(tool_tabs) algorithm_selection_group = AlgoSelGroup(frmAlgo, topwin=self) algorithm_selection_group.pack(side='left', fill='y') parameter_group = ParamsGroup(frmAlgo, topwin=self, wavesyn_root=self.root_node) parameter_group.pack(side='left', fill='y') solve_group = OptimizeGroup(frmAlgo, topwin=self, wavesyn_root=self.root_node) solve_group.pack(side='left', fill='y') tool_tabs.add(frmAlgo, text='Algorithm') with self.attribute_lock: set_attributes(self, algorithm_selection_group=algorithm_selection_group, parameter_group=parameter_group, solve_group=solve_group) self._make_view_tab() self._make_marker_tab() self._make_export_tab() self._make_window_manager_tab() # End toolbar figure_book.make_figures(figure_meta=[ dict(name='Envelope', polar=False), dict(name='Phase', polar=False), dict(name='AutoCorrelation', polar=False), dict(name='PSD', polar=False) ]) with open(self.root_node.config_file_path) as f: config = json.load(f) algorithms = config['SingleWaveformAlgorithms'] for algo in algorithms: self.load_algorithm(module_name=algo['ModuleName'], class_name=algo['ClassName']) self.algorithm_selection_group.algorithm_list.current( len(algorithms) - 1) envelope_figure = figure_book[0] envelope_figure.plot_function = lambda current_data, *args, **kwargs:\ envelope_figure.plot(abs(current_data), *args, **kwargs) phase_figure = figure_book[1] phase_figure.plot_function = lambda current_data, *args, **kwargs:\ phase_figure.plot(angle(current_data), *args, **kwargs) def plot_acdb(current_data, *args, **kwargs): s = current_data if not isinstance(s, ndarray): s = array(s) N = len(s) ac = convolve(s, conj(s[::-1])) acdb = 20 * log10(abs(ac)) acdb = acdb - max(acdb) autocorrelatino_figure.plot(r_[(-N + 1):N], acdb, *args, **kwargs) autocorrelatino_figure = figure_book[2] autocorrelatino_figure.plot_function = plot_acdb psd_figure = figure_book[3] psd_figure.plot_function = lambda current_data, *args, **kwargs:\ psd_figure.plot(abs(fft.fft(current_data)), *args, **kwargs)