Changeset 4664


Ignore:
Timestamp:
Nov 29, 2020 8:41:57 PM (11 months ago)
Author:
toby
Message:

pretty up Controls panel; add & update help

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r4660 r4664  
    65416541        seqSizer = wx.BoxSizer(wx.VERTICAL)
    65426542        dataSizer = wx.BoxSizer(wx.HORIZONTAL)
    6543         dataSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Sequential Refinement: '),0,WACV)
    6544         selSeqData = wx.Button(G2frame.dataWindow,-1,label=' Select data')
     6543        SeqData = data.get('Seq Data',[])
     6544        if not SeqData:
     6545            dataSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Select datasets to switch to sequential refinement: '),0,WACV)
     6546            selSeqData = wx.Button(G2frame.dataWindow,label='Select datasets')
     6547        else:
     6548            lbl = 'Sequential Refinement with '+str(len(SeqData))+' dataset(s) selected'
     6549            dataSizer.Add(wx.StaticText(G2frame.dataWindow,label=lbl),0,WACV)
     6550            selSeqData = wx.Button(G2frame.dataWindow,label=' Reselect datasets')           
    65456551        selSeqData.Bind(wx.EVT_BUTTON,OnSelectData)
    65466552        dataSizer.Add(selSeqData,0,WACV)
    6547         SeqData = data.get('Seq Data',[])
    6548         if not SeqData:
    6549             lbl = ' (no data selected)'
    6550         else:
    6551             lbl = ' ('+str(len(SeqData))+' dataset(s) selected)'
    6552 
    6553         dataSizer.Add(wx.StaticText(G2frame.dataWindow,label=lbl),0,WACV)
    6554         seqSizer.Add(dataSizer,0)
     6553        seqSizer.Add(dataSizer)
    65556554        if SeqData:
    65566555            selSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    65636562            copySel.SetValue(data['Copy2Next'])
    65646563            selSizer.Add(copySel,0,WACV)
    6565             clrSeq = wx.Button(G2frame.dataWindow,label='Clear previous seq.results')
     6564            clrSeq = wx.Button(G2frame.dataWindow,label='Clear previous seq. results')
    65666565            clrSeq.Bind(wx.EVT_BUTTON,OnClrSeq)
    65676566            selSizer.Add(clrSeq,0,WACV)
     
    65976596           
    65986597        LSSizer = wx.FlexGridSizer(cols=4,vgap=5,hgap=5)
    6599         LSSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Refinement derivatives: '),0,WACV)
     6598
     6599        tmpSizer=wx.BoxSizer(wx.HORIZONTAL)
     6600        tmpSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Refinement type: '),0,WACV)
     6601        tmpSizer.Add(G2G.HelpButton(G2frame.dataWindow,helpIndex='RefineType'))
     6602        LSSizer.Add(tmpSizer,0,WACV)
    66006603        Choice=['analytic Jacobian','numeric','analytic Hessian','Hessian SVD']   #TODO +'SVD refine' - what flags will it need?
    66016604        derivSel = wx.ComboBox(parent=G2frame.dataWindow,value=data['deriv type'],choices=Choice,
     
    66276630            Factr = G2G.ValidatedTxtCtrl(G2frame.dataWindow,data,'shift factor',nDig=(10,5),xmin=1.e-5,xmax=100.)
    66286631            LSSizer.Add(Factr,0,WACV)
     6632
     6633        ShklSizer = None
    66296634        if G2frame.Sngl:
     6635            ShklSizer = wx.FlexGridSizer(cols=4,vgap=5,hgap=5)
    66306636            userReject = data['UsrReject']
    66316637            usrRej = {'minF/sig':[' Min obs/sig (0-5): ',[0.,5.], ],'MinExt':[' Min extinct. (0-.9): ',[0.,.9],],
     
    66366642            fsqRef.SetValue(data['F**2'])
    66376643            fsqRef.Bind(wx.EVT_CHECKBOX,OnFsqRef)
    6638             LSSizer.Add(fsqRef,0,WACV)
    6639             LSSizer.Add((1,0),)
     6644            ShklSizer.Add(fsqRef,0,WACV)
     6645            ShklSizer.Add((1,0),)
    66406646            for item in usrRej:
    6641                 LSSizer.Add(wx.StaticText(G2frame.dataWindow,-1,label=usrRej[item][0]),0,WACV)
     6647                ShklSizer.Add(wx.StaticText(G2frame.dataWindow,-1,label=usrRej[item][0]),0,WACV)
    66426648                usrrej = G2G.ValidatedTxtCtrl(G2frame.dataWindow,userReject,item,nDig=(10,2),
    66436649                    xmin=usrRej[item][1][0],xmax=usrRej[item][1][1])
    6644                 LSSizer.Add(usrrej,0,WACV)
    6645         return LSSizer
     6650                ShklSizer.Add(usrrej,0,WACV)
     6651        return LSSizer,ShklSizer
    66466652       
    66476653    def AuthSizer():
     
    66776683    subSizer.Add(wx.StaticText(G2frame.dataWindow,label='Refinement Controls'),0,WACV)   
    66786684    subSizer.Add((-1,-1),1,wx.EXPAND)
     6685    subSizer.Add(G2G.HelpButton(G2frame.dataWindow,helpIndex='Controls'))
    66796686    mainSizer.Add(subSizer,0,wx.EXPAND)
    66806687    mainSizer.Add((5,5),0)
    6681     mainSizer.Add(LSSizer())
    6682     mainSizer.Add((5,5),0)
     6688    LSSizer,ShklSizer = LSSizer()
     6689    mainSizer.Add(LSSizer)
     6690    if ShklSizer:
     6691        mainSizer.Add((5,15),0)
     6692        G2G.HorizontalLine(mainSizer,G2frame.dataWindow)
     6693        subSizer = wx.BoxSizer(wx.HORIZONTAL)
     6694        subSizer.Add((-1,-1),1,wx.EXPAND)
     6695        subSizer.Add(wx.StaticText(G2frame.dataWindow,label='Single Crystal Refinement Settings'),0,WACV)   
     6696        subSizer.Add((-1,-1),1,wx.EXPAND)
     6697        mainSizer.Add(subSizer,0,wx.EXPAND)
     6698        mainSizer.Add(ShklSizer)
     6699       
     6700    mainSizer.Add((5,15),0)
     6701    G2G.HorizontalLine(mainSizer,G2frame.dataWindow)
     6702    subSizer = wx.BoxSizer(wx.HORIZONTAL)
     6703    subSizer.Add((-1,-1),1,wx.EXPAND)
     6704    subSizer.Add(wx.StaticText(G2frame.dataWindow,label='Sequential Settings'),0,WACV)   
     6705    subSizer.Add((-1,-1),1,wx.EXPAND)
     6706    mainSizer.Add(subSizer,0,wx.EXPAND)
    66836707    mainSizer.Add(SeqSizer())
    6684     mainSizer.Add((5,5),0)
     6708    mainSizer.Add((5,15),0)
     6709    G2G.HorizontalLine(mainSizer,G2frame.dataWindow)
     6710    subSizer = wx.BoxSizer(wx.HORIZONTAL)
     6711    subSizer.Add((-1,-1),1,wx.EXPAND)
     6712    subSizer.Add(wx.StaticText(G2frame.dataWindow,label='Global Settings'),0,WACV)   
     6713    subSizer.Add((-1,-1),1,wx.EXPAND)
     6714    mainSizer.Add(subSizer,0,wx.EXPAND)
    66856715    mainSizer.Add(AuthSizer())
    66866716    mainSizer.Add((5,5),0)
     
    67156745    G2frame.dataWindow.SetDataSize()
    67166746    G2frame.SendSizeEvent()
    6717      
     6747   
    67186748################################################################################
    67196749#####  Display of Sequential Results
  • trunk/help/gsasII.html

    r4659 r4664  
    36773677
    36783678<p class=MsoNormal style='margin-left:.5in'><span style='mso-fareast-font-family:
    3679 "Times New Roman"'>This window provides the main controls for the refinement
    3680 calculations in GSAS-II. Two of the main refinement tools are the <span
    3681 class=SpellE>fortran</span> MINPACK <span class=SpellE>lmdif</span> and <span
    3682 class=SpellE>lmder</span> algorithms wrapped in python as provided in the <span
    3683 class=SpellE>Scipy</span> package and a third one is a python version utilizing
    3684 only the <span class=SpellE>numpy</span> package. The purpose is to </span>minimize
     3679"Times New Roman"'>This window provides the main controls and a few
     3680global parameters for GSAS-II.
     3681
     3682<h5 style='margin-left:.5in'><span
     3683style='mso-fareast-font-family:"Times New Roman"'>
     3684What can I do here?</span></h5>
     3685<p style='margin-left:0.75in'>On this page, there are three or four sets of
     3686controls. The first is for how refinements operate.
     3687</p>
     3688<A name="RefineType"></A>
     3689<DL style='margin-left:1.0in'>
     3690  <DT><B>Refinement type</B></DT>
     3691  <DD>This determines how refinements are performed. The choices
     3692    are:</DD>
     3693    <UL style='margin-left:0.25in'>
     3694      <LI><U>analytic Hessian</U>: This is the default option and is usually
     3695      the most useful. It uses as custom-developed least-squares
     3696      minimizer that uses singular-value decomposition (SVD) to reduce the
     3697      errors caused by correlated variables and the
     3698      Levenberg-Marquardt algorithm to down-weight the off-diagonal
     3699      Hessian terms when refinements fail to lower χ<sup>2</sup>.
     3700      <LI><u>analytic Jacobian</u>: This uses a numpy-provided <I>leastsq</I>
     3701      minimizer, which not applicable for larger
     3702      problems as it requires
     3703      much more memory than the Hessian routines. This because it
     3704      creates a Jacobian matrix is shaped N x M (N parameters x M
     3705      observations) and uses that to create the N x N Hessian. The
     3706      "Hessian" minimizers create the Hessian matrix directly.
     3707      <LI><u>numeric</u>: This also uses the numpy <I>leastsq</I>
     3708      minimizer, and is also not applicable for larger
     3709      problems. Unlike, the "analytic Jacobian", numerical derivates
     3710      are computed for derivatives rather than analytical derivatives
     3711      that are coded directly into GSAS-II. This will be slower than
     3712      the analytical derivatives and will converge more slowly. It is
     3713      typically used for code development to check the accuracy of the
     3714      analytical derivative formulations.
     3715      <LI><u>Hessian SVD</u>: This is very similar to <U>analytic
     3716      Hessian</U> but does not include the Levenberg-Marquardt
     3717      algorithm. It can be faster, but is more prone to
     3718      diverge when severe correlation is present.
     3719    </UL>
     3720<p style='margin-left:0.25in'>
     3721Note that the Jacobian refinement tools are the Fortran
     3722MINPACK <I>lmdif</I > and <I>lmder</I> algorithms wrapped in python as
     3723provided in the <span class=SpellE>Scipy</span> package. The
     3724Hessian routines are were developed for GSAS-II based on routines in
     3725numpy and scipy and using the material in Numerical Recipes (Press, Flannery, <span class=SpellE>Teulosky</span>
     3726&amp; <span class=SpellE>Vetterling</span>) for the <span
     3727class=SpellE>Levenberg</span>-Marquardt.
     3728The purpose is to </span>minimize
    36853729the sum of the squares of M<span style='mso-fareast-font-family:"Times New Roman"'>
    36863730nonlinear functions in N variables by a modification of the <span class=SpellE>Levenberg</span>-Marquardt
     
    36883732routines were written by </span>Burton S. <span class=SpellE>Garbow</span>,
    36893733Kenneth E. <span class=SpellE>Hillstrom</span>, Jorge J. More (Argonne National
    3690 Laboratory, 1980). The python/numpy version was developed by us based on the
    3691 material in Numerical Recipes (Press, Flannery, <span class=SpellE>Teulosky</span>
    3692 &amp; <span class=SpellE>Vetterling</span>) for the <span class=SpellE>Levenberg</span>-Marquardt
    3693 algorithm and is the default.<span style='mso-fareast-font-family:"Times New Roman"'><o:p></o:p></span></p>
    3694 
    3695 <h5 style='margin-left:.5in'><span
    3696 style='mso-fareast-font-family:"Times New Roman"'>
    3697 What can I do here?</span></h5>
    3698 
    3699 <p class=MsoListParagraphCxSpFirst style='margin-left:1.0in;mso-add-space:auto;
    3700 text-indent:-.25in;mso-list:l22 level1 lfo9'><![if !supportLists]><span
    3701 style='mso-fareast-font-family:"Times New Roman"'><span style='mso-list:Ignore'>1.<span
    3702 style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span
    3703 style='mso-fareast-font-family:"Times New Roman"'>Select whether the refinement
    3704 uses ‘analytic Jacobian’, ‘analytic Hessian’ or ‘numeric’ derivatives. The last
    3705 is slower and perhaps a bit less accurate, but may be needed if the analytic
    3706 functions are not fully developed. The Jacobian matrix is shaped N x M
    3707 (parameters x observations) and is much larger than the Hessian matrix which is
    3708 shaped M x M (parameters x parameters). Generally use ‘analytic Hessian’ for
    3709 routine work.<o:p></o:p></span></p>
    3710 
    3711 <p class=MsoListParagraphCxSpMiddle style='margin-left:1.0in;mso-add-space:
    3712 auto;text-indent:-.25in;mso-list:l22 level1 lfo9'><![if !supportLists]><span
    3713 style='mso-fareast-font-family:"Times New Roman"'><span style='mso-list:Ignore'>2.<span
    3714 style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span
    3715 style='mso-fareast-font-family:"Times New Roman"'>Select ‘Min delta-M/M’ for
    3716 convergence; the refinement will stop when the change in the minimization
    3717 function is less than this value. Set Min delta-M/M = 1.0 to force just a
    3718 single cycle to be performed. A value less than 10<sup>-4</sup> (the default)
    3719 generally gives no better result. The allowed range is 10<sup>-9</sup> to 1.0.<o:p></o:p></span></p>
    3720 
    3721 <p class=MsoListParagraphCxSpMiddle style='margin-left:1.0in;mso-add-space:
    3722 auto;text-indent:-.25in;mso-list:l22 level1 lfo9'><![if !supportLists]><span
    3723 style='mso-fareast-font-family:"Times New Roman"'><span style='mso-list:Ignore'>3.<span
    3724 style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span
    3725 style='mso-fareast-font-family:"Times New Roman"'>If ‘analytic Jacobean’ is
    3726 chosen then select ‘Initial shift factor’ for the first cycle of refinement.
    3727 This value is modified by the least squares routine. The allowed range is 10<sup>-5</sup>
    3728 to 100. Smaller values may be needed if your initial refinement trials
    3729 immediately diverge, however make sure your starting parameter values are
    3730 ‘reasonable’. The selected default (=1.0) normally gives good performance.<o:p></o:p></span></p>
    3731 
    3732 <p class=MsoListParagraphCxSpMiddle style='margin-left:1.0in;mso-add-space:
    3733 auto;text-indent:-.25in;mso-list:l22 level1 lfo9'><![if !supportLists]><span
    3734 style='mso-fareast-font-family:"Times New Roman"'><span style='mso-list:Ignore'>4.<span
    3735 style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span
    3736 style='mso-fareast-font-family:"Times New Roman"'>If ‘analytic Hessian’ is
    3737 chosen then select ‘Max cycles’, the maximum number of least squares cycles to
    3738 be performed. Least squares cycles are determined by the number of times a new
    3739 Hessian matrix is computes; the <span class=SpellE>Levenberg</span>-Marquardt
    3740 algorithm may compute the function several times between cycles as it finds the
    3741 optimal value of the Marquardt coefficient. Choices are given in the pull down
    3742 selection; the default is 3 cycles.<o:p></o:p></span></p>
    3743 
    3744 <p class=MsoListParagraphCxSpLast style='margin-left:1.0in;mso-add-space:auto;
    3745 text-indent:-.25in;mso-list:l22 level1 lfo9'><![if !supportLists]><span
    3746 style='mso-fareast-font-family:"Times New Roman"'><span style='mso-list:Ignore'>5.<span
    3747 style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><![endif]><span
    3748 style='mso-fareast-font-family:"Times New Roman"'>Select data for sequential
    3749 refinement; the data sets may be done in ‘reverse order’. <o:p></o:p></span></p>
     3734Laboratory, 1980).
     3735</p>
     3736  <DT><B>Min delta-M/M</B></DT>
     3737  <DD>This determines when convergence is recognized;
     3738    the refinement will stop when the change in the minimization
     3739    function is less than this value. Set Min delta-M/M = 1.0 to force just a
     3740single cycle to be performed. The default is 0.001. A value less than
     3741    10<sup>-4</sup> causes the refinement to cycle with no meaningful
     3742    improvement since shifts become a small fraction of the
     3743    parameter's uncertainties. Set Min delta-M/M = 1.0 to force
     3744    refinement to stop after a single refinement.
     3745    The allowed range is 10<sup>-9</sup> to 1.0.
     3746  </DD>
     3747  <DT><B>Max cycles</B></DT>
     3748  <DD>This determines the maximum number of refinement cycles that
     3749    will be performed. This is only available with the "Hessian" minimizers.</DD>
     3750  <DT><B>Initial lambda</B></DT>
     3751  <DD>Note that here λ is the Marquardt coefficient, which when large
     3752    down-weights the significance of the off-diagonal terms in the
     3753    Hessian. Thus, when λ is large, the refinement is effectively one of
     3754    steepest-descents, where correlation between variables is
     3755    ignored. Note that steepest-descents minimization is typically
     3756    slow and may not always find the local minimum.
     3757    This is only available with the "analytical Hessian" minimizer.
     3758  </DD>
     3759  <DT><B>SVD zero tolerance</B></DT>
     3760  <DD>This determines the level where SVD considers values to be the
     3761    same. Default is 10<sup>-6</sup>. Make larger to where problems occur due to correlation. This is only available with the "Hessian" minimizers.
     3762  </DD>
     3763  <DT><B>Initial shift factor</B></DT>
     3764  <DD>?
     3765  </DD>
     3766</DL>
     3767  <A name="SingleXtlSettings"></A>
     3768<p style='margin-left:0.75in'>A set of controls is provided for
     3769control of single-crystal refinements.
     3770These only appear when single crystal (HKLF) histograms are present
     3771in the project.
     3772</p>
     3773<DL style='margin-left:1.0in'>
     3774  <DT><B>Refine HKLF as F^2?</B></DT>
     3775  <DD>When checked, refinements are against F<sup>2</sup> rather than
     3776    |F|.
     3777  </DD>
     3778  <DT><B>Min obs/sig</B></DT>
     3779  <DD>?
     3780  </DD>
     3781  <DT><B>Min extinct.</B></DT>
     3782  <DD>?
     3783  </DD>
     3784  <DT><B>Max delt-F/sig</B></DT>
     3785  <DD>?
     3786  </DD>
     3787  <DT><B>Max d-spacing</B></DT>
     3788  <DD>Reflections with d-space values larger than this value are ignored.
     3789  </DD>
     3790  <DT><B>Min d-spacing</B></DT>
     3791  <DD>Reflections with d-space values smaller than this value are ignored.
     3792  </DD>
     3793 
     3794</DL>
     3795
     3796  <A name="SequentialSettings"></A>
     3797<p style='margin-left:0.75in'>A set of controls is for
     3798sequential refinement. Settings here determine if "normal" or "sequential"
     3799refinement is performed. If no datasets are selected, then all "used"
     3800histograms are included in one combined refinement. However, if any
     3801number histogram are selected used here, then a
     3802sequential refinement is performed, where a fit is made to each
     3803histogram in turn. Only the first item below is shown in "normal" mode.
     3804</p>
     3805<DL style='margin-left:1.0in'>
     3806  <DT><B>Select datasets/Reselect Datasets</B></DT>
     3807  <DD>This brings up a menu where histograms can be selected, which
     3808    potentially switches between a normal and a sequential refinement.
     3809    If one or more histograms are selected, a sequential
     3810    refinement is used. If none are selected, then the refinement be
     3811    set as "normal". The button is labeled "Select" when in normal refinement
     3812    mode and "Reselect" in sequential refinement mode.
     3813    </DD>
     3814  <DT><B>Reverse order?</B></DT>
     3815  <DD>Normally, in a sequential histograms are fit in the order they
     3816    are in the data tree (which can be reordered by dragging tree
     3817    items),
     3818    but when this option is selected, the sequential fit is performed
     3819    with the last tree entry first.
     3820  </DD>
     3821  <DT><B>Copy results to next histogram?</B></DT>
     3822  <DD>When this option is selected, the fitted parameters from each
     3823    refinement are copied to the next histogram, so that the starting
     3824    point for each refinement will be the results from fitting the
     3825    previous. This works well for parametric experiments where
     3826    parameters such as the lattice parameters change gradually over
     3827    the course of successive measurements.
     3828    This option is usually used only for the initial refinement after
     3829    a sequential fit is started and the setting is reset once that
     3830    refinement is completed. For subsequent refinements, it is usually
     3831    better to start with the results from the previous fit.
     3832  </DD>
     3833  <DT><B>Clear previous seq. results</B></DT>
     3834  <DD>When this button is pressed, the "Sequential Results" entry
     3835    with the results from the last sequential fit is deleted from the
     3836    tree.
     3837  </DD>
     3838</DL>
    37503839
    37513840<h4 style='margin-left:0.25in'><a
     
    74437532<hr size=2 width="100%" align=center>
    74447533
    7445 <!-- hhmts start -->Last modified: Sat Nov 21 12:25:40 CST 2020 <!-- hhmts end -->
     7534<!-- hhmts start -->Last modified: Sun Nov 29 20:05:28 CST 2020 <!-- hhmts end -->
    74467535
    74477536</div>
Note: See TracChangeset for help on using the changeset viewer.