Changeset 904713c in sasview


Ignore:
Timestamp:
Mar 28, 2009 12:52:48 PM (15 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
ead38a7
Parents:
ff54ce7
Message:

Cleaned up obvious flaws: still needs work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/model_thread.py

    rc77d859 r904713c  
    22from calcthread import CalcThread 
    33import sys 
     4import numpy 
    45 
    56class Calc2D_all(CalcThread): 
     
    2728        self.starttime = 0 
    2829         
    29     def isquit(self): 
    30         try: 
    31             CalcThread.isquit(self) 
    32         except KeyboardInterrupt: 
    33             wx.PostEvent(self.parent, StatusEvent(status=\ 
    34                        "Calc %s interrupted" % self.model.name)) 
    35             raise KeyboardInterrupt 
    36          
    3730    def compute(self): 
    38         import numpy 
    3931        x = self.x 
    4032        y = self.y 
     
    108100        ## the model on to calculate 
    109101        self.model = model 
    110         self.starttime = 0 
    111        
    112        
    113     def isquit(self): 
    114         try: 
    115             CalcThread.isquit(self) 
    116         except KeyboardInterrupt: 
    117             wx.PostEvent(self.parent, StatusEvent(status=\ 
    118                        "Calc %s interrupted" % self.model.name)) 
    119             
    120             raise KeyboardInterrupt 
    121          
     102        self.starttime = 0   
    122103         
    123104    def compute(self): 
     
    125106            Compute the data given a model function 
    126107        """ 
    127         import numpy 
    128108        x = self.x 
    129109        y = self.y 
     
    133113            self.qmin = 0 
    134114        if self.qmax== None: 
    135             if data ==None: 
     115            if self.data ==None: 
    136116                return 
    137             newx= math.pow(max(math.fabs(data.xmax),math.fabs(data.xmin)),2) 
    138             newy= math.pow(max(math.fabs(data.ymax),math.fabs(data.ymin)),2) 
     117            newx= math.pow(max(math.fabs(self.data.xmax),math.fabs(self.data.xmin)),2) 
     118            newy= math.pow(max(math.fabs(self.data.ymax),math.fabs(self.data.ymin)),2) 
    139119            self.qmax=math.sqrt( newx + newy ) 
    140120         
     
    189169        self.starttime = 0 
    190170         
    191     def isquit(self): 
    192         try: 
    193             CalcThread.isquit(self) 
    194         except KeyboardInterrupt: 
    195             #printEVT("Calc %s interrupted" % self.model.name) 
    196             wx.PostEvent(self.parent, StatusEvent(status=\ 
    197                        "Calc %s interrupted" % self.model.name)) 
    198             
    199             raise KeyboardInterrupt 
    200          
    201171    def compute(self): 
    202         import numpy 
    203172        x = self.x 
    204173        y = self.y 
     
    284253            Compute model 1d value given qmin , qmax , x value  
    285254        """ 
    286         import numpy 
    287          
    288255        output = numpy.zeros(len(self.x)) 
    289256        
     
    312279        #print thread.get_ident() 
    313280        from sans.models.CylinderModel import CylinderModel 
    314         from sans.models.DisperseModel import DisperseModel 
    315         import pylab 
    316          
    317         submodel = CylinderModel() 
    318          
    319         model = DisperseModel(submodel, ['cyl_phi', 'cyl_theta', 'length'], 
    320                                         [0.2, 0.2, 10.0]) 
    321         model.setParam('n_pts', 10) 
     281         
     282        model = CylinderModel() 
     283         
    322284          
    323285        print model.runXY([0.01, 0.02]) 
     
    327289        self.done = False 
    328290         
    329         x = pylab.arange(-qmax, qmax+qstep*0.01, qstep) 
    330         y = pylab.arange(-qmax, qmax+qstep*0.01, qstep) 
    331      
    332         calc_thread_2D = Calc2D(x, y, model.clone(),-qmax, qmax,qstep, 
     291        x = numpy.arange(-qmax, qmax+qstep*0.01, qstep) 
     292        y = numpy.arange(-qmax, qmax+qstep*0.01, qstep) 
     293     
     294     
     295        calc_thread_2D = Calc2D(x, y, None, model.clone(),-qmax, qmax,qstep, 
    333296                                        completefn=self.complete, 
    334297                                        updatefn=self.update , 
     
    344307        print "update" 
    345308 
    346     def complete(self, output, model, elapsed, qmin, qmax, qstep ): 
     309    def complete(self, image, data, model, elapsed, qmin, qmax, qstep ): 
    347310        print "complete" 
    348311        self.done = True 
Note: See TracChangeset for help on using the changeset viewer.