Changeset e090ba90 in sasview for src/sas/sascalc/dataloader
- Timestamp:
- Oct 11, 2018 1:59:57 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1249
- Children:
- 88d2e70
- Parents:
- 67ed543
- Location:
- src/sas/sascalc/dataloader
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/data_info.py
r9e6aeaf re090ba90 26 26 import numpy as np 27 27 import math 28 from math import fabs 28 29 29 30 class plottable_1D(object): … … 656 657 return self._perform_operation(other, operation) 657 658 658 def __ div__(self, other):659 def __truediv__(self, other): 659 660 """ 660 661 Divided a data set by another … … 667 668 return a/b 668 669 return self._perform_operation(other, operation) 669 670 def __rdiv__(self, other): 670 __div__ = __truediv__ 671 672 def __rtruediv__(self, other): 671 673 """ 672 674 Divided a data set by another … … 679 681 return b/a 680 682 return self._perform_operation(other, operation) 683 __rdiv__ = __rtruediv__ 681 684 682 685 def __or__(self, other): … … 800 803 TOLERANCE = 0.01 801 804 for i in range(len(self.x)): 802 if math.fabs((self.x[i] - other.x[i])/self.x[i]) >TOLERANCE:805 if fabs(self.x[i] - other.x[i]) > self.x[i]*TOLERANCE: 803 806 msg = "Incompatible data sets: x-values do not match" 804 807 raise ValueError(msg) … … 1022 1025 raise ValueError(msg) 1023 1026 for ind in range(len(self.data)): 1024 if math.fabs((self.qx_data[ind] - other.qx_data[ind])/self.qx_data[ind]) >TOLERANCE:1027 if fabs(self.qx_data[ind] - other.qx_data[ind]) > fabs(self.qx_data[ind])*TOLERANCE: 1025 1028 msg = "Incompatible data sets: qx-values do not match: %s %s" % (self.qx_data[ind], other.qx_data[ind]) 1026 1029 raise ValueError(msg) 1027 if math.fabs((self.qy_data[ind] - other.qy_data[ind])/self.qy_data[ind]) >TOLERANCE:1030 if fabs(self.qy_data[ind] - other.qy_data[ind]) > fabs(self.qy_data[ind])*TOLERANCE: 1028 1031 msg = "Incompatible data sets: qy-values do not match: %s %s" % (self.qy_data[ind], other.qy_data[ind]) 1029 1032 raise ValueError(msg) -
src/sas/sascalc/dataloader/loader.py
r4a8d55c re090ba90 169 169 if self._identify_plugin(module): 170 170 readers_found += 1 171 except :171 except Exception as exc: 172 172 msg = "Loader: Error importing " 173 msg += "%s\n %s" % (item, sys.exc_value)173 msg += "%s\n %s" % (item, exc) 174 174 logger.error(msg) 175 175 … … 191 191 if self._identify_plugin(module): 192 192 readers_found += 1 193 except :193 except Exception as exc: 194 194 msg = "Loader: Error importing" 195 msg += " %s\n %s" % (mfile, sys.exc_value)195 msg += " %s\n %s" % (mfile, exc) 196 196 logger.error(msg) 197 197 198 except :198 except Exception as exc: 199 199 msg = "Loader: Error importing " 200 msg += " %s\n %s" % (item, sys.exc_value)200 msg += " %s\n %s" % (item, exc) 201 201 logger.error(msg) 202 202 … … 242 242 self.writers[ext].append(loader.write) 243 243 244 except :244 except Exception as exc: 245 245 msg = "Loader: Error accessing" 246 msg += " Reader in %s\n %s" % (module.__name__, sys.exc_value)246 msg += " Reader in %s\n %s" % (module.__name__, exc) 247 247 logger.error(msg) 248 248 return reader_found … … 275 275 self.wildcards.append(wcard) 276 276 277 except :277 except Exception as exc: 278 278 msg = "Loader: Error accessing Reader " 279 msg += "in %s\n %s" % (loader.__name__, sys.exc_value)279 msg += "in %s\n %s" % (loader.__name__, exc) 280 280 logger.error(msg) 281 281 return reader_found … … 320 320 self.writers[ext].insert(0, loader.write) 321 321 322 except :322 except Exception as exc: 323 323 msg = "Loader: Error accessing Reader" 324 msg += " in %s\n %s" % (module.__name__, sys.exc_value)324 msg += " in %s\n %s" % (module.__name__, exc) 325 325 logger.error(msg) 326 326 return reader_found -
src/sas/sascalc/dataloader/manipulations.py
r574adc7 re090ba90 928 928 929 929 # Organize the results 930 for i in range(self.nbins): 931 y[i] = y[i] / y_counts[i] 932 y_err[i] = math.sqrt(y_err[i]) / y_counts[i] 933 930 with np.errstate(divide='ignore', invalid='ignore'): 931 y = y/y_counts 932 y_err = np.sqrt(y_err)/y_counts 934 933 # The type of averaging: phi,q2, or q 935 934 # Calculate x[i]should be at the center of the bin 936 935 if run.lower() == 'phi': 937 x[i] = (self.phi_max - self.phi_min) / self.nbins * \938 (1.0 * i + 0.5)+ self.phi_min936 step = (self.phi_max - self.phi_min) / self.nbins 937 x = (np.arange(self.nbins) + 0.5) * step + self.phi_min 939 938 else: 940 939 # We take the center of ring area, not radius. … … 944 943 # r_outer = r_inner + delta_r 945 944 # x[i] = math.sqrt((r_inner * r_inner + r_outer * r_outer) / 2) 946 x [i] = x[i] / y_counts[i]947 y_err[y_err == 0] = np.average(y_err) 945 x = x/y_counts 946 948 947 idx = (np.isfinite(y) & np.isfinite(y_err)) 949 948 if x_err is not None: -
src/sas/sascalc/dataloader/readers/associations.py
ra32c19c re090ba90 53 53 exec("loader.associate_file_type('%s', %s)" 54 54 % (ext.upper(), reader)) 55 except :55 except Exception as exc: 56 56 msg = "read_associations: skipping association" 57 msg += " for %s\n %s" % (ext.lower(), sys.exc_value)57 msg += " for %s\n %s" % (ext.lower(), exc) 58 58 logger.error(msg) -
src/sas/sascalc/dataloader/readers/cansas_reader.py
r2469df7 re090ba90 1239 1239 conv = Converter(units) 1240 1240 setattrchain(storage, variable, conv(value, units=local_unit)) 1241 except Exception: 1242 _, exc_value, _ = sys.exc_info() 1241 except Exception as exc: 1243 1242 err_mess = "CanSAS reader: could not convert" 1244 1243 err_mess += " %s unit [%s]; expecting [%s]\n %s" \ 1245 % (variable, units, local_unit, exc _value)1244 % (variable, units, local_unit, exc) 1246 1245 self.errors.add(err_mess) 1247 1246 if optional: -
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
r61f329f0 re090ba90 475 475 for i in range(0, dataset.mask.size - 1): 476 476 zeros[i] = dataset.mask[i] 477 except :478 self.errors.add( sys.exc_value)477 except Exception as exc: 478 self.errors.add(exc) 479 479 dataset.mask = zeros 480 480 # Calculate the actual Q matrix
Note: See TracChangeset
for help on using the changeset viewer.