Changeset d15c0202 in sasview
- Timestamp:
- Jan 13, 2009 5:52:02 PM (16 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:
- e8d1066
- Parents:
- e4032d64
- Location:
- sansview/perspectives/fitting
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitpage1D.py
rdb709e4 rd15c0202 181 181 self.model_list_box={} 182 182 self.data = data 183 183 ## Q range 184 self.qmin= 0.001 185 self.qmax= 0.1 184 186 """ 185 187 bs = wx.BoxSizer(wx.VERTICAL) … … 536 538 print "went here",len(self.parameters) ,self.model 537 539 if len(self.parameters) !=0 and self.model !=None: 540 # Flag to register when a parameter has changed. 541 is_modified = False 538 542 for item in self.parameters: 539 543 try: … … 543 547 name=str(item[0].GetLabelText()) 544 548 value= float(item[1].GetValue()) 545 self.model.setParam(name,value) 549 # If the value of the parameter has changed, 550 # update the model and set the is_modified flag 551 if value != self.model.getParam(name): 552 self.model.setParam(name,value) 553 is_modified = True 546 554 except: 547 555 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 548 556 "Drawing Error:wrong value entered : %s"% sys.exc_value)) 549 550 is_modified = False 551 if self.xmin.IsModified(): 552 is_modified = True 553 if self.xmax.IsModified(): 554 is_modified = True 555 556 try: 557 558 if item[1].IsModified() or is_modified: 559 print str(item[0].GetLabelText()),item[1].IsModified() 560 item[1].SetModified(False) 561 name=str(item[0].GetLabelText()) 562 value= float(item[1].GetValue()) 563 self.model.setParam(name,value) 564 self.xmin.SetModified(False) 565 self.xmax.SetModified(False) 566 is_modified=False 567 568 self.manager.redraw_model( 569 float(self.xmin.GetValue()), 570 float(self.xmax.GetValue()) ) 571 572 except: 573 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 574 "Model Drawing Error:wrong value entered : %s"% sys.exc_value)) 575 557 # Here we should check whether the boundaries have been modified. 558 # If qmin and qmax have been modified, update qmin and qmax and 559 # set the is_modified flag to True 560 if float(self.xmin.GetValue()) != self.qmin: 561 self.qmin = float(self.xmin.GetValue()) 562 is_modified = True 563 if float(self.xmax.GetValue()) != self.qmax: 564 self.qmax = float(self.xmax.GetValue()) 565 is_modified = True 566 567 if is_modified: 568 self.manager.redraw_model( 569 qmin=self.qmin, qmax=self.qmax, 570 ) 571 #self.manager.draw_model(self,model,description=None, 572 # enable1D=True,qmin=None,qmax=None, qstep=None) 576 573 577 574 def select_all_param(self,event): -
sansview/perspectives/fitting/fitpage2D.py
rdb709e4 rd15c0202 72 72 self.vbox.Add(self.sizer4) 73 73 self.vbox.Add(self.sizer1) 74 ## Q range 75 self.qmin= 0.001 76 self.qmax= 0.1 74 77 75 78 id = wx.NewId() … … 496 499 and the reset model according to paramaters changes 497 500 """ 501 print "went here",len(self.parameters) ,self.model 498 502 if len(self.parameters) !=0 and self.model !=None: 503 # Flag to register when a parameter has changed. 504 is_modified = False 499 505 for item in self.parameters: 500 501 is_modified = False 502 if self.xmin.IsModified(): 503 is_modified = True 504 if self.xmax.IsModified(): 505 is_modified = True 506 507 try: 508 509 if item[1].IsModified() or is_modified: 510 print str(item[0].GetLabelText()),item[1].IsModified() 511 item[1].SetModified(False) 512 name=str(item[0].GetLabelText()) 513 value= float(item[1].GetValue()) 506 try: 507 item[2].Hide() 508 item[3].Clear() 509 item[3].Hide() 510 name=str(item[0].GetLabelText()) 511 value= float(item[1].GetValue()) 512 # If the value of the parameter has changed, 513 # update the model and set the is_modified flag 514 if value != self.model.getParam(name): 514 515 self.model.setParam(name,value) 515 self.xmin.SetModified(False) 516 self.xmax.SetModified(False) 517 is_modified=False 518 519 self.manager.redraw_model( 520 float(self.xmin.GetValue()), 521 float(self.xmax.GetValue()) ) 522 516 is_modified = True 523 517 except: 524 518 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 525 "Model Drawing Error:wrong value entered : %s"% sys.exc_value)) 519 "Drawing Error:wrong value entered : %s"% sys.exc_value)) 520 # Here we should check whether the boundaries have been modified. 521 # If qmin and qmax have been modified, update qmin and qmax and 522 # set the is_modified flag to True 523 if float(self.xmin.GetValue()) != self.qmin: 524 self.qmin = float(self.xmin.GetValue()) 525 is_modified = True 526 if float(self.xmax.GetValue()) != self.qmax: 527 self.qmax = float(self.xmax.GetValue()) 528 is_modified = True 526 529 530 if is_modified: 531 532 self.manager.redraw_model( 533 qmin=self.qmin, qmax=self.qmax, 534 ) 535 #self.manager.draw_model(self,model,description=None, 536 # enable1D=True,qmin=None,qmax=None, qstep=None) 527 537 528 538 def select_all_param(self,event): -
sansview/perspectives/fitting/fitpanel.py
r86c1832 rd15c0202 122 122 @param page_title: the name of the page 123 123 """ 124 print "page_title fitpanel", page_title124 #print "page_title fitpanel", page_title 125 125 if self.draw_model_name ==None: 126 126 -
sansview/perspectives/fitting/fitting.py
rdb709e4 rd15c0202 611 611 qmax= 1.0 612 612 if qstep ==None: 613 qstep = 0.001613 qstep =100 614 614 615 615 #print "x in data1D",qmin,qmax 616 x = numpy.arange(qmin, qmax, qstep) 616 #x = numpy.arange(qmin, qmax, qstep) 617 x= numpy.linspace(start= qmin, 618 stop= qmax, 619 num= qstep, 620 endpoint=True 621 ) 617 622 xlen= len(x) 618 623 y = numpy.zeros(xlen) … … 620 625 for i in range(xlen): 621 626 y[i] = model.run(x[i]) 622 627 623 628 try: 624 629 new_plot = Theory1D(x, y) … … 635 640 for i in range(xlen): 636 641 y[i] = model.run(x[i]) 637 642 #print x, y 638 643 try: 639 644 new_plot = Theory1D(x, y) … … 655 660 wx.PostEvent(self.parent, StatusEvent(status="Calc \ 656 661 complete in %g sec" % elapsed)) 657 658 print "complete",output, model,qmin, qmax 662 #print "complete",output, model,qmin, qmax 659 663 data = output 660 664 theory= Data2D(data) 665 #print data.detector 666 #theory.detector= data.detector 667 from DataLoader.data_info import Detector, Source 668 669 detector = Detector() 670 theory.detector=[] 671 theory.detector.append(detector) 672 673 theory.detector[0].pixel_size.x= 5.0 674 theory.detector[0].pixel_size.y= 5.0 675 theory.source= Source() 676 theory.source.wavelength= 8.4 677 theory.detector[0].beam_center.x= 0 678 theory.detector[0].beam_center.y= 0 679 theory.detector[0].distance= 13705.0 680 661 681 theory.name= model.name 662 682 theory.group_id ="Model" 663 683 theory.id ="Model" 664 theory.xmin= qmin684 theory.xmin= -qmax 665 685 theory.xmax= qmax 666 theory.ymin= qmin686 theory.ymin= -qmax 667 687 theory.ymax= qmax 688 print "model draw comptele xmax",theory.xmax 668 689 wx.PostEvent(self.parent, NewPlotEvent(plot=theory, 669 690 title="Analytical model 2D %s" %str(model.name))) … … 673 694 def _draw_model2D(self,model,description=None, enable2D=False,qmin=None,qmax=None, qstep=None): 674 695 if qmin==None: 675 qmin= -0.05696 qmin= 0.0 676 697 if qmax==None: 677 698 qmax= 0.05 678 699 if qstep ==None: 679 qstep =0.001 680 x = numpy.arange(qmin,qmax, qstep) 681 y = numpy.arange(qmin,qmax,qstep) 700 qstep =100 701 702 x= numpy.linspace(start= -1*qmax, 703 stop= qmax, 704 num= qstep, 705 endpoint=True ) 706 y = numpy.linspace(start= -1*qmax, 707 stop= qmax, 708 num= qstep, 709 endpoint=True ) 710 682 711 lx = len(x) 683 712 #print x … … 686 715 if enable2D: 687 716 from model_thread import Calc2D 688 self.calc_thread = Calc2D(parent =self.parent,x=x, y=y,model= self.model, qmin=qmin,qmax=qmax, 717 self.calc_thread = Calc2D(parent =self.parent,x=x, 718 y=y,model= self.model, 719 qmin=qmin, 720 qmax=qmax, 689 721 completefn=self.complete, 690 722 updatefn=self.update) -
sansview/perspectives/fitting/model_thread.py
rdb709e4 rd15c0202 125 125 y = self.y 126 126 output = numpy.zeros((len(x),len(y))) 127 """ 127 128 if self.qmin *self.qmax >=0: 128 129 print "same signe plotting" … … 134 135 center_y= (self.qmax -self.qmin)/2 135 136 else: 136 center_x=0 137 center_y=0 137 """ 138 center_x=0 139 center_y=0 138 140 #print "center_x , center_y",center_x , center_y 139 141 #print "x ",len(x) … … 143 145 lx = len(self.x) 144 146 145 for i_x in range( int(len(self.x)/2)+1):146 147 # Check whether we need to bail out 148 self.update(output=output) 149 self.isquit() 150 151 for i_y in range(int(len(self.y) /2)+1):147 for i_x in range(len(self.x)): 148 149 # Check whether we need to bail out 150 self.update(output=output) 151 self.isquit() 152 153 for i_y in range(int(len(self.y))): 152 154 try: 153 value1 = self.model.runXY([self.x[i_x]-center_x, self.y[i_y]-center_y]) 154 value2 = self.model.runXY([self.x[i_x]-center_x, self.y[lx-i_y-1]-center_y]) 155 value3 = self.model.runXY([self.x[lx-i_x-1]-center_x, self.y[i_y]-center_y]) 156 value4 = self.model.runXY([self.x[lx-i_x-1]-center_x, self.y[lx-i_y-1]-center_y]) 155 if (self.x[i_x]*self.x[i_x]+self.y[i_y]*self.y[i_y]) \ 156 < self.qmin * self.qmin: 157 output[i_x] [i_y]=0 158 159 else: 160 value1 = self.model.runXY([self.x[i_x]-center_x, self.y[i_y]-center_y]) 161 162 163 output[i_x] [i_y]=value1 164 157 165 158 output[i_x] [i_y]=value1159 output[lx-i_x-1][lx-i_y-1] =value4160 output[i_x] [lx-i_y-1]= value2161 output[lx-i_x-1][i_y] = value3162 163 164 166 except: 165 167 wx.PostEvent(self.parent, StatusEvent(status=\ -
sansview/perspectives/fitting/modelpage.py
ra5aaec9 rd15c0202 73 73 self.sizer4.Add(wx.StaticText(self, -1, 'Min'),(iy, ix),(1,1),\ 74 74 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 75 ix += 275 ix += 1 76 76 self.sizer4.Add(wx.StaticText(self, -1, 'Max'),(iy, ix),(1,1),\ 77 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 78 ix += 1 79 self.sizer4.Add(wx.StaticText(self, -1, 'Npts'),(iy, ix),(1,1),\ 77 80 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 78 81 ix = 0 … … 83 86 self.qmin= 0.001 84 87 self.qmax= 0.1 88 self.num_points= 100 85 89 86 90 ix += 1 … … 93 97 94 98 95 ix += 299 ix += 1 96 100 self.xmax = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 97 101 self.xmax.SetValue(format_number(self.qmax)) … … 99 103 self.xmax.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 100 104 self.xmax.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter) 105 self.sizer4.Add(self.xmax,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 106 ix += 1 107 self.npts = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 108 self.npts.SetValue(format_number(self.num_points)) 109 self.npts.SetToolTipString("Number of point to plot.") 110 self.npts.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 111 self.npts.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter) 101 112 102 self.sizer4.Add(self. xmax,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)113 self.sizer4.Add(self.npts,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 103 114 ix = 0 104 115 iy += 1 … … 134 145 # preview selected model name 135 146 self.prevmodel_name=name 136 print "model view prev_model",name147 #print "model view prev_model",name 137 148 self.modelbox.SetValue(self.prevmodel_name) 138 149 # flag to check if the user has selected a new model in the combox box … … 388 399 self.qmax = float(self.xmax.GetValue()) 389 400 is_modified = True 401 if float(self.npts.GetValue()) != self.num_points: 402 self.qmax = float(self.npts.GetValue()) 403 is_modified = True 390 404 391 405 if is_modified: 392 406 self.manager.draw_model(self.model, self.model.name, 393 407 qmin=self.qmin, qmax=self.qmax, 408 qstep= self.num_points, 394 409 enable2D=self.enable2D) 395 410 #self.manager.draw_model(self,model,description=None,
Note: See TracChangeset
for help on using the changeset viewer.