Changeset 599


Ignore:
Timestamp:
May 7, 2012 2:59:54 PM (9 years ago)
Author:
vondreele
Message:

GSASIIstruct.py - set up a DEBUG flag
comment out some dead code
begin inclusion of penalty fxns.
add Tutorials to help stuff

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r584 r599  
    126126        parent.Append(menu=self.Import, title='Import')
    127127        parent.Append(menu=self.Export, title='Export')
     128        parent.Append(menu=G2gd.MyHelp(self,helpType='Tutorials'),title='&Tutorials' )
    128129        parent.Append(menu=G2gd.MyHelp(self,helpType='Data tree'),title='&Help' )
    129130
  • trunk/GSASIIgrid.py

    r584 r599  
    3333htmlFrame = None
    3434if sys.platform.lower().startswith('win'):
    35 #    helpMode = 'browser'    # need a global control to set this
    36     helpMode = 'internal'    # need a global control to set this
     35    helpMode = 'browser'    # need a global control to set this
     36#    helpMode = 'internal'    # need a global control to set this
    3737else:
    3838    helpMode = 'browser'    # need a global control to set this
  • trunk/GSASIIstruct.py

    r584 r599  
    3333   
    3434ateln2 = 8.0*math.log(2.0)
     35DEBUG = False
    3536
    3637
     
    967968            for i,refl in enumerate(pawleyRef):
    968969                key = pfx+'PWLref:'+str(i)
    969                 refl[6] = abs(parmDict[key])        #suppress negative Fsq
     970                refl[6] = parmDict[key]
    970971                if key in sigDict:
    971972                    refl[7] = sigDict[key]
     
    17401741                PrintInstParmsSig(Inst,instSig)
    17411742                PrintBackgroundSig(Background,backSig)
     1743               
     1744################################################################################
     1745##### Penalty & restraint functions
     1746################################################################################
     1747
     1748def getPenalties():
     1749    return []
     1750   
     1751def penaltyFxn(penalties):
     1752    return []
     1753   
     1754def penaltyDeriv(penalties):
     1755    return []
    17421756
    17431757################################################################################
     
    24632477                if Phase['General'].get('doPawley'):
    24642478                    try:
    2465                         refl[9] = abs(parmDict[pfx+'PWLref:%d'%(pawleyLookup[pfx+'%d,%d,%d'%(h,k,l)])])
     2479                        refl[9] = parmDict[pfx+'PWLref:%d'%(pawleyLookup[pfx+'%d,%d,%d'%(h,k,l)])]
    24662480                    except KeyError:
    24672481#                        print ' ***Error %d,%d,%d missing from Pawley reflection list ***'%(h,k,l)
     
    25702584                if Phase['General'].get('doPawley'):
    25712585                    try:
    2572                         refl[9] = abs(parmDict[pfx+'PWLref:%d'%(pawleyLookup[pfx+'%d,%d,%d'%(h,k,l)])])
     2586                        refl[9] = parmDict[pfx+'PWLref:%d'%(pawleyLookup[pfx+'%d,%d,%d'%(h,k,l)])]
    25732587                    except KeyError:
    25742588#                        print ' ***Error %d,%d,%d missing from Pawley reflection list ***'%(h,k,l)
     
    27242738    return dMdv
    27252739
    2726 def dervRefine(values,HistoPhases,parmdict,varylist,calcControls,pawleyLookup,dlg):
     2740def dervRefine(values,HistoPhases,penalties,parmdict,varylist,calcControls,pawleyLookup,dlg):
    27272741    parmdict.update(zip(varylist,values))
    27282742    G2mv.Dict2Map(parmdict,varylist)
     
    27472761            else:
    27482762                dMdv = dMdvh
     2763    if penalties:
     2764        dmdv = np.concatenate((dmdv.T,penaltyDeriv(penalties).T)).T
    27492765    return dMdv
    27502766
    2751 def ComputePowderHessian(args):
    2752     Histogram,parmdict,varylist,Phases,calcControls,pawleyLookup = args
    2753     hId = Histogram['hId']
    2754     hfx = ':%d:'%(hId)
    2755     Limits = calcControls[hfx+'Limits']
    2756     x,y,w,yc,yb,yd = Histogram['Data']
    2757     dy = y-yc
    2758     xB = np.searchsorted(x,Limits[0])
    2759     xF = np.searchsorted(x,Limits[1])
    2760     dMdvh = np.sqrt(w[xB:xF])*getPowderProfileDerv(
    2761         parmdict,x[xB:xF],
    2762         varylist,Histogram,Phases,calcControls,pawleyLookup)
    2763     Vec = np.sum(dMdvh*np.sqrt(w[xB:xF])*dy[xB:xF],axis=1)
    2764     Hess = np.inner(dMdvh,dMdvh)
    2765     return Vec,Hess
    2766 
    2767 def HessRefine(values,HistoPhases,parmdict,varylist,calcControls,pawleyLookup,dlg):
     2767#def ComputePowderHessian(args):
     2768#    Histogram,parmdict,varylist,Phases,calcControls,pawleyLookup = args
     2769#    hId = Histogram['hId']
     2770#    hfx = ':%d:'%(hId)
     2771#    Limits = calcControls[hfx+'Limits']
     2772#    x,y,w,yc,yb,yd = Histogram['Data']
     2773#    dy = y-yc
     2774#    xB = np.searchsorted(x,Limits[0])
     2775#    xF = np.searchsorted(x,Limits[1])
     2776#    dMdvh = np.sqrt(w[xB:xF])*getPowderProfileDerv(
     2777#        parmdict,x[xB:xF],
     2778#        varylist,Histogram,Phases,calcControls,pawleyLookup)
     2779#    Vec = np.sum(dMdvh*np.sqrt(w[xB:xF])*dy[xB:xF],axis=1)
     2780#    Hess = np.inner(dMdvh,dMdvh)
     2781#    return Vec,Hess
     2782#
     2783def HessRefine(values,HistoPhases,penalties,parmdict,varylist,calcControls,pawleyLookup,dlg):
    27682784    parmdict.update(zip(varylist,values))
    27692785    G2mv.Dict2Map(parmdict,varylist)
     
    27952811    return Vec,Hess
    27962812
    2797 def ComputePowderProfile(args):
    2798     Histogram,parmdict,varylist,Phases,calcControls,pawleyLookup = args
    2799     hId = Histogram['hId']
    2800     hfx = ':%d:'%(hId)
    2801     x,y,w,yc,yb,yd = Histogram['Data']
    2802     Limits = calcControls[hfx+'Limits']
    2803     xB = np.searchsorted(x,Limits[0])
    2804     xF = np.searchsorted(x,Limits[1])
    2805     yc,yb = getPowderProfile(parmdict,x[xB:xF],varylist,Histogram,Phases,
    2806         calcControls,pawleyLookup)
    2807     return xB,xF,yc,yb,Histogram['Reflection Lists']
    2808 
    2809 def errRefine(values,HistoPhases,parmdict,varylist,calcControls,pawleyLookup,dlg):       
     2813#def ComputePowderProfile(args):
     2814#    Histogram,parmdict,varylist,Phases,calcControls,pawleyLookup = args
     2815#    hId = Histogram['hId']
     2816#    hfx = ':%d:'%(hId)
     2817#    x,y,w,yc,yb,yd = Histogram['Data']
     2818#    Limits = calcControls[hfx+'Limits']
     2819#    xB = np.searchsorted(x,Limits[0])
     2820#    xF = np.searchsorted(x,Limits[1])
     2821#    yc,yb = getPowderProfile(parmdict,x[xB:xF],varylist,Histogram,Phases,
     2822#        calcControls,pawleyLookup)
     2823#    return xB,xF,yc,yb,Histogram['Reflection Lists']
     2824#
     2825def errRefine(values,HistoPhases,penalties,parmdict,varylist,calcControls,pawleyLookup,dlg):       
    28102826    parmdict.update(zip(varylist,values))
    28112827    Values2Dict(parmdict, varylist, values)
     
    28512867            parmDict['saved values'] = values
    28522868            raise Exception         #Abort!!
     2869    if penalties:
     2870        M = np.concatenate((M,penaltyFxn(penalties)))
    28532871    return M
    28542872                       
     
    29132931        begin = time.time()
    29142932        values =  np.array(Dict2Values(parmDict, varyList))
     2933        penalties = getPenalties()
    29152934        Ftol = Controls['min dM/M']
    29162935        Factor = Controls['shift factor']
     
    29192938            result = so.leastsq(errRefine,values,Dfun=dervRefine,full_output=True,
    29202939                ftol=Ftol,col_deriv=True,factor=Factor,
    2921                 args=([Histograms,Phases],parmDict,varyList,calcControls,pawleyLookup,dlg))
     2940                args=([Histograms,Phases],penalties,parmDict,varyList,calcControls,pawleyLookup,dlg))
    29222941            ncyc = int(result[2]['nfev']/2)
    29232942        elif 'Hessian' in Controls['deriv type']:
    29242943            result = G2mth.HessianLSQ(errRefine,values,Hess=HessRefine,ftol=Ftol,maxcyc=maxCyc,
    2925                 args=([Histograms,Phases],parmDict,varyList,calcControls,pawleyLookup,dlg))
     2944                args=([Histograms,Phases],penalties,parmDict,varyList,calcControls,pawleyLookup,dlg))
    29262945            ncyc = result[2]['num cyc']+1
    29272946            Rvals['lamMax'] = result[2]['lamMax']                           
    29282947        else:           #'numeric'
    29292948            result = so.leastsq(errRefine,values,full_output=True,ftol=Ftol,epsfcn=1.e-8,factor=Factor,
    2930                 args=([Histograms,Phases],parmDict,varyList,calcControls,pawleyLookup,dlg))
     2949                args=([Histograms,Phases],penalties,parmDict,varyList,calcControls,pawleyLookup,dlg))
    29312950            ncyc = int(result[2]['nfev']/len(varyList))
    29322951#        table = dict(zip(varyList,zip(values,result[0],(result[0]-values))))
     
    29913010   
    29923011#for testing purposes!!!
    2993 #    import cPickle
    2994 #    fl = open('structTestdata.dat','wb')
    2995 #    cPickle.dump(parmDict,fl,1)
    2996 #    cPickle.dump(varyList,fl,1)
    2997 #    for histogram in Histograms:
    2998 #        if 'PWDR' in histogram[:4]:
    2999 #            Histogram = Histograms[histogram]
    3000 #    cPickle.dump(Histogram,fl,1)
    3001 #    cPickle.dump(Phases,fl,1)
    3002 #    cPickle.dump(calcControls,fl,1)
    3003 #    cPickle.dump(pawleyLookup,fl,1)
    3004 #    fl.close()
     3012    if DEBUG:
     3013        import cPickle
     3014        fl = open('structTestdata.dat','wb')
     3015        cPickle.dump(parmDict,fl,1)
     3016        cPickle.dump(varyList,fl,1)
     3017        for histogram in Histograms:
     3018            if 'PWDR' in histogram[:4]:
     3019                Histogram = Histograms[histogram]
     3020        cPickle.dump(Histogram,fl,1)
     3021        cPickle.dump(Phases,fl,1)
     3022        cPickle.dump(calcControls,fl,1)
     3023        cPickle.dump(pawleyLookup,fl,1)
     3024        fl.close()
    30053025
    30063026    if dlg:
     
    30963116        while True:
    30973117            begin = time.time()
    3098             values =  np.array(Dict2Values(parmDict, varyList))
     3118            values =  np.array(Dict2Values(parmDict,varyList))
     3119            penalties = getPenalties()
    30993120            Ftol = Controls['min dM/M']
    31003121            Factor = Controls['shift factor']
     
    31043125                result = so.leastsq(errRefine,values,Dfun=dervRefine,full_output=True,
    31053126                    ftol=Ftol,col_deriv=True,factor=Factor,
    3106                     args=([Histo,Phases],parmDict,varyList,calcControls,pawleyLookup,dlg))
     3127                    args=([Histo,Phases],penalties,parmDict,varyList,calcControls,pawleyLookup,dlg))
    31073128                ncyc = int(result[2]['nfev']/2)
    31083129            elif 'Hessian' in Controls['deriv type']:
    31093130                result = G2mth.HessianLSQ(errRefine,values,Hess=HessRefine,ftol=Ftol,maxcyc=maxCyc,
    3110                     args=([Histo,Phases],parmDict,varyList,calcControls,pawleyLookup,dlg))
     3131                    args=([Histo,Phases],penalties,parmDict,varyList,calcControls,pawleyLookup,dlg))
    31113132                ncyc = result[2]['num cyc']+1                           
    31123133            else:           #'numeric'
    31133134                result = so.leastsq(errRefine,values,full_output=True,ftol=Ftol,epsfcn=1.e-8,factor=Factor,
    3114                     args=([Histo,Phases],parmDict,varyList,calcControls,pawleyLookup,dlg))
     3135                    args=([Histo,Phases],penalties,parmDict,varyList,calcControls,pawleyLookup,dlg))
    31153136                ncyc = int(result[2]['nfev']/len(varyList))
    31163137
  • trunk/help/gsasII.html

    r592 r599  
    2525  <o:Author>Von Dreele</o:Author>
    2626  <o:LastAuthor>Von Dreele</o:LastAuthor>
    27   <o:Revision>84</o:Revision>
     27  <o:Revision>86</o:Revision>
    2828  <o:TotalTime>2820</o:TotalTime>
    2929  <o:Created>2011-11-28T16:49:00Z</o:Created>
    30   <o:LastSaved>2012-05-07T03:17:00Z</o:LastSaved>
    31   <o:Pages>9</o:Pages>
     30  <o:LastSaved>2012-05-07T19:57:00Z</o:LastSaved>
     31  <o:Pages>8</o:Pages>
    3232  <o:Words>7204</o:Words>
    33   <o:Characters>41066</o:Characters>
     33  <o:Characters>41065</o:Characters>
    3434  <o:Company>Argonne National Laboratory</o:Company>
    3535  <o:Lines>342</o:Lines>
    3636  <o:Paragraphs>96</o:Paragraphs>
    37   <o:CharactersWithSpaces>48174</o:CharactersWithSpaces>
     37  <o:CharactersWithSpaces>48173</o:CharactersWithSpaces>
    3838  <o:Version>14.00</o:Version>
    3939 </o:DocumentProperties>
     
    605605        mso-font-kerning:14.0pt;}
    606606a:link, span.MsoHyperlink
    607         {mso-style-priority:99;
     607        {mso-style-noshow:yes;
     608        mso-style-priority:99;
    608609        color:blue;
    609610        text-decoration:underline;
     
    19631964 <o:lock v:ext="edit" aspectratio="t"/>
    19641965</v:shapetype><v:shape id="Picture_x0020_2" o:spid="_x0000_s1026" type="#_x0000_t75"
    1965  alt="Description: Description: Description: Description: Description: GSAS-II logo"
     1966 alt="Description: Description: Description: Description: Description: Description: Description: GSAS-II logo"
    19661967 style='position:absolute;margin-left:44.8pt;margin-top:0;width:96pt;height:96pt;
    19671968 z-index:251657728;visibility:visible;mso-wrap-style:square;
     
    19761977</v:shape><![endif]--><![if !vml]><img width=128 height=128 src=gsas2logo.png
    19771978align=right
    1978 alt="Description: Description: Description: Description: Description: GSAS-II logo"
     1979alt="Description: Description: Description: Description: Description: Description: Description: GSAS-II logo"
    19791980v:shapes="Picture_x0020_2"><![endif]><span style='mso-fareast-font-family:"Times New Roman"'>Help
    19801981for GSAS-II<o:p></o:p></span></h1>
     
    19921993<p class=MsoNormal><span style='mso-fareast-font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p>
    19931994
    1994 <h2><strong>GSAS-II tutorials:<o:p></o:p></strong></h2>
     1995<h2><a name=Tutorials><strong>GSAS-II tutorials</strong></a><strong>:<o:p></o:p></strong></h2>
    19951996
    19961997<p class=MsoNormal><strong><a href="Starting%20GSAS.htm"><span
     
    20122013
    20132014<p class=MsoNormal><strong><a href="Neutron%20CW%20Powder%20Data.htm"><span
    2014 style='font-weight:normal'>CW Neutron powder pattern Rietveld refi</span><span
    2015 style='font-weight:normal'>nement with constraints</span></a><o:p></o:p></strong></p>
     2015style='font-weight:normal'>CW Neutron powder pattern Rietveld refinement with
     2016constraints</span></a><o:p></o:p></strong></p>
    20162017
    20172018<p class=MsoNormal><strong>Synchrotron X-ray powder pattern Rietveld refinement
     
    22282229pair distribution function (PDF) controls for each powder pattern selected in
    22292230the dialog box. See <b style='mso-bidi-font-weight:normal'><span
    2230 style='color:#4F81BD;mso-themecolor:accent1'><a href="#PDF_Controls">PDF Controls</a></span></b>
    2231 for further directions.</p>
     2231style='color:#4F81BD;mso-themecolor:accent1'><a href="#PDF_Controls">PDF
     2232Controls</a></span></b> for further directions.</p>
    22322233
    22332234<p class=MsoListParagraphCxSpMiddle style='margin-left:1.0in;mso-add-space:
     
    38713872mso-no-proof:yes'><img border=0 width=225 height=31 id="_x0000_i1032"
    38723873src=graphbar.jpg
    3873 alt="Description: Description: Description: Description: Description: D:\pyGSAS\help\graphbar.jpg"></span><span
     3874alt="Description: Description: Description: Description: Description: Description: Description: D:\pyGSAS\help\graphbar.jpg"></span><span
    38743875style='mso-fareast-font-family:"Times New Roman"'><o:p></o:p></span></p>
    38753876
  • trunk/help/gsasII_files/props011.xml

    r592 r599  
    11<?xml version="1.0" encoding="UTF-8" standalone="no"?>
    2 <ds:datastoreItem ds:itemID="{2F27EE4F-99E9-45F4-AE92-593783FDEC2E}" xmlns:ds="http://schemas.openxmlformats.org/officeDocument/2006/customXml"><ds:schemaRefs><ds:schemaRef ds:uri="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"/></ds:schemaRefs></ds:datastoreItem>
     2<ds:datastoreItem ds:itemID="{FB1632E6-7E53-4F7F-9F33-A4BD693EF3DE}" xmlns:ds="http://schemas.openxmlformats.org/officeDocument/2006/customXml"><ds:schemaRefs><ds:schemaRef ds:uri="http://schemas.openxmlformats.org/officeDocument/2006/bibliography"/></ds:schemaRefs></ds:datastoreItem>
Note: See TracChangeset for help on using the changeset viewer.