Changeset 4124


Ignore:
Timestamp:
Aug 29, 2019 5:56:28 PM (2 years ago)
Author:
toby
Message:

scriptable docs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIscriptable.py

    r4120 r4124  
    4747    gpx.set_refinement(pardict)
    4848
    49 GSASIIscriptable can be used to setup and start sequential refinements. This script
    50 is used to take the single-dataset fit at the end of Step 1 of the
    51 `Sequential Refinement tutorial <https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/SeqRefine/SequentialTutorial.htm>`
    52 and turn off refinement flags, add histograms and setup the sequential fit, which is then run:
    53 
    54 .. code-block::  python
    55 
    56     import os,sys,glob
    57     sys.path.insert(0,'/Users/toby/software/G2/GSASII')
    58     import GSASIIscriptable as G2sc
    59     datadir = os.path.expanduser("~/Scratch/SeqTut2019Mar")
    60     PathWrap = lambda fil: os.path.join(datadir,fil)
    61     # load and rename project
    62     gpx = G2sc.G2Project(PathWrap('7Konly.gpx'))
    63     gpx.save(PathWrap('SeqRef.gpx'))
    64     # turn off some variables; turn on Dijs
    65     for p in gpx.phases():
    66         p.set_refinements({"Cell": False})
    67     gpx.phase(0).set_HAP_refinements(
    68         {'Scale': False,
    69          "Size": {'type':'isotropic', 'refine': False},
    70          "Mustrain": {'type':'uniaxial', 'refine': False},
    71          "HStrain":True,})
    72     gpx.phase(1).set_HAP_refinements({'Scale': False})
    73     gpx.histogram(0).clear_refinements({'Background':False,
    74                      'Sample Parameters':['DisplaceX'],})
    75     gpx.histogram(0).ref_back_peak(0,[])
    76     gpx.phase(1).set_HAP_refinements({"HStrain":(1,1,1,0)})
    77     for fil in sorted(glob.glob(PathWrap('*.fxye'))): # load in remaining fxye files
    78         if '00' in fil: continue
    79         gpx.add_powder_histogram(fil, PathWrap('OH_00.prm'), fmthint="GSAS powder",phases='all')
    80     # copy HAP values, background, instrument params. & limits, not sample params.
    81     gpx.copyHistParms(0,'all',['b','i','l'])
    82     for p in gpx.phases(): p.copyHAPvalues(0,'all')
    83     # setup and launch sequential fit
    84     gpx.set_Controls('sequential',gpx.histograms())
    85     gpx.set_Controls('cycles',10)
    86     gpx.set_Controls('seqCopy',True)
    87     gpx.refine() 
    88 
    8949Most functionality is provided via the objects and methods described in this section.
     50
     51---------------------
     52Functions
     53---------------------
     54
     55A small amount of the Scriptable code does not require use of objects.
     56
     57==================================================    ===============================================================================================================
     58method                                                Use
     59==================================================    ===============================================================================================================
     60:func:`GenerateReflections`                            Generates a list of unique powder reflections
     61:func:`SetPrintLevel`                                  Sets the amout of output generated when running a script
     62==================================================    ===============================================================================================================
    9063
    9164---------------------
     
    185158:meth:`G2PwdrData.getdata`                            Provides access to the diffraction data associated with the histogram.
    186159:meth:`G2PwdrData.reflections`                        Provides access to the reflection lists for the histogram.
    187 :meth:`G2PwdrData.Export`                             Writes the diffraction data into a file
     160:meth:`G2PwdrData.Export`                             Writes the diffraction data or reflection list into a file
    188161:meth:`G2PwdrData.add_peak`                           Adds a peak to the peak list. Also see :ref:`PeakRefine`.
    189162:meth:`G2PwdrData.set_peakFlags`                      Sets refinement flags for peaks
     
    695668Peak Refinement
    696669--------------------
     670
    697671Peak refinement is performed with routines
    698672:meth:`G2PwdrData.add_peak`, :meth:`G2PwdrData.set_peakFlags` and
     
    737711    #gpx.save()  # gpx file is not written without this
    738712
    739 
    740713--------------------
    741714Pattern Simulation
     
    770743    gpx.histogram(0).Export('PbSO4refl','.csv','refl') # reflections
    771744
     745----------------------
     746Sequential Refinement
     747----------------------
     748
     749GSASIIscriptable can be used to setup and perform sequential refinements. This example script
     750is used to take the single-dataset fit at the end of Step 1 of the
     751`Sequential Refinement tutorial <https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/SeqRefine/SequentialTutorial.htm>`
     752and turn on and off refinement flags, add histograms and setup the sequential fit, which is then run:
     753
     754.. code-block::  python
     755
     756    import os,sys,glob
     757    sys.path.insert(0,'/Users/toby/software/G2/GSASII')
     758    import GSASIIscriptable as G2sc
     759    datadir = os.path.expanduser("~/Scratch/SeqTut2019Mar")
     760    PathWrap = lambda fil: os.path.join(datadir,fil)
     761    # load and rename project
     762    gpx = G2sc.G2Project(PathWrap('7Konly.gpx'))
     763    gpx.save(PathWrap('SeqRef.gpx'))
     764    # turn off some variables; turn on Dijs
     765    for p in gpx.phases():
     766        p.set_refinements({"Cell": False})
     767    gpx.phase(0).set_HAP_refinements(
     768        {'Scale': False,
     769         "Size": {'type':'isotropic', 'refine': False},
     770         "Mustrain": {'type':'uniaxial', 'refine': False},
     771         "HStrain":True,})
     772    gpx.phase(1).set_HAP_refinements({'Scale': False})
     773    gpx.histogram(0).clear_refinements({'Background':False,
     774                     'Sample Parameters':['DisplaceX'],})
     775    gpx.histogram(0).ref_back_peak(0,[])
     776    gpx.phase(1).set_HAP_refinements({"HStrain":(1,1,1,0)})
     777    for fil in sorted(glob.glob(PathWrap('*.fxye'))): # load in remaining fxye files
     778        if '00' in fil: continue
     779        gpx.add_powder_histogram(fil, PathWrap('OH_00.prm'), fmthint="GSAS powder",phases='all')
     780    # copy HAP values, background, instrument params. & limits, not sample params.
     781    gpx.copyHistParms(0,'all',['b','i','l'])
     782    for p in gpx.phases(): p.copyHAPvalues(0,'all')
     783    # setup and launch sequential fit
     784    gpx.set_Controls('sequential',gpx.histograms())
     785    gpx.set_Controls('cycles',10)
     786    gpx.set_Controls('seqCopy',True)
     787    gpx.refine() 
    772788
    773789.. _CommandlineInterface:
     
    12711287
    12721288def GenerateReflections(spcGrp,cell,Qmax=None,dmin=None,TTmax=None,wave=None):
     1289    """Generates the crystallographically unique powder diffraction reflections
     1290    for a lattice and space group (see :func:`GSASIIlattice.GenHLaue`).
     1291
     1292    :param str spcGrp: A GSAS-II formatted space group (with spaces between
     1293       axial fields, e.g. 'P 21 21 21' or 'P 42/m m c'). Note that non-standard
     1294       space groups, such as 'P 21/n' or 'F -1' are allowed (see
     1295       :func:`GSASIIspc.SpcGroup`).
     1296    :param list cell: A list/tuple with six unit cell constants,
     1297      (a, b, c, alpha, beta, gamma) with values in Angstroms/degrees.
     1298      Note that the cell constants are not checked for consistency
     1299      with the space group.
     1300    :param float Qmax: Reflections up to this Q value are computed
     1301       (do not use with dmin or TTmax)
     1302    :param float dmin: Reflections with d-space above this value are computed
     1303       (do not use with Qmax or TTmax)
     1304    :param float TTmax: Reflections up to this 2-theta value are computed
     1305       (do not use with dmin or Qmax, use of wave is required.)
     1306    :param float wave: wavelength in Angstroms for use with TTmax (ignored
     1307       otherwise.)
     1308    """
     1309
    12731310    import GSASIIlattice as G2lat
    12741311    if len(cell) != 6:
Note: See TracChangeset for help on using the changeset viewer.