- Timestamp:
- Dec 6, 2016 8:35:10 AM (8 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 64f1e93
- Parents:
- 6d05e1d
- Location:
- src/sas/qtgui
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/DataExplorer.py
ref01be4 r55d89f8 768 768 method_name='Plotter2D' 769 769 770 # TODO: Replace this with the proper MaskPlotPanel from plottools771 770 new_plot = globals()[method_name](self, quickplot=True) 772 771 new_plot.data = data … … 782 781 def quickData3DPlot(self): 783 782 """ 784 """ 785 print "quickData3DPlot" 786 pass 783 Slowish 3D plot 784 """ 785 index = self.treeView.selectedIndexes()[0] 786 model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 787 data = GuiUtils.dataFromItem(model_item) 788 789 new_plot = Plotter2D(self, quickplot=True, dimension=3) 790 new_plot.data = data 791 new_plot.plot(marker='o', linestyle='') 792 793 # Update the global plot counter 794 title = "Plot " + data.name 795 new_plot.setWindowTitle(title) 796 797 # Show the plot 798 new_plot.show() 787 799 788 800 def showEditDataMask(self): -
src/sas/qtgui/Plotter2D.py
r6d05e1d r55d89f8 11 11 12 12 class Plotter2D(PlotterBase): 13 def __init__(self, parent=None, quickplot=False): 13 def __init__(self, parent=None, quickplot=False, dimension=2): 14 self.dimension = dimension 14 15 super(Plotter2D, self).__init__(parent, quickplot=quickplot) 15 16 … … 31 32 self.zmax=data.zmax 32 33 self.label=data.name 33 self.dimension=234 34 self.xLabel="%s(%s)"%(data._xaxis, data._xunit) 35 35 self.yLabel="%s(%s)"%(data._yaxis, data._yunit) … … 41 41 """ 42 42 # create an axis object 43 ax = self.ax 43 zmin_2D_temp = self.zmin 44 zmax_2D_temp = self.zmax 45 if self.scale == 'log_{10}': 46 self.scale = 'linear' 47 if not self.zmin is None: 48 zmin_2D_temp = numpy.pow(10, self.zmin) 49 if not self.zmax is None: 50 zmax_2D_temp = numpy.pow(10, self.zmax) 51 else: 52 self.scale = 'log_{10}' 53 if not self.zmin is None: 54 # min log value: no log(negative) 55 if self.zmin <= 0: 56 zmin_2D_temp = -32 57 else: 58 zmin_2D_temp = numpy.log10(self.zmin) 59 if not self.zmax is None: 60 zmax_2D_temp = numpy.log10(self.zmax) 44 61 45 # graph properties 46 ax.set_xlabel(self.x_label) 47 ax.set_ylabel(self.y_label) 48 # Title only for regular charts 49 if not self.quickplot: 50 ax.set_title(label=self._title) 51 52 # Re-adjust colorbar 53 self.figure.subplots_adjust(left=0.2, right=.8, bottom=.2) 54 55 output = PlotUtilities.build_matrix(self._data.data, self.qx_data, self.qy_data) 56 57 im = ax.imshow(output, 58 interpolation='nearest', 59 origin='lower', 60 vmin=self.zmin, vmax=self.zmax, 61 cmap=self.cmap, 62 extent=(self.xmin, self.xmax, 63 self.ymin, self.ymax)) 64 65 cbax = self.figure.add_axes([0.84, 0.2, 0.02, 0.7]) 66 cb = self.figure.colorbar(im, cax=cbax) 67 cb.update_bruteforce(im) 68 cb.set_label('$' + self.scale + '$') 69 70 # Schedule the draw for the next time the event loop is idle. 71 self.canvas.draw_idle() 62 self.image(data=self.data.data, qx_data=self.qx_data, 63 qy_data=self.qy_data, xmin=self.xmin, 64 xmax=self.xmax, 65 ymin=self.ymin, ymax=self.ymax, 66 cmap=self.cmap, zmin=zmin_2D_temp, 67 zmax=zmax_2D_temp) 72 68 73 69 def contextMenuQuickPlot(self): … … 81 77 self.actionCopyToClipboard = self.contextMenu.addAction("Copy to Clipboard") 82 78 self.contextMenu.addSeparator() 83 self.actionToggleGrid = self.contextMenu.addAction("Toggle Grid On/Off") 84 self.contextMenu.addSeparator() 79 if self.dimension == 2: 80 self.actionToggleGrid = self.contextMenu.addAction("Toggle Grid On/Off") 81 self.contextMenu.addSeparator() 85 82 self.actionChangeScale = self.contextMenu.addAction("Toggle Linear/Log Scale") 86 83 … … 89 86 self.actionPrintImage.triggered.connect(self.onImagePrint) 90 87 self.actionCopyToClipboard.triggered.connect(self.onClipboardCopy) 91 self.actionToggleGrid.triggered.connect(self.onGridToggle) 88 if self.dimension == 2: 89 self.actionToggleGrid.triggered.connect(self.onGridToggle) 92 90 self.actionChangeScale.triggered.connect(self.onToggleScale) 93 91 … … 95 93 """ 96 94 Toggle axis and replot image 97 98 95 """ 99 zmin_2D_temp = self.zmin 100 zmax_2D_temp = self.zmax 101 if self.scale == 'log_{10}': 102 self.scale = 'linear' 103 if not self.zmin is None: 104 zmin_2D_temp = math.pow(10, self.zmin) 105 if not self.zmax is None: 106 zmax_2D_temp = math.pow(10, self.zmax) 107 else: 108 self.scale = 'log_{10}' 109 if not self.zmin is None: 110 # min log value: no log(negative) 111 if self.zmin <= 0: 112 zmin_2D_temp = -32 113 else: 114 zmin_2D_temp = math.log10(self.zmin) 115 if not self.zmax is None: 116 zmax_2D_temp = math.log10(self.zmax) 117 118 self.image(data=self.data.data, qx_data=self.qx_data, 119 qy_data=self.qy_data, xmin=self.xmin, 120 xmax=self.xmax, 121 ymin=self.ymin, ymax=self.ymax, 122 cmap=self.cmap, zmin=zmin_2D_temp, 123 zmax=zmax_2D_temp) 124 96 self.plot() 125 97 126 98 def image(self, data, qx_data, qy_data, xmin, xmax, ymin, ymax, … … 129 101 """ 130 102 Render the current data 131 132 103 """ 133 #self.data = data134 104 self.qx_data = qx_data 135 105 self.qy_data = qy_data … … 140 110 self.zmin = zmin 141 111 self.zmax = zmax 142 #c = self.color(color)143 112 # If we don't have any data, skip. 144 113 if data == None: 145 114 return 146 115 if data.ndim == 1: 147 #output = self._build_matrix()148 116 output = PlotUtilities.build_matrix(data, self.qx_data, self.qy_data) 149 117 else: … … 157 125 zmin_temp = self.zmin_2D 158 126 output[output > 0] = numpy.log10(output[output > 0]) 159 #In log scale Negative values are not correct in general160 #output[output<=0] = math.log(numpy.min(output[output>0]))161 127 elif self.zmin <= 0: 162 128 zmin_temp = self.zmin … … 166 132 zmin_temp = self.zmin 167 133 output[output > 0] = numpy.log10(output[output > 0]) 168 #In log scale Negative values are not correct in general169 #output[output<=0] = math.log(numpy.min(output[output>0]))170 134 except: 171 135 #Too many problems in 2D plot with scale … … 193 157 self.figure.subplots_adjust(left=0.1, right=.8, bottom=.1) 194 158 195 X = self. x_bins[0:-1]196 Y = self. y_bins[0:-1]159 X = self._data.x_bins[0:-1] 160 Y = self._data.y_bins[0:-1] 197 161 X, Y = numpy.meshgrid(X, Y) 198 162 … … 200 164 # mpl >= 1.0.0 201 165 ax = self.figure.gca(projection='3d') 202 #ax.disable_mouse_rotation()203 166 cbax = self.figure.add_axes([0.84, 0.1, 0.02, 0.8]) 204 167 if len(X) > 60: … … 218 181 im = ax.plot_surface(X, Y, output, rstride=1, cstride=1, cmap=cmap, 219 182 linewidth=0, antialiased=False) 220 self. set_axis_off()183 self.ax.set_axis_off() 221 184 222 185 if cbax == None: -
src/sas/qtgui/PlotterBase.py
- Property mode changed from 100755 to 100644
r6d05e1d r55d89f8 52 52 self.color=0 53 53 self.symbol=0 54 self.dimension=155 54 self.grid_on = False 56 55 self.scale = 'linear' -
src/sas/qtgui/run_tests.bat
r363fbfa r55d89f8 12 12 python -m UnitTesting.PlotHelperTest 13 13 python -m UnitTesting.KiessigCalculatorTest 14 python -m UnitTesting.PlotterTest 15 python -m UnitTesting.Plotter2DTest 16 python -m UnitTesting.ScalePropertiesTest -
src/sas/qtgui/run_tests.sh
r363fbfa r55d89f8 9 9 python -m UnitTesting.PlotHelperTest 10 10 python -m UnitTesting.SasviewLoggerTest 11 python -m UnitTesting.PlotterTest 12 python -m UnitTesting.Plotter2DTest 13 python -m UnitTesting.ScalePropertiesTest 14 python -m UnitTesting.KiessigCalculatorTest 11 15 python -m UnitTesting.DensityCalculatorTest 12 python -m UnitTesting.KiessigCalculatorTest
Note: See TracChangeset
for help on using the changeset viewer.