Changeset 0cc77d8 in sasview for src/sas/sascalc
- Timestamp:
- May 1, 2017 5:00:53 PM (8 years ago)
- Children:
- 733cdcd
- Parents:
- b9d74f3 (diff), c00a797a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Paul Kienzle <pkienzle@…> (05/01/17 17:00:53)
- git-committer:
- GitHub <noreply@…> (05/01/17 17:00:53)
- Location:
- src/sas/sascalc
- Files:
-
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/calculator/sas_gen.py
rb9d74f3 r0cc77d8 3 3 SAS generic computation and sld file readers 4 4 """ 5 from __future__ import print_function 6 5 7 import sas.sascalc.calculator.core.sld2i as mod 6 8 from sas.sascalc.calculator.BaseComponent import BaseComponent … … 558 560 vol_pix = np.append(vol_pix, vol) 559 561 except: 560 print "Error: set the sld of %s to zero"% atom_name562 print("Error: set the sld of %s to zero"% atom_name) 561 563 sld_n = np.append(sld_n, 0.0) 562 564 sld_mx = np.append(sld_mx, 0) … … 609 611 Write 610 612 """ 611 print "Not implemented... "613 print("Not implemented... ") 612 614 613 615 class SLDReader(object): … … 1044 1046 from mpl_toolkits.mplot3d import Axes3D 1045 1047 current_dir = os.path.abspath(os.path.curdir) 1046 print current_dir1048 print(current_dir) 1047 1049 for i in range(6): 1048 1050 current_dir, _ = os.path.split(current_dir) -
src/sas/sascalc/data_util/calcthread.py
r7432acb ra1b8fee 4 4 # \brief Abstract class for defining calculation threads. 5 5 # 6 from __future__ import print_function 6 7 7 8 import thread … … 295 296 """ 296 297 def __init__(self, n=20000): 297 print thread.get_ident()298 print(thread.get_ident()) 298 299 self.starttime = clock() 299 300 self.done = False … … 307 308 self.work2.queue(n) 308 309 self.work3.queue(n) 309 print "Expect updates from Main every second and from thread every 2.5 seconds"310 print ""310 print("Expect updates from Main every second and from thread every 2.5 seconds") 311 print("") 311 312 self.work.ready(.5) 312 313 while not self.done: 313 314 sleep(1) 314 print 315 clock() - self.starttime) 315 print("Main thread %d at %.2f" % (thread.get_ident(), 316 clock() - self.starttime)) 316 317 317 318 def update(self, i=0): 318 print 319 clock() - self.starttime) 319 print("Update i=%d from thread %d at %.2f" % (i, thread.get_ident(), 320 clock() - self.starttime)) 320 321 self.work.ready(2.5) 321 322 322 323 def complete(self, total=0.0): 323 print 324 print("Complete total=%g from thread %d at %.2f" % (total, 324 325 thread.get_ident(), 325 clock() - self.starttime) 326 clock() - self.starttime)) 326 327 self.done = True -
src/sas/sascalc/data_util/formatnum.py
r9a5097c ra1b8fee 37 37 formatter.compact flag. 38 38 """ 39 from __future__ import division 39 from __future__ import division, print_function 40 40 41 41 import math -
src/sas/sascalc/data_util/registry.py
rb9d74f3 r0cc77d8 6 6 and registers the built-in file extensions. 7 7 """ 8 from __future__ import print_function 8 9 9 10 import os.path -
src/sas/sascalc/dataloader/data_info.py
rb9d74f3 r0cc77d8 16 16 ###################################################################### 17 17 18 from __future__ import print_function 18 19 19 20 #TODO: Keep track of data manipulation in the 'process' data structure. -
src/sas/sascalc/dataloader/readers/IgorReader.py
r959eb01 ra1b8fee 12 12 #copyright 2008, University of Tennessee 13 13 ############################################################################# 14 from __future__ import print_function 15 14 16 import os 15 17 -
src/sas/sascalc/dataloader/readers/associations.py
r959eb01 ra1b8fee 14 14 #copyright 2009, University of Tennessee 15 15 ############################################################################# 16 from __future__ import print_function 17 16 18 import os 17 19 import sys … … 71 73 logger.error(msg) 72 74 else: 73 print "Could not find reader association settings\n %s [%s]" % (__file__, os.getcwd())75 print("Could not find reader association settings\n %s [%s]" % (__file__, os.getcwd())) 74 76 75 77 -
src/sas/sascalc/dataloader/readers/red2d_reader.py
rb9d74f3 r0cc77d8 9 9 #copyright 2008, University of Tennessee 10 10 ###################################################################### 11 from __future__ import print_function 12 11 13 import os 12 14 import numpy as np … … 81 83 detector = Detector() 82 84 if len(output.detector) > 0: 83 print str(output.detector[0])85 print(str(output.detector[0])) 84 86 output.detector.append(detector) 85 87 -
src/sas/sascalc/fit/AbstractFitEngine.py
rb9d74f3 r0cc77d8 1 from __future__ import print_function 1 2 2 3 import copy … … 627 628 """ 628 629 """ 629 print str(self)630 print(str(self)) -
src/sas/sascalc/fit/Loader.py
rb9d74f3 r0cc77d8 1 from __future__ import print_function 2 1 3 # class Loader to load any king of file 2 4 #import wx … … 54 56 self.dx = np.zeros(len(self.x)) 55 57 except: 56 print "READ ERROR", line58 print("READ ERROR", line) 57 59 # Sanity check 58 60 if not len(self.x) == len(self.dx): … … 80 82 load = Load() 81 83 load.set_filename("testdata_line.txt") 82 print load.get_filename()84 print(load.get_filename()) 83 85 load.set_values() 84 print load.get_values()86 print(load.get_values()) 85 87 86 88 -
src/sas/sascalc/fit/expression.py
rb9d74f3 r0cc77d8 43 43 Ideally, this interface will change 44 44 """ 45 from __future__ import print_function 46 45 47 import math 46 48 import re -
src/sas/sascalc/pr/fit/AbstractFitEngine.py
rb9d74f3 r0cc77d8 1 from __future__ import print_function 1 2 2 3 import copy … … 630 631 """ 631 632 """ 632 print str(self)633 print(str(self)) -
src/sas/sascalc/pr/fit/Loader.py
rb9d74f3 r0cc77d8 1 from __future__ import print_function 2 1 3 # class Loader to load any king of file 2 4 #import wx … … 54 56 self.dx = np.zeros(len(self.x)) 55 57 except: 56 print "READ ERROR", line58 print("READ ERROR", line) 57 59 # Sanity check 58 60 if not len(self.x) == len(self.dx): … … 80 82 load = Load() 81 83 load.set_filename("testdata_line.txt") 82 print load.get_filename()84 print(load.get_filename()) 83 85 load.set_values() 84 print load.get_values()86 print(load.get_values()) 85 87 86 88 -
src/sas/sascalc/pr/fit/expression.py
rb9d74f3 r0cc77d8 1 from __future__ import print_function 2 1 3 # This program is public domain 2 4 """ -
src/sas/sascalc/pr/num_term.py
r7432acb ra1b8fee 1 from __future__ import print_function 2 1 3 import math 2 4 import numpy as np … … 197 199 # Testing estimator 198 200 est = NTermEstimator(invert) 199 print est.num_terms()201 print(est.num_terms()) -
src/sas/sascalc/simulation/analmodelpy/tests/signon.py
rd85c194 r9c3d784 17 17 from analmodelpy import analmodelpy as analmodelpymodule 18 18 19 print "copyright information:"20 print " ", analmodelpy.copyright()21 print " ", analmodelpymodule.copyright()19 print("copyright information:") 20 print(" ", analmodelpy.copyright()) 21 print(" ", analmodelpymodule.copyright()) 22 22 23 print 24 print "module information:"25 print " file:", analmodelpymodule.__file__26 print " doc:", analmodelpymodule.__doc__27 print " contents:", dir(analmodelpymodule)23 print() 24 print("module information:") 25 print(" file:", analmodelpymodule.__file__) 26 print(" doc:", analmodelpymodule.__doc__) 27 print(" contents:", dir(analmodelpymodule)) 28 28 29 print 30 print analmodelpymodule.hello()29 print() 30 print(analmodelpymodule.hello()) 31 31 32 32 # version -
src/sas/sascalc/simulation/analmodelpy/tests/testanal_model.py
rd85c194 ra1b8fee 11 11 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12 12 # 13 from __future__ import print_function 14 13 15 14 16 if __name__ == "__main__": … … 18 20 from SASsimulation import geoshapespy 19 21 20 print "copyright information:"21 print " ", analmodelpymodule.copyright()22 print("copyright information:") 23 print(" ", analmodelpymodule.copyright()) 22 24 23 print 24 print "module information:"25 print " file:", analmodelpymodule.__file__26 print " doc:", analmodelpymodule.__doc__27 print " contents:", dir(analmodelpymodule)25 print() 26 print("module information:") 27 print(" file:", analmodelpymodule.__file__) 28 print(" doc:", analmodelpymodule.__doc__) 29 print(" contents:", dir(analmodelpymodule)) 28 30 29 31 a = geoshapespy.new_sphere(1.0) -
src/sas/sascalc/simulation/geoshapespy/tests/testshapes.py
rd85c194 ra1b8fee 11 11 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12 12 # 13 from __future__ import print_function 14 13 15 14 16 if __name__ == "__main__": … … 16 18 from SASsimulation import geoshapespy 17 19 18 print 19 print "module information:"20 print " file:", geoshapespy.__file__21 print " doc:", geoshapespy.__doc__22 print " contents:", dir(geoshapespy)20 print() 21 print("module information:") 22 print(" file:", geoshapespy.__file__) 23 print(" doc:", geoshapespy.__doc__) 24 print(" contents:", dir(geoshapespy)) 23 25 24 26 sp = geoshapespy.new_sphere(10) -
src/sas/sascalc/simulation/iqPy/tests/signon.py
rd85c194 ra1b8fee 11 11 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12 12 # 13 from __future__ import print_function 14 13 15 14 16 if __name__ == "__main__": … … 17 19 from iqPy import iqPy as iqPymodule 18 20 19 print "copyright information:"20 print " ", iqPy.copyright()21 print " ", iqPymodule.copyright()21 print("copyright information:") 22 print(" ", iqPy.copyright()) 23 print(" ", iqPymodule.copyright()) 22 24 23 print 24 print "module information:"25 print " file:", iqPymodule.__file__26 print " doc:", iqPymodule.__doc__27 print " contents:", dir(iqPymodule)25 print() 26 print("module information:") 27 print(" file:", iqPymodule.__file__) 28 print(" doc:", iqPymodule.__doc__) 29 print(" contents:", dir(iqPymodule)) 28 30 29 print 31 print() 30 32 31 33 # version -
src/sas/sascalc/simulation/iqPy/tests/testiq.py
rd85c194 r9c3d784 17 17 iqPy.new_iq(10,0.01,0.4) 18 18 19 print "pass."19 print("pass.") 20 20 21 21 # version -
src/sas/sascalc/simulation/pointsmodelpy/tests/signon.py
rd85c194 ra1b8fee 11 11 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 12 12 # 13 from __future__ import print_function 14 13 15 14 16 if __name__ == "__main__": … … 17 19 from pointsmodelpy import pointsmodelpy as pointsmodelpymodule 18 20 19 print "copyright information:"20 print " ", pointsmodelpy.copyright()21 print " ", pointsmodelpymodule.copyright()21 print("copyright information:") 22 print(" ", pointsmodelpy.copyright()) 23 print(" ", pointsmodelpymodule.copyright()) 22 24 23 print 24 print "module information:"25 print " file:", pointsmodelpymodule.__file__26 print " doc:", pointsmodelpymodule.__doc__27 print " contents:", dir(pointsmodelpymodule)25 print() 26 print("module information:") 27 print(" file:", pointsmodelpymodule.__file__) 28 print(" doc:", pointsmodelpymodule.__doc__) 29 print(" contents:", dir(pointsmodelpymodule)) 28 30 29 print 30 print pointsmodelpymodule.hello()31 print() 32 print(pointsmodelpymodule.hello()) 31 33 32 34 # version -
src/sas/sascalc/simulation/pointsmodelpy/tests/test2dui.py
r959eb01 ra1b8fee 7 7 # Imports: 8 8 #-------------------------------------------------------------------------------- 9 from __future__ import print_function 9 10 10 11 import wx … … 46 47 47 48 data = ImageData(value_grid, index_vals) 48 print value_grid, index_vals49 print(value_grid, index_vals) 49 50 50 51 # Create the index axes -
src/sas/sascalc/simulation/pointsmodelpy/tests/testcomplexmodel.py
r959eb01 ra1b8fee 1 from __future__ import print_function 2 1 3 from sasModeling.pointsmodelpy import pointsmodelpy 2 4 from sasModeling.iqPy import iqPy 3 5 from sasModeling.geoshapespy import geoshapespy 6 4 7 5 8 #First testing: a normal case, a lores model holds a sphere … … 61 64 iqPy.OutputIQ(iqcomplex,"testcomplex2.iq") 62 65 63 print "p(r) is saved in testcomplex2.pr"64 print "I(Q) is saved in testcomplex2.iq"65 print "pass"66 print("p(r) is saved in testcomplex2.pr") 67 print("I(Q) is saved in testcomplex2.iq") 68 print("pass") 66 69 67 70 #testing 3, insert one empty pdbmodel and one loresmodel … … 88 91 iqPy.OutputIQ(iqcomplex,"testcomplex3.iq") 89 92 90 print "p(r) is saved in testcomplex3.pr"91 print "I(Q) is saved in testcomplex3.iq"92 print "pass"93 print("p(r) is saved in testcomplex3.pr") 94 print("I(Q) is saved in testcomplex3.iq") 95 print("pass") 93 96 94 97 # Test 2D complex model … … 106 109 pointsmodelpy.get_complexpoints(complex,vpcomplex); 107 110 108 print pointsmodelpy.get_complex_iq_2D(complex,vpcomplex,0.1,0.1);109 print pointsmodelpy.get_complex_iq_2D(complex,vpcomplex,0.01,0.1);111 print(pointsmodelpy.get_complex_iq_2D(complex,vpcomplex,0.1,0.1)); 112 print(pointsmodelpy.get_complex_iq_2D(complex,vpcomplex,0.01,0.1)); 110 113 111 114 -
src/sas/sascalc/simulation/pointsmodelpy/tests/testlores.py
r959eb01 ra1b8fee 1 from __future__ import print_function 2 3 1 4 if __name__ == "__main__": 2 5 … … 10 13 # print " ", pointsmodelpymodule.copyright() 11 14 12 print 13 print "module information:"14 print " file:", pointsmodelpy.__file__15 print " doc:", pointsmodelpy.__doc__16 print " contents:", dir(pointsmodelpy)17 print " contents:", dir(geoshapespy)15 print() 16 print("module information:") 17 print(" file:", pointsmodelpy.__file__) 18 print(" doc:", pointsmodelpy.__doc__) 19 print(" contents:", dir(pointsmodelpy)) 20 print(" contents:", dir(geoshapespy)) 18 21 19 22 # a = geoshapespy.new_singlehelix(10,2,30,2) … … 46 49 pointsmodelpy.outputPDB(lm,vp,"modelpy.pseudo.pdb") 47 50 48 print "calculating distance distribution"51 print("calculating distance distribution") 49 52 rmax = pointsmodelpy.get_lores_pr(lm,vp) 50 print "finish calculating get_lores_pr, and rmax is:", rmax53 print("finish calculating get_lores_pr, and rmax is:", rmax) 51 54 pointsmodelpy.outputPR(lm,"testlores.pr") 52 55 pointsmodelpy.get_lores_iq(lm,iq) … … 54 57 iqPy.OutputIQ(iq, "testlores.iq") 55 58 56 print "Testing get I from a single q"59 print("Testing get I from a single q") 57 60 result = pointsmodelpy.get_lores_i(lm,0.1) 58 print "The I(0.1) is: %s" % str(result)61 print("The I(0.1) is: %s" % str(result)) 59 62 60 63 # version -
src/sas/sascalc/simulation/pointsmodelpy/tests/testlores2d.py
r959eb01 ra1b8fee 1 from __future__ import print_function 2 3 1 4 def test_lores2d(phi): 2 5 from sasModeling.pointsmodelpy import pointsmodelpy … … 45 48 value_grid = zeros((100,100),Float) 46 49 width, height = value_grid.shape 47 print width,height50 print(width,height) 48 51 49 52 I = pointsmodelpy.calculateI_Qxy(lm,0.00001,0.000002) 50 print I53 print(I) 51 54 52 55 Imax = 0 … … 86 89 value_grid = zeros((100,100),Float) 87 90 width, height = value_grid.shape 88 print width,height91 print(width,height) 89 92 90 93 I = pointsmodelpy.calculateI_Qxy(lm,0.00001,0.000002) 91 print I94 print(I) 92 95 93 96 Imax = 0 … … 109 112 if __name__ == "__main__": 110 113 111 print "start to test lores 2D"114 print("start to test lores 2D") 112 115 # test_lores2d(10) 113 116 value_grid = get2d_2() 114 print value_grid115 print "pass"117 print(value_grid) 118 print("pass") -
src/sas/sascalc/calculator/BaseComponent.py
r9a5097c rb9d74f3 143 143 qdist[1].__class__.__name__ != 'ndarray': 144 144 msg = "evalDistribution expects a list of 2 ndarrays" 145 raise RuntimeError , msg145 raise RuntimeError(msg) 146 146 147 147 # Extract qx and qy for code clarity … … 167 167 mesg = "evalDistribution is expecting an ndarray of scalar q-values" 168 168 mesg += " or a list [qx,qy] where qx,qy are 2D ndarrays." 169 raise RuntimeError , mesg169 raise RuntimeError(mesg) 170 170 171 171 … … 228 228 return 229 229 230 raise ValueError , "Model does not contain parameter %s" % name230 raise ValueError("Model does not contain parameter %s" % name) 231 231 232 232 def getParam(self, name): … … 250 250 return self.params[item] 251 251 252 raise ValueError , "Model does not contain parameter %s" % name252 raise ValueError("Model does not contain parameter %s" % name) 253 253 254 254 def getParamList(self): … … 294 294 add 295 295 """ 296 raise ValueError , "Model operation are no longer supported"296 raise ValueError("Model operation are no longer supported") 297 297 def __sub__(self, other): 298 298 """ 299 299 sub 300 300 """ 301 raise ValueError , "Model operation are no longer supported"301 raise ValueError("Model operation are no longer supported") 302 302 def __mul__(self, other): 303 303 """ 304 304 mul 305 305 """ 306 raise ValueError , "Model operation are no longer supported"306 raise ValueError("Model operation are no longer supported") 307 307 def __div__(self, other): 308 308 """ 309 309 div 310 310 """ 311 raise ValueError , "Model operation are no longer supported"311 raise ValueError("Model operation are no longer supported") 312 312 313 313 -
src/sas/sascalc/calculator/instrument.py
r9a5097c rb9d74f3 324 324 plt.show() 325 325 except: 326 raise RuntimeError , "Can't import matplotlib required to plot..."326 raise RuntimeError("Can't import matplotlib required to plot...") 327 327 328 328 -
src/sas/sascalc/calculator/resolution_calculator.py
r7432acb rb9d74f3 208 208 if wavelength == 0: 209 209 msg = "Can't compute the resolution: the wavelength is zero..." 210 raise RuntimeError , msg210 raise RuntimeError(msg) 211 211 return self.intensity 212 212 … … 503 503 # otherwise 504 504 else: 505 raise ValueError , " Improper input..."505 raise ValueError(" Improper input...") 506 506 # get them squared 507 507 sigma = x_comp * x_comp … … 766 766 """ 767 767 if len(size) < 1 or len(size) > 2: 768 raise RuntimeError , "The length of the size must be one or two."768 raise RuntimeError("The length of the size must be one or two.") 769 769 self.aperture.set_source_size(size) 770 770 … … 783 783 """ 784 784 if len(size) < 1 or len(size) > 2: 785 raise RuntimeError , "The length of the size must be one or two."785 raise RuntimeError("The length of the size must be one or two.") 786 786 self.aperture.set_sample_size(size) 787 787 … … 806 806 """ 807 807 if len(distance) < 1 or len(distance) > 2: 808 raise RuntimeError , "The length of the size must be one or two."808 raise RuntimeError("The length of the size must be one or two.") 809 809 self.aperture.set_sample_distance(distance) 810 810 … … 816 816 """ 817 817 if len(distance) < 1 or len(distance) > 2: 818 raise RuntimeError , "The length of the size must be one or two."818 raise RuntimeError("The length of the size must be one or two.") 819 819 self.sample.set_distance(distance) 820 820 … … 826 826 """ 827 827 if len(distance) < 1 or len(distance) > 2: 828 raise RuntimeError , "The length of the size must be one or two."828 raise RuntimeError("The length of the size must be one or two.") 829 829 self.detector.set_distance(distance) 830 830 … … 998 998 pix_y_size = detector_pix_size[1] 999 999 else: 1000 raise ValueError , " Input value format error..."1000 raise ValueError(" Input value format error...") 1001 1001 # Sample to detector distance = sample slit to detector 1002 1002 # minus sample offset -
src/sas/sascalc/corfunc/corfunc_calculator.py
rff11b21 rb9d74f3 80 80 # Only process data of the class Data1D 81 81 if not issubclass(data.__class__, Data1D): 82 raise ValueError , "Data must be of the type DataLoader.Data1D"82 raise ValueError("Data must be of the type DataLoader.Data1D") 83 83 84 84 # Prepare the data … … 151 151 err = ("Incorrect transform type supplied, must be 'fourier'", 152 152 " or 'hilbert'") 153 raise ValueError , err153 raise ValueError(err) 154 154 155 155 self._transform_thread.queue() -
src/sas/sascalc/data_util/nxsunit.py
rb699768 rb9d74f3 189 189 190 190 def _check(expect,get): 191 if expect != get: raise ValueError , "Expected %s but got %s"%(expect,get)191 if expect != get: raise ValueError("Expected %s but got %s"%(expect,get)) 192 192 #print expect,"==",get 193 193 -
src/sas/sascalc/data_util/odict.py
rb699768 rb9d74f3 612 612 """ 613 613 if len(args) > 1: 614 raise TypeError ,('pop expected at most 2 arguments, got %s' %614 raise TypeError('pop expected at most 2 arguments, got %s' % 615 615 (len(args) + 1)) 616 616 if key in self: -
src/sas/sascalc/dataloader/loader.py
r463e7ffc rb9d74f3 295 295 # Raise an error if there are no matching extensions 296 296 if len(writers) == 0: 297 raise ValueError , "Unknown file type for " + path297 raise ValueError("Unknown file type for " + path) 298 298 # All done 299 299 return writers -
src/sas/sascalc/dataloader/manipulations.py
r7432acb rb9d74f3 81 81 """ 82 82 if data2d.data is None or data2d.x_bins is None or data2d.y_bins is None: 83 raise ValueError , "Can't convert this data: data=None..."83 raise ValueError("Can't convert this data: data=None...") 84 84 new_x = numpy.tile(data2d.x_bins, (len(data2d.y_bins), 1)) 85 85 new_y = numpy.tile(data2d.y_bins, (len(data2d.x_bins), 1)) … … 146 146 msg = "_Slab._avg: invalid number of " 147 147 msg += " detectors: %g" % len(data2D.detector) 148 raise RuntimeError , msg148 raise RuntimeError(msg) 149 149 150 150 # Get data … … 168 168 nbins = int(math.ceil((self.y_max - y_min) / self.bin_width)) 169 169 else: 170 raise RuntimeError , "_Slab._avg: unrecognized axis %s" % str(maj)170 raise RuntimeError("_Slab._avg: unrecognized axis %s" % str(maj)) 171 171 172 172 x = numpy.zeros(nbins) … … 229 229 if not idx.any(): 230 230 msg = "Average Error: No points inside ROI to average..." 231 raise ValueError , msg231 raise ValueError(msg) 232 232 return Data1D(x=x[idx], y=y[idx], dy=err_y[idx]) 233 233 … … 302 302 msg = "Circular averaging: invalid number " 303 303 msg += "of detectors: %g" % len(data2D.detector) 304 raise RuntimeError , msg304 raise RuntimeError(msg) 305 305 # Get data 306 306 data = data2D.data[numpy.isfinite(data2D.data)] … … 464 464 if len(data2D.q_data) is None: 465 465 msg = "Circular averaging: invalid q_data: %g" % data2D.q_data 466 raise RuntimeError , msg466 raise RuntimeError(msg) 467 467 468 468 # Build array of Q intervals … … 488 488 ## No need to calculate the frac when all data are within range 489 489 if self.r_min >= self.r_max: 490 raise ValueError , "Limit Error: min > max"490 raise ValueError("Limit Error: min > max") 491 491 492 492 if self.r_min <= q_value and q_value <= self.r_max: … … 539 539 if not idx.any(): 540 540 msg = "Average Error: No points inside ROI to average..." 541 raise ValueError , msg541 raise ValueError(msg) 542 542 543 543 return Data1D(x=x[idx], y=y[idx], dy=err_y[idx], dx=d_x) … … 580 580 """ 581 581 if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 582 raise RuntimeError , "Ring averaging only take plottable_2D objects"582 raise RuntimeError("Ring averaging only take plottable_2D objects") 583 583 584 584 Pi = math.pi … … 640 640 if not idx.any(): 641 641 msg = "Average Error: No points inside ROI to average..." 642 raise ValueError , msg642 raise ValueError(msg) 643 643 #elif len(phi_bins[idx])!= self.nbins_phi: 644 644 # print "resulted",self.nbins_phi- len(phi_bins[idx]) … … 765 765 """ 766 766 if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 767 raise RuntimeError , "Ring averaging only take plottable_2D objects"767 raise RuntimeError("Ring averaging only take plottable_2D objects") 768 768 Pi = math.pi 769 769 … … 931 931 if not idx.any(): 932 932 msg = "Average Error: No points inside sector of ROI to average..." 933 raise ValueError , msg933 raise ValueError(msg) 934 934 #elif len(y[idx])!= self.nbins: 935 935 # print "resulted",self.nbins- len(y[idx]), … … 1007 1007 """ 1008 1008 if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 1009 raise RuntimeError , "Ring cut only take plottable_2D objects"1009 raise RuntimeError("Ring cut only take plottable_2D objects") 1010 1010 1011 1011 # Get data … … 1055 1055 """ 1056 1056 if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 1057 raise RuntimeError , "Boxcut take only plottable_2D objects"1057 raise RuntimeError("Boxcut take only plottable_2D objects") 1058 1058 # Get qx_ and qy_data 1059 1059 qx_data = data2D.qx_data … … 1106 1106 """ 1107 1107 if data2D.__class__.__name__ not in ["Data2D", "plottable_2D"]: 1108 raise RuntimeError , "Sectorcut take only plottable_2D objects"1108 raise RuntimeError("Sectorcut take only plottable_2D objects") 1109 1109 Pi = math.pi 1110 1110 # Get data -
src/sas/sascalc/dataloader/readers/abs_reader.py
r959eb01 rb9d74f3 50 50 input_f = open(path,'r') 51 51 except: 52 raise RuntimeError , "abs_reader: cannot open %s" % path52 raise RuntimeError("abs_reader: cannot open %s" % path) 53 53 buff = input_f.read() 54 54 lines = buff.split('\n') … … 99 99 #goes to ASC reader 100 100 msg = "abs_reader: cannot open %s" % path 101 raise RuntimeError , msg101 raise RuntimeError(msg) 102 102 103 103 # Distance in meters … … 114 114 #goes to ASC reader 115 115 msg = "abs_reader: cannot open %s" % path 116 raise RuntimeError , msg116 raise RuntimeError(msg) 117 117 # Transmission 118 118 try: … … 223 223 if not len(y) == len(dy): 224 224 msg = "abs_reader: y and dy have different length" 225 raise ValueError , msg225 raise ValueError(msg) 226 226 # If the data length is zero, consider this as 227 227 # though we were not able to read the file. 228 228 if len(x) == 0: 229 raise ValueError , "ascii_reader: could not load file"229 raise ValueError("ascii_reader: could not load file") 230 230 231 231 output.x = x[x != 0] … … 246 246 return output 247 247 else: 248 raise RuntimeError , "%s is not a file" % path248 raise RuntimeError("%s is not a file" % path) 249 249 return None -
src/sas/sascalc/dataloader/readers/ascii_reader.py
r235f514 rb9d74f3 64 64 input_f = open(path,'rb') 65 65 except: 66 raise RuntimeError , "ascii_reader: cannot open %s" % path66 raise RuntimeError("ascii_reader: cannot open %s" % path) 67 67 buff = input_f.read() 68 68 lines = buff.splitlines() … … 173 173 if not is_data: 174 174 msg = "ascii_reader: x has no data" 175 raise RuntimeError , msg175 raise RuntimeError(msg) 176 176 # Sanity check 177 177 if has_error_dy == True and not len(ty) == len(tdy): 178 178 msg = "ascii_reader: y and dy have different length" 179 raise RuntimeError , msg179 raise RuntimeError(msg) 180 180 if has_error_dx == True and not len(tx) == len(tdx): 181 181 msg = "ascii_reader: y and dy have different length" 182 raise RuntimeError , msg182 raise RuntimeError(msg) 183 183 # If the data length is zero, consider this as 184 184 # though we were not able to read the file. 185 185 if len(tx) == 0: 186 raise RuntimeError , "ascii_reader: could not load file"186 raise RuntimeError("ascii_reader: could not load file") 187 187 188 188 #Let's re-order the data to make cal. … … 222 222 output.meta_data['loader'] = self.type_name 223 223 if len(output.x) < 1: 224 raise RuntimeError , "%s is empty" % path224 raise RuntimeError("%s is empty" % path) 225 225 return output 226 226 227 227 else: 228 raise RuntimeError , "%s is not a file" % path228 raise RuntimeError("%s is not a file" % path) 229 229 return None 230 230 -
src/sas/sascalc/dataloader/readers/cansas_reader.py
r7432acb rb9d74f3 1479 1479 logger.info(err_mess) 1480 1480 else: 1481 raise ValueError , err_mess1481 raise ValueError(err_mess) 1482 1482 else: 1483 1483 err_mess = "CanSAS reader: unrecognized %s unit [%s];"\ … … 1488 1488 logger.info(err_mess) 1489 1489 else: 1490 raise ValueError , err_mess1490 raise ValueError(err_mess) 1491 1491 else: 1492 1492 exec "storage.%s = value" % variable -
src/sas/sascalc/dataloader/readers/danse_reader.py
r235f514 rb9d74f3 56 56 datafile = open(filename, 'r') 57 57 except: 58 raise RuntimeError ,"danse_reader cannot open %s" % (filename)58 raise RuntimeError("danse_reader cannot open %s" % (filename)) 59 59 60 60 # defaults … … 271 271 if not fversion >= 1.0: 272 272 msg = "Danse_reader can't read this file %s" % filename 273 raise ValueError , msg273 raise ValueError(msg) 274 274 else: 275 275 logger.info("Danse_reader Reading %s \n" % filename) -
src/sas/sascalc/dataloader/readers/hfir1d_reader.py
r959eb01 rb9d74f3 49 49 input_f = open(path,'r') 50 50 except: 51 raise RuntimeError , "hfir1d_reader: cannot open %s" % path51 raise RuntimeError("hfir1d_reader: cannot open %s" % path) 52 52 buff = input_f.read() 53 53 lines = buff.split('\n') … … 99 99 if not len(y) == len(dy): 100 100 msg = "hfir1d_reader: y and dy have different length" 101 raise RuntimeError , msg101 raise RuntimeError(msg) 102 102 if not len(x) == len(dx): 103 103 msg = "hfir1d_reader: x and dx have different length" 104 raise RuntimeError , msg104 raise RuntimeError(msg) 105 105 106 106 # If the data length is zero, consider this as 107 107 # though we were not able to read the file. 108 108 if len(x) == 0: 109 raise RuntimeError , "hfir1d_reader: could not load file"109 raise RuntimeError("hfir1d_reader: could not load file") 110 110 111 111 output.x = x … … 126 126 return output 127 127 else: 128 raise RuntimeError , "%s is not a file" % path128 raise RuntimeError("%s is not a file" % path) 129 129 return None -
src/sas/sascalc/dataloader/readers/nexus_reader.py
r959eb01 rb9d74f3 35 35 msg = "Error reading Nexus file: Nexus package is missing.\n" 36 36 msg += " Get it from http://http://www.nexusformat.org/" 37 raise RuntimeError , msg37 raise RuntimeError(msg) 38 38 39 39 # Instantiate data object -
src/sas/sascalc/dataloader/readers/sesans_reader.py
r9a5097c rb9d74f3 57 57 input_f = open(path,'rb') 58 58 except: 59 raise RuntimeError , "sesans_reader: cannot open %s" % path59 raise RuntimeError("sesans_reader: cannot open %s" % path) 60 60 buff = input_f.read() 61 61 lines = buff.splitlines() … … 158 158 159 159 if len(output.x) < 1: 160 raise RuntimeError , "%s is empty" % path160 raise RuntimeError("%s is empty" % path) 161 161 return output 162 162 163 163 else: 164 raise RuntimeError , "%s is not a file" % path164 raise RuntimeError("%s is not a file" % path) 165 165 return None 166 166 -
src/sas/sascalc/dataloader/readers/tiff_reader.py
r959eb01 rb9d74f3 44 44 except: 45 45 msg = "tiff_reader: could not load file. Missing Image module." 46 raise RuntimeError , msg46 raise RuntimeError(msg) 47 47 48 48 # Instantiate data object … … 54 54 im = Image.open(filename) 55 55 except: 56 raise RuntimeError , "cannot open %s"%(filename)56 raise RuntimeError("cannot open %s"%(filename)) 57 57 data = im.getdata() 58 58 -
src/sas/sascalc/file_converter/cansas_writer.py
r7432acb rb9d74f3 32 32 valid_class = all([issubclass(data.__class__, Data1D) for data in frame_data]) 33 33 if not valid_class: 34 raise RuntimeError ,("The cansas writer expects an array of "34 raise RuntimeError("The cansas writer expects an array of " 35 35 "Data1D instances") 36 36 -
src/sas/sascalc/fit/MultiplicationModel.py
r7432acb rb9d74f3 245 245 return 246 246 247 raise ValueError , "Model does not contain parameter %s" % name247 raise ValueError("Model does not contain parameter %s" % name) 248 248 249 249 -
src/sas/sascalc/fit/pluginmodel.py
r5213d22 rb9d74f3 35 35 return self.function(x_val)*self.function(y_val) 36 36 elif x.__class__.__name__ == 'tuple': 37 raise ValueError , "Tuples are not allowed as input to BaseComponent models"37 raise ValueError("Tuples are not allowed as input to BaseComponent models") 38 38 else: 39 39 return self.function(x) … … 52 52 return self.function(x[0])*self.function(x[1]) 53 53 elif x.__class__.__name__ == 'tuple': 54 raise ValueError , "Tuples are not allowed as input to BaseComponent models"54 raise ValueError("Tuples are not allowed as input to BaseComponent models") 55 55 else: 56 56 return self.function(x) -
src/sas/sascalc/invariant/invariant.py
r7432acb rb9d74f3 424 424 if not issubclass(data.__class__, LoaderData1D): 425 425 #Process only data that inherited from DataLoader.Data_info.Data1D 426 raise ValueError , "Data must be of type DataLoader.Data1D"426 raise ValueError("Data must be of type DataLoader.Data1D") 427 427 #from copy import deepcopy 428 428 new_data = (self._scale * data) - self._background … … 484 484 msg = "Length x and y must be equal" 485 485 msg += " and greater than 1; got x=%s, y=%s" % (len(data.x), len(data.y)) 486 raise ValueError , msg486 raise ValueError(msg) 487 487 else: 488 488 # Take care of smeared data … … 533 533 msg = "Length of data.x and data.y must be equal" 534 534 msg += " and greater than 1; got x=%s, y=%s" % (len(data.x), len(data.y)) 535 raise ValueError , msg535 raise ValueError(msg) 536 536 else: 537 537 #Create error for data without dy error … … 742 742 range = range.lower() 743 743 if range not in ['high', 'low']: 744 raise ValueError , "Extrapolation range should be 'high' or 'low'"744 raise ValueError("Extrapolation range should be 'high' or 'low'") 745 745 function = function.lower() 746 746 if function not in ['power_law', 'guinier']: 747 747 msg = "Extrapolation function should be 'guinier' or 'power_law'" 748 raise ValueError , msg748 raise ValueError(msg) 749 749 750 750 if range == 'high': 751 751 if function != 'power_law': 752 752 msg = "Extrapolation only allows a power law at high Q" 753 raise ValueError , msg753 raise ValueError(msg) 754 754 self._high_extrapolation_npts = npts 755 755 self._high_extrapolation_power = power … … 852 852 """ 853 853 if contrast <= 0: 854 raise ValueError , "The contrast parameter must be greater than zero"854 raise ValueError("The contrast parameter must be greater than zero") 855 855 856 856 # Make sure Q star is up to date … … 859 859 if self._qstar <= 0: 860 860 msg = "Invalid invariant: Invariant Q* must be greater than zero" 861 raise RuntimeError , msg861 raise RuntimeError(msg) 862 862 863 863 # Compute intermediate constant … … 869 869 if discrim < 0: 870 870 msg = "Could not compute the volume fraction: negative discriminant" 871 raise RuntimeError , msg871 raise RuntimeError(msg) 872 872 elif discrim == 0: 873 873 return 1 / 2 … … 881 881 return volume2 882 882 msg = "Could not compute the volume fraction: inconsistent results" 883 raise RuntimeError , msg883 raise RuntimeError(msg) 884 884 885 885 def get_qstar_with_error(self, extrapolation=None): -
src/sas/sascalc/pr/invertor.py
r45dffa69 rb9d74f3 148 148 msg = "Invertor: one of your q-values is zero. " 149 149 msg += "Delete that entry before proceeding" 150 raise ValueError , msg150 raise ValueError(msg) 151 151 return self.set_x(value) 152 152 elif name == 'y': … … 159 159 msg = "Invertor: d_max must be greater than zero." 160 160 msg += "Correct that entry before proceeding" 161 raise ValueError , msg161 raise ValueError(msg) 162 162 return self.set_dmax(value) 163 163 elif name == 'q_min': … … 181 181 return self.set_has_bck(0) 182 182 else: 183 raise ValueError , "Invertor: has_bck can only be True or False"183 raise ValueError("Invertor: has_bck can only be True or False") 184 184 185 185 return Cinvertor.__setattr__(self, name, value) … … 325 325 if self.is_valid() <= 0: 326 326 msg = "Invertor.invert: Data array are of different length" 327 raise RuntimeError , msg327 raise RuntimeError(msg) 328 328 329 329 p = np.ones(nfunc) … … 358 358 if self.is_valid() <= 0: 359 359 msg = "Invertor.invert: Data arrays are of different length" 360 raise RuntimeError , msg360 raise RuntimeError(msg) 361 361 362 362 p = np.ones(nfunc) … … 442 442 if self.is_valid() < 0: 443 443 msg = "Invertor: invalid data; incompatible data lengths." 444 raise RuntimeError , msg444 raise RuntimeError(msg) 445 445 446 446 self.nfunc = nfunc … … 467 467 self._get_matrix(nfunc, nq, a, b) 468 468 except: 469 raise RuntimeError , "Invertor: could not invert I(Q)\n %s" % sys.exc_value469 raise RuntimeError("Invertor: could not invert I(Q)\n %s" % sys.exc_value) 470 470 471 471 # Perform the inversion (least square fit) … … 751 751 except: 752 752 msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_value 753 raise RuntimeError , msg753 raise RuntimeError(msg) 754 754 else: 755 755 msg = "Invertor.from_file: '%s' is not a file" % str(path) 756 raise RuntimeError , msg756 raise RuntimeError(msg)
Note: See TracChangeset
for help on using the changeset viewer.