Changeset b3e8629 in sasview for src/sas/qtgui/Plotting
- Timestamp:
- Nov 9, 2017 8:41:54 AM (7 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:
- cee5c78
- Parents:
- 749b715
- git-author:
- Piotr Rozyczko <rozyczko@…> (10/26/17 03:13:05)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (11/09/17 08:41:54)
- Location:
- src/sas/qtgui/Plotting
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Plotting/Arrow3D.py
rfef38e8 rb3e8629 59 59 return 60 60 xs3d, ys3d, zs3d = self._verts3d 61 for i in xrange(len(xs3d)):61 for i in range(len(xs3d)): 62 62 xs, ys, _ = proj3d.proj_transform(xs3d[i], ys3d[i], zs3d[i], renderer.M) 63 63 self.set_positions((xs[0], ys[0]), (xs[1], ys[1])) -
src/sas/qtgui/Plotting/Binder.py
rdc5ef15 rb3e8629 24 24 return self.artist is not other.artist 25 25 26 def __ nonzero__(self):26 def __bool__(self): 27 27 return self.artist is not None 28 28 … … 61 61 ] 62 62 except: 63 print "bypassing scroll_event: wrong matplotlib version"63 print("bypassing scroll_event: wrong matplotlib version") 64 64 self._connections = [ 65 65 canvas.mpl_connect('motion_notify_event', self._onMotion), … … 121 121 for cid in self._connections: self.canvas.mpl_disconnect(cid) 122 122 except: 123 logging.error("Error disconnection canvas: %s" % sys.exc_ value)123 logging.error("Error disconnection canvas: %s" % sys.exc_info()[1]) 124 124 self._connections = [] 125 125 … … 185 185 # Check that the trigger is valid 186 186 if trigger not in self._actions: 187 raise ValueError ,"%s invalid --- valid triggers are %s"\188 % (trigger, ", ".join(self.events)) 187 raise ValueError("%s invalid --- valid triggers are %s"\ 188 % (trigger, ", ".join(self.events))) 189 189 190 190 # Register the trigger callback … … 201 201 """ 202 202 if action not in self.events: 203 raise ValueError , "Trigger expects " + ", ".join(self.events)203 raise ValueError("Trigger expects " + ", ".join(self.events)) 204 204 205 205 # Tag the event with modifiers -
src/sas/qtgui/Plotting/ColorMap.py
- Property mode changed from 100644 to 100755
rdc5ef15 rb3e8629 13 13 from sas.qtgui.Plotting.PlotterData import Data2D 14 14 from sas.qtgui.Utilities.GuiUtils import formatNumber 15 from rangeSlider import RangeSlider15 from .rangeSlider import RangeSlider 16 16 17 17 DEFAULT_MAP = 'jet' -
src/sas/qtgui/Plotting/ConvertUnits.py
r749b715 rb3e8629 42 42 unit = toks[0] + "^{" + str(powerer) + "}" 43 43 else: 44 raise ValueError , "missing } in unit expression"44 raise ValueError("missing } in unit expression") 45 45 else: # no powerer 46 46 if power != 1: 47 47 unit = "(" + unit + ")" + "^{" + str(power) + "}" 48 48 else: 49 raise ValueError , "empty unit ,enter a powerer different from zero"49 raise ValueError("empty unit ,enter a powerer different from zero") 50 50 return unit 51 51 … … 68 68 unit8 = "m/s^{4}" # x^2 (m/s^{4})^{2} 69 69 70 print "this unit1 %s ,its powerer %s , and value %s" % (unit1, 1, convert_unit(1, unit1))71 print "this unit2 %s ,its powerer %s , and value %s" % (unit2, 1, convert_unit(1, unit2))72 print "this unit3 %s ,its powerer %s , and value %s" % (unit3, 2, convert_unit(2, unit3))73 print "this unit4 %s ,its powerer %s , and value %s" % (unit4, -1, convert_unit(-1, unit4))74 print "this unit5 %s ,its powerer %s , and value %s" % (unit5, 2, convert_unit(2, unit5))75 print "this unit6 %s ,its powerer %s , and value %s" % (unit6, 2, convert_unit(2, unit6))76 print "this unit7 %s ,its powerer %s , and value %s" % (unit7, -1, convert_unit(-1, unit7))77 print "this unit8 %s ,its powerer %s , and value %s" % (unit8, 2, convert_unit(2, unit8))78 print "this unit9 %s ,its powerer %s , and value %s" % (unit9, 2, convert_unit(2, unit9))70 print("this unit1 %s ,its powerer %s , and value %s" % (unit1, 1, convert_unit(1, unit1))) 71 print("this unit2 %s ,its powerer %s , and value %s" % (unit2, 1, convert_unit(1, unit2))) 72 print("this unit3 %s ,its powerer %s , and value %s" % (unit3, 2, convert_unit(2, unit3))) 73 print("this unit4 %s ,its powerer %s , and value %s" % (unit4, -1, convert_unit(-1, unit4))) 74 print("this unit5 %s ,its powerer %s , and value %s" % (unit5, 2, convert_unit(2, unit5))) 75 print("this unit6 %s ,its powerer %s , and value %s" % (unit6, 2, convert_unit(2, unit6))) 76 print("this unit7 %s ,its powerer %s , and value %s" % (unit7, -1, convert_unit(-1, unit7))) 77 print("this unit8 %s ,its powerer %s , and value %s" % (unit8, 2, convert_unit(2, unit8))) 78 print("this unit9 %s ,its powerer %s , and value %s" % (unit9, 2, convert_unit(2, unit9))) 79 79 80 80 -
src/sas/qtgui/Plotting/DataTransform.py
r749b715 rb3e8629 24 24 """ 25 25 if not x > 0: 26 raise ValueError , "Transformation only accepts positive values."26 raise ValueError("Transformation only accepts positive values.") 27 27 else: 28 28 return x … … 50 50 """ 51 51 if not x >= 0: 52 raise ValueError , "square root of a negative value "52 raise ValueError("square root of a negative value ") 53 53 else: 54 54 return math.sqrt(x) … … 76 76 """ 77 77 if not x >= 0: 78 raise ValueError , "double square root of a negative value "78 raise ValueError("double square root of a negative value ") 79 79 else: 80 80 return math.sqrt(math.sqrt(x)) … … 90 90 """ 91 91 if not x > 0: 92 raise ValueError , "Log(x)of a negative value "92 raise ValueError("Log(x)of a negative value ") 93 93 else: 94 94 return math.log(x) … … 100 100 return 1 / x 101 101 else: 102 raise ValueError , "cannot divide by zero"102 raise ValueError("cannot divide by zero") 103 103 104 104 … … 109 109 return 1 / math.sqrt(y) 110 110 else: 111 raise ValueError , "transform.toOneOverSqrtX: cannot be computed"111 raise ValueError("transform.toOneOverSqrtX: cannot be computed") 112 112 113 113 … … 118 118 return math.log(y * (x ** 2)) 119 119 else: 120 raise ValueError , "transform.toLogYX2: cannot be computed"120 raise ValueError("transform.toLogYX2: cannot be computed") 121 121 122 122 … … 127 127 return math.log(math.pow(x, 4) * y) 128 128 else: 129 raise ValueError , "transform.toLogYX4: input error"129 raise ValueError("transform.toLogYX4: input error") 130 130 131 131 … … 149 149 """ 150 150 if not (x * y) > 0: 151 raise ValueError , "Log(X*Y)of a negative value "151 raise ValueError("Log(X*Y)of a negative value ") 152 152 else: 153 153 return math.log(x * y) … … 211 211 else: 212 212 msg = "transform.errFromX2: can't compute error of negative x" 213 raise ValueError , msg213 raise ValueError(msg) 214 214 215 215 … … 245 245 else: 246 246 msg = "transform.errFromX4: can't compute error of negative x" 247 raise ValueError , msg247 raise ValueError(msg) 248 248 249 249 … … 264 264 msg = "Transformation does not accept" 265 265 msg += " point that are consistent with zero." 266 raise ValueError , msg266 raise ValueError(msg) 267 267 if x != 0: 268 268 dx = dx / (x * math.log(10)) 269 269 else: 270 raise ValueError , "errToLogX: divide by zero"270 raise ValueError("errToLogX: divide by zero") 271 271 return dx 272 272 … … 287 287 dx = dx / x 288 288 else: 289 raise ValueError , "errToLogX: divide by zero"289 raise ValueError("errToLogX: divide by zero") 290 290 return dx 291 291 … … 312 312 msg = "Transformation does not accept point " 313 313 msg += " that are consistent with zero." 314 raise ValueError , msg314 raise ValueError(msg) 315 315 if x != 0 and y != 0: 316 316 if dx == None: … … 320 320 err = (dx / x) ** 2 + (dy / y) ** 2 321 321 else: 322 raise ValueError , "cannot compute this error"322 raise ValueError("cannot compute this error") 323 323 324 324 return math.sqrt(math.fabs(err)) … … 335 335 msg = "Transformation does not accept point" 336 336 msg += " that are consistent with zero." 337 raise ValueError , msg337 raise ValueError(msg) 338 338 if x > 0 and y > 0: 339 339 if dx == None: … … 343 343 err = (2.0 * dx / x) ** 2 + (dy / y) ** 2 344 344 else: 345 raise ValueError , "cannot compute this error"345 raise ValueError("cannot compute this error") 346 346 return math.sqrt(math.fabs(err)) 347 347 … … 357 357 err = dx / x ** 2 358 358 else: 359 raise ValueError , "Cannot compute this error"359 raise ValueError("Cannot compute this error") 360 360 return math.fabs(err) 361 361 … … 371 371 err = -1 / 2 * math.pow(x, -3.0 / 2.0) * dx 372 372 else: 373 raise ValueError , "Cannot compute this error"373 raise ValueError("Cannot compute this error") 374 374 return math.fabs(err) 375 375 … … 387 387 msg = "Transformation does not accept point " 388 388 msg += " that are consistent with zero." 389 raise ValueError , msg389 raise ValueError(msg) 390 390 if dx == None: 391 391 dx = 0 -
src/sas/qtgui/Plotting/Fittings.py
- Property mode changed from 100644 to 100755
radc49fc rb3e8629 97 97 # Testing implementation 98 98 # Fit a Line model 99 from LineModel import LineModel99 from .LineModel import LineModel 100 100 line = LineModel() 101 101 cstA = Parameter(line, 'A', event.cstA) … … 104 104 chisqr, out, cov = sasfit(line, [cstA, cstB], event.x, y, 0) 105 105 # print "Output parameters:", out 106 print "The right answer is [70.0, 1.0]"107 print chisqr, out, cov106 print("The right answer is [70.0, 1.0]") 107 print(chisqr, out, cov) 108 108 -
src/sas/qtgui/Plotting/LineModel.py
r749b715 rb3e8629 81 81 elif x.__class__.__name__ == 'tuple': 82 82 msg = "Tuples are not allowed as input to BaseComponent models" 83 raise ValueError , msg83 raise ValueError(msg) 84 84 else: 85 85 return self._line(x) … … 103 103 elif x.__class__.__name__ == 'tuple': 104 104 msg = "Tuples are not allowed as input to BaseComponent models" 105 raise ValueError , msg105 raise ValueError(msg) 106 106 else: 107 107 return self._line(x) -
src/sas/qtgui/Plotting/LinearFit.py
- Property mode changed from 100644 to 100755
rdc5ef15 rb3e8629 79 79 Overwrite default fit range label to correspond to actual unit 80 80 """ 81 assert(isinstance(label, basestring))81 assert(isinstance(label, str)) 82 82 self.lblRange.setText(label) 83 83 … … 195 195 for i in range(len(x)) if x[i] >= xmin_check] 196 196 else: 197 tempy = map(numpy.log10, y)198 tempdy = map(lambda t1,t2:DataTransform.errToLogX(t1,0,t2,0),y,dy)197 tempy = list(map(numpy.log10, y)) 198 tempdy = list(map(lambda t1,t2:DataTransform.errToLogX(t1,0,t2,0),y,dy)) 199 199 else: 200 200 tempy = y -
src/sas/qtgui/Plotting/PlotHelper.py
- Property mode changed from 100644 to 100755
r83eb5208 rb3e8629 35 35 Returns a list of IDs for all currently active plots 36 36 """ 37 return this._plots.keys()37 return list(this._plots.keys()) 38 38 39 39 def plotById(plot_id): … … 48 48 """ 49 49 plot_id = None 50 for key in this._plots.keys():50 for key in list(this._plots.keys()): 51 51 if this._plots[key] == plot: 52 52 plot_id = key -
src/sas/qtgui/Plotting/PlotProperties.py
- Property mode changed from 100644 to 100755
rcd2cc745 rb3e8629 26 26 27 27 # Fill out the color combobox 28 self.cbColor.addItems( COLORS.keys()[:-1])28 self.cbColor.addItems(list(COLORS.keys())[:-1]) 29 29 # data1d.custom_color can now be a simple integer, 30 30 # specifying COLORS dict index or a string containing … … 34 34 else: 35 35 # Need the Custom entry here. "Custom" is always last. 36 self.cbColor.addItems([ COLORS.keys()[-1]])37 self.cbColor.setCurrentIndex( COLORS.keys().index("Custom"))36 self.cbColor.addItems([list(COLORS.keys())[-1]]) 37 self.cbColor.setCurrentIndex(list(COLORS.keys()).index("Custom")) 38 38 39 39 # Fill out the marker combobox 40 self.cbShape.addItems( SHAPES.keys())40 self.cbShape.addItems(list(SHAPES.keys())) 41 41 try: 42 42 self.cbShape.setCurrentIndex(self._marker) … … 83 83 # Add Custom to the color combo box 84 84 self.cbColor.addItems(["Custom"]) 85 self.cbColor.setCurrentIndex( COLORS.keys().index("Custom"))85 self.cbColor.setCurrentIndex(list(COLORS.keys()).index("Custom")) 86 86 # unblock currentIndexChanged 87 87 self.cbColor.blockSignals(False) -
src/sas/qtgui/Plotting/PlotUtilities.py
- Property mode changed from 100644 to 100755
r83eb5208 rb3e8629 273 273 # Check if it's within the range 274 274 if 0 <= color <=6: 275 color = COLORS.values()[color]275 color = list(COLORS.values())[color] 276 276 # Check if it's an RGB string 277 277 elif isinstance(color, str): -
src/sas/qtgui/Plotting/Plottables.py
rdc5ef15 rb3e8629 239 239 selected_color = None 240 240 selected_plottable = None 241 for p in self.plottables.keys():241 for p in list(self.plottables.keys()): 242 242 if plottable.id == p.id: 243 243 selected_plottable = p … … 384 384 385 385 """ 386 raise NotImplemented , "Not a valid transform"386 raise NotImplemented("Not a valid transform") 387 387 388 388 # Related issues … … 512 512 label_dict[collection[0]] = basename 513 513 else: 514 for i in xrange(len(collection)):514 for i in range(len(collection)): 515 515 label_dict[collection[i]] = "%s %d" % (basename, i) 516 516 return label_dict … … 684 684 msg = "Plottable.View: Given x and dx are not" 685 685 msg += " of the same length" 686 raise ValueError , msg686 raise ValueError(msg) 687 687 # Check length of y array 688 688 if not len(y) == len(x): 689 689 msg = "Plottable.View: Given y " 690 690 msg += "and x are not of the same length" 691 raise ValueError , msg691 raise ValueError(msg) 692 692 693 693 if not dy is None and not len(dy) == 0 and not len(y) == len(dy): 694 694 msg = "Plottable.View: Given y and dy are not of the same " 695 695 msg += "length: len(y)=%s, len(dy)=%s" % (len(y), len(dy)) 696 raise ValueError , msg696 raise ValueError(msg) 697 697 self.x = [] 698 698 self.y = [] … … 729 729 msg = "Plottable.View: transformed x " 730 730 msg += "and y are not of the same length" 731 raise ValueError , msg731 raise ValueError(msg) 732 732 if has_err_x and not (len(self.x) == len(self.dx)): 733 733 msg = "Plottable.View: transformed x and dx" 734 734 msg += " are not of the same length" 735 raise ValueError , msg735 raise ValueError(msg) 736 736 if has_err_y and not (len(self.y) == len(self.dy)): 737 737 msg = "Plottable.View: transformed y" 738 738 msg += " and dy are not of the same length" 739 raise ValueError , msg739 raise ValueError(msg) 740 740 # Check that negative values are not plot on x and y axis for 741 741 # log10 transformation … … 809 809 except: 810 810 logging.error("check_data_logX: skipping point x %g", self.x[i]) 811 logging.error(sys.exc_ value)811 logging.error(sys.exc_info()[1]) 812 812 self.x = tempx 813 813 self.y = tempy … … 839 839 except: 840 840 logging.error("check_data_logY: skipping point %g", self.y[i]) 841 logging.error(sys.exc_ value)841 logging.error(sys.exc_info()[1]) 842 842 843 843 self.x = tempx … … 1101 1101 Plottable.__init__(self) 1102 1102 msg = "Theory1D is no longer supported, please use Data1D and change symbol.\n" 1103 raise DeprecationWarning , msg1103 raise DeprecationWarning(msg) 1104 1104 1105 1105 class PlottableFit1D(Plottable): -
src/sas/qtgui/Plotting/Plotter.py
- Property mode changed from 100644 to 100755
r749b715 rb3e8629 90 90 marker = PlotUtilities.SHAPES[marker] 91 91 except KeyError: 92 marker = PlotUtilities.SHAPES.values()[marker]92 marker = list(PlotUtilities.SHAPES.values())[marker] 93 93 94 94 assert marker is not None … … 206 206 Adds operations on all plotted sets of data to the context menu 207 207 """ 208 for id in self.plot_dict.keys():208 for id in list(self.plot_dict.keys()): 209 209 plot = self.plot_dict[id] 210 210 … … 391 391 Deletes the selected plot from the chart 392 392 """ 393 if id not in self.plot_dict.keys():393 if id not in list(self.plot_dict.keys()): 394 394 return 395 395 … … 482 482 """ 483 483 # Transform all the plots on the chart 484 for id in self.plot_dict.keys():484 for id in list(self.plot_dict.keys()): 485 485 current_plot = self.plot_dict[id] 486 486 if current_plot.id == "fit": -
src/sas/qtgui/Plotting/SlicerModel.py
- Property mode changed from 100644 to 100755
r83eb5208 rb3e8629 19 19 self._model.removeRows( 0, self._model.rowCount() ) 20 20 # Crete/overwrite model items 21 for parameter in parameters.keys():21 for parameter in list(parameters.keys()): 22 22 item1 = QtGui.QStandardItem(parameter) 23 23 item2 = QtGui.QStandardItem(GuiUtils.formatNumber(parameters[parameter])) -
src/sas/qtgui/Plotting/Slicers/AnnulusSlicer.py
rdc5ef15 rb3e8629 4 4 5 5 import sas.qtgui.Utilities.GuiUtils as GuiUtils 6 from BaseInteractor import BaseInteractor6 from .BaseInteractor import BaseInteractor 7 7 from sas.qtgui.Plotting.PlotterData import Data1D 8 8 from sas.qtgui.Utilities.GuiUtils import formatNumber -
src/sas/qtgui/Plotting/Slicers/Arc.py
r749b715 rb3e8629 4 4 import math 5 5 6 from BaseInteractor import BaseInteractor6 from .BaseInteractor import BaseInteractor 7 7 8 8 class ArcInteractor(BaseInteractor): -
src/sas/qtgui/Plotting/Slicers/AzimutSlicer.py
rdc5ef15 rb3e8629 5 5 # 6 6 import math 7 from BaseInteractor import BaseInteractor7 from .BaseInteractor import BaseInteractor 8 8 9 9 class SectorInteractor(BaseInteractor): … … 26 26 27 27 # Inner circle 28 from Arc import ArcInteractor28 from .Arc import ArcInteractor 29 29 self.inner_circle = ArcInteractor(self, self.base.subplot, 30 30 zorder=zorder, -
src/sas/qtgui/Plotting/Slicers/BoxSlicer.py
rdc5ef15 rb3e8629 3 3 from PyQt4 import QtCore 4 4 5 from BaseInteractor import BaseInteractor5 from .BaseInteractor import BaseInteractor 6 6 from sas.qtgui.Plotting.PlotterData import Data1D 7 7 import sas.qtgui.Utilities.GuiUtils as GuiUtils … … 136 136 if new_slab is None: 137 137 msg = "post data:cannot average , averager is empty" 138 raise ValueError , msg138 raise ValueError(msg) 139 139 self.averager = new_slab 140 140 if self.direction == "X": … … 152 152 else: 153 153 msg = "post data:no Box Average direction was supplied" 154 raise ValueError , msg154 raise ValueError(msg) 155 155 # # Average data2D given Qx or Qy 156 156 box = self.averager(x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max, -
src/sas/qtgui/Plotting/Slicers/BoxSum.py
rdc5ef15 rb3e8629 8 8 from sas.qtgui.Utilities.GuiUtils import formatNumber 9 9 10 from BaseInteractor import BaseInteractor10 from .BaseInteractor import BaseInteractor 11 11 from sas.sascalc.dataloader.manipulations import Boxavg 12 12 from sas.sascalc.dataloader.manipulations import Boxsum -
src/sas/qtgui/Plotting/Slicers/SectorSlicer.py
rdc5ef15 rb3e8629 6 6 from PyQt4 import QtCore 7 7 8 from BaseInteractor import BaseInteractor8 from .BaseInteractor import BaseInteractor 9 9 from sas.qtgui.Plotting.PlotterData import Data1D 10 10 import sas.qtgui.Utilities.GuiUtils as GuiUtils … … 230 230 msg = "Phi left and phi right are different" 231 231 msg += " %f, %f" % (self.left_line.phi, self.right_line.phi) 232 raise ValueError , msg232 raise ValueError(msg) 233 233 params["Phi [deg]"] = self.main_line.theta * 180 / numpy.pi 234 234 params["Delta_Phi [deg]"] = numpy.fabs(self.left_line.phi * 180 / numpy.pi)
Note: See TracChangeset
for help on using the changeset viewer.