- Timestamp:
- Mar 26, 2019 3:14:45 PM (6 years ago)
- Branches:
- ticket-1094-headless
- Children:
- 9cc1f49
- Parents:
- cb44d66 (diff), 2b3eb3d (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. - Location:
- src/sas
- Files:
-
- 1 added
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader.py
r8c9e65c rf0b9bce 493 493 self.current_datainfo.errors.add(error) 494 494 self.data_cleanup() 495 self.sort_one_d_data() 496 self.sort_two_d_data() 495 self.sort_data() 497 496 self.reset_data_list() 498 497 return self.output[0], None -
src/sas/sascalc/calculator/instrument.py
rf4775563 re090ba90 128 128 self.size = 0 129 129 else: 130 self.size = size 130 # TODO: Make sure detector size is number of pixels 131 # Could be detector dimensions in e.g., mm, but 132 # the resolution calculator assumes it is pixels. 133 # Being pixels, it has to be integers rather than float 134 self.size = [int(s) for s in size] 131 135 validate(size[0]) 132 136 -
src/sas/sascalc/calculator/resolution_calculator.py
r574adc7 re090ba90 1007 1007 try: 1008 1008 detector_offset = self.sample2detector_distance[1] 1009 except :1010 logger.error( sys.exc_value)1009 except Exception as exc: 1010 logger.error(exc) 1011 1011 1012 1012 # detector size in [no of pix_x,no of pix_y] … … 1094 1094 output.qx_data = qx_value 1095 1095 output.qy_data = qy_value 1096 except :1097 logger.error( sys.exc_value)1096 except Exception as exc: 1097 logger.error(exc) 1098 1098 1099 1099 return output -
src/sas/sascalc/corfunc/corfunc_calculator.py
ra26f67f rdbfd307 30 30 self.start = start 31 31 self.stop = stop 32 self._lastx = []33 self._lasty = []32 self._lastx = np.empty(0, dtype='d') 33 self._lasty = None 34 34 35 35 def __call__(self, x): 36 36 # If input is a single number, evaluate the function at that number 37 37 # and return a single number 38 if type(x) == float or type(x) == int:38 if isinstance(x, (float, int)): 39 39 return self._smoothed_function(np.array([x]))[0] 40 40 # If input is a list, and is different to the last input, evaluate … … 42 42 # the function was called, return the result that was calculated 43 43 # last time instead of explicity evaluating the function again. 44 elif self._lastx == [] or x.tolist() != self._lastx.tolist(): 45 self._lasty = self._smoothed_function(x) 46 self._lastx = x 44 if not np.array_equal(x, self._lastx): 45 self._lastx, self._lasty = x, self._smoothed_function(x) 47 46 return self._lasty 48 47 … … 88 87 # Only process data of the class Data1D 89 88 if not issubclass(data.__class__, Data1D): 90 raise ValueError(" Data must be of the type DataLoader.Data1D")89 raise ValueError("Correlation function cannot be computed with 2D data.") 91 90 92 91 # Prepare the data … … 246 245 """Fit the Guinier region of the curve""" 247 246 A = np.vstack([q**2, np.ones(q.shape)]).T 248 return lstsq(A, np.log(iq)) 247 # CRUFT: numpy>=1.14.0 allows rcond=None for the following default 248 rcond = np.finfo(float).eps * max(A.shape) 249 return lstsq(A, np.log(iq), rcond=rcond) 249 250 250 251 def _fit_porod(self, q, iq): -
src/sas/sascalc/data_util/calcthread.py
r574adc7 re090ba90 6 6 from __future__ import print_function 7 7 8 import traceback9 8 import sys 10 9 import logging 10 import traceback 11 from time import sleep 12 11 13 try: 12 14 import _thread as thread 13 15 except ImportError: # CRUFT: python 2 support 14 16 import thread 15 16 if sys.platform.count("darwin") > 0: 17 import time 18 stime = time.time() 19 20 def clock(): 21 return time.time() - stime 22 23 def sleep(t): 24 return time.sleep(t) 25 else: 26 from time import clock 27 from time import sleep 17 try: 18 from time import perf_counter as clock 19 except ImportError: # CRUFT: python < 3.3 20 if sys.platform.count("darwin") > 0: 21 from time import time as clock 22 else: 23 from time import clock 28 24 29 25 logger = logging.getLogger(__name__) 30 31 26 32 27 class CalcThread: … … 248 243 self.exception_handler(*sys.exc_info()) 249 244 return 250 except Exception :245 except Exception as exc: 251 246 pass 252 247 logger.error(traceback.format_exc()) -
src/sas/sascalc/data_util/nxsunit.py
rb011ecb r8c9e65c 99 99 Strip '^' from unit names. 100 100 101 * WARNING * this will incorrect transform 10^3 to 103. 102 """ 103 s.update((k.replace('^',''),v) 104 for k, v in list(s.items()) 105 if '^' in k) 101 * WARNING * this will incorrectly transform 10^3 to 103. 102 """ 103 stripped = [(k.replace('^',''),v) for k, v in s.items() if '^' in k] 104 s.update(stripped) 106 105 107 106 def _build_all_units(): -
src/sas/sascalc/data_util/ordereddicttest.py
rb699768 re090ba90 147 147 ]): 148 148 self.assert_(dup is not od) 149 self.assertEqual s(dup, od)150 self.assertEqual s(list(dup.items()), list(od.items()))151 self.assertEqual s(len(dup), len(od))152 self.assertEqual s(type(dup), type(od))149 self.assertEqual(dup, od) 150 self.assertEqual(list(dup.items()), list(od.items())) 151 self.assertEqual(len(dup), len(od)) 152 self.assertEqual(type(dup), type(od)) 153 153 154 154 def test_repr(self): -
src/sas/sascalc/data_util/registry.py
ra26f67f re090ba90 148 148 # If file has associated loader(s) and they;ve failed 149 149 raise last_exc 150 raise NoKnownLoaderException( e.message) # raise generic exception150 raise NoKnownLoaderException(str(message)) # raise generic exception -
src/sas/sascalc/data_util/uncertainty.py
r574adc7 re090ba90 19 19 import numpy as np 20 20 21 from . import err1d21 from . import err1d 22 22 from .formatnum import format_uncertainty 23 23 -
src/sas/sascalc/dataloader/data_info.py
r4fdcc65 r8c9e65c 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) … … 1032 1035 raise ValueError(msg) 1033 1036 for ind in range(len(self.data)): 1034 if math.fabs((self.qx_data[ind] - other.qx_data[ind])/self.qx_data[ind]) >TOLERANCE:1037 if fabs(self.qx_data[ind] - other.qx_data[ind]) > fabs(self.qx_data[ind])*TOLERANCE: 1035 1038 msg = "Incompatible data sets: qx-values do not match: %s %s" % (self.qx_data[ind], other.qx_data[ind]) 1036 1039 raise ValueError(msg) 1037 if math.fabs((self.qy_data[ind] - other.qy_data[ind])/self.qy_data[ind]) >TOLERANCE:1040 if fabs(self.qy_data[ind] - other.qy_data[ind]) > fabs(self.qy_data[ind])*TOLERANCE: 1038 1041 msg = "Incompatible data sets: qy-values do not match: %s %s" % (self.qy_data[ind], other.qy_data[ind]) 1039 1042 raise ValueError(msg) -
src/sas/sascalc/dataloader/loader.py
rb1ec23d r8c9e65c 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 re4e9162 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 934 # The type of averaging: phi,q2, or q 935 # Calculate x[i]should be at the center of the bin 930 with np.errstate(divide='ignore', invalid='ignore'): 931 y = y/y_counts 932 y_err = np.sqrt(y_err)/y_counts 933 # The type of averaging: phi, q2, or q 934 # Calculate x values 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 # We take the center of ring area, not radius. 941 # This is more accurate than taking the radial center of ring. 942 # delta_r = (self.r_max - self.r_min) / self.nbins 943 # r_inner = self.r_min + delta_r * i 944 # r_outer = r_inner + delta_r 945 # 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) 939 # set q to the average of the q values within each bin 940 x = x/y_counts 941 942 ### Alternate algorithm 943 ## We take the center of ring area, not radius. 944 ## This is more accurate than taking the radial center of ring. 945 #step = (self.r_max - self.r_min) / self.nbins 946 #r_inner = self.r_min + step * np.arange(self.nbins) 947 #x = math.sqrt((r_inner**2 + (r_inner + step)**2) / 2) 948 948 949 idx = (np.isfinite(y) & np.isfinite(y_err)) 949 950 if x_err is not None: -
src/sas/sascalc/dataloader/readers/associations.py
rc7c8143 r8c9e65c 54 54 exec("loader.associate_file_type('%s', %s)" 55 55 % (ext.upper(), reader)) 56 except :56 except Exception as exc: 57 57 msg = "read_associations: skipping association" 58 msg += " for %s\n %s" % (ext.lower(), sys.exc_value)58 msg += " for %s\n %s" % (ext.lower(), exc) 59 59 logger.error(msg) -
src/sas/sascalc/fit/BumpsFitting.py
r1386b2f r0aeba4e 2 2 BumpsFitting module runs the bumps optimizer. 3 3 """ 4 from __future__ import print_function 5 4 6 import os 5 7 from datetime import timedelta, datetime … … 9 11 10 12 from bumps import fitters 13 11 14 try: 12 15 from bumps.options import FIT_CONFIG 16 # Preserve bumps default fitter in case someone wants it later 17 BUMPS_DEFAULT_FITTER = FIT_CONFIG.selected_id 13 18 # Default bumps to use the Levenberg-Marquardt optimizer 14 19 FIT_CONFIG.selected_id = fitters.LevenbergMarquardtFit.id … … 17 22 except ImportError: 18 23 # CRUFT: Bumps changed its handling of fit options around 0.7.5.6 24 # Preserve bumps default fitter in case someone wants it later 25 BUMPS_DEFAULT_FITTER = fitters.FIT_DEFAULT 19 26 # Default bumps to use the Levenberg-Marquardt optimizer 20 27 fitters.FIT_DEFAULT = 'lm' … … 126 133 if initial_values is not None: 127 134 self._reset_pars(fitted, initial_values) 135 #print("constraints", constraints) 128 136 self.constraints = dict(constraints) 129 137 self.set_fitted(fitted) … … 222 230 def _setup(self): 223 231 exprs = {} 224 for M in self.models: 225 exprs.update((".".join((M.name, k)), v) for k, v in M.constraints.items()) 232 for model in self.models: 233 exprs.update((".".join((model.name, k)), v) 234 for k, v in model.constraints.items()) 226 235 if exprs: 227 symtab = dict((".".join(( M.name, k)), p)228 for Min self.models229 for k, p in M.parameters().items())236 symtab = dict((".".join((model.name, k)), p) 237 for model in self.models 238 for k, p in model.parameters().items()) 230 239 self.update = compile_constraints(symtab, exprs) 231 240 else: -
src/sas/sascalc/fit/expression.py
r574adc7 re090ba90 210 210 211 211 #print("Function: "+functiondef) 212 exec functiondef in globals,locals212 exec(functiondef, globals, locals) 213 213 retfn = locals['eval_expressions'] 214 214 -
src/sas/sascalc/fit/models.py
rb963b20 re090ba90 12 12 import py_compile 13 13 import shutil 14 15 from six import reraise 14 16 15 17 from sasmodels.sasview_model import load_custom_model, load_standard_models … … 62 64 try: 63 65 new_instance = model() 64 except Exception: 65 msg = "Plugin %s error in __init__ \n\t: %s %s\n" % (str(name), 66 str(sys.exc_type), 67 sys.exc_info()[1]) 66 except Exception as exc: 67 msg = ("Plugin %s error in __init__ \n\t: %s %s\n" 68 % (name, type(exc), exc)) 68 69 plugin_log(msg) 69 70 return None … … 72 73 try: 73 74 value = new_instance.function() 74 except Exception :75 except Exception as exc: 75 76 msg = "Plugin %s: error writing function \n\t :%s %s\n " % \ 76 (str(name), str( sys.exc_type), sys.exc_info()[1])77 (str(name), str(type(exc)), exc) 77 78 plugin_log(msg) 78 79 return None … … 139 140 if type is not None and issubclass(type, py_compile.PyCompileError): 140 141 print("Problem with", repr(value)) 141 r aise type, value, tb142 reraise(type, value, tb) 142 143 return 1 143 144 … … 153 154 compileall.compile_dir(dir=dir, ddir=dir, force=0, 154 155 quiet=report_problem) 155 except Exception :156 return sys.exc_info()[1]156 except Exception as exc: 157 return exc 157 158 return None 158 159 … … 185 186 model.name = PLUGIN_NAME_BASE + model.name 186 187 plugins[model.name] = model 187 except Exception :188 except Exception as exc: 188 189 msg = traceback.format_exc() 189 190 msg += "\nwhile accessing model in %r" % path -
src/sas/sascalc/fit/pagestate.py
r863ac2c rcb44d66 1 1 """ 2 2 Class that holds a fit page state 3 4 Pagestate fields reflect the names of the gui controls from the sasview 3.x 5 fit page, so they are somewhat difficult to interpret. 6 7 Pagestate attributes are as follows: 8 9 # =>name: desc indicates the attribute is derived 10 # name(xml): desc indicates the attribute name differs from the xml tag 11 12 # SasView version which saved the file 13 version: (4, 1, 2) from <fitting_plug_in version="major.minor.point"> 14 15 # Session information 16 group_id: unique id for fit page in running system (int) 17 => data_group_id: unique id for data item in running system (None) 18 19 # Data file 20 data: contents of <SASdata> (Data1D or Data2D) 21 data_name: filename + [num] (latex_smeared.xml [1]) 22 data_id: filename + [num] + timestamp (latex_smeared.xml [1]1523303027.73) 23 file: filename + [date time] (latex_smeared.xml [Apr 09 15:45]) 24 name: ?? (None) 25 npts: number of points (float) 26 enable2D: True if data is 2D (or if model is 2D and no data) 27 is_data: True (pagestate will not save if there is no data attached) 28 29 # Data weighting 30 dI_didata: True if dy = data.dy 31 dI_idata: True if dy = data.y 32 dI_noweight: True if dy = 1 33 dI_sqrdata: True if dy = sqrt(data.y) 34 35 # Data selection 36 qmax: maximum q (float) 37 qmin: minimum q (float) 38 => qmax_x: ?? (None) 39 => qmin_x: ?? (None) 40 41 # Resolution smearing 42 enable_smearer: True if use data.dx 43 disable_smearer: True if no smearing 44 pinhole_smearer: True if custom pinhole smear 45 slit_smearer: True if custom slit smear 46 dq_l: 2D resolution <dQp> 47 dq_r: 2D resolution <dQs> 48 dx_old: True for 3.x version of custom pinhole, which used dx_min rather 49 than dx_percent, with dx_percent interpreted as 100 * dx_percent/q[0] 50 dx_percent: custom pinhole resolution percentage 51 dxl: slit height for custom slit resolution 52 dxw: slit width for custom slit resolution 53 smearer: repr() for active smearer (None on load) 54 smear_type: None (None on load) 55 56 # Model selection 57 categorycombobox: model category 58 formfactorcombobox: model name (could be "[plug-in] name") 59 structurecombobox: structure factor model name (string or None or "None") 60 multi_factor: multiplicity (integer or None) 61 magnetic_on: True if model is magnetic (only for 2D data for now) 62 => model: active model object (None on load) 63 64 # Model parameters 65 # Parameter is a tuple with the following structure. The parentheses 66 # indicate xml attribute for the <parameter .../> tag: 67 # fitted(selected_to_fit): True if parameter is fitted 68 # name(name): display name for the parameter (string) 69 # value(value): displayed parameter value (string) 70 # => plusminus: '+/-' (constant string) 71 # => uncertainty: tuple 72 # (uncertainty_displayed): True if there is an uncertainty 73 # (uncertainty_value): displayed uncertainty (string) 74 # => lower: tuple 75 # (minimum_displayed): True if there is a lower bound 76 # (minimum_value): displayed lower bound (string) 77 # => upper: tuple 78 # (maximum_displayed): True if there is a upper bound 79 # (maximum_value): displayed upper bound (string) 80 # units(unit): displayed units 81 parameters: list of normal parameters 82 fixed_param: list of non-fitting parameters (nsigma, npts in dispersity) 83 fittable_param: list of fittable dispersity parameters (distribution width) 84 str_parameters: list of selection parameters (e.g, shell forms in spherical_sld) 85 orientation_params(orientation_parameters): list of orientation and 86 magnetic parameters (already included in parameters, so safe to ignore) 87 orientation_params_disp(dispersity_parameters): list of orientation 88 disperisty parameters (already included in fixed_param and 89 fittable_param so safe to ignore) 90 91 # Dispersity controls 92 enable_disp: True if dispersity parameters 93 disable_disp: True if no dispersity parameters 94 disp_obj_dict(disp_obj): {'parameter.width': 'dispersity distribution'} 95 values: {'parameter.width': [array distribution parameter values] } 96 weights: {'parameter.width': [array distribution parameter weights] } 97 => disp_box 0 98 => disp_cb_dict {} 99 => disp_list [] 100 101 # Simultaneous fitting 102 103 => images: None (initialized but unused?) 104 => reset: False (initialized but unused?) 105 => event_owner None 106 => m_name None 107 => manager None 108 => page_name 109 => param_toFit: [] 110 => process: list of process done on object [] (maybe managed by guiframe?) 111 => saved_states {} 112 => cb1: False (simfit cb1 is now stored in select_all) 113 114 tcChi 1.3463 115 theory_data None 116 timestamp 1523303103.74 117 118 Constraint attributes are as follows: 119 120 constraint_dict {} 121 constraints_list 122 {'model_cbox': 'M2', 'param_cbox': 'scale', 'egal_txt': ' = ', 'constraint': 'M1.scale'} 123 {'model_cbox': 'M2', 'param_cbox': 'radius', 'egal_txt': ' = ', 'constraint': 'M1.radius'} 124 {'model_cbox': 'M2', 'param_cbox': 'radius.width', 'egal_txt': ' = ', 'constraint': 'M1.radius.width'} 125 fit_page_no None 126 model_list 127 {'fit_number': '393', 'checked': 'True', 'fit_page_source': 'M2', 'name': 'latex_smeared.xml [1]1523535051.03', 'model_name': 'sphere'} 128 {'fit_number': '335', 'checked': 'True', 'fit_page_source': 'M1', 'name': 'latex_smeared.xml 1523535050.03', 'model_name': 'sphere'} 129 model_to_fit 130 no_constraint 0 131 select_all True 132 133 3 134 """ 4 135 # TODO: Refactor code so we don't need to use getattr/setattr … … 162 293 self.theory_data = None 163 294 # Is 2D 164 self.is_2D = False165 295 self.images = None 166 296 … … 557 687 temp_parameters = [] 558 688 temp_fittable_param = [] 559 if self.data.__class__.__name__ == "Data2D":560 self.is_2D = True561 else:562 self.is_2D = False563 689 if self.data is not None: 564 if not self.is_2D: 690 is_2D = (self.data.__class__.__name__ == "Data2D") 691 if not is_2D: 565 692 for item in self.parameters: 566 693 if item not in self.orientation_params: … … 650 777 #Truncating string so print doesn't complain of being outside margins 651 778 if sys.platform != "win32": 652 MAX_STRING_LENG HT= 50653 if len(file_value) > MAX_STRING_LENG HT:654 file_value = "File name:.."+file_value[-MAX_STRING_LENG HT+10:]779 MAX_STRING_LENGTH = 50 780 if len(file_value) > MAX_STRING_LENGTH: 781 file_value = "File name:.."+file_value[-MAX_STRING_LENGTH+10:] 655 782 file_name = CENTRE % file_value 656 783 if len(title) == 0: … … 905 1032 doc_model = newdoc.createElement('model_list_item') 906 1033 doc_model.setAttribute('checked', str(model[0].GetValue())) 907 keys = model[1].keys()1034 keys = list(model[1].keys()) 908 1035 doc_model.setAttribute('name', str(keys[0])) 909 1036 values = model[1].get(keys[0]) … … 964 1091 if node.get('version'): 965 1092 # Get the version for model conversion purposes 966 x = re.sub( '[^\d.]', '', node.get('version'))1093 x = re.sub(r'[^\d.]', '', node.get('version')) 967 1094 self.version = tuple(int(e) for e in str.split(x, ".")) 968 1095 # The tuple must be at least 3 items long … … 984 1111 try: 985 1112 self.timestamp = float(entry.get('epoch')) 986 except Exception :1113 except Exception as exc: 987 1114 msg = "PageState.fromXML: Could not" 988 msg += " read timestamp\n %s" % sys.exc_value1115 msg += " read timestamp\n %s" % exc 989 1116 logger.error(msg) 990 1117 … … 1282 1409 if isinstance(data.run_name, dict): 1283 1410 # Note: key order in dict is not guaranteed, so sort 1284 name = data.run_name.keys()[0]1411 name = list(data.run_name.keys())[0] 1285 1412 else: 1286 1413 name = data.run_name -
src/sas/sascalc/invariant/invariant.py
r574adc7 rdbfd307 344 344 else: 345 345 A = np.vstack([linearized_data.x / linearized_data.dy, 1.0 / linearized_data.dy]).T 346 (p, residuals, _, _) = np.linalg.lstsq(A, linearized_data.y / linearized_data.dy) 346 # CRUFT: numpy>=1.14.0 allows rcond=None for the following default 347 rcond = np.finfo(float).eps * max(A.shape) 348 p, residuals, _, _ = np.linalg.lstsq(A, linearized_data.y / linearized_data.dy, 349 rcond=rcond) 347 350 348 351 # Get the covariance matrix, defined as inv_cov = a_transposed * a -
src/sas/sascalc/pr/distance_explorer.py
r959eb01 re090ba90 99 99 results.pos_err.append(pos_err) 100 100 results.osc.append(osc) 101 except :101 except Exception as exc: 102 102 # This inversion failed, skip this D_max value 103 103 msg = "ExploreDialog: inversion failed for " 104 msg += "D_max=%s\n %s" % (str(d), sys.exc_value)104 msg += "D_max=%s\n %s" % (str(d), exc) 105 105 results.errors.append(msg) 106 106 -
src/sas/sascalc/pr/fit/expression.py
r574adc7 re090ba90 210 210 211 211 #print("Function: "+functiondef) 212 exec functiondef in globals,locals212 exec(functiondef, globals, locals) 213 213 retfn = locals['eval_expressions'] 214 214 -
src/sas/sascalc/pr/invertor.py
r57e48ca r7af652d 474 474 475 475 # Perform the inversion (least square fit) 476 c, chi2, _, _ = lstsq(a, b, rcond=-1) 476 # CRUFT: numpy>=1.14.0 allows rcond=None for the following default 477 rcond = np.finfo(float).eps * max(a.shape) 478 c, chi2, _, _ = lstsq(a, b, rcond=rcond) 477 479 # Sanity check 478 480 try: -
src/sas/sascalc/pr/num_term.py
r3e6829d r8c9e65c 182 182 data_y = np.append(data_y, test_y) 183 183 data_err = np.append(data_err, err) 184 except :185 logger.error( sys.exc_value)184 except Exception as exc: 185 logger.error(exc) 186 186 187 187 return data_x, data_y, data_err -
src/sas/sascalc/realspace/VolumeCanvas.py
r98e3f24 re090ba90 472 472 Return a list of the shapes 473 473 """ 474 return self.shapes.keys()474 return list(self.shapes.keys()) 475 475 476 476 def _addSingleShape(self, shapeDesc): -
src/sas/sasgui/perspectives/corfunc/media/corfunc_help.rst
r490f790 r4d06668 30 30 of the profile provides measures of the layer thickness, and the area under 31 31 the profile is related to the amount of material that is adsorbed. 32 33 .. note:: 34 These transforms assume that the data has been measured on a pinhole- 35 collimated instrument or, if not, that the data has been Lorentz- 36 corrected beforehand. 32 37 33 38 Both analyses are performed in 3 stages: -
src/sas/sasgui/perspectives/fitting/fitpage.py
rca4f40d rcb44d66 56 56 # draw sizer 57 57 self._fill_data_sizer() 58 self.is_2D = None59 58 self.fit_started = False 60 59 self.weightbt_string = None -
src/sas/sasgui/plottools/PlotPanel.py
r2469df7 r75313af 1434 1434 1435 1435 """ 1436 # TODO: include mask info in plotter 1436 1437 self.data = data 1437 1438 self.qx_data = qx_data … … 1451 1452 else: 1452 1453 output = copy.deepcopy(self.data) 1453 # check scale1454 # rescale data if necessary 1454 1455 if self.scale == 'log_{10}': 1455 try: 1456 if self.zmin_2D <= 0 and len(output[output > 0]) > 0: 1457 zmin_temp = self.zmin_2D 1458 output[output > 0] = np.log10(output[output > 0]) 1459 #In log scale Negative values are not correct in general 1460 #output[output<=0] = math.log(np.min(output[output>0])) 1461 elif self.zmin_2D <= 0: 1462 zmin_temp = self.zmin_2D 1463 output[output > 0] = np.zeros(len(output)) 1464 output[output <= 0] = -32 1465 else: 1466 zmin_temp = self.zmin_2D 1467 output[output > 0] = np.log10(output[output > 0]) 1468 #In log scale Negative values are not correct in general 1469 #output[output<=0] = math.log(np.min(output[output>0])) 1470 except: 1471 #Too many problems in 2D plot with scale 1472 pass 1473 1474 else: 1475 zmin_temp = self.zmin_2D 1456 with np.errstate(all='ignore'): 1457 output = np.log10(output) 1458 index = np.isfinite(output) 1459 if not index.all(): 1460 cutoff = (np.min(output[index]) - np.log10(2) 1461 if index.any() else 0.) 1462 output[~index] = cutoff 1463 # TODO: fix handling of zmin_2D/zmax_2D in _onToggleScale 1464 # For now, use default vmin/vmax from data 1465 #vmin, vmax = self.zmin_2D, self.zmax_2D 1466 vmin, vmax = None, None 1476 1467 self.cmap = cmap 1477 1468 if self.dimension != 3: 1478 1469 #Re-adjust colorbar 1479 1470 self.subplot.figure.subplots_adjust(left=0.2, right=.8, bottom=.2) 1480 1481 1471 im = self.subplot.imshow(output, interpolation='nearest', 1482 1472 origin='lower', 1483 vmin= zmin_temp, vmax=self.zmax_2D,1473 vmin=vmin, vmax=vmax, 1484 1474 cmap=self.cmap, 1485 1475 extent=(self.xmin_2D, self.xmax_2D,
Note: See TracChangeset
for help on using the changeset viewer.