Changeset 3845


Ignore:
Timestamp:
Mar 8, 2019 12:59:26 PM (3 years ago)
Author:
toby
Message:

more sequential timing; doc fixes for scriptable

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIscriptable.py

    r3844 r3845  
    12771277            into[:] = from_
    12781278
    1279 def GetCorrImage(ImageReaderlist,proj,imageRef):
     1279def _getCorrImage(ImageReaderlist,proj,imageRef):
    12801280    '''Gets image & applies dark, background & flat background corrections.
    1281     based on :func:`GSASIIimgGUI.GetImageZ`. Likely for internal use only.
     1281    based on :func:`GSASIIimgGUI.GetImageZ`. Expected to be for internal
     1282    use only.
    12821283
    12831284    :param list ImageReaderlist: list of Reader objects for images
     
    18591860        .. seealso::
    18601861            :meth:`G2Project.images`
    1861             """
     1862        """
    18621863        if isinstance(imageRef, G2Image):
    18631864            if imageRef.proj == self:
     
    33823383
    33833384class G2Image(G2ObjectWrapper):
    3384     """Wrapper for an IMG tree entry, containing an image and various metadata.
    3385 
    3386     Example:
     3385    """Wrapper for an IMG tree entry, containing an image and various metadata.
     3386    Note that in a GSASIIscriptable script, instances of G2Image will be created by
     3387    calls to :meth:`G2Project.add_image` or :meth:`G2Project.images`, not via calls
     3388    to :meth:`G2Image.__init__`.
     3389
     3390    Example use of G2Image:
    33873391
    33883392    >>> gpx = G2sc.G2Project(filename='itest.gpx')
    3389     >>> img2 = gpx.add_image(idata,fmthint="TIF")
    3390     >>> img2[0].loadControls('stdSettings.imctrl')
    3391     >>> img2[0].setCalibrant('Si    SRM640c')
    3392     >>> img2[0].loadMasks('stdMasks.immask')
    3393     >>> img2[0].Recalibrate()
    3394     >>> img2[0].setControl('outAzimuths',3)
    3395     >>> pwdrList = img2[0].Integrate()
     3393    >>> imlst = gpx.add_image(idata,fmthint="TIF")
     3394    >>> imlst[0].loadControls('stdSettings.imctrl')
     3395    >>> imlst[0].setCalibrant('Si    SRM640c')
     3396    >>> imlst[0].loadMasks('stdMasks.immask')
     3397    >>> imlst[0].Recalibrate()
     3398    >>> imlst[0].setControl('outAzimuths',3)
     3399    >>> pwdrList = imlst[0].Integrate()
     3400
     3401
     3402    Sample script using an image:   
     3403
     3404.. code-block::  python
     3405
     3406    import os,sys
     3407    sys.path.insert(0,'/Users/toby/software/G2/GSASII')
     3408    import GSASIIscriptable as G2sc
     3409    datadir = "/tmp/V4343_IntegrationError/"
     3410    PathWrap = lambda fil: os.path.join(datadir,fil)
     3411
     3412    gpx = G2sc.G2Project(filename=PathWrap('inttest.gpx'))
     3413    imlst = gpx.add_image(PathWrap('Si_free_dc800_1-00000.tif'),fmthint="TIF")
     3414    imlst[0].loadControls(PathWrap('Si_free_dc800_1-00000.imctrl'))
     3415    pwdrList = imlst[0].Integrate()
     3416    gpx.save()
    33963417
    33973418    """
    3398     # parameters in that can be accessed via setControl
     3419    # parameters in that can be accessed via setControl. This may need future attention
    33993420    ControlList = {
    34003421        'int': ['calibskip', 'pixLimit', 'edgemin', 'outChannels',
     
    34133434        }
    34143435    '''Defines the items known to exist in the Image Controls tree section
    3415     and the item's data types. A few are not included
     3436    and the item's data types. A few are not included here
    34163437    ('background image', 'dark image', 'Gain map', and 'calibrant') because
    34173438    these items have special set routines,
     
    34193440    correct.
    34203441    '''
    3421     # this may need future attention
    34223442       
    34233443    def __init__(self, data, name, proj):
     
    36253645        '''
    36263646        LoadG2fil()
    3627         ImageZ = GetCorrImage(Readers['Image'],self.proj,self)
     3647        ImageZ = _getCorrImage(Readers['Image'],self.proj,self)
    36283648        G2img.ImageRecalibrate(None,ImageZ,self.data['Image Controls'],self.data['Masks'])
    36293649
     
    36403660        '''
    36413661        blkSize = 256   #256 seems to be optimal; will break in polymask if >1024
    3642         ImageZ = GetCorrImage(Readers['Image'],self.proj,self)
     3662        ImageZ = _getCorrImage(Readers['Image'],self.proj,self)
    36433663        # do integration
    36443664        ints,azms,Xvals,cancel = G2img.ImageIntegrate(ImageZ,self.data['Image Controls'],self.data['Masks'],blkSize=blkSize)
  • trunk/GSASIIstrMain.py

    r3839 r3845  
    365365    NewparmDict = {}
    366366    for ihst,histogram in enumerate(histNames):
    367         if GSASIIpath.GetConfigValue('debug'): t1 = time.time()
     367        if GSASIIpath.GetConfigValue('Show_timing'): t1 = time.time()
    368368        print('\nRefining with '+str(histogram))
    369369        ifPrint = False
     
    415415        # do constraint processing
    416416        #reload(G2mv) # debug
    417         if GSASIIpath.GetConfigValue('debug'):
     417        if GSASIIpath.GetConfigValue('Show_timing'):
    418418            t2 = time.time()
    419             print("#1 debug time {:.2f} sec.".format(t2-t1))
     419            print("#1 show time {:.2f} sec.".format(t2-t1))
    420420            t1 = t2
    421421        G2mv.InitVars()
    422422        constrDict,fixedList = G2stIO.GetConstraints(GPXfile)
    423         if GSASIIpath.GetConfigValue('debug'):
     423        if GSASIIpath.GetConfigValue('Show_timing'):
    424424            t2 = time.time()
    425             print("#2 debug time {:.2f} sec.".format(t2-t1))
     425            print("#2 show time {:.2f} sec.".format(t2-t1))
    426426            t1 = t2
    427427        varyListStart = tuple(varyList) # save the original varyList before dependent vars are removed
     
    484484        printFile.write('\n Refinement results for histogram: %s\n'%histogram)
    485485        printFile.write(135*'-'+'\n')
    486         if GSASIIpath.GetConfigValue('debug'):
     486        if GSASIIpath.GetConfigValue('Show_timing'):
    487487            t2 = time.time()
    488             print("#3 debug time {:.2f} sec.".format(t2-t1))
     488            print("#3 show time {:.2f} sec.".format(t2-t1))
    489489            t1 = t2
    490490        if True:
     
    492492            IfOK,Rvals,result,covMatrix,sig = RefineCore(Controls,Histo,Phases,restraintDict,
    493493                rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifSeq,printFile,dlg)
     494            if GSASIIpath.GetConfigValue('Show_timing'):
     495                t2 = time.time()
     496                print("#4a show time {:.2f} sec.".format(t2-t1))
     497                t1 = t2
    494498            if PlotFunction:
    495499                PlotFunction(G2frame,Histo[histogram]['Data'],histogram)
    496500
     501            if GSASIIpath.GetConfigValue('Show_timing'):
     502                t2 = time.time()
     503                print("#4b show time {:.2f} sec.".format(t2-t1))
     504                t1 = t2
    497505            print ('  wR = %7.2f%%, chi**2 = %12.6g, reduced chi**2 = %6.2f, last delta chi = %.4f'%(
    498506                Rvals['Rwp'],Rvals['chisq'],Rvals['GOF']**2,Rvals['DelChi2']))
     
    517525                'parmDict':parmDict}
    518526            SeqResult[histogram] = histRefData
    519             if GSASIIpath.GetConfigValue('debug'):
     527            if GSASIIpath.GetConfigValue('Show_timing'):
    520528                t2 = time.time()
    521                 print("#4 debug time {:.2f} sec.".format(t2-t1))
     529                print("#4c show time {:.2f} sec.".format(t2-t1))
    522530                t1 = t2
    523531            G2stMth.ApplyRBModels(parmDict,Phases,rigidbodyDict,True)
     532            if GSASIIpath.GetConfigValue('Show_timing'):
     533                t2 = time.time()
     534                print("#5a show time {:.2f} sec.".format(t2-t1))
     535                t1 = t2
    524536    #        G2stIO.SetRigidBodyModels(parmDict,sigDict,rigidbodyDict,printFile)
    525537            G2stIO.SetHistogramPhaseData(parmDict,sigDict,Phases,Histo,None,ifPrint,printFile)
     538            if GSASIIpath.GetConfigValue('Show_timing'):
     539                t2 = time.time()
     540                print("#5b show time {:.2f} sec.".format(t2-t1))
     541                t1 = t2
    526542            G2stIO.SetHistogramData(parmDict,sigDict,Histo,None,ifPrint,printFile)
     543            if GSASIIpath.GetConfigValue('Show_timing'):
     544                t2 = time.time()
     545                print("#5c show time {:.2f} sec.".format(t2-t1))
     546                t1 = t2
    527547            G2stIO.SetUsedHistogramsAndPhases(GPXfile,Histo,Phases,rigidbodyDict,histRefData,makeBack)
    528             if GSASIIpath.GetConfigValue('debug'):
     548            if GSASIIpath.GetConfigValue('Show_timing'):
    529549                t2 = time.time()
    530                 print("#5 debug time {:.2f} sec.".format(t2-t1))
     550                print("#5d show time {:.2f} sec.".format(t2-t1))
    531551                t1 = t2
    532552            makeBack = False
     
    548568#            print (' ***** Refinement aborted *****')
    549569#            return False,Msg.msg
    550         if GSASIIpath.GetConfigValue('debug'):
     570        if GSASIIpath.GetConfigValue('Show_timing'):
    551571            t2 = time.time()
    552             print("#6 debug time {:.2f} sec.".format(t2-t1))
     572            print("#6 show time {:.2f} sec.".format(t2-t1))
    553573            t1 = t2
    554574    SeqResult['histNames'] = [itm for itm in G2stIO.GetHistogramNames(GPXfile,['PWDR',]) if itm in SeqResult.keys()]
Note: See TracChangeset for help on using the changeset viewer.