Changeset bfe4644 in sasview for sansview/perspectives
- Timestamp:
- Sep 17, 2009 6:21:56 AM (15 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 104f3da
- Parents:
- c5cd3b9
- Location:
- sansview/perspectives/fitting
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitting.py
r7ad6ff5 rbfe4644 277 277 @param return 278 278 """ 279 detector=None 280 source=None 279 281 280 info = None 282 281 id=None 283 dxl=None 284 dxw=None 285 dx=None 286 if hasattr(item, "dxl"): 287 dxl = copy.deepcopy(item.dxl) 288 if hasattr(item, "dxw"): 289 dxw = copy.deepcopy(item.dxw) 290 if hasattr(item, "detector"): 291 detector = copy.deepcopy(item.detector) 292 if hasattr(item, "source"): 293 source = copy.deepcopy(item.source) 282 294 283 if hasattr(item ,"info"): 295 284 info= copy.deepcopy(item.info) 296 285 if hasattr(item,"id"): 297 286 id = copy.deepcopy(item.id) 298 if hasattr(item, "dx"): 299 dx= item.dx 300 301 302 data= Data1D(x=item.x, y=item.y,dx=dx, dy=dy) 303 data.dxl = dxl 304 data.dxw = dxw 305 287 288 data= Data1D(x=item.x, y=item.y,dx=None, dy=None) 289 data.copy_from_datainfo(item) 290 item.clone_without_data(clone=data) 291 data.dy= dy 306 292 data.name = item.name 307 data.detector = detector 308 data.source = source 293 309 294 ## allow to highlight data when plotted 310 295 data.interactive = copy.deepcopy(item.interactive) … … 314 299 ## to save data 1D as cansas xml file 315 300 data.info= info 316 ## If the data file does not tell us what the axes are, just assume...317 data.xaxis(copy.deepcopy(item._xaxis),copy.deepcopy(item._xunit))318 data.yaxis(copy.deepcopy(item._yaxis),copy.deepcopy(item._yunit))319 ##group_id specify on which panel to plot this data320 301 data.group_id = item.group_id 321 302 return data 322 303 323 304 def set_fit_range(self, page, qmin, qmax): 324 305 """ … … 409 390 410 391 smear =self.page_finder[current_pg].get_smearer() 411 self.draw_model( model=model, data= data, smearer= smear, 392 if model!= None: 393 self.draw_model( model=model, data= data, smearer= smear, 412 394 qmin= qmin, qmax= qmax) 413 395 -
sansview/perspectives/fitting/gui_thread.py
r785c8233 rbfe4644 78 78 # Thread was interrupted, just proceed and re-raise. 79 79 # Real code should not print, but this is an example... 80 raise 81 except: 82 raise 80 raise KeyboardInterrupt 81 83 82 84 83 class CalcChisqr2D(CalcThread): … … 149 148 # Thread was interrupted, just proceed and re-raise. 150 149 # Real code should not print, but this is an example... 151 raise 152 except: 153 raise 150 raise KeyboardInterrupt 151 -
sansview/perspectives/fitting/model_thread.py
raeb3c20 rbfe4644 115 115 index= (self.qmin <= self.x)& (self.x <= self.qmax) 116 116 output[index] = self.model.evalDistribution(self.x[index]) 117 118 _first_bin = None 119 _last_bin = None 120 121 for i_x in xrange(len(self.x)): 122 if index[i_x]: 123 # Identify first and last bin 124 #TODO: refactor this to pass q-values to the smearer 125 # and let it figure out which bin range to use 126 if _first_bin is None: 127 _first_bin = i_x 128 else: 129 _last_bin = i_x 117 130 118 131 ##smearer the ouput of the plot 119 132 if self.smearer!=None: 120 output = self.smearer(output) #Todo: Why always output[0]=0??? 121 133 #output= self.smearer(output) 134 output = self.smearer(output, _first_bin,_last_bin) #Todo: Why always output[0]=0??? 135 122 136 ######Temp. FIX for Qrange w/ smear. #ToDo: Should not pass all the data to 'run' or 'smear'... 123 new_index = (self.qmin > self.x) |(self.x > self.qmax)124 output[new_index] = None137 #new_index = (self.qmin > self.x) |(self.x > self.qmax) 138 #output[new_index] = None 125 139 140 #print "output------",output 126 141 elapsed = time.time()-self.starttime 127 142 -
sansview/perspectives/fitting/models.py
r9002927 rbfe4644 11 11 import os,sys,math 12 12 import os.path 13 13 from sans.models.pluginmodel import Model1DPlugin 14 14 (ModelEvent, EVT_MODEL) = wx.lib.newevent.NewEvent() 15 15 from sans.guicomm.events import StatusEvent … … 33 33 return [] 34 34 35 def _check_plugin(model, name): 36 """ 37 Do some checking before model adding plugins in the list 38 @param model: class model to add into the plugin list 39 @param name:name of the module plugin 40 @return model: model if valid model or nothing if not valid 41 """ 42 #Check is the plugin is of type Model1DPlugin 43 if not issubclass(model, Model1DPlugin): 44 msg= "Plugin %s must be of type Model1DPlugin \n"%str(name) 45 log(msg) 46 return 47 if model.__name__!="Model": 48 msg= "Plugin %s class name must be Model \n"%str(name) 49 log(msg) 50 return 51 try: 52 new_instance= model() 53 except: 54 msg="Plugin %s error in __init__ \n\t: %s %s\n"%(str(name), 55 str(sys.exc_type),sys.exc_value) 56 log(msg) 57 return 58 59 new_instance= model() 60 if hasattr(new_instance,"function"): 61 try: 62 value=new_instance.function() 63 except: 64 msg="Plugin %s: error writing function \n\t :%s %s\n "%(str(name), 65 str(sys.exc_type),sys.exc_value) 66 log(msg) 67 return 68 else: 69 msg="Plugin %s needs a method called function \n"%str(name) 70 log(msg) 71 return 72 return model 73 74 35 75 def _findModels(dir): 36 76 # List of plugin objects … … 51 91 if hasattr(module, "Model"): 52 92 try: 53 plugins.append(module.Model) 93 if _check_plugin(module.Model, name)!=None: 94 #plugins.append(module.Model) 95 plugins.append(module.Model) 54 96 except: 55 log("Error accessing Model in %s\n %s" % (name, sys.exc_value)) 97 msg="Error accessing Model" 98 msg+="in %s\n %s %s\n" % (name, 99 str(sys.exc_type), sys.exc_value) 100 log(msg) 56 101 except: 57 log("Error accessing Model in %s\n %s" % (name, sys.exc_value)) 102 msg="Error accessing Model" 103 msg +=" in %s\n %s %s \n" %(name, 104 str(sys.exc_type), sys.exc_value) 105 log(msg) 58 106 finally: 59 107 … … 285 333 list1= self.struct_list ) 286 334 287 self._fill_ simple_menu( menuinfo = ["Customized Models", added_models,335 self._fill_plugin_menu( menuinfo = ["Customized Models", added_models, 288 336 "List of additional models"], 289 337 list1= self.plugins ) … … 297 345 return 0 298 346 347 def _fill_plugin_menu(self,menuinfo, list1): 348 """ 349 fill the plugin menu with costumized models 350 """ 351 if len(list1)==0: 352 id = wx.NewId() 353 msg= "No model available check plugins.log for errors to fix problem" 354 menuinfo[1].Append(int(id),"Empty",msg) 355 self._fill_simple_menu( menuinfo,list1) 356 357 299 358 def _fill_simple_menu(self,menuinfo, list1): 300 359 """
Note: See TracChangeset
for help on using the changeset viewer.