Changeset 1245
 Timestamp:
 Mar 12, 2014 11:15:28 AM (8 years ago)
 Location:
 trunk
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIplot.py
r1244 r1245 699 699 Plot = Page.figure.gca() #get a fresh plot after clf() 700 700 except ValueError: 701 if plottype == 'SASD': 702 G2frame.logPlot = True 703 G2frame.ErrorBars = True 701 704 newPlot = True 702 705 G2frame.Cmax = 1.0 
trunk/GSASIIsasd.py
r1244 r1245 105 105 ''' Compute form factor for cylinders  can use numpy arrays 106 106 param float: Q Q value array (A1) 107 param float: L cylinder length (A)108 param float: Dcylinder diameter (A)107 param float: L cylinder half length (A) 108 param float: R cylinder diameter (A) 109 109 returns float: form factor 110 110 ''' 111 D= args[0]112 return CylinderFF(Q, D/2.,L)111 R = args[0] 112 return CylinderFF(Q,R,2.*L) 113 113 114 114 def CylinderARFF(Q,R,args): … … 205 205 ''' Compute cylinder volume for length & diameter 206 206  numpy array friendly 207 param float: L length (A)207 param float: L half length (A) 208 208 param float: D diameter (A) 209 209 returns float:volume (A^3) 210 210 ''' 211 return CylinderVol(D/2., L)211 return CylinderVol(D/2.,2.*L) 212 212 213 213 def CylinderARVol(R,AR): … … 322 322 ''' 323 323 324 TEST_LIMIT = 0. 10# for convergence324 TEST_LIMIT = 0.05 # for convergence 325 325 CHI_SQR_LIMIT = 0.01 # maximum difference in ChiSqr for a solution 326 326 SEARCH_DIRECTIONS = 3 # <10. This code requires value = 3 … … 482 482 chtarg = ctarg * chisq 483 483 return w, chtarg, loop, a_new, fx, beta 484 484 485 #MaxEnt_SB starts here 486 485 487 if image_to_data == None: 486 488 image_to_data = opus … … 583 585 584 586 # calculate the normalized entropy 585 S = sum((f/fSum) * numpy.log(f/fSum)) # normalized entropy, S&B eq. 1587 S = sum((f/fSum) * numpy.log(f/fSum)) # normalized entropy, S&B eq. 1 586 588 z = (datum  image_to_data (f, G)) / sigma # standardized residuals 587 589 chisq = sum(z*z) # report this ChiSq 588 590 589 591 if report: 590 print " %3d/%3d" % ((iter+1), IterMax)591 print " %5.2lf%%%8lg" % (100*test, S)592 print " MaxEnt trial/max: %3d/%3d" % ((iter+1), IterMax) 593 print " Residual: %5.2lf%% Entropy: %8lg" % (100*test, S) 592 594 if iter > 0: 593 595 value = 100*( math.sqrt(chisq/chtarg)1) 594 596 else: 595 597 value = 0 596 print " %12.5lg %10.4lf" % ( math.sqrt(chtarg/npt), value )597 print " %12.6lg %8.2lf\n" % (fSum,100*fChange/fSum)598 # print " %12.5lg %10.4lf" % ( math.sqrt(chtarg/npt), value ) 599 print " Function sum: %.6lg Change from last: %.2lf%%\n" % (fSum,100*fChange/fSum) 598 600 599 601 # See if we have finished our task. 600 602 # do the hardest test first 601 603 if (abs(chisq/chizer1.0) < CHI_SQR_LIMIT) and (test < TEST_LIMIT): 602 return f,image_to_data (f, G) # solution FOUND returns here 603 604 return f,image_to_data (f, G) # no solution after IterMax iterations 604 print ' Convergence achieved.' 605 return chisq,f,image_to_data(f, G) # solution FOUND returns here 606 print ' No convergence! Try increasing Error multiplier.' 607 return chisq,f,image_to_data(f, G) # no solution after IterMax iterations 605 608 606 609 … … 658 661 G = G_matrix(qVec,r,rhosq,SphereFF,SphereVol,args=()) 659 662 660 f_dr,Ic = MaxEnt_SB(I  bkg, dI*errFac, b, IterMax, G, report=report)663 chisq,f_dr,Ic = MaxEnt_SB(I  bkg, dI*errFac, b, IterMax, G, report=report) 661 664 if f_dr is None: 662 665 print "no solution" … … 698 701 Qmax = Limits[1][1] 699 702 Contrast = Sample['Contrast'][1] 703 wtFactor = ProfDict['wtFactor'] 700 704 Ibeg = np.searchsorted(Q,Qmin) 701 705 Ifin = np.searchsorted(Q,Qmax) … … 704 708 Ic[Ibeg:Ifin] = Back[0] 705 709 Gmat = G_matrix(Q[Ibeg:Ifin],Bins,Contrast,shapes[Shape][0],shapes[Shape][1],args=Parms) 706 BinMag,Ic[Ibeg:Ifin] = MaxEnt_SB(Io[Ibeg:Ifin]Back[0],1./np.sqrt(wt[Ibeg:Ifin]),BinsBack,707 data['Size']['MaxEnt']['Niter'],Gmat )708 print BinMag.shape709 data['Size']['Distribution'] = [Bins,Dbins,BinMag]710 print np.sum(BinMag)711 712 710 chisq,BinMag,Ic[Ibeg:Ifin] = MaxEnt_SB(Io[Ibeg:Ifin]Back[0],1./np.sqrt(wtFactor*wt[Ibeg:Ifin]),BinsBack, 711 data['Size']['MaxEnt']['Niter'],Gmat,report=True) 712 print ' Final chi^2: %.3f'%(chisq) 713 Vols = shapes[Shape][1](Bins,Parms) 714 data['Size']['Distribution'] = [Bins,Dbins,BinMag/(2.*Dbins)] 715 716
Note: See TracChangeset
for help on using the changeset viewer.