Changeset 923


Ignore:
Timestamp:
May 17, 2013 4:25:32 PM (9 years ago)
Author:
toby
Message:

more doc updates

Location:
trunk
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIElemGUI.py

    r903 r923  
    11# -*- coding: utf-8 -*-
    2 """ElementGUI: class defn. for element GUIs
    3    Copyright: 2008, Robert B. Von Dreele & Brian H. Toby (Argonne National Laboratory)
    4 """
    52########### SVN repository information ###################
    63# $Date$
     
    107# $Id$
    118########### SVN repository information ###################
     9'''
     10*GSASIIElemGUI: GUI to select and delete element lists*
     11-------------------------------------------------------
     12
     13Module to select elements from a periodic table and
     14to delete an element from a list of selected elements.
     15'''
     16"""ElementGUI: class defn. for element GUIs
     17   Copyright: 2008, Robert B. Von Dreele & Brian H. Toby (Argonne National Laboratory)
     18"""
     19
    1220import wx
    1321import os
     
    3745
    3846    def __init__(self, parent,oneOnly=False,ifNone=False):
     47        'Needs a doc string'
    3948        self.oneOnly = oneOnly
    4049        self.ifNone = ifNone
     
    4251       
    4352    def ElButton(self, name, pos, tip, color):
     53        'Needs a doc string'
    4454        Black = wx.Colour(0,0,0)
    4555        if not self.ifNone and name[0] == 'None':
     
    91101
    92102    def ElButton(self, id, name, pos):
     103        'Needs a doc string'
    93104        White = wx.Colour(255, 255, 255)
    94105        El = wscs.ColourSelect(label=name, parent=self, colour = White,
  • trunk/GSASIIIO.py

    r905 r923  
    11# -*- coding: utf-8 -*-
    2 """GSASIIIO: functions for IO of data
    3    Copyright: 2008, Robert B. Von Dreele (Argonne National Laboratory)
    4 """
    52########### SVN repository information ###################
    63# $Date$
     
    107# $Id$
    118########### SVN repository information ###################
     9'''
     10*GSASIIIO: Misc I/O routines*
     11=============================
     12
     13Module with miscellaneous routines for input and output. Many
     14are GUI routines to interact with user.
     15
     16Includes support for image reading.
     17
     18Also includes base classes for data import routines.
     19
     20'''
     21"""GSASIIIO: functions for IO of data
     22   Copyright: 2008, Robert B. Von Dreele (Argonne National Laboratory)
     23"""
    1224import wx
    1325import math
     
    2739
    2840def sfloat(S):
     41    'Convert a string to float. An empty field is treated as zero'
    2942    if S.strip():
    3043        return float(S)
     
    3346
    3447def sint(S):
     48    'Convert a string to int. An empty field is treated as zero'
    3549    if S.strip():
    3650        return int(S)
     
    4660
    4761def FileDlgFixExt(dlg,file):
    48     #this is needed to fix a problem in linux wx.FileDialog
     62    'this is needed to fix a problem in linux wx.FileDialog'
    4963    ext = dlg.GetWildcard().split('|')[2*dlg.GetFilterIndex()+1].strip('*')
    5064    if ext not in file:
     
    5367       
    5468def GetPowderPeaks(fileName):
     69    'Read powder peaks from a file'
    5570    sind = lambda x: math.sin(x*math.pi/180.)
    5671    asind = lambda x: 180.*math.asin(x)/math.pi
     
    92107
    93108def CheckImageFile(G2frame,imagefile):
     109    '''Get an new image file name if the specified one does not
     110    exist
     111
     112    :param wx.Frame G2frame: main GSAS-II Frame and data object
     113
     114    :param str imagefile: name of image file
     115
     116    :returns: imagefile, if it exists, or the name of a file
     117      that does exist or False if the user presses Cancel
     118
     119    '''
    94120    if not ospath.exists(imagefile):
    95121        dlg = wx.FileDialog(G2frame, 'Bad image file name; choose name', '.', '',\
     
    112138    return imagefile
    113139       
    114 def GetImageData(G2frame,imagefile,imageOnly=False):       
     140def GetImageData(G2frame,imagefile,imageOnly=False):
     141    '''Read an image with the file reader keyed by the
     142    file extension
     143
     144    :param wx.Frame G2frame: main GSAS-II Frame and data object
     145
     146    :param str imagefile: name of image file
     147
     148    :param bool imageOnly: If True return only the image,
     149      otherwise  (default) return more (see below)
     150
     151    :returns: an image as a numpy array or a list of four items:
     152      Comments, Data, Npix and the Image, as selected by imageOnly
     153
     154    '''
    115155    ext = ospath.splitext(imagefile)[1]
    116156    Comments = []
     
    134174       
    135175def PutG2Image(filename,Comments,Data,Npix,image):
     176    'Write an image as a python pickle'
    136177    File = open(filename,'wb')
    137178    cPickle.dump([Comments,Data,Npix,image],File,1)
     
    140181   
    141182def GetG2Image(filename):
     183    'Read an image as a python pickle'
    142184    File = open(filename,'rb')
    143185    Comments,Data,Npix,image = cPickle.load(File)
     
    146188   
    147189def GetEdfData(filename,imageOnly=False):   
     190    'Read European detector data edf file'
    148191    import struct as st
    149192    import array as ar
     
    197240       
    198241def GetGEsumData(filename,imageOnly=False):
     242    'Read SUM file as produced at 1-ID from G.E. images'
    199243    import struct as st
    200244    import array as ar
     
    234278       
    235279def GetImgData(filename,imageOnly=False):
     280    'Read an ADSC image file'
    236281    import struct as st
    237282    import array as ar
     
    284329       
    285330def GetMAR345Data(filename,imageOnly=False):
     331    'Read a MAR-345 image plate image'
    286332    import array as ar
    287333    import struct as st
     
    341387
    342388def GetTifData(filename,imageOnly=False):
     389    '''Read an image in a pseudo-tif format,
     390    as produced by a wide variety of software, almost always
     391    incorrectly in some way.
     392    '''
    343393    import struct as st
    344394    import array as ar
     
    640690#   
    641691def ProjFileOpen(G2frame):
     692    'Read a GSAS-II project file'
    642693    file = open(G2frame.GSASprojectfile,'rb')
    643694    print 'load from file: ',G2frame.GSASprojectfile
     
    686737   
    687738def ProjFileSave(G2frame):
     739    'Save a GSAS-II project file'
    688740    if not G2frame.PatternTree.IsEmpty():
    689741        file = open(G2frame.GSASprojectfile,'wb')
     
    709761
    710762def SaveIntegration(G2frame,PickId,data):
     763    'Save image integration results as powder pattern(s)'
    711764    azms = G2frame.Integrate[1]
    712765    X = G2frame.Integrate[2][:-1]
     
    776829           
    777830def powderFxyeSave(G2frame,exports,powderfile):
     831    'Save a powder histogram as a GSAS FXYE file'
    778832    head,tail = ospath.split(powderfile)
    779833    name,ext = tail.split('.')
     
    815869       
    816870def powderXyeSave(G2frame,exports,powderfile):
     871    'Save a powder histogram as a Topas XYE file'
    817872    head,tail = ospath.split(powderfile)
    818873    name,ext = tail.split('.')
     
    831886        print 'powder pattern file '+filename+' written'
    832887       
    833 def PDFSave(G2frame,exports):   
     888def PDFSave(G2frame,exports):
     889    'Save a PDF G(r) and S(Q) in column formats'
    834890    for export in exports:
    835891        PickId = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, export)
     
    856912   
    857913def PeakListSave(G2frame,file,peaks):
     914    'Save powder peaks to a data file'
    858915    print 'save peak list to file: ',G2frame.peaklistfile
    859916    if not peaks:
     
    870927             
    871928def IndexPeakListSave(G2frame,peaks):
     929    'Save powder peaks from the indexing list'
    872930    file = open(G2frame.peaklistfile,'wa')
    873931    print 'save index peak list to file: ',G2frame.peaklistfile
     
    889947   
    890948def SetNewPhase(Name='New Phase',SGData=G2spc.SpcGroup('P 1')[1],cell=[1.0,1.0,1.0,90.,90,90.,1.]):
     949    'Create a new phase'
    891950    phaseData = {
    892951        'ranId':ran.randint(0,sys.maxint),
     
    918977   
    919978def ReadEXPPhase(G2frame,filename):
     979    '''Read a phase from a GSAS .EXP file.
     980    Called in the GSAS phase import routine (see imports/G2phase.py)
     981    '''
    920982    shModels = ['cylindrical','none','shear - 2/m','rolling - mmm']
    921983    textureData = {'Order':0,'Model':'cylindrical','Sample omega':[False,0.0],
     
    10421104       
    10431105def ReadPDBPhase(filename):
     1106    '''Read a phase from a PDB file.
     1107    Called in the PDB phase import routine (see imports/G2phase.py)
     1108    '''
    10441109    EightPiSq = 8.*math.pi**2
    10451110    file = open(filename, 'Ur')
     
    11281193
    11291194class MultipleChoicesDialog(wx.Dialog):
    1130     '''A dialog that offers a series of choices, each with a title and a wx.Choice
    1131     widget. Intended to be used Modally.
     1195    '''A dialog that offers a series of choices, each with a
     1196    title and a wx.Choice widget. Intended to be used Modally.
    11321197    typical input:
    1133           choicelist=[ ('a','b','c'), ('test1','test2'),('no choice',)]
    1134           headinglist = [ 'select a, b or c', 'select 1 of 2', 'No option here']
     1198
     1199        *  choicelist=[ ('a','b','c'), ('test1','test2'),('no choice',)]
     1200        *  headinglist = [ 'select a, b or c', 'select 1 of 2', 'No option here']
     1201       
    11351202    selections are placed in self.chosen when OK is pressed
    11361203    '''
     
    11901257                       confirmoverwrite=True, parent=None,
    11911258                       multipleselect=False):
    1192     '''If the filename is a zip file, extract a file from that archive.
    1193       selection is used to predefine the name of the file to be extracted
    1194          filename case and zip directory name are ignored in selection;
    1195          the first matching file is used
    1196       confirmread if True asks the user to confirm before expanding
    1197          the only file in a zip
    1198       confirmoverwrite if True asks the user to confirm before
    1199         overwriting if the extracted file already exists
    1200       multipleselect if True allows more than one zip file to be extracted,
    1201         a list of file(s) is returned
    1202     If only one file is present, do not ask which one, otherwise offer a
    1203        list of choices (unless selection is used)
    1204     Return the name of the file that has been created or a list of files (see multipleselect)
    1205       If the file is not a zipfile, return the name of the input file.
    1206       If the zipfile is empty or no file has been selected, return None
     1259    '''If the filename is a zip file, extract a file from that
     1260    archive.
     1261
     1262    :param list Selection: used to predefine the name of the file
     1263      to be extracted. Filename case and zip directory name are
     1264      ignored in selection; the first matching file is used.
     1265
     1266    :param bool confirmread: if True asks the user to confirm before expanding
     1267      the only file in a zip
     1268
     1269    :param bool confirmoverwrite: if True asks the user to confirm
     1270      before overwriting if the extracted file already exists
     1271
     1272    :param bool multipleselect: if True allows more than one zip
     1273      file to be extracted, a list of file(s) is returned.
     1274      If only one file is present, do not ask which one, otherwise
     1275      offer a list of choices (unless selection is used).
     1276   
     1277    :returns: the name of the file that has been created or a
     1278      list of files (see multipleselect)
     1279
     1280    If the file is not a zipfile, return the name of the input file.
     1281    If the zipfile is empty or no file has been selected, return None
    12071282    '''
    12081283    import zipfile # do this now, since we can save startup time by doing this only on need
     
    13601435    def MultipleBlockSelector(self, ChoiceList, ParentFrame=None,
    13611436        title='Select a block',size=None, header='Block Selector'):
    1362         ''' Provide a wx dialog to select a block of data if the file contains more
    1363         than one set of data and one must be selected.
    1364         Returns a list of the selected blocks
     1437        '''Provide a wx dialog to select a block of data if the
     1438        file contains more than one set of data and one must be
     1439        selected.
     1440
     1441        :returns: a list of the selected blocks
    13651442        '''
    13661443        dlg = wx.MultiChoiceDialog(ParentFrame,title, header,ChoiceList+['Select all'],
     
    13811458    def MultipleChoicesDialog(self, choicelist, headinglist, ParentFrame=None, **kwargs):
    13821459        '''A modal dialog that offers a series of choices, each with a title and a wx.Choice
    1383         widget.
    1384         typical input:
    1385            choicelist=[ ('a','b','c'), ('test1','test2'),('no choice',)]
    1386            headinglist = [ 'select a, b or c', 'select 1 of 2', 'No option here']
     1460        widget. Typical input:
     1461       
     1462           * choicelist=[ ('a','b','c'), ('test1','test2'),('no choice',)]
     1463           
     1464           * headinglist = [ 'select a, b or c', 'select 1 of 2', 'No option here']
     1465           
    13871466        optional keyword parameters are: head (window title) and title
    13881467        returns a list of selected indicies for each choice (or None)
  • trunk/GSASIIconstrGUI.py

    r906 r923  
    88# $Id: GSASIIconstrGUI.py 810 2012-12-05 21:38:26Z vondreele $
    99########### SVN repository information ###################
     10'''
     11*GSASIIconstrGUI: Constraint GUI routines*
     12------------------------------------------
     13
     14Used to define constraints and rigid bodies.
     15
     16'''
    1017import sys
    1118import wx
     
    2734
    2835class MultiIntegerDialog(wx.Dialog):
    29    
     36    '''Input a series of integers based on prompts
     37    '''
    3038    def __init__(self,parent,title,prompts,values):
    3139        wx.Dialog.__init__(self,parent,-1,title,
  • trunk/GSASIIddataGUI.py

    r912 r923  
    1010'''
    1111*GSASIIddataGUI: Phase Diffraction Data GUI*
    12 ============================================
     12--------------------------------------------
     13
    1314Module to create the GUI for display of diffraction data * phase
    1415information that is shown in the data display window
  • trunk/GSASIIgrid.py

    r914 r923  
    1010'''
    1111*GSASIIgrid: Basic GUI routines*
    12 ================================
     12--------------------------------
     13
    1314
    1415'''
     
    19511952       
    19521953def UpdatePWHKPlot(G2frame,kind,item):
    1953     '''Not sure what this does
     1954    '''Needs a doc string
    19541955    '''
    19551956
     
    19971998       
    19981999def UpdateHKLControls(G2frame,data):
    1999     '''Not sure what this does
     2000    '''Needs a doc string
    20002001    '''
    20012002   
     
    20922093       
    20932094def GetPatternTreeDataNames(G2frame,dataTypes):
    2094     '''Not sure what this does
     2095    '''Needs a doc string
    20952096    '''
    20962097    names = []
     
    21042105                         
    21052106def GetPatternTreeItemId(G2frame, parentId, itemText):
    2106     '''Not sure what this does
     2107    '''Needs a doc string
    21072108    '''
    21082109    item, cookie = G2frame.PatternTree.GetFirstChild(parentId)
     
    21142115
    21152116def MovePatternTreeToGrid(G2frame,item):
    2116     '''Not sure what this does
     2117    '''Needs a doc string
    21172118    '''
    21182119   
  • trunk/GSASIIimage.py

    r893 r923  
    88# $Id$
    99########### SVN repository information ###################
     10'''
     11*GSASIIimage: Image calc module*
     12================================
     13
     14Ellipse fitting & image integration
     15
     16needs some minor refactoring to remove wx code
     17'''
     18
    1019import math
    1120import wx
  • trunk/GSASIIimgGUI.py

    r892 r923  
    88# $Id$
    99########### SVN repository information ###################
     10'''
     11*GSASIIimgGUI: Image GUI*
     12-------------------------
     13
     14Control image display and processing
     15
     16'''
    1017import wx
    1118import matplotlib as mpl
     
    3441################################################################################                   
    3542def UpdateImageControls(G2frame,data,masks):
     43    '''Shows and handles the controls on the "Image Controls"
     44    data tree entry
     45    '''
    3646    import ImageCalibrants as calFile
    3747#patch
     
    819829   
    820830def UpdateMasks(G2frame,data):
     831    '''Shows and handles the controls on the "Masks"
     832    data tree entry
     833    '''
    821834   
    822835    def OnTextMsg(event):
     
    11361149
    11371150def UpdateStressStrain(G2frame,data):
     1151    '''Shows and handles the controls on the "Stress/Strain"
     1152    data tree entry
     1153    '''
    11381154   
    11391155    def OnAppendDzero(event):
  • trunk/GSASIIindex.py

    r792 r923  
    99# $Id$
    1010########### SVN repository information ###################
     11'''
     12*GSASIIindex: Cell Indexing Module*
     13===================================
     14
     15Cell indexing program: variation on that of A. Coehlo
     16includes cell refinement from peak positions (not zero as yet)
     17
     18This needs a bit of refactoring to remove the little bit of GUI
     19code referencing wx
     20'''
     21
    1122import math
    1223import wx
  • trunk/GSASIIpwdGUI.py

    r904 r923  
    11# -*- coding: utf-8 -*-
    2 #GSASII - data display routines
     2#GSASIIpwdGUI - powder data display routines
    33########### SVN repository information ###################
    44# $Date$
     
    88# $Id$
    99########### SVN repository information ###################
     10'''
     11*GSASIIpwdGUI: Powder Pattern GUI routines*
     12-------------------------------------------
     13
     14Used to define GUI controls for the routines that interact
     15with the powder histogram (PWDR) data tree items.
     16
     17'''
    1018import sys
    1119import os.path
     
    3947   
    4048def IsHistogramInAnyPhase(G2frame,histoName):
     49    'Needs a doc string'
    4150    phases = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Phases')
    4251    if phases:
     
    5362
    5463def SetDefaultSample():
     64    'Needs a doc string'
    5565    return {'ranId':ran.randint(0,sys.maxint),
    5666        'Scale':[1.0,True],'Type':'Debye-Scherrer','Absorption':[0.0,False],
     
    6575       
    6676def UpdatePeakGrid(G2frame, data):
     77    '''respond to selection of PWDR powder peaks data tree item.
     78    '''
    6779    if G2frame.dataDisplay:
    6880        G2frame.dataFrame.Clear()
     
    318330       
    319331def UpdateBackground(G2frame,data):
     332    '''respond to selection of PWDR background data tree item.
     333    '''
    320334    if len(data) < 2:       #add Debye diffuse & peaks scattering here
    321335        data.append({'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]})
     
    588602       
    589603def UpdateLimitsGrid(G2frame, data):
     604    '''respond to selection of PWDR Limits data tree item.
     605    '''
    590606    if G2frame.dataDisplay:
    591607        G2frame.dataFrame.Clear()
     
    643659       
    644660def UpdateInstrumentGrid(G2frame,data):
    645    
     661    '''respond to selection of PWDR Instrument Parameters
     662    data tree item.
     663    '''
    646664    def keycheck(keys):
    647665        good = []
     
    10361054       
    10371055def UpdateSampleGrid(G2frame,data):
    1038    
     1056    '''respond to selection of PWDR Sample Parameters
     1057    data tree item.
     1058    '''
    10391059    def SetCopyNames(histName,addNames=[]):
    10401060        copyNames = ['Scale',]
     
    13181338       
    13191339def UpdateIndexPeaksGrid(G2frame, data):
     1340    '''respond to selection of PWDR Index Peak List data
     1341    tree item.
     1342    '''
    13201343    IndexId = G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Index Peak List')
    13211344    Inst = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters'))[0]
     
    14151438       
    14161439def UpdateUnitCellsGrid(G2frame, data):
     1440    '''respond to selection of PWDR Unit Cells data tree item.
     1441    '''
    14171442    UnitCellsId = G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Unit Cells List')
    14181443    SPGlist = G2spc.spglist
     
    19051930       
    19061931def UpdateReflectionGrid(G2frame,data,HKLF=False,Name=''):
     1932    '''respond to selection of PWDR Reflections data tree item.
     1933    '''
    19071934    if not data:
    19081935        print 'No phases, no reflections'
     
    19711998       
    19721999def UpdatePDFGrid(G2frame,data):
     2000    '''respond to selection of PWDR PDF data tree item.
     2001    '''
    19732002    global inst
    19742003    tth2q = lambda t,w:4.0*math.pi*sind(t/2.0)/w
  • trunk/GSASIIrestrGUI.py

    r919 r923  
    88# $Id: GSASIIrestrGUI.py 810 2012-12-05 21:38:26Z vondreele $
    99########### SVN repository information ###################
     10'''
     11*GSASIIrestrGUI: Restraint GUI routines*
     12----------------------------------------
     13
     14Used to define restraints.
     15
     16'''
    1017import wx
    1118import wx.grid as wg
     
    3037       
    3138def UpdateRestraints(G2frame,data,Phases,phaseName):
     39    '''Respond to selection of the Restraints item on the
     40    data tree
     41    '''
     42    if not Phases:
     43        print 'There are no phases to form restraints'
     44        return
    3245    if not len(Phases):
    3346        print 'There are no phases to form restraints'
Note: See TracChangeset for help on using the changeset viewer.