Changeset 939 for trunk/GSASIIstrIO.py


Ignore:
Timestamp:
Jun 2, 2013 11:07:35 PM (9 years ago)
Author:
toby
Message:

fix & cleanup unit tests; add/change doc strings for sphinx; add all G2 py files to sphinx

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstrIO.py

    r934 r939  
    11# -*- coding: utf-8 -*-
    2 #GSASIIstrIO - structure computation IO routines
     2'''
     3*GSASIIstrIO: structure I/O routines*
     4-------------------------------------
     5
     6'''
    37########### SVN repository information ###################
    48# $Date: 2013-05-17 12:13:15 -0500 (Fri, 17 May 2013) $
     
    3943def GetControls(GPXfile):
    4044    ''' Returns dictionary of control items found in GSASII gpx file
    41     input:
    42         GPXfile = .gpx full file name
    43     return:
    44         Controls = dictionary of control items
     45
     46    :param str GPXfile: full .gpx file name
     47    :return: dictionary of control items
    4548    '''
    4649    Controls = {'deriv type':'analytic Hessian','max cyc':3,'max Hprocess':1,
     
    169172       
    170173def GetFprime(controlDict,Histograms):
     174    'Needs a doc string'
    171175    FFtables = controlDict['FFtables']
    172176    if not FFtables:
     
    188192def GetPhaseNames(GPXfile):
    189193    ''' Returns a list of phase names found under 'Phases' in GSASII gpx file
    190     input:
    191         GPXfile = gpx full file name
    192     return:
    193         PhaseNames = list of phase names
     194
     195    :param str GPXfile: full .gpx file name
     196    :return: list of phase names
    194197    '''
    195198    fl = open(GPXfile,'rb')
     
    209212def GetAllPhaseData(GPXfile,PhaseName):
    210213    ''' Returns the entire dictionary for PhaseName from GSASII gpx file
    211     input:
    212         GPXfile = gpx full file name
    213         PhaseName = phase name
    214     return:
    215         phase dictionary
     214
     215    :param str GPXfile: full .gpx file name
     216    :param str PhaseName: phase name
     217    :return: phase dictionary
    216218    '''       
    217219    fl = open(GPXfile,'rb')
     
    233235def GetHistograms(GPXfile,hNames):
    234236    """ Returns a dictionary of histograms found in GSASII gpx file
    235     input:
    236         GPXfile = .gpx full file name
    237         hNames = list of histogram names
    238     return:
    239         Histograms = dictionary of histograms (types = PWDR & HKLF)
     237
     238    :param str GPXfile: full .gpx file name
     239    :param str hNames: list of histogram names
     240    :return: dictionary of histograms (types = PWDR & HKLF)
     241
    240242    """
    241243    fl = open(GPXfile,'rb')
     
    281283def GetHistogramNames(GPXfile,hType):
    282284    """ Returns a list of histogram names found in GSASII gpx file
    283     input:
    284         GPXfile = .gpx full file name
    285         hType = list ['PWDR','HKLF']
    286     return:
    287         HistogramNames = list of histogram names (types = PWDR & HKLF)
     285
     286    :param str GPXfile: full .gpx file name
     287    :param str hNames: list of histogram names
     288    :return: list of histogram names (types = PWDR & HKLF)
     289
    288290    """
    289291    fl = open(GPXfile,'rb')
     
    303305    ''' Returns all histograms that are found in any phase
    304306    and any phase that uses a histogram
    305     input:
    306         GPXfile = .gpx full file name
    307     return:
    308         Histograms = dictionary of histograms as {name:data,...}
    309         Phases = dictionary of phases that use histograms
     307
     308    :param str GPXfile: full .gpx file name
     309    :return: (Histograms,Phases)
     310
     311     * Histograms = dictionary of histograms as {name:data,...}
     312     * Phases = dictionary of phases that use histograms
     313
    310314    '''
    311315    phaseNames = GetPhaseNames(GPXfile)
     
    334338   
    335339def getBackupName(GPXfile,makeBack):
     340    '''
     341    Get the name for the backup .gpx file name
     342   
     343    :param str GPXfile: full .gpx file name
     344    :param bool makeBack: if True the name of a new file is returned, if
     345      False the name of the last file that exists is returned
     346    :returns: the name of a backup file
     347   
     348    '''
    336349    GPXpath,GPXname = ospath.split(GPXfile)
    337350    if GPXpath == '': GPXpath = '.'
     
    350363       
    351364def GPXBackup(GPXfile,makeBack=True):
     365    '''
     366    makes a backup of the current .gpx file (?)
     367   
     368    :param str GPXfile: full .gpx file name
     369    :param bool makeBack: if True (default), the backup is written to
     370      a new file; if False, the last backup is overwritten
     371    :returns: the name of the backup file that was written
     372    '''
    352373    import distutils.file_util as dfu
    353374    GPXback = getBackupName(GPXfile,makeBack)
     
    358379    ''' Updates gpxfile from all histograms that are found in any phase
    359380    and any phase that used a histogram. Also updates rigid body definitions.
    360     input:
    361         GPXfile = .gpx full file name
    362         Histograms = dictionary of histograms as {name:data,...}
    363         Phases = dictionary of phases that use histograms
    364         RigidBodies = dictionary of rigid bodies
    365         CovData = dictionary of refined variables, varyList, & covariance matrix
    366         makeBack = True if new backup of .gpx file is to be made; else use the last one made
     381
     382
     383    :param str GPXfile: full .gpx file name
     384    :param dict Histograms: dictionary of histograms as {name:data,...}
     385    :param dict Phases: dictionary of phases that use histograms
     386    :param dict RigidBodies: dictionary of rigid bodies
     387    :param dict CovData: dictionary of refined variables, varyList, & covariance matrix
     388    :param bool makeBack: True if new backup of .gpx file is to be made; else use the last one made
     389
    367390    '''
    368391                       
     
    405428   
    406429def SetSeqResult(GPXfile,Histograms,SeqResult):
     430    '''
     431    Needs doc string
     432   
     433    :param str GPXfile: full .gpx file name
     434    '''
    407435    GPXback = GPXBackup(GPXfile)
    408436    print 'Read from file:',GPXback
     
    433461                       
    434462def ShowBanner(pFile=None):
     463    'Print authorship, copyright and citation notice'
    435464    print >>pFile,80*'*'
    436465    print >>pFile,'   General Structure Analysis System-II Crystal Structure Refinement'
     
    445474
    446475def ShowControls(Controls,pFile=None):
     476    'Print controls information'
    447477    print >>pFile,' Least squares controls:'
    448478    print >>pFile,' Refinement type: ',Controls['deriv type']
     
    455485def GetFFtable(General):
    456486    ''' returns a dictionary of form factor data for atom types found in General
    457     input:
    458         General = dictionary of phase info.; includes AtomTypes
    459     return:
    460         FFtable = dictionary of form factor data; key is atom type
     487
     488    :param dict General: dictionary of phase info.; includes AtomTypes
     489    :return: FFtable, dictionary of form factor data; key is atom type
     490
    461491    '''
    462492    atomTypes = General['AtomTypes']
     
    471501def GetBLtable(General):
    472502    ''' returns a dictionary of neutron scattering length data for atom types & isotopes found in General
    473     input:
    474         General = dictionary of phase info.; includes AtomTypes & Isotopes
    475     return:
    476         BLtable = dictionary of scattering length data; key is atom type
     503
     504    :param dict General: dictionary of phase info.; includes AtomTypes & Isotopes
     505    :return: BLtable, dictionary of scattering length data; key is atom type
    477506    '''
    478507    atomTypes = General['AtomTypes']
     
    485514       
    486515def GetPawleyConstr(SGLaue,PawleyRef,pawleyVary):
     516    'needs a doc string'
    487517#    if SGLaue in ['-1','2/m','mmm']:
    488518#        return                      #no Pawley symmetry required constraints
     
    529559                   
    530560def cellVary(pfx,SGData):
     561    'needs a doc string'
    531562    if SGData['SGLaue'] in ['-1',]:
    532563        return [pfx+'A0',pfx+'A1',pfx+'A2',pfx+'A3',pfx+'A4',pfx+'A5']
     
    554585       
    555586def GetRigidBodyModels(rigidbodyDict,Print=True,pFile=None):
     587    'needs a doc string'
    556588   
    557589    def PrintResRBModel(RBModel):
     
    612644   
    613645def SetRigidBodyModels(parmDict,sigDict,rigidbodyDict,pFile=None):
     646    'needs a doc string'
    614647   
    615648    def PrintRBVectandSig(VectRB,VectSig):
     
    648681                   
    649682def GetPhaseData(PhaseData,RestraintDict={},rbIds={},Print=True,pFile=None):
     683    'needs a doc string'
    650684           
    651685    def PrintFFtable(FFtable):
     
    9891023   
    9901024def cellFill(pfx,SGData,parmDict,sigDict):
     1025    'needs a doc string'
    9911026    if SGData['SGLaue'] in ['-1',]:
    9921027        A = [parmDict[pfx+'A0'],parmDict[pfx+'A1'],parmDict[pfx+'A2'],
     
    10301065       
    10311066def PrintRestraints(cell,SGData,AtPtrs,Atoms,AtLookup,textureData,phaseRest,pFile):
     1067    'needs a doc string'
    10321068    if phaseRest:
    10331069        Amat = G2lat.cell2AB(cell)[0]
     
    11161152       
    11171153def getCellEsd(pfx,SGData,A,covData):
     1154    'needs a doc string'
    11181155    dpr = 180./np.pi
    11191156    rVsq = G2lat.calc_rVsq(A)
     
    11741211   
    11751212def SetPhaseData(parmDict,sigDict,Phases,RBIds,covData,RestraintDict=None,pFile=None):
     1213    'needs a doc string'
    11761214   
    11771215    def PrintAtomsAndSig(General,Atoms,atomsSig):
     
    14811519                   
    14821520def GetHistogramPhaseData(Phases,Histograms,Print=True,pFile=None):
     1521    'needs a doc string'
    14831522   
    14841523    def PrintSize(hapData):
     
    17391778   
    17401779def SetHistogramPhaseData(parmDict,sigDict,Phases,Histograms,Print=True,pFile=None):
     1780    'needs a doc string'
    17411781   
    17421782    def PrintSizeAndSig(hapData,sizeSig):
     
    20342074                   
    20352075def GetHistogramData(Histograms,Print=True,pFile=None):
     2076    'needs a doc string'
    20362077   
    20372078    def GetBackgroundParms(hId,Background):
     
    22452286   
    22462287def SetHistogramData(parmDict,sigDict,Histograms,Print=True,pFile=None):
     2288    'needs a doc string'
    22472289   
    22482290    def SetBackgroundParms(pfx,Background,parmDict,sigDict):
Note: See TracChangeset for help on using the changeset viewer.