def __init__(self, *args, **kwargs): win = CurveDialog(edit=False, toolbar=True) # Make Plot plot = win.get_plot() self.verticalLayout_5.addWidget(plot) self.fret_line_plot = plot FRETLineGenerator.__init__(self, **kwargs) self.fit = mfm.FitQtThread() # the fit has to be a QtThread self.fit.data = self._data_points self.verbose = kwargs.get('verbose', chisurf.verbose) self.model_names = [str(model[0].name) for model in self.models] self.comboBox.addItems(self.model_names) self.model = self.current_model_index self.actionModel_changed.triggered.connect(self.onModelChanged) self.actionParameter_changed.triggered.connect(self.onParameterChanged) self.actionUpdate_Parameter.triggered.connect(self.update_parameter) self.actionCalculate_FRET_Line.triggered.connect(self.onCalculate) self.actionClear_plot.triggered.connect(self.onClearPlot) self.onModelChanged() self.update_parameter() self.hide()
def testFcn(self): x = np.linspace(0, 100, 1000) y = (np.random.rand(len(x)) - 0.5).cumsum() curve = make.curve(x, y, "ab", "b") range = make.range(0, 5) disp2 = make.computations( range, "TL", [ (curve, "min=%.5f", lambda x, y: y.min()), (curve, "max=%.5f", lambda x, y: y.max()), (curve, "avg=%.5f", lambda x, y: y.mean()), ], ) legend = make.legend("TR") items = [curve, range, disp2, legend] win = CurveDialog(edit=False, toolbar=True, parent=self) plot = win.get_plot() for item in items: plot.add_item(item) win.show()
def __init__(self, main, title, ylabel, xlabel, yunit, xunit, itemlist=False, toolbar=False): super(Plot, self).__init__() self._plot = CurveDialog(toolbar=toolbar, wintitle=title, options=dict(ylabel=ylabel, yunit=yunit, xlabel=xlabel, xunit=xunit)) if itemlist: self._plot.get_itemlist_panel().show() set_size_policy(self, QSizePolicy.Expanding, QSizePolicy.Expanding) set_size_policy(self._plot, QSizePolicy.Expanding, QSizePolicy.Expanding) QtCore.QMetaObject.connectSlotsByName(self) self.setObjectName("Plot") main.addWidget(self._plot)
def __init__(self, parent=None, designMode=False, taurusparam=None, toolbar=True, **kwargs): '''see :class:`guiqwt.plot.CurveDialog` for other valid initialization parameters''' CurveDialog.__init__(self, parent=parent, toolbar=toolbar, **kwargs) TaurusBaseWidget.__init__(self, 'TaurusTrendDialog') self.deprecated(rel='4.1', dep='TaurusTrendDialog', alt='TaurusTrend / taurus tpg trend launcher') self.setWindowFlags(Qt.Qt.Widget) self._designMode = designMode self._modelNames = CaselessList() from guiqwt.styles import style_generator self.style = style_generator() self.setSupportedMimeTypes( [TAURUS_MODEL_LIST_MIME_TYPE, TAURUS_ATTR_MIME_TYPE]) from taurus.qt.qtgui.extra_guiqwt.tools import TaurusModelChooserTool, AutoScrollTool self.add_tool(TaurusModelChooserTool, singleModel=False) self.add_tool(AutoScrollTool) self.setModifiableByUser(self._modifiableByUser) if taurusparam is None: taurusparam = TaurusTrendParam() self.defaultTaurusparam = taurusparam self.setContextMenuPolicy(Qt.Qt.CustomContextMenu) self.registerConfigDelegate(self.get_tool(AutoScrollTool))
class PlotWidget(): '''GuiQwt Plot''' def __init__(self, title, x_axis='lin', x_label='x', y_label='y'): '''Init plot and curves''' self.plot_dlg = CurveDialog(edit=False, toolbar=False, wintitle=title, options=dict(xlabel=x_label, ylabel=y_label)) self.curves = [] self._x_axis = x_axis self._init_plot(x_label, y_label) def _init_plot(self, xlabel, ylabel): '''Init plot''' self.plot_dlg.get_itemlist_panel().show() _plot = self.plot_dlg.get_plot() #_label = '{0} = %.2f<br>{1} = %.2f'.format(xlabel, ylabel) #_xcursor = make.xcursor(0, 0, _label) #_plot.add_item(_xcursor) _plot.set_antialiasing(True) def add_curve(self, x, y, title, color): '''Add curves''' self.curves.append(make.curve(x, y, title=title, color=color)) def update_curve(self, curve_item, x, y): '''Update curve values''' curve_item.set_data(x, y) curve_item.plot().replot() def del_curves(self): '''Delete curves''' _plot = self.plot_dlg.get_plot() for curve_item in self.curves: _plot.del_item(curve_item) self.curves = [] def _plot_items(self): '''Plot curve items''' _plot = self.plot_dlg.get_plot() for curve_item in self.curves: _plot.add_item(curve_item) _plot.set_axis_scale(curve_item.xAxis(), self._x_axis) self.refresh() def refresh(self): '''Refersh plots''' _plot = self.plot_dlg.get_plot() _plot.do_autoscale() self.plot_dlg.adjustSize() def show(self): '''Show Plot''' self._plot_items() self.plot_dlg.show()
def __init__(self, title, x_axis='lin', x_label='x', y_label='y'): '''Init plot and curves''' self.plot_dlg = CurveDialog(edit=False, toolbar=False, wintitle=title, options=dict(xlabel=x_label, ylabel=y_label)) self.curves = [] self._x_axis = x_axis self._init_plot(x_label, y_label)
def taurusTrendMain(): from taurus.qt.qtgui.extra_guiqwt.builder import make from taurus.qt.qtgui.application import TaurusApplication from guiqwt.plot import CurveDialog from guiqwt.tools import HRangeTool import taurus.core.util.argparse import sys parser = taurus.core.util.argparse.get_taurus_parser() parser.set_usage("%prog [options] [<model1> [<model2>] ...]") parser.set_description("a taurus application for plotting 1D data sets") parser.add_option("-x", "--x-axis-mode", dest="x_axis_mode", default='d', metavar="t|d|e", help="interpret X values as timestamps (t), time deltas (d) or event numbers (e). Accepted values: t|d|e") parser.add_option("-b", "--buffer", dest="max_buffer_size", default='16384', help="maximum number of values to be plotted (when reached, the oldest values will be discarded)") parser.add_option("-a", "--use-archiving", action="store_true", dest="use_archiving", default=False) parser.add_option("--demo", action="store_true", dest="demo", default=False, help="show a demo of the widget") app = TaurusApplication( cmd_line_parser=parser, app_name="taurusplot2", app_version=taurus.Release.version) args = app.get_command_line_args() options = app.get_command_line_options() # check & process options stackModeMap = dict(t='datetime', d='deltatime', e='event') if options.x_axis_mode.lower() not in stackModeMap: parser.print_help(sys.stderr) sys.exit(1) stackMode = stackModeMap[options.x_axis_mode.lower()] if options.demo: args.append('eval:rand()') w = CurveDialog(edit=False, toolbar=True, wintitle="Taurus Trend") # set archiving if options.use_archiving: raise NotImplementedError('Archiving support is not yet implemented') w.setUseArchiving(True) w.add_tool(HRangeTool) # w.add_tool(TaurusCurveChooserTool) # w.add_tool(TimeAxisTool) if len(args) == 0: parser.print_help(sys.stderr) sys.exit(1) plot = w.get_plot() for a in args: item = TaurusTrendItem(stackMode=stackMode, buffersize=int(options.max_buffer_size)) plot.add_item(item) item.setModel(a) w.show() sys.exit(app.exec_())
def __init__(self, parent): super(plotWidget, self).__init__() self.setAcceptDrops(True) # Just some button connected to `plot` method self.resize(500, 500) self.gWindow = CurveDialog(edit=False, toolbar=True) self.lay = QHBoxLayout() self.teditor = QLabel("Hello How are you") self.lay.addWidget(self.gWindow) self.setLayout(self.lay)
def test_graph_window_properly_added_to_MDI(self): self.graph = CurveDialog(wintitle="XXX YYH #DKLJLKFE Kadk #kdfd", icon="guiqwt.svg", edit=False, toolbar=True, options=None, parent=self.aw, panels=None) self.aw.addSubWindow(self.graph) self.assertEqual(self.aw.mdi.subWindowList()[-1].windowTitle(), self.graph.windowTitle())
def plot(*items): win = CurveDialog(edit=False, toolbar=True, wintitle="CurveDialog test", options=dict(title="Temperaturverlauf", xlabel="Zeit [s]", ylabel="Temperatur [\xb0C]")) win.add_tool(HRangeTool) plot = win.get_plot() for item in items: plot.add_item(item) #plot.set_axis_font("left", QFont("Courier")) win.get_itemlist_panel().show() plot.set_items_readonly(False) win.show() win.exec_()
def __init__(self, parent=None, designMode=False, toolbar=True, **kwargs): '''see :class:`guiqwt.plot.CurveDialog` for other valid initialization parameters''' CurveDialog.__init__(self, parent=parent, toolbar=toolbar, **kwargs) TaurusBaseWidget.__init__(self, 'TaurusCurveDialog') self.setWindowFlags(Qt.Qt.Widget) self._designMode = designMode self._modelNames = CaselessList() from guiqwt.styles import style_generator self.style = style_generator() self.setSupportedMimeTypes( [TAURUS_MODEL_LIST_MIME_TYPE, TAURUS_ATTR_MIME_TYPE]) from taurus.qt.qtgui.extra_guiqwt.tools import TaurusCurveChooserTool self.add_tool(TaurusCurveChooserTool) self.setModifiableByUser(self._modifiableByUser) self.setContextMenuPolicy(Qt.Qt.CustomContextMenu)
def testTool(tool): from taurus.qt.qtgui.application import TaurusApplication from guiqwt.plot import CurveDialog app = TaurusApplication() win = CurveDialog(edit=False, toolbar=True) win.add_tool(tool) win.show() win.exec_()
def openCurveDialog(self): self.curvedialog = CurveDialog(edit=False, toolbar=True, wintitle="CurveDialog", options=dict(title="Title", xlabel="xlabel", ylabel="ylabel")) plot = self.curvedialog.get_plot() for array in self.csvmodel.array: item = make.curve(np.array(range(array.data.size)), array.data, color="b") plot.add_item(item) plot.set_axis_font("left", QFont("Courier")) self.curvedialog.get_itemlist_panel().show() plot.set_items_readonly(False) self.curvedialog.show()
class plotWidget(QWidget): def __init__(self, parent): super(plotWidget, self).__init__() self.setAcceptDrops(True) # Just some button connected to `plot` method self.resize(500, 500) self.gWindow = CurveDialog(edit=False, toolbar=True) self.lay = QHBoxLayout() self.teditor = QLabel("Hello How are you") self.lay.addWidget(self.gWindow) self.setLayout(self.lay) def plot(self, pdDataFrame): ''' plot some random stuff ''' x1 = pdDataFrame.index y1 = pdDataFrame['Close'] x = np.linspace(0, 100, 1000) y = (np.random.rand(len(x)) - 0.5).cumsum() curve = make.curve(x1, y1, "ab", "b") range = make.range(0, 5) disp2 = make.computations(range, "TL", [(curve, "min=%.5f", lambda x, y: y.min()), (curve, "max=%.5f", lambda x, y: y.max()), (curve, "avg=%.5f", lambda x, y: y.mean())]) legend = make.legend("TR") # items = [ curve, range, disp2, legend] items = [curve] self.plotw = self.gWindow.get_plot() for item in items: self.plotw.add_item(item) # win.show() def dragEnterEvent(self, event): # Defining the dragENterEvent event.accept() def dragMoveEvent(self, event): #Defning the DragMoveEvent event.accept() def dropEvent(self, event): #Defininf the Drop Event stockSymbol = event.mimeData().text( ) #Getting MimeData Text, this text is set in DragableListWidget print stockSymbol if event.mimeData().hasFormat( "+Stock+"): #Checking if the dropped item is a stock #Plotting the StockSymbol print stockSymbol stockData = stockDataCollector("AAPL") pdDataFrame = stockData._getStockdata() self.plot(pdDataFrame) else: event.ignore()
def plot(*items): win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() for item in items: plot.add_item(item) win.show() win.exec_()
def hist(data): """Plots histogram""" win = CurveDialog(edit=False, toolbar=True, wintitle="Histogram test") plot = win.get_plot() plot.add_item(make.histogram(data)) win.show() win.exec_()
def plot(*items): win = CurveDialog( edit=False, toolbar=True, wintitle="CurveDialog test", options=dict(title="Title", xlabel="xlabel", ylabel="ylabel"), ) plot = win.get_plot() for item in items: plot.add_item(item) # plot.set_axis_font("left", QFont("Courier")) win.get_itemlist_panel().show() plot.set_items_readonly(False) win.show() win.exec_()
def plot(*items): win = CurveDialog(edit=False, toolbar=True, wintitle="CurveDialog test", options=dict(title="Title", xlabel="xlabel", ylabel="ylabel")) plot = win.get_plot() for item in items: plot.add_item(item) plot.set_axis_font("left", QFont("Courier")) win.get_itemlist_panel().show() plot.set_items_readonly(False) win.show() win.exec_()
def test(): """Test""" from numpy.random import normal data = normal(0, 1, (2000, )) win = CurveDialog(edit=False, toolbar=True, wintitle="Histogram test") plot = win.get_plot() plot.add_item(make.histogram(data)) win.show() win.exec_()
def testFcn(self): x = np.linspace(0, 100, 1000) y = (np.random.rand(len(x)) - 0.5).cumsum() curve = make.curve(x, y, "ab", "b") range = make.range(0, 5) disp2 = make.computations(range, "TL", [(curve, "min=%.5f", lambda x, y: y.min()), (curve, "max=%.5f", lambda x, y: y.max()), (curve, "avg=%.5f", lambda x, y: y.mean())]) legend = make.legend("TR") items = [curve, range, disp2, legend] win = CurveDialog(edit=False, toolbar=True, parent=self) plot = win.get_plot() for item in items: plot.add_item(item) win.show()
def plot( *items ): win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() for item in items: plot.add_item(item) win.show() win.exec_()
def loadDialog(self): filename = QtGui.QFileDialog.getOpenFileName(self.Form, 'Open File', '.') fname = open(filename) data = fname.read() #self.le.setText(filename) do = pandas.read_csv(str(filename), delimiter=",") #data = pd.read_csv('C:/Users/se00075/PycharmProjects/Test2/src' + '/' + 'data.csv') if (self.startD.text().isEmpty()) & (self.endD.text().isEmpty()): d=do else: do['time_stamp'] = do['time_stamp'].astype('datetime64[ns]') st = int(self.startD.text()) en = int(self.endD.text()) select = (do['time_stamp'] >= do.time_stamp[0]+datetime.timedelta(days=st-1)) & (do['time_stamp'] < do.time_stamp[0]+datetime.timedelta(days=en)) d = do[select] #d = pandas.read_csv(str(filename), delimiter=",") #print d ##Lets add clean missing data here space = 0 self.checkboxes = [] for i in d.columns: c = QtGui.QCheckBox(self.Form) #print space c.setGeometry(QtCore.QRect(10 + space, 50, 70, 17)) c.setText(_fromUtf8(i)) c.show() c.clicked.connect(self.selected) self.checkboxes.append(c) space += 68 self.original_data = d #self.original_data=(self.original_data-self.original_data.mean()) / self.original_data.std() self.dialog = CurveDialog(edit=False, toolbar=False, parent=self.widget) self.plot = self.dialog.get_plot() self.plot.set_antialiasing(True) self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, 'Time') self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, 'Value') self.manager = PlotManager(self) self.manager.add_plot(self.plot) legend = make.legend('TL') self.plot.add_item(legend) ly = QtGui.QVBoxLayout() ly.addWidget(self.plot) self.widget.setLayout(ly) self.widget.show() self.Form.update() self.Form.repaint()
def setupUi(self): """loads numpy array Args: self Returns: nothing """ #self.plot = CurvePlot(self) self.dialog = CurveDialog(edit=False, toolbar=True, parent=self) self.plot = self.dialog.get_plot() self.plot.set_antialiasing(True) #x = np.linspace(-10,10,200) #dy = x/100. #y = np.sin(np.sin(np.sin(x))) #self.plot.add_item(make.curve(x,y)) self.loadButton = QtGui.QPushButton("Load") self.trainButton = QtGui.QPushButton("Train Model") ly = QtGui.QVBoxLayout() ly.addWidget(self.plot) #ly.addWidget(self.loadButton) #ly.addWidget(self.trainButton) self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, 'Time') self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, 'Value') self.manager = PlotManager(self) self.manager.add_plot(self.plot) #self.manager. legend = make.legend('TL') self.plot.add_item(legend) self.setLayout(ly) self.move(300, 200) self.show() self.dataController = DataController.DataController()
def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- import numpy as np x = np.linspace(-10, 10, 200) y = x*np.exp(-x) item = make.curve(x, y, color="b") win = CurveDialog() plot = win.get_plot() plot.add_item(item) plot.set_axis_direction("left", True) plot.set_axis_direction("bottom", True) win.show() win.exec_()
def get_point(*args): """ Plot curves and return selected point(s) coordinates """ win = CurveDialog(_("Select one point then press OK to accept"), edit=True) default = win.add_tool(SelectPointTool, title="Test", on_active_item=True, mode="create", end_callback=test_function) default.activate() plot = win.get_plot() for cx, cy in args: item = make.mcurve(cx, cy) plot.add_item(item) plot.set_active_item(item) win.show() if win.exec_(): return default.get_coordinates()
def get_point( *args ): """ Plot curves and return selected point(s) coordinates """ win = CurveDialog(_("Select one point then press OK to accept"), edit=True) default = win.add_tool(SelectPointTool, title="Test", on_active_item=True, mode="create", end_callback=test_function) default.activate() plot = win.get_plot() for cx, cy in args: item = make.mcurve(cx, cy) plot.add_item(item) plot.set_active_item(item) win.show() if win.exec_(): return default.get_coordinates()
def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- import numpy as np x = np.linspace(1, 10, 200) y = np.exp(-x) y[0] = 0 item = make.curve(x, y, color="b") item = make.error(x, y, None, y*.23) win = CurveDialog() plot = win.get_plot() plot.set_axis_scale("left", "log") plot.set_axis_scale("bottom", "log") # plot.set_axis_limits("left", 4.53999297625e-05, 22026.4657948) plot.add_item(item) win.show() win.exec_()
class Ui_Form(object): def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(750, 453) self.Form = Form self.pushButton = QtGui.QPushButton(Form) self.pushButton.setGeometry(QtCore.QRect(30, 0, 75, 23)) self.pushButton.setObjectName(_fromUtf8("pushButton")) '''self.checkBox = QtGui.QCheckBox(Form) self.checkBox.setGeometry(QtCore.QRect(20, 70, 70, 17)) self.checkBox.setObjectName(_fromUtf8("checkBox")) self.checkBox_2 = QtGui.QCheckBox(Form) self.checkBox_2.setGeometry(QtCore.QRect(100, 70, 70, 17)) self.checkBox_2.setObjectName(_fromUtf8("checkBox_2")) self.checkBox_3 = QtGui.QCheckBox(Form) self.checkBox_3.setGeometry(QtCore.QRect(180, 70, 70, 17)) self.checkBox_3.setObjectName(_fromUtf8("checkBox_3"))''' self.widget = QtGui.QWidget(Form) self.widget.setGeometry(QtCore.QRect(10, 110, 581, 251)) self.widget.setObjectName(_fromUtf8("widget")) self.startD = QtGui.QLineEdit(Form) self.startD.setGeometry(QtCore.QRect(120, 0, 81, 20)) self.startD.setObjectName(_fromUtf8("startD")) self.endD = QtGui.QLineEdit(Form) self.endD.setGeometry(QtCore.QRect(240, 0, 71, 20)) self.endD.setObjectName(_fromUtf8("endD")) self.label = QtGui.QLabel(Form) self.label.setGeometry(QtCore.QRect(290, 20, 46, 13)) self.label.setObjectName(_fromUtf8("label")) self.label_2 = QtGui.QLabel(Form) self.label_2.setGeometry(QtCore.QRect(170, 20, 46, 13)) self.label_2.setObjectName(_fromUtf8("label_2")) self.Hint = QtGui.QLabel(Form) self.Hint.setGeometry(QtCore.QRect(330, 10, 281, 16)) self.Hint.setObjectName(_fromUtf8("Hint")) self.pushButton_2 = QtGui.QPushButton(Form) self.pushButton_2.setGeometry(QtCore.QRect(30, 30, 75, 23)) self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.pushButton.clicked.connect(self.loadDialog) self.pushButton_2.clicked.connect(self.saveDialog) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): Form.setWindowTitle(_translate("Form", "Form", None)) self.pushButton.setText(_translate("Form", "Load Data", None)) self.label.setText(_translate("Form", "End", None)) self.label_2.setText(_translate("Form", "Begin", None)) self.Hint.setText(_translate("Form", "Enter before loading. To load whole dataset, leave blank", None)) self.pushButton_2.setText(_translate("Form", "Save", None)) def loadDialog(self): filename = QtGui.QFileDialog.getOpenFileName(self.Form, 'Open File', '.') fname = open(filename) data = fname.read() #self.le.setText(filename) do = pandas.read_csv(str(filename), delimiter=",") #data = pd.read_csv('C:/Users/se00075/PycharmProjects/Test2/src' + '/' + 'data.csv') if (self.startD.text().isEmpty()) & (self.endD.text().isEmpty()): d=do else: do['time_stamp'] = do['time_stamp'].astype('datetime64[ns]') st = int(self.startD.text()) en = int(self.endD.text()) select = (do['time_stamp'] >= do.time_stamp[0]+datetime.timedelta(days=st-1)) & (do['time_stamp'] < do.time_stamp[0]+datetime.timedelta(days=en)) d = do[select] #d = pandas.read_csv(str(filename), delimiter=",") #print d ##Lets add clean missing data here space = 0 self.checkboxes = [] for i in d.columns: c = QtGui.QCheckBox(self.Form) #print space c.setGeometry(QtCore.QRect(10 + space, 50, 70, 17)) c.setText(_fromUtf8(i)) c.show() c.clicked.connect(self.selected) self.checkboxes.append(c) space += 68 self.original_data = d #self.original_data=(self.original_data-self.original_data.mean()) / self.original_data.std() self.dialog = CurveDialog(edit=False, toolbar=False, parent=self.widget) self.plot = self.dialog.get_plot() self.plot.set_antialiasing(True) self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, 'Time') self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, 'Value') self.manager = PlotManager(self) self.manager.add_plot(self.plot) legend = make.legend('TL') self.plot.add_item(legend) ly = QtGui.QVBoxLayout() ly.addWidget(self.plot) self.widget.setLayout(ly) self.widget.show() self.Form.update() self.Form.repaint() def selected(self, state): dc = logic.DataFlowControl.DataController() from itertools import cycle colors = cycle(["r", "g", "b", "y"]) self.plot.del_all_items() selItems = [] for c in self.checkboxes: c.isChecked() c.text() if c.isChecked(): selItems.append(str(c.text())) self.selected_data = np.array(self.original_data[selItems]) print "fileLoader self.selected_data.shape", self.selected_data.shape x = range(self.selected_data.shape[0]) for g in selItems: k = make.curve(x, np.array(self.original_data[g]), color=colors.next()) self.plot.add_item(k) print "fileLoader current data flow object",self.selected_data #dc.setCurrentDataFlowObject(self.selected_data) dc.originalData = self.selected_data self.Form.repaint() self.Form.repaint() self.plot.update() def saveDialog(self): path = QtGui.QFileDialog.getSaveFileName(self.Form, 'Save File', '', 'CSV(*.csv)') if not path.isEmpty(): with open(unicode(path), 'wb') as stream: writer = csv.writer(stream) [a,b]=self.selected_data.shape print(a) print(b) for row in range(a): rowdata = [] for column in range(b): item = self.selected_data.item(row, column) if item is not None: rowdata.append(item) else: rowdata.append('') writer.writerow(rowdata)
def taurusCurveMain(): from taurus.qt.qtgui.extra_guiqwt.builder import make from taurus.qt.qtgui.application import TaurusApplication from guiqwt.plot import CurveDialog from guiqwt.tools import HRangeTool from taurus.qt.qtgui.extra_guiqwt.tools import TaurusCurveChooserTool, TimeAxisTool import taurus.core.util.argparse import sys parser = taurus.core.util.argparse.get_taurus_parser() parser.set_usage("%prog [options] [<model1> [<model2>] ...]") parser.set_description("a taurus application for plotting 1D data sets") app = TaurusApplication(cmd_line_parser=parser, app_name="taurusplot2", app_version=taurus.Release.version) args = app.get_command_line_args() win = CurveDialog(edit=False, toolbar=True, wintitle="TaurusPlot2", options=dict(title="", xlabel="xlabel", ylabel="ylabel")) win.add_tool(HRangeTool) win.add_tool(TaurusCurveChooserTool) win.add_tool(TimeAxisTool) plot = win.get_plot() for a in args: mx_my = a.split('|') n = len(mx_my) if n == 1: mx, my = None, mx_my[0] elif n == 2: mx, my = mx_my else: print "Invalid model: %s\n" % mx_my parser.print_help(sys.stderr) sys.exit(1) # cycle colors style = make.style.next() color = style[0] linestyle = style[1:] plot.add_item( make.curve(mx, my, color=color, linestyle=linestyle, linewidth=2)) win.get_itemlist_panel().show() plot.set_items_readonly(False) win.show() win.exec_()
import datetime class stockDataCollector(object): def __init__(self, stockName): super(stockDataCollector, self).__init__() self.stockName = stockName self.stockDataFrame = 0 self.start = datetime.datetime(1900, 1, 1) self.end = datetime.date.today() def _getStockdata(self): self.stockDataFrame = data.DataReader(self.stockName, 'yahoo', self.start, self.end) return self.stockDataFrame if __name__ == '__main__': _app = guidata.qapplication() main = stockDataCollector("AAPL") sro = main._getStockdata() x1 = sro.index x2 = x1.Date y1 = sro['Close'].values curve = make.curve(x1, y1, "ab", "b") gWindow = CurveDialog(edit=False, toolbar=False) plotw = gWindow.get_plot() plotw.add_item(curve) gWindow.show() gWindow.exec_()
def __init__(self, fit): Plot.__init__(self, fit) self.layout = QtWidgets.QVBoxLayout(self) self.source = fit.surface self.d1 = np.array([0.0]) self.d2 = np.array([0.0]) top_left = QtWidgets.QFrame(self) top_left.setMaximumHeight(150) top_left.setFrameShape(QtWidgets.QFrame.StyledPanel) topl = QtWidgets.QVBoxLayout(top_left) top_right = QtWidgets.QFrame(self) top_right.setMaximumHeight(150) top_right.setFrameShape(QtWidgets.QFrame.StyledPanel) topr = QtWidgets.QVBoxLayout(top_right) bottom = QtWidgets.QFrame(self) bottom.setFrameShape(QtWidgets.QFrame.StyledPanel) bot = QtWidgets.QVBoxLayout(bottom) splitter1 = QtWidgets.QSplitter(QtCore.Qt.Horizontal) splitter1.addWidget(top_left) splitter1.addWidget(top_right) splitter2 = QtWidgets.QSplitter(QtCore.Qt.Vertical) splitter2.addWidget(splitter1) splitter2.addWidget(bottom) self.splitter = splitter2 self.layout.addWidget(splitter2) # x-axis win = CurveDialog() self.g_xplot = win.get_plot() self.g_xhist_m = make.histogram([], color='#ff00ff') self.g_xhist_a = make.histogram([], color='#6f0000') self.g_xplot.add_item(self.g_xhist_a) self.g_xplot.add_item(self.g_xhist_m) topl.addWidget(self.g_xplot) # y-axis win = CurveDialog() self.g_yplot = win.get_plot() self.g_yhist_m = make.histogram([], color='#00ff00') self.g_yhist_a = make.histogram([], color='#006600') self.g_yplot.add_item(self.g_yhist_a) self.g_yplot.add_item(self.g_yhist_m) topr.addWidget(self.g_yplot) # 2D-Histogram self.g_hist2d_m = make.histogram2D(np.array([0.0, 0.0]), np.array([0.0, 0.0]), logscale=True) self.g_hist2d_a = make.histogram2D(np.array([0.0, 0.0]), np.array([0.0, 0.0]), logscale=True) self.g_hist2d_m.set_color_map('hot') self.g_hist2d_a.set_color_map('Blues') #self.g_hist2d_m.set_interpolation(INTERP_LINEAR) #self.g_hist2d_a.set_interpolation(INTERP_LINEAR) win = ImageDialog(edit=False, toolbar=False) self.g_xyplot = win.get_plot() self.g_xyplot.set_aspect_ratio(lock=False) self.g_xyplot.add_item(self.g_hist2d_a) self.g_xyplot.add_item(self.g_hist2d_m) bot.addWidget(win) #selection self.selection_x = make.range(.25, .5) self.g_xplot.add_item(self.selection_x) self.selection_y = make.range(.25, .5) self.g_yplot.add_item(self.selection_y) self.pltControl = SurfacePlotWidget(self) self.widgets = [self.pltControl]
def __init__(self, fit, d_scalex='lin', d_scaley='lin', r_scalex='lin', r_scaley='lin'): Plot.__init__(self) self.layout = QtGui.QVBoxLayout(self) self.fit = fit bottom = QtGui.QFrame(self) bottom.setFrameShape(QtGui.QFrame.StyledPanel) botl = QtGui.QVBoxLayout(bottom) top = QtGui.QFrame(self) top.setMaximumHeight(140) top.setFrameShape(QtGui.QFrame.StyledPanel) topl = QtGui.QVBoxLayout(top) splitter1 = QtGui.QSplitter(QtCore.Qt.Vertical) splitter1.addWidget(top) splitter1.addWidget(bottom) self.layout.addWidget(splitter1) # Data-Fit dialog fd = CurveDialog(edit=False, toolbar=True) #self.get_itemlist_panel().show() plot = fd.get_plot() self.data_curve = make.curve([1], [1], color="b", linewidth=1) self.irf_curve = make.curve([1], [1], color="r", linewidth=1) self.model_curve = make.curve([1], [1], color="g", linewidth=4) plot.add_item(self.data_curve) plot.add_item(self.irf_curve) plot.add_item(self.model_curve) self.dataPlot = plot botl.addWidget(fd) splitter1 = QtGui.QSplitter(QtCore.Qt.Horizontal) topl.addWidget(splitter1) # Residual dialog win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.residual_curve = make.curve([1], [1], color="r", linewidth=2) plot.add_item(self.residual_curve) self.chi2_label = make.label("", "R", (-10, 27), "R") plot.add_item(self.chi2_label) title = make.label("w.res.", "R", (0, -40), "R") plot.add_item(title) self.residualPlot = plot splitter1.addWidget(plot) win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.autocorr_curve = make.curve([1], [1], color="r", linewidth=2) plot.add_item(self.autocorr_curve) title = make.label("auto.cor.", "R", (0, -40), "R") plot.add_item(title) self.autoCorrPlot = plot splitter1.addWidget(plot) self.pltControl = linePlotWidget(self, d_scalex, d_scaley, r_scalex, r_scaley)
class CentralWidget(QSplitter): def __init__(self, parent, toolbar): QSplitter.__init__(self, parent) # Define csvModel 提供csv處理的Model self.csvmodel = CsvFileModel() self.selectedRow = -1 #connect error message self.connect(self.csvmodel, SIGNAL("ERROR_NOT_NONAME_ARRAY"), partial(self.showErrorMessage, "NOT_NONAME_ARRAY")) # 連接csvlist與製造ImageListWithProperties imagelistwithproperties = ImageListWithProperties(self) self.addWidget(imagelistwithproperties) self.csvlist = imagelistwithproperties.csvlist self.connect(imagelistwithproperties, SIGNAL("PLOT"), partial(self.csvmodel.plotCSV, self.csvlist)) self.connect(imagelistwithproperties, SIGNAL("REMOVE"), partial(self.csvmodel.removeCSV, self.csvlist)) self.connect(imagelistwithproperties, SIGNAL("EXTRACT_ARRAY"), partial(self.csvmodel.extractArray, self.csvlist)) # View signal connect self.connect(self.csvlist, SIGNAL("itemDoubleClicked(QListWidgetItem*)"), partial(self.csvmodel.plotCSV, self.csvlist)) self.connect(self.csvlist, SIGNAL("currentRowChanged(int)"), self.current_item_changed) self.connect(self.csvlist, SIGNAL("itemSelectionChanged()"), self.selection_changed) self.properties = imagelistwithproperties.properties self.connect(self.properties, SIGNAL("apply_button_clicked()"), self.properties_changed) # CsvModel signal connect self.connect(self.csvmodel, SIGNAL("CSV_UPDATED"), self.refresh_list) self.connect(self.csvmodel, SIGNAL("ARRAY_UPDATED"), self.refresh_array_list) # 製造ArrayListWithProperties self.arraylistwithproperties = ArrayListWithProperties(self) self.arraylist = self.arraylistwithproperties.arraylist self.addWidget(self.arraylistwithproperties) self.connect(self.arraylistwithproperties, SIGNAL("PASTE_NO_NAME"), partial(self.csvmodel.pasteArrayNoName, self.arraylist)) self.connect(self.arraylistwithproperties, SIGNAL("PASTE_WITH_NAME"), partial(self.csvmodel.pasteArrayWithName, self.arraylist)) self.connect(self.arraylistwithproperties, SIGNAL("PLOT"), partial(self.csvmodel.plotArray, self.arraylist)) self.connect(self.arraylistwithproperties, SIGNAL("MODIFY_ARRAY"), partial(self.csvmodel.modifyArray, self.arraylist)) self.connect(self.arraylistwithproperties, SIGNAL("PLOT_SCATTER"), partial(self.csvmodel.plotScatter, self.arraylist)) self.connect(self.arraylistwithproperties, SIGNAL("PLOT_HISTOGRAM"), self.plotHist) self.connect(self.arraylistwithproperties, SIGNAL("REMOVE"), partial(self.csvmodel.removeArray, self.arraylist)) self.connect(self.arraylistwithproperties, SIGNAL("OPEN_CURVEDIALOG"), self.openCurveDialog) #arraylist action signal self.connect(self.arraylist, SIGNAL("currentRowChanged(int)"), self.array_current_item_changed) self.arrayproperties = self.arraylistwithproperties.properties self.connect(self.arrayproperties, SIGNAL("apply_button_clicked()"), self.array_properties_changed) self.connect(self.arraylist, SIGNAL("itemSelectionChanged()"), self.array_selection_changed) self.connect(self.arraylist, SIGNAL("itemDoubleClicked(QListWidgetItem*)"), partial(self.csvmodel.plotArray, self.arraylist)) # 設定基本properity self.setContentsMargins(10, 10, 10, 10) self.setOrientation(Qt.Vertical) self.setStretchFactor(0, 0) self.setStretchFactor(1, 1) self.setHandleWidth(10) self.setSizes([1, 2]) def refresh_list(self): self.csvlist.clear() for csv in self.csvmodel.csvName: self.csvlist.addItem(csv) def refresh_array_list(self): self.arraylist.clear() for array in self.csvmodel.arrayName: self.arraylist.addItem(array) def selection_changed(self): """Image list: selection changed, make right properity box selectable""" row = self.csvlist.currentRow() self.properties.setDisabled(row == -1) def array_selection_changed(self): """Array list: selection changed, make right properity box selectable""" row = self.arraylist.currentRow() self.arrayproperties.setDisabled(row == -1) def current_item_changed(self, row): """Image list: current image changed""" #csvdata, csvname = self.csvmodel.csvData[row], self.csvmodel.csvName[row] update_dataset(self.properties.dataset, self.csvmodel.csv[row]) self.properties.get() def array_current_item_changed(self, row): """Image list: current image changed""" #csvdata, csvname = self.csvmodel.csvData[row], self.csvmodel.csvName[row] update_dataset(self.arrayproperties.dataset, self.csvmodel.array[row]) self.arrayproperties.get() def plotHist(self): self.histWindow = HistogramWindow( self.csvmodel.arrayData[self.arraylist.currentRow()], self.csvmodel.arrayName[self.arraylist.currentRow()]) self.histWindow.show() def openCurveDialog(self): self.curvedialog = CurveDialog(edit=False, toolbar=True, wintitle="CurveDialog", options=dict(title="Title", xlabel="xlabel", ylabel="ylabel")) plot = self.curvedialog.get_plot() for array in self.csvmodel.array: item = make.curve(np.array(range(array.data.size)), array.data, color="b") plot.add_item(item) plot.set_axis_font("left", QFont("Courier")) self.curvedialog.get_itemlist_panel().show() plot.set_items_readonly(False) self.curvedialog.show() # #============================================================================== # def lut_range_changed(self): # row = self.imagelist.currentRow() # self.lut_ranges[row] = self.item.get_lut_range() #============================================================================== #============================================================================== # def show_data(self, data, lut_range=None): # plot = self.imagewidget.plot # if self.item is not None: # self.item.set_data(data) # if lut_range is None: # lut_range = self.item.get_lut_range() # self.imagewidget.set_contrast_range(*lut_range) # self.imagewidget.update_cross_sections() # else: # self.item = make.image(data) # plot.add_item(self.item, z=0) # plot.replot() #============================================================================== def properties_changed(self): """The properties 'Apply' button was clicked: updating image""" row = self.csvlist.currentRow() csvdata = self.csvmodel.csv[row] update_dataset(csvdata, self.properties.dataset) self.csvmodel.csvName[row] = csvdata.title self.refresh_list() #self.show_data(image.data) def array_properties_changed(self): """The properties 'Apply' button was clicked: updating image""" print("apply button click") row = self.arraylist.currentRow() arraydata = self.csvmodel.array[row] update_dataset(arraydata, self.arrayproperties.dataset) self.csvmodel.arrayName[row] = arraydata.title self.refresh_array_list() #============================================================================== # def add_image(self, image): # self.images.append(image) # #self.lut_ranges.append(None) # self.refresh_list() # self.imagelist.setCurrentRow(len(self.images)-1) # plot = self.imagewidget.plot # plot.do_autoscale() #============================================================================== #def add_csv_from_file(self, filename): def showErrorMessage(self, message): print("error") if message == "NOT_NONAME_ARRAY": QMessageBox.about( self, "Error message box", "Please make sure the data in the clip board is an array")
class Ui_PlotWidget_Reduce_Set(QtGui.QWidget): """""" def __init__(self, parent=None): """Constructor for Ui_PlotWidget""" QtGui.QWidget.__init__(self, parent) self.setupUi() def setupUi(self): """loads numpy array Args: self Returns: nothing """ #self.plot = CurvePlot(self) self.dialog = CurveDialog(edit=False, toolbar=True, parent=self) self.plot = self.dialog.get_plot() self.plot.set_antialiasing(True) #x = np.linspace(-10,10,200) #dy = x/100. #y = np.sin(np.sin(np.sin(x))) #self.plot.add_item(make.curve(x,y)) self.loadButton = QtGui.QPushButton("Load") self.trainButton = QtGui.QPushButton("Train Model") ly = QtGui.QVBoxLayout() ly.addWidget(self.plot) #ly.addWidget(self.loadButton) #ly.addWidget(self.trainButton) self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, 'Time') self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, 'Value') self.manager = PlotManager(self) self.manager.add_plot(self.plot) #self.manager. legend = make.legend('TL') self.plot.add_item(legend) self.setLayout(ly) self.move(300, 200) self.show() self.dataController = DataController.DataController() def loadData(self): self.trainingData = self.dataController.loadSampleData() import logic.DimensionalityReduceControl as controller c = controller.DimensionalityReduceControl() c.selectAlgorithm(2) outpN = 100 params = {"none": "none", "output_length": outpN} data = c.reduceData(self.trainingData["PIR"][:],params) print data self.plot.add_item(make.curve(range(0, len(data)), data)) self.rangeSelection = make.range(-2, 2) disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm", title="Range infos") self.plot.add_item(self.rangeSelection) self.plot.add_item(disp0) self.plot.replot() def trainData(self,string_length, vocab, window_length, clusterN): a, b = self.rangeSelection.get_range() if a > b: a, b = b, a print a, b print "in widget", int(string_length), int(vocab), int(window_length), int(clusterN) self.dataController.trainData(a,b,int(string_length), int(vocab), int(window_length), int(clusterN))
class Ui_Form(object): def __init__(self, type): self.dc = DataController() self.prc = PreProcessingControl() self.flowData = self.dc.originalData pos = self.prc.getAvailableAlgorithms().keys().index(type) self.prc.selectAlgorithm(pos) def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(536, 384) self.Form=Form self.tableWidget = QtGui.QTableWidget(Form) self.tableWidget.setGeometry(QtCore.QRect(90, 261, 221, 121)) self.tableWidget.setObjectName(_fromUtf8("tableWidget")) self.tableWidget.setColumnCount(2) self.tableWidget.setRowCount(1) item = QtGui.QTableWidgetItem() self.tableWidget.setVerticalHeaderItem(0, item) item = QtGui.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(0, item) item = QtGui.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(1, item) item = QtGui.QTableWidgetItem() self.tableWidget.setItem(0, 0, item) item = QtGui.QTableWidgetItem() self.tableWidget.setItem(0, 1, item) self.pushButton = QtGui.QPushButton(Form) self.pushButton.setGeometry(QtCore.QRect(0, 300, 75, 23)) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.widget = QtGui.QWidget(Form) self.widget.setGeometry(QtCore.QRect(10, 10, 521, 211)) self.widget.setObjectName(_fromUtf8("widget")) #self.pushButton_2 = QtGui.QPushButton(Form) #self.pushButton_2.setGeometry(QtCore.QRect(0, 330, 75, 23)) #self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.pushButton_3 = QtGui.QPushButton(Form) self.pushButton_3.setGeometry(QtCore.QRect(0, 360, 75, 23)) self.pushButton_3.setObjectName(_fromUtf8("pushButton_3")) #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% self.dialog = CurveDialog(edit=False, toolbar=False, parent=self.widget) self.plot = self.dialog.get_plot() self.plot.set_antialiasing(True) self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, 'Time') self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, 'Value') self.manager = PlotManager(self) self.manager.add_plot(self.plot) legend = make.legend('TL') self.plot.add_item(legend) ly = QtGui.QVBoxLayout() ly.addWidget(self.plot) self.widget.setLayout(ly) # item = QtGui.QTableWidgetItem() # self.tableWidget.setHorizontalHeaderItem(0, item) # item = QtGui.QTableWidgetItem() # self.tableWidget.setItem(0, 0, item) # item = QtGui.QTableWidgetItem() # self.tableWidget.setItem(0, 1, item) # item = self.tableWidget.horizontalHeaderItem(0) # item.setText(_translate("Form", "Attribute", None)) c = 0 for it in self.prc.getRequiredParameters(): # item = QtGui.QTableWidgetItem() # item.setText(_translate("Form", "Id" + str(c), None)) # self.tableWidget.setVerticalHeaderItem(c, item) item = QtGui.QTableWidgetItem() item.setText(it) self.tableWidget.setItem(c, 0, item) #print it, self.prc.getRequiredParameters()[it] item = QtGui.QTableWidgetItem() item.setText(str(self.prc.getRequiredParameters()[it])) self.tableWidget.setItem(c, 1, item) # print c c += 1 ####%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) self.currentdata=[] def retranslateUi(self, Form): Form.setWindowTitle(_translate("Form", "Form", None)) __sortingEnabled = self.tableWidget.isSortingEnabled() self.tableWidget.setSortingEnabled(False) self.tableWidget.setSortingEnabled(__sortingEnabled) self.pushButton.setText(_translate("Form", "Process", None)) #self.pushButton_2.setText(_translate("Form", "Load", None)) self.pushButton_3.setText(_translate("Form", "Save", None)) Form.connect(self.pushButton, QtCore.SIGNAL('clicked()'),self.process) #Form.connect(self.pushButton_2, QtCore.SIGNAL('clicked()'),self.loadDialog) Form.connect(self.pushButton_3, QtCore.SIGNAL('clicked()'),self.saveDialog) def process(self): params = {} print(self.tableWidget.rowCount()) for i in range(self.tableWidget.rowCount()): a = self.tableWidget.item(i, 0) b = self.tableWidget.item(i, 1) params[str(a.text())] = int(b.text()) # print "params",params outpN = self.tableWidget.item(0, 0) #params = {"none": "none", "output_length": outpN} ''' if self.currentdata==[]: data = self.prc.preprocData(self.flowData, params) else: data = self.prc.preprocData(self.currentdata, params) ''' #self.dc.setCurrentDataFlowObject(data) #print data if params==[]: data = self.prc.preprocData(self.flowData, params) elif params!=[]: data = self.prc.preprocData(self.flowData, params) self.plot.del_all_items() print data print type(data) self.plot.add_item(make.curve(range(0, len(data)), data)) self.rangeSelection = make.range(-2, 2) disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm", title="Range infos") #self.plot.add_item(self.rangeSelection) #self.plot.add_item(disp0) self.plot.replot() #self.dc.setCurrentDataFlowObject(data) self.dc.preprocData = data self.currentdata = np.reshape(data, (-1, 1)) #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% '''def loadDialog(self): params = {} for i in range(self.tableWidget.rowCount()): a = self.tableWidget.item(i, 0) b = self.tableWidget.item(i, 1) params[str(a.text())] = int(b.text()) # print "params",params outpN = self.tableWidget.item(0, 0) #params = {"none": "none", "output_length": outpN} filename = QtGui.QFileDialog.getOpenFileName(self.Form, 'Open File', '.') fname = open(filename) self.original_data = pandas.read_csv(str(filename), delimiter=",") self.plot.del_all_items() self.currentdata = np.array(self.original_data) #print "fileLoader self.currentdata.shape", self.currentdata.shape print type(self.currentdata) print(self.currentdata.shape) ''' def saveDialog(self): path = QtGui.QFileDialog.getSaveFileName(self.Form, 'Save File', '', 'CSV(*.csv)') if not path.isEmpty(): with open(unicode(path), 'wb') as stream: writer = csv.writer(stream) [a,b]=self.currentdata.shape print(a) print(b) for row in range(a): rowdata = [] for column in range(b): item = self.currentdata.item(row, column) if item is not None: rowdata.append(item) else: rowdata.append('') writer.writerow(rowdata)
def __init__( self, fit: fitting.fit.FitGroup, f_scalex: str = 'log', f_scaley: str = 'lin', e_scalex: str = 'log', e_scaley: str = 'lin', *args, **kwargs ): self.fit = fit ## Distance distribution plot fd = CurveDialog(edit=False, toolbar=False) plot = fd.get_plot() self.p_rda_plot = plot self.verticalLayout_12.addWidget(fd) self.p_rda_curve = make.curve([1], [1], color="r", linewidth=2) plot.add_item(self.p_rda_curve) ## Fluorescence intensity plot win = CurveDialog(edit=False, toolbar=False) plot = win.get_plot() plot.do_autoscale(True) title = make.label("FDA,FD0", "R", (0, 10), "R") plot.add_item(title) self.fd0_curve = make.curve([1], [1], color="g", linewidth=2) self.fda_curve = make.curve([1], [1], color="r", linewidth=2) plot.add_item(self.fd0_curve) plot.add_item(self.fda_curve) self.fd_plot = plot self.fd_plot.set_scales(f_scalex, f_scaley) self.verticalLayout.addWidget(plot) ## Calculated E(t) plot win = CurveDialog(edit=False, toolbar=False) plot = win.get_plot() plot.do_autoscale(True) self.et_curve = make.curve([1], [1], color="b", linewidth=2) plot.add_item(self.et_curve) title = make.label("E(t)", "R", (0, 10), "R") plot.add_item(title) self.et_plot = plot self.et_plot.set_scales(e_scalex, e_scaley) self.verticalLayout_2.addWidget(plot) ## weighted-residuals of inversion win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.wres_curve = make.curve([1], [1], color="m", linewidth=2) plot.add_item(self.wres_curve) title = make.label("w.res", "R", (0, 10), "R") plot.add_item(title) self.wres_plot = plot self.wres_plot.set_scales('lin', 'lin') self.verticalLayout_3.addWidget(plot) ## L-Curve plot win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.l_curve_1 = make.curve([1], [1], color="k", linewidth=2) plot.add_item(self.l_curve_1) title = make.label("Reg.", "R", (0, 10), "R") plot.set_titles(ylabel='reg. par', xlabel='Chi2r') plot.add_item(title) self.l_curve_plot_1 = plot self.l_curve_plot_1.set_scales('lin', 'lin') self.verticalLayout_4.addWidget(self.l_curve_plot_1) win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.l_curve_2 = make.curve([1], [1], color="k", linewidth=2) plot.add_item(self.l_curve_2) title = make.label("L-Curve", "R", (0, 10), "R") plot.set_titles(ylabel='|x| (sol. norm)', xlabel='Chi2r') plot.add_item(title) self.l_curve_plot_2 = plot self.l_curve_plot_2.set_scales('log', 'log') self.verticalLayout_7.addWidget(self.l_curve_plot_2)
def __init__( self, fit: fitting.fit.FitGroup, d_scalex: str = 'lin', d_scaley: str = 'lin', r_scalex: str = 'lin', r_scaley: str = 'lin', **kwargs ): super(GlobalAnisotropy, self).__init__( fit=fit, **kwargs ) self.verbose = kwargs.get('verbose', chisurf.verbose) self.layout = QtWidgets.QVBoxLayout(self) self.fit = fit bottom = QtWidgets.QFrame(self) bottom.setFrameShape(QtWidgets.QFrame.StyledPanel) botl = QtWidgets.QVBoxLayout(bottom) top = QtWidgets.QFrame(self) top.setMaximumHeight(140) top.setFrameShape(QtWidgets.QFrame.StyledPanel) topl = QtWidgets.QVBoxLayout(top) splitter1 = QtWidgets.QSplitter(QtCore.Qt.Vertical) splitter1.addWidget(top) splitter1.addWidget(bottom) self.layout.addWidget(splitter1) # Data-Fit dialog fd = CurveDialog(edit=False, toolbar=True) #self.get_itemlist_panel().show() plot = fd.get_plot() self.data_curve_vv = make.curve([], [], color="b", linewidth=1) self.irf_curve_vv = make.curve([], [], color="r", linewidth=1) self.model_curve_vv = make.curve([], [], color="g", linewidth=4) self.data_curve_vh = make.curve([], [], color="c", linewidth=1) self.irf_curve_vh = make.curve([], [], color="m", linewidth=1) self.model_curve_vh = make.curve([], [], color="k", linewidth=4) plot.add_item(self.data_curve_vv) plot.add_item(self.irf_curve_vv) plot.add_item(self.model_curve_vv) plot.add_item(self.data_curve_vh) plot.add_item(self.irf_curve_vh) plot.add_item(self.model_curve_vh) self.dataPlot = plot botl.addWidget(fd) splitter1 = QtWidgets.QSplitter(QtCore.Qt.Horizontal) topl.addWidget(splitter1) # Residual dialog win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.residual_curve_vv = make.curve([], [], color="r", linewidth=2) self.residual_curve_vh = make.curve([], [], color="b", linewidth=2) plot.add_item(self.residual_curve_vv) plot.add_item(self.residual_curve_vh) self.chi2_label = make.label("", "R", (-10, 27), "R") plot.add_item(self.chi2_label) title = make.label("w.res.", "R", (0, -40), "R") plot.add_item(title) self.residualPlot = plot splitter1.addWidget(plot) win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.autocorr_curve_vv = make.curve([], [], color="r", linewidth=2) self.autocorr_curve_vh = make.curve([], [], color="b", linewidth=2) plot.add_item(self.autocorr_curve_vv) plot.add_item(self.autocorr_curve_vh) title = make.label("auto.cor.", "R", (0, -40), "R") plot.add_item(title) self.autoCorrPlot = plot splitter1.addWidget(plot) self.pltControl = LinePlotWidget( self, d_scalex, d_scaley, r_scalex, r_scaley )
def taurusCurveMain(): from taurus.qt.qtgui.extra_guiqwt.builder import make from taurus.qt.qtgui.application import TaurusApplication from guiqwt.plot import CurveDialog from guiqwt.tools import HRangeTool from taurus.qt.qtgui.extra_guiqwt.tools import TaurusCurveChooserTool, TimeAxisTool import taurus.core.util.argparse import sys parser = taurus.core.util.argparse.get_taurus_parser() parser.set_usage("%prog [options] [<model1> [<model2>] ...]") parser.set_description("a taurus application for plotting 1D data sets") app = TaurusApplication( cmd_line_parser=parser, app_name="taurusplot2", app_version=taurus.Release.version) args = app.get_command_line_args() win = CurveDialog(edit=False, toolbar=True, wintitle="TaurusPlot2", options=dict(title="", xlabel="xlabel", ylabel="ylabel")) win.add_tool(HRangeTool) win.add_tool(TaurusCurveChooserTool) win.add_tool(TimeAxisTool) plot = win.get_plot() for a in args: mx_my = a.split('|') n = len(mx_my) if n == 1: mx, my = None, mx_my[0] elif n == 2: mx, my = mx_my else: print "Invalid model: %s\n" % mx_my parser.print_help(sys.stderr) sys.exit(1) # cycle colors style = make.style.next() color = style[0] linestyle = style[1:] plot.add_item(make.curve(mx, my, color=color, linestyle=linestyle, linewidth=2)) win.get_itemlist_panel().show() plot.set_items_readonly(False) win.show() win.exec_()
def __init__( self, verbose=False, settings_file=None ): super(TransientDecayGenerator, self).__init__() uic.loadUi( os.path.join( os.path.dirname( __file__ ), 'dye_diffusion2.ui' ), self ) if settings_file is None: settings_file = os.path.join( os.path.dirname( __file__ ), 'dye_diffusion.json' ) self.pdb_selector = PDBSelector() self.verticalLayout_10.addWidget(self.pdb_selector) self._settings_file = None self.settings_file = settings_file fp = open(settings_file) settings = json.load(fp) fp.close() DonorDecay.__init__(self, **settings) ## User-interface self.actionLoad_PDB.triggered.connect(self.onLoadPDB) self.actionLoad_settings.triggered.connect(self.onLoadSettings) self.doubleSpinBox_6.valueChanged.connect(self.onSimulationTimeChanged) self.doubleSpinBox_7.valueChanged.connect(self.onSimulationDtChanged) self.pushButton_3.clicked.connect(self.update_all) self.pushButton_4.clicked.connect(self.onSaveHist) self.pushButton_5.clicked.connect(self.onSaveAV) self.tmp_dir = tempfile.gettempdir() print("Temporary Directory: %s" % self.tmp_dir) ## Decay-Curve fd = CurveDialog(edit=False, toolbar=True) self.plot_decay = fd.get_plot() self.hist_curve = make.curve([1], [1], color="r", linewidth=1) self.unquenched_curve = make.curve([1], [1], color="b", linewidth=1) self.plot_decay.add_item(self.hist_curve) self.plot_decay.add_item(self.unquenched_curve) self.plot_decay.set_scales('lin', 'log') self.verticalLayout_2.addWidget(fd) ## Diffusion-Trajectory-Curve options = dict(title="Trajectory", xlabel="time [ns]", ylabel=("|R-<R>|")) fd = CurveDialog(edit=False, toolbar=True, options=options) self.plot_diffusion = fd.get_plot() self.diffusion_curve = make.curve([1], [1], color="b", linewidth=1) self.plot_diffusion.add_item(self.diffusion_curve) self.plot_diffusion.set_scales('lin', 'lin') self.verticalLayout_6.addWidget(fd) options = dict(xlabel="corr. time [ns]", ylabel=("A.Corr.(|R-<R>|)")) fd = CurveDialog(edit=False, toolbar=True, options=options) self.plot_autocorr = fd.get_plot() self.diffusion_autocorrelation = make.curve([1], [1], color="r", linewidth=1) self.plot_autocorr.add_item(self.diffusion_autocorrelation) self.plot_autocorr.set_scales('log', 'lin') self.verticalLayout_6.addWidget(fd) ## Protein Structure self.molview = MolQtWidget(self, enableUi=False) self.verticalLayout_4.addWidget(self.molview) self.diff_file = None self.av_slow_file = None self.av_fast_file = None
def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(536, 384) self.Form=Form self.tableWidget = QtGui.QTableWidget(Form) self.tableWidget.setGeometry(QtCore.QRect(90, 261, 221, 121)) self.tableWidget.setObjectName(_fromUtf8("tableWidget")) self.tableWidget.setColumnCount(2) self.tableWidget.setRowCount(1) item = QtGui.QTableWidgetItem() self.tableWidget.setVerticalHeaderItem(0, item) item = QtGui.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(0, item) item = QtGui.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(1, item) item = QtGui.QTableWidgetItem() self.tableWidget.setItem(0, 0, item) item = QtGui.QTableWidgetItem() self.tableWidget.setItem(0, 1, item) self.pushButton = QtGui.QPushButton(Form) self.pushButton.setGeometry(QtCore.QRect(0, 300, 75, 23)) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.widget = QtGui.QWidget(Form) self.widget.setGeometry(QtCore.QRect(10, 10, 521, 211)) self.widget.setObjectName(_fromUtf8("widget")) #self.pushButton_2 = QtGui.QPushButton(Form) #self.pushButton_2.setGeometry(QtCore.QRect(0, 330, 75, 23)) #self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.pushButton_3 = QtGui.QPushButton(Form) self.pushButton_3.setGeometry(QtCore.QRect(0, 360, 75, 23)) self.pushButton_3.setObjectName(_fromUtf8("pushButton_3")) #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% self.dialog = CurveDialog(edit=False, toolbar=False, parent=self.widget) self.plot = self.dialog.get_plot() self.plot.set_antialiasing(True) self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, 'Time') self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, 'Value') self.manager = PlotManager(self) self.manager.add_plot(self.plot) legend = make.legend('TL') self.plot.add_item(legend) ly = QtGui.QVBoxLayout() ly.addWidget(self.plot) self.widget.setLayout(ly) # item = QtGui.QTableWidgetItem() # self.tableWidget.setHorizontalHeaderItem(0, item) # item = QtGui.QTableWidgetItem() # self.tableWidget.setItem(0, 0, item) # item = QtGui.QTableWidgetItem() # self.tableWidget.setItem(0, 1, item) # item = self.tableWidget.horizontalHeaderItem(0) # item.setText(_translate("Form", "Attribute", None)) c = 0 for it in self.prc.getRequiredParameters(): # item = QtGui.QTableWidgetItem() # item.setText(_translate("Form", "Id" + str(c), None)) # self.tableWidget.setVerticalHeaderItem(c, item) item = QtGui.QTableWidgetItem() item.setText(it) self.tableWidget.setItem(c, 0, item) #print it, self.prc.getRequiredParameters()[it] item = QtGui.QTableWidgetItem() item.setText(str(self.prc.getRequiredParameters()[it])) self.tableWidget.setItem(c, 1, item) # print c c += 1 ####%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) self.currentdata=[]
class Ui_Form(object): def __init__(self, type): self.dc = DataController() self.drc = RepresentationControl() self.flowData = self.dc.abstractionData pos = self.drc.getAvailableAlgorithms().keys().index(type) self.drc.selectAlgorithm(pos) def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(536, 384) self.tableWidget = QtGui.QTableWidget(Form) self.tableWidget.setGeometry(QtCore.QRect(90, 261, 221, 121)) if self.dc.getCurrentLabels() is None: QtGui.QMessageBox.warning(Form, "No Features Found", "Please select Feature Extraction Method first", QtGui.QMessageBox.Ok) self.tableWidget.setObjectName(_fromUtf8("tableWidget")) self.tableWidget.setColumnCount(2) self.tableWidget.setRowCount(len(list(set(self.dc.getCurrentLabels())))) self.pushButton = QtGui.QPushButton(Form) self.pushButton.setGeometry(QtCore.QRect(0, 360, 75, 23)) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.label = QtGui.QLabel(Form) self.label.setGeometry(QtCore.QRect(10, 10, 521, 211)) self.label.setText("The state figure will be saved") self.widget = QtGui.QWidget() self.widget.setGeometry(QtCore.QRect(10, 10, 521, 211)) self.widget.setObjectName(_fromUtf8("widget")) self.dialog = CurveDialog(edit=False, toolbar=False, parent=self.widget) self.plot = self.dialog.get_plot() self.plot.set_antialiasing(True) self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, 'Time') self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, 'Value') self.manager = PlotManager(self) self.manager.add_plot(self.plot) ly = QtGui.QVBoxLayout() ly.addWidget(QtGui.QLabel(self.widget)) ly.addWidget(QtGui.QLabel(self.plot)) self.widget.setLayout(ly) # item = QtGui.QTableWidgetItem() # self.tableWidget.setHorizontalHeaderItem(0, item) # item = QtGui.QTableWidgetItem() # self.tableWidget.setItem(0, 0, item) # item = QtGui.QTableWidgetItem() # self.tableWidget.setItem(0, 1, item) # item = self.tableWidget.horizontalHeaderItem(0) # item.setText(_translate("Form", "Attribute", None)) c = 0 for it in list(set(self.dc.getCurrentLabels())): # item = QtGui.QTableWidgetItem() # item.setText(_translate("Form", "Id" + str(c), None)) # self.tableWidget.setVerticalHeaderItem(c, item) item = QtGui.QTableWidgetItem() item.setText(str(it)) self.tableWidget.setItem(c, 0, item) #print "jgaboo timeig", it #print it, self.drc.getRequiredParameters()[it] item = QtGui.QTableWidgetItem() item.setText("States!") self.tableWidget.setItem(c, 1, item) #print c c += 1 self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): Form.setWindowTitle(_translate("Form", "Form", None)) __sortingEnabled = self.tableWidget.isSortingEnabled() self.tableWidget.setSortingEnabled(False) self.tableWidget.setSortingEnabled(__sortingEnabled) self.pushButton.setText(_translate("Form", "Picture It!", None)) Form.connect(self.pushButton, QtCore.SIGNAL('clicked()'), self.processor) def processor(self): print "in process" params = {} for i in range(self.tableWidget.rowCount()): a = self.tableWidget.item(i, 0) b = self.tableWidget.item(i, 1) params[str(a.text())] = str(b.text()) #print "paramsjo", params #print "paramsjo2", self.dc.params self.drc.represent(None,{"states":self.dc.params})
class Ui_PlotWidget_Feature_Set(QtGui.QWidget): """""" def __init__(self, parent=None): """Constructor for Ui_PlotWidget""" QtGui.QWidget.__init__(self, parent) self.setupUi() def setupUi(self): """loads numpy array Args: self Returns: nothing """ # self.plot = CurvePlot(self) self.dialog = CurveDialog(edit=False, toolbar=True, parent=self) self.plot = self.dialog.get_plot() self.plot.set_antialiasing(True) # x = np.linspace(-10,10,200) # dy = x/100. # y = np.sin(np.sin(np.sin(x))) # self.plot.add_item(make.curve(x,y)) self.loadButton = QtGui.QPushButton("Load") self.trainButton = QtGui.QPushButton("Train Model") ly = QtGui.QVBoxLayout() ly.addWidget(self.plot) # ly.addWidget(self.loadButton) # ly.addWidget(self.trainButton) self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, "Time") self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, "Value") self.manager = PlotManager(self) self.manager.add_plot(self.plot) # self.manager. legend = make.legend("TL") self.plot.add_item(legend) self.setLayout(ly) self.move(300, 200) self.show() self.dataController = DataController.DataController() def loadData(self): self.trainingData = self.dataController.loadSampleData() import logic.dimreduce.paa as PAA p = PAA.paa() data = p.process(self.trainingData["PIR"][:], 100) r = np.array(range(len(data))).reshape(len(data), 1) s = np.array(data).reshape(len(data), 1) rs = np.hstack((s, s)) print rs import logic.featurex.kmeans as km k = km.kmeans() labels = k.process(rs, 2) print labels self.plot.add_item(make.curve(range(0, len(data)), data)) from guiqwt.styles import AnnotationParam i = 0 i_beg = 0 i_end = 0 while i < len(labels): cur = labels[i_end] if i < len(labels) - 1: if labels[i_end + 1] != cur: i_end = i from guiqwt.annotations import AnnotatedRectangle param = AnnotationParam() param.title = str(labels[int(i_beg)]) param.show_computations = False anno = AnnotatedRectangle(r[int(i_beg)], 0.5, r[int(i_end)], 0.2, param) # TODO: y axis scaling self.plot.add_item(anno) i_beg = i_end print "s1" else: i_end = i print "s2" print "s3" print "s4", i_end, len(labels) i += 1 # param = AnnotationParam() # param.title = "alright" # param.show_computations = False ##anno = AnnotatedRectangle(0., 1., 1.5, 0.5, param) # anno.set_style("plot", "shape/drag") # anno.set_style("shape/drag/fill/color", "white") # self.plot.add_item(anno) # self.rangeSelection = make.range(-2, 2) # disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm", # title="Range infos") # self.plot.add_item(self.rangeSelection) # self.plot.add_item(disp0) self.plot.replot() def trainData(self, string_length, vocab, window_length, clusterN): a, b = self.rangeSelection.get_range() if a > b: a, b = b, a print a, b print "in widget", int(string_length), int(vocab), int(window_length), int(clusterN) self.dataController.trainData(a, b, int(string_length), int(vocab), int(window_length), int(clusterN))
class Ui_Form(object): def __init__(self, type): self.dc = DataController() self.fec = FeatureExtractionControl() self.flowData = self.dc.dimrecprocData pos = self.fec.getAvailableAlgorithms().keys().index(type) self.fec.selectAlgorithm(pos) def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(536, 384) self.Form=Form self.tableWidget = QtGui.QTableWidget(Form) self.tableWidget.setGeometry(QtCore.QRect(90, 261, 221, 121)) self.tableWidget.setObjectName(_fromUtf8("tableWidget")) self.tableWidget.setColumnCount(2) self.tableWidget.setRowCount(len(self.fec.getRequiredParameters())) item = QtGui.QTableWidgetItem() self.tableWidget.setVerticalHeaderItem(0, item) item = QtGui.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(0, item) item = QtGui.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(1, item) item = QtGui.QTableWidgetItem() self.tableWidget.setItem(0, 0, item) item = QtGui.QTableWidgetItem() self.tableWidget.setItem(0, 1, item) self.pushButton = QtGui.QPushButton(Form) self.pushButton.setGeometry(QtCore.QRect(0, 300, 75, 23)) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.widget = QtGui.QWidget(Form) self.widget.setGeometry(QtCore.QRect(10, 10, 521, 211)) self.widget.setObjectName(_fromUtf8("widget")) self.pushButton_3 = QtGui.QPushButton(Form) self.pushButton_3.setGeometry(QtCore.QRect(0, 360, 75, 23)) self.pushButton_3.setObjectName(_fromUtf8("pushButton_3")) self.dialog = CurveDialog(edit=False, toolbar=False, parent=self.widget) self.plot = self.dialog.get_plot() self.plot.set_antialiasing(True) self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, 'Time') self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, 'Value') self.manager = PlotManager(self) self.manager.add_plot(self.plot) legend = make.legend('TL') self.plot.add_item(legend) ly = QtGui.QVBoxLayout() ly.addWidget(self.plot) self.widget.setLayout(ly) # item = QtGui.QTableWidgetItem() # self.tableWidget.setHorizontalHeaderItem(0, item) # item = QtGui.QTableWidgetItem() # self.tableWidget.setItem(0, 0, item) # item = QtGui.QTableWidgetItem() # self.tableWidget.setItem(0, 1, item) # item = self.tableWidget.horizontalHeaderItem(0) # item.setText(_translate("Form", "Attribute", None)) c = 0 for it in self.fec.getRequiredParameters(): # item = QtGui.QTableWidgetItem() # item.setText(_translate("Form", "Id" + str(c), None)) # self.tableWidget.setVerticalHeaderItem(c, item) item = QtGui.QTableWidgetItem() item.setText(it) self.tableWidget.setItem(c, 0, item) print it, self.fec.getRequiredParameters()[it] item = QtGui.QTableWidgetItem() item.setText(str(self.fec.getRequiredParameters()[it])) self.tableWidget.setItem(c, 1, item) print c c += 1 self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): Form.setWindowTitle(_translate("Form", "Form", None)) __sortingEnabled = self.tableWidget.isSortingEnabled() self.tableWidget.setSortingEnabled(False) self.tableWidget.setSortingEnabled(__sortingEnabled) self.pushButton.setText(_translate("Form", "Process", None)) Form.connect(self.pushButton, QtCore.SIGNAL('clicked()'), self.process) self.pushButton_3.setText(_translate("Form", "Save", None)) Form.connect(self.pushButton_3, QtCore.SIGNAL('clicked()'),self.saveDialog) def process(self): params = {} for i in range(self.tableWidget.rowCount()): a = self.tableWidget.item(i, 0) b = self.tableWidget.item(i, 1) params[str(a.text())] = int(b.text()) print "params", params outpN = self.tableWidget.item(0, 0) #params = {"none": "none", "output_length": outpN} r = np.array(range(len(self.dc.dimrecprocData))).reshape(len(self.dc.dimrecprocData), 1) s = np.array(self.dc.dimrecprocData).reshape(len(self.dc.dimrecprocData), 1) rs = np.hstack((s, s)) labels = self.fec.extractFeature(rs, params) print labels self.plot.del_all_items() self.plot.replot() self.plot.add_item( make.curve(range(0, len(self.dc.dimrecprocData)), self.dc.dimrecprocData)) from guiqwt.styles import AnnotationParam i = 0 i_beg = 0 i_end = 0 while i < len(labels): cur = labels[i_end] if i < len(labels) - 1: if labels[i_end + 1] != cur: i_end = i from guiqwt.annotations import AnnotatedRectangle param = AnnotationParam() param.title = str(labels[int(i_beg)]) param.show_computations = False anno = AnnotatedRectangle(r[int(i_beg)], self.dc.dimrecprocData[int(i_beg)], int(i_end), self.dc.dimrecprocData[r[int(i_end)]], param) #TODO: y axis scaling self.plot.add_item(anno) i_beg = i_end print "s1" else: i_end = i print "s2" print "s3" print "s4", i_end, len(labels) i += 1 self.rangeSelection = make.range(-2, 2) disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm", title="Range infos") #self.plot.add_item(self.rangeSelection) #self.plot.add_item(disp0) #self.dc.setCurrentDataFlowObject(self.flowData) self.dc.featureexData = self.flowData self.dc.setCurrentLabels(labels) print(self.dc.setCurrentLabels) #ToDo: Check that following line, make property in data controller self.dc.dimrecprocData = rs self.plot.replot() self.currentdata = np.reshape(labels, (-1, 1)) def saveDialog(self): path = QtGui.QFileDialog.getSaveFileName(self.Form, 'Save File', '', 'CSV(*.csv)') if not path.isEmpty(): with open(unicode(path), 'wb') as stream: writer = csv.writer(stream) [a,b]=self.currentdata.shape print(a) print(b) for row in range(a): rowdata = [] for column in range(b): item = self.currentdata.item(row, column) if item is not None: rowdata.append(item) else: rowdata.append('') writer.writerow(rowdata)
def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(536, 384) self.tableWidget = QtGui.QTableWidget(Form) self.tableWidget.setGeometry(QtCore.QRect(90, 261, 221, 121)) if self.dc.getCurrentLabels() is None: QtGui.QMessageBox.warning(Form, "No Features Found", "Please select Feature Extraction Method first", QtGui.QMessageBox.Ok) self.tableWidget.setObjectName(_fromUtf8("tableWidget")) self.tableWidget.setColumnCount(2) self.tableWidget.setRowCount(len(list(set(self.dc.getCurrentLabels())))) self.pushButton = QtGui.QPushButton(Form) self.pushButton.setGeometry(QtCore.QRect(0, 360, 75, 23)) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.label = QtGui.QLabel(Form) self.label.setGeometry(QtCore.QRect(10, 10, 521, 211)) self.label.setText("The state figure will be saved") self.widget = QtGui.QWidget() self.widget.setGeometry(QtCore.QRect(10, 10, 521, 211)) self.widget.setObjectName(_fromUtf8("widget")) self.dialog = CurveDialog(edit=False, toolbar=False, parent=self.widget) self.plot = self.dialog.get_plot() self.plot.set_antialiasing(True) self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.xBottom, 'Time') self.plot.setAxisTitle(Qwt5.Qwt.QwtPlot.yLeft, 'Value') self.manager = PlotManager(self) self.manager.add_plot(self.plot) ly = QtGui.QVBoxLayout() ly.addWidget(QtGui.QLabel(self.widget)) ly.addWidget(QtGui.QLabel(self.plot)) self.widget.setLayout(ly) # item = QtGui.QTableWidgetItem() # self.tableWidget.setHorizontalHeaderItem(0, item) # item = QtGui.QTableWidgetItem() # self.tableWidget.setItem(0, 0, item) # item = QtGui.QTableWidgetItem() # self.tableWidget.setItem(0, 1, item) # item = self.tableWidget.horizontalHeaderItem(0) # item.setText(_translate("Form", "Attribute", None)) c = 0 for it in list(set(self.dc.getCurrentLabels())): # item = QtGui.QTableWidgetItem() # item.setText(_translate("Form", "Id" + str(c), None)) # self.tableWidget.setVerticalHeaderItem(c, item) item = QtGui.QTableWidgetItem() item.setText(str(it)) self.tableWidget.setItem(c, 0, item) #print "jgaboo timeig", it #print it, self.drc.getRequiredParameters()[it] item = QtGui.QTableWidgetItem() item.setText("States!") self.tableWidget.setItem(c, 1, item) #print c c += 1 self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def __init__( self, *args, dye_diffusion_settings_file: str = None, verbose: bool = chisurf.verbose, **kwargs ): if dye_diffusion_settings_file is None: dye_diffusion_settings_file = os.path.join( chisurf.settings.package_directory, './settings/sample.json' ) settings = json.load( chisurf.fio.zipped.open_maybe_zipped( filename=dye_diffusion_settings_file, mode='r' ) ) super().__init__( *args, verbose=verbose, **settings ) QtWidgets.QWidget.__init__(self) uic.loadUi( os.path.join( os.path.dirname(os.path.abspath(__file__)), "dye_diffusion2.ui" ), self ) self.pdb_selector = PDBSelector() self.verticalLayout_10.addWidget(self.pdb_selector) self._settings_file = None self.settings_file = dye_diffusion_settings_file self.protein_quenching = chisurf.fluorescence.av.widgets.ProteinQuenchingWidget( k_quench_protein=kwargs.get('k_quench_protein', 5.0), ) self.verticalLayout_11.addWidget(self.protein_quenching) self.dye_parameter = chisurf.fluorescence.av.dynamic.DyeParameterWidget(**kwargs) self.verticalLayout_14.addWidget(self.dye_parameter) self.sticking = chisurf.fluorescence.av.dynamic.StickingParameterWidget() self.verticalLayout_13.addWidget(self.sticking) # # User-interface self.actionLoad_PDB.triggered.connect(self.onLoadPDB) self.actionLoad_settings.triggered.connect(self.onLoadSettings) self.actionSave_AV.triggered.connect(self.onSaveAV) self.actionLoad_settings.triggered.connect(self.onLoadSettings) self.actionUpdate_all.triggered.connect(self.update_model) self.actionSave_histogram.triggered.connect(self.onSaveHist) self.actionSave_trajectory.triggered.connect(self.onSaveTrajectory) self.doubleSpinBox_6.valueChanged.connect(self.onSimulationTimeChanged) self.doubleSpinBox_7.valueChanged.connect(self.onSimulationDtChanged) self.tmp_dir = tempfile.gettempdir() print("Temporary Directory: %s" % self.tmp_dir) ## Decay-Curve fd = CurveDialog(edit=False, toolbar=True) self.plot_decay = fd.get_plot() self.hist_curve = make.curve([1], [1], color="r", linewidth=1) self.unquenched_curve = make.curve([1], [1], color="b", linewidth=1) self.plot_decay.add_item(self.hist_curve) self.plot_decay.add_item(self.unquenched_curve) self.plot_decay.set_scales('lin', 'log') self.verticalLayout_2.addWidget(fd) ## Diffusion-Trajectory-Curve options = dict(title="Trajectory", xlabel="time [ns]", ylabel=("|R-<R>|")) fd = CurveDialog(edit=False, toolbar=True, options=options) self.plot_diffusion = fd.get_plot() self.diffusion_curve = make.curve([1], [1], color="b", linewidth=1) self.plot_diffusion.add_item(self.diffusion_curve) self.plot_diffusion.set_scales('lin', 'lin') self.verticalLayout_6.addWidget(fd) options = dict(xlabel="corr. time [ns]", ylabel=("A.Corr.(|R-<R>|)")) fd = CurveDialog(edit=False, toolbar=True, options=options) self.plot_autocorr = fd.get_plot() self.diffusion_autocorrelation = make.curve([1], [1], color="r", linewidth=1) self.plot_autocorr.add_item(self.diffusion_autocorrelation) self.plot_autocorr.set_scales('log', 'lin') self.verticalLayout_6.addWidget(fd) ## Protein Structure self.molview = MolQtWidget(self, enableUi=False) self.verticalLayout_4.addWidget(self.molview) self.diff_file = None self.av_slow_file = None self.av_fast_file = None self.hide()