Changeset 0cc77d8 in sasview for src/sas/sascalc/dataloader
- Timestamp:
- May 1, 2017 3: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 15:00:53)
- git-committer:
- GitHub <noreply@…> (05/01/17 15:00:53)
- Location:
- src/sas/sascalc/dataloader
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
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/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
Note: See TracChangeset
for help on using the changeset viewer.