Ignore:
Timestamp:
Feb 24, 2020 4:38:19 PM (20 months ago)
Author:
toby
Message:

misc doc updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIscriptable.py

    r4326 r4327  
    948948        img.saveControls(os.path.splitext(img.name)[0]+'.imctrl')
    949949    gpx.save()
     950
     951.. _HistExport:
     952
     953--------------------
     954Histogram Export
     955--------------------
     956
     957This example shows how to export a series of histograms from a collection of
     958.gpx (project) files. The Python ``glob()`` function is used to find all files
     959matching a wildcard in the specified directory (``dataloc``). For each file
     960there is a loop over histograms in that project and for each histogram
     961:meth:`G2PwdrData.Export` is called to write out the contents of that histogram
     962as CSV (comma-separated variable) file that contains data positions,
     963observed, computed and backgroun intensities as well as weighting for each
     964point and Q. Note that for the Export call, there is more than one choice of
     965exporter that can write ``.csv`` extension files, so the export hint must
     966be specified.
     967
     968.. code-block::  python
     969
     970    import os,sys,glob
     971    sys.path.insert(0,'/Users/toby/software/G2/GSASII')  # change this
     972    import GSASIIscriptable as G2sc
     973
     974    dataloc = "/Users/toby/Scratch/"                 # where to find data
     975    PathWrap = lambda fil: os.path.join(dataloc,fil) # EZ way 2 add dir to filename
     976
     977    for f in glob.glob(PathWrap('bkg*.gpx')):  # put filename prefix here
     978        print(f)
     979        gpx = G2sc.G2Project(f)
     980        for i,h in enumerate(gpx.histograms()):
     981            hfil = os.path.splitext(f)[0]+'_'+str(i) # file to write
     982            print('\t',h.name,hfil+'.csv')
     983            h.Export(hfil,'.csv','histogram CSV')
    950984
    951985.. _CommandlineInterface:
Note: See TracChangeset for help on using the changeset viewer.