Changes in / [9e0aa69a:a6fccd7] in sasview
- Location:
- src/sas
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/data_util/qsmearing.py
r345e7e4 rd3911e3 41 41 elif data.dqx_data == None or data.dqy_data == None: 42 42 return None 43 return P inhole2D(data)43 return PySmear2D(data, model) 44 44 45 45 if not hasattr(data, "dx") and not hasattr(data, "dxl")\ … … 142 142 width = data.dx if data.dx is not None else 0 143 143 return PySmear(Pinhole1D(q, width), model) 144 145 146 class PySmear2D(object): 147 """ 148 Q smearing class for SAS 2d pinhole data 149 """ 150 151 def __init__(self, data=None, model=None): 152 self.data = data 153 self.model = model 154 self.accuracy = 'Low' 155 self.limit = 3.0 156 self.index = None 157 self.coords = 'polar' 158 self.smearer = True 159 160 def set_accuracy(self, accuracy='Low'): 161 """ 162 Set accuracy. 163 164 :param accuracy: string 165 """ 166 self.accuracy = accuracy 167 168 def set_smearer(self, smearer=True): 169 """ 170 Set whether or not smearer will be used 171 172 :param smearer: smear object 173 174 """ 175 self.smearer = smearer 176 177 def set_data(self, data=None): 178 """ 179 Set data. 180 181 :param data: DataLoader.Data_info type 182 """ 183 self.data = data 184 185 def set_model(self, model=None): 186 """ 187 Set model. 188 189 :param model: sas.models instance 190 """ 191 self.model = model 192 193 def set_index(self, index=None): 194 """ 195 Set index. 196 197 :param index: 1d arrays 198 """ 199 self.index = index 200 201 def get_value(self): 202 """ 203 Over sampling of r_nbins times phi_nbins, calculate Gaussian weights, 204 then find smeared intensity 205 """ 206 if self.smearer: 207 res = Pinhole2D(data=self.data, index=self.index, 208 nsigma=3.0, accuracy=self.accuracy, 209 coords=self.coords) 210 val = self.model.evalDistribution(res.q_calc) 211 return res.apply(val) 212 else: 213 index = self.index if self.index is not None else slice(None) 214 qx_data = self.data.qx_data[index] 215 qy_data = self.data.qy_data[index] 216 q_calc = [qx_data, qy_data] 217 val = self.model.evalDistribution(q_calc) 218 return val 219 -
src/sas/sascalc/fit/AbstractFitEngine.py
r345e7e4 rd3911e3 359 359 if self.smearer != None: 360 360 fn.set_index(self.idx) 361 # Get necessary data from self.data and set the data for smearing362 fn.get_data()363 364 361 gn = fn.get_value() 365 362 else: -
src/sas/sasgui/guiframe/gui_manager.py
r67b0a99 rd3911e3 1990 1990 wx.PostEvent(self, 1991 1991 StatusEvent(status="Completed saving.")) 1992 except :1992 except Exception: 1993 1993 msg = "Error occurred while saving: " 1994 msg += traceback.format_exc() 1994 1995 msg += "To save, the application panel should have a data set.." 1995 1996 wx.PostEvent(self, StatusEvent(status=msg)) … … 2040 2041 logging.warning(msg) 2041 2042 wx.PostEvent(self, StatusEvent(status=msg, info="error")) 2042 except :2043 except Exception: 2043 2044 msg = "Error occurred while saving: " 2045 msg += traceback.format_exc() 2044 2046 msg += "To save, at least one application panel " 2045 2047 msg += "should have a data set.." -
src/sas/sasgui/perspectives/fitting/basepage.py
r9e0aa69a r9e0aa69a 52 52 FONT_VARIANT = 1 53 53 ON_MAC = True 54 55 54 56 55 class BasicPage(ScrolledPanel, PanelBase): … … 1042 1041 disp_model = POLYDISPERSITY_MODELS['array']() 1043 1042 if hasattr(state, "values") and \ 1044 self.disp_cb_dict[item].GetValue() is True:1043 self.disp_cb_dict[item].GetValue(): 1045 1044 if len(state.values) > 0: 1046 1045 self.values = state.values … … 1451 1450 self.state_change = True 1452 1451 self._draw_model() 1452 # Time delay has been introduced to prevent _handle error 1453 # on Windows 1454 # This part of code is executed when model is selected and 1455 # it's parameters are changed (with respect to previously 1456 # selected model). There are two Iq evaluations occuring one 1457 # after another and therefore there may be compilation error 1458 # if model is calculated for the first time. 1459 # This seems to be Windows only issue - haven't tested on Linux 1460 # though.The proper solution (other than time delay) requires 1461 # more fundemental code refatoring 1462 # Wojtek P. Nov 7, 2016 1463 if not ON_MAC: 1464 time.sleep(0.1) 1453 1465 self.Refresh() 1454 1466 … … 2129 2141 flag = False 2130 2142 else: 2131 self.Npts_fit.SetValue(str(len(index_data[index_data is True])))2143 self.Npts_fit.SetValue(str(len(index_data[index_data]))) 2132 2144 self.fitrange = True 2133 2145 … … 2164 2176 flag = False 2165 2177 else: 2166 val = index_data[index_data is True] 2167 val = len(val) if isinstance(val, list) else 1 2168 self.Npts_fit.SetValue(str(val)) 2178 self.Npts_fit.SetValue(str(len(index_data[index_data]))) 2169 2179 self.fitrange = True 2170 2180 … … 2390 2400 2391 2401 # Redraw the model 2392 self._draw_model() 2402 # Wojtek P. Nov 7, 2016: Redrawing seems to be unnecessary here 2403 # self._draw_model() 2393 2404 # self._undo.Enable(True) 2394 2405 event = PageInfoEvent(page=self) … … 2609 2620 Layout after self._draw_model 2610 2621 """ 2611 if ON_MAC is True:2622 if ON_MAC: 2612 2623 time.sleep(1) 2613 2624 -
src/sas/sasgui/perspectives/fitting/fitpage.py
r345e7e4 r24fd27a 81 81 flag = check_data_validity(self.data) & (self.model is not None) 82 82 self.btFit.Enable(flag) 83 83 84 84 def on_set_focus(self, event): 85 85 """ 86 Override the basepage focus method to ensure the save flag is set 86 Override the basepage focus method to ensure the save flag is set 87 87 properly when focusing on the fit page. 88 88 """ … … 238 238 239 239 weighting_set_box = wx.StaticBox(self, wx.ID_ANY, 240 'Set Weighting by Selecting dI Source')240 'Set Weighting by Selecting dI Source') 241 241 weighting_box = wx.StaticBoxSizer(weighting_set_box, wx.HORIZONTAL) 242 242 sizer_weighting = wx.BoxSizer(wx.HORIZONTAL) … … 1164 1164 if event is not None: 1165 1165 if (event.GetEventObject() == self.formfactorbox 1166 1167 1168 1166 and self.structurebox.GetLabel() != 'None')\ 1167 or event.GetEventObject() == self.structurebox\ 1168 or event.GetEventObject() == self.multifactorbox: 1169 1169 copy_flag = self.get_copy_params() 1170 1170 is_poly_enabled = self.enable_disp.GetValue() … … 1206 1206 self._keep.Enable(not self.batch_on) 1207 1207 self._set_save_flag(True) 1208 self._set_smear(self.data) 1208 #Setting smearing for cases with and without data. 1209 self._set_smear(self.data) 1209 1210 1210 1211 # more disables for 2D … … 1213 1214 try: 1214 1215 # update smearer sizer 1215 self.onSmear(None) 1216 #This call for smearing set up caused double evaluation of 1217 #I(q) and double compilation as results 1218 #self.onSmear(None) 1216 1219 temp_smear = None 1217 1220 if not self.disable_smearer.GetValue(): … … 1227 1230 # set smearing value whether or not data contain the smearing info 1228 1231 evt = ModelEventbox(model=self.model, 1229 smearer=temp_smear,1230 enable_smearer=not self.disable_smearer.GetValue(),1231 qmin=float(self.qmin_x),1232 uid=self.uid,1233 caption=self.window_caption,1234 qmax=float(self.qmax_x))1232 smearer=temp_smear, 1233 enable_smearer=not self.disable_smearer.GetValue(), 1234 qmin=float(self.qmin_x), 1235 uid=self.uid, 1236 caption=self.window_caption, 1237 qmax=float(self.qmax_x)) 1235 1238 1236 1239 self._manager._on_model_panel(evt=evt) … … 1616 1619 return 1617 1620 # check if it is pinhole smear and get min max if it is. 1618 if data.dx is not None and n ot numpy.any(data.dx):1621 if data.dx is not None and numpy.any(data.dx): 1619 1622 self.smear_type = "Pinhole" 1620 1623 self.dq_l = data.dx[0] -
src/sas/sasgui/perspectives/fitting/fitting.py
r1a5d5f2 r1a5d5f2 864 864 enable1D=enable1D, enable2D=enable2D, 865 865 qmin=qmin, qmax=qmax, weight=weight) 866 self._mac_sleep(0.2)867 866 868 867 def _mac_sleep(self, sec=0.2): … … 1964 1963 ## May need rethinking 1965 1964 ## 1966 ## -PDB August 12, 2014 1965 ## -PDB August 12, 2014 1967 1966 while self.calc_1D.isrunning(): 1968 1967 time.sleep(0.1) -
src/sas/sasgui/perspectives/fitting/model_thread.py
r286c757 rd3911e3 82 82 fn.set_model(self.model) 83 83 fn.set_index(index_model) 84 # Get necessary data from self.data and set the data for smearing85 fn.get_data()86 84 # Calculate smeared Intensity 87 85 #(by Gaussian averaging): DataLoader/smearing2d/Smearer2D() … … 89 87 else: 90 88 # calculation w/o smearing 91 value = self.model.evalDistribution(\ 92 [self.data.qx_data[index_model], 93 self.data.qy_data[index_model]]) 89 value = self.model.evalDistribution([ 90 self.data.qx_data[index_model], 91 self.data.qy_data[index_model] 92 ]) 94 93 output = numpy.zeros(len(self.data.qx_data)) 95 94 # output default is None
Note: See TracChangeset
for help on using the changeset viewer.