Changeset 906 for trunk/GSASII.py


Ignore:
Timestamp:
May 15, 2013 6:18:22 PM (9 years ago)
Author:
toby
Message:

switch to aui.notebook for data display window; work on phase data display window - quicker initial draw, fix horizontal lines (needs more work); more sphinx documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r903 r906  
    255255
    256256    def OnImportGeneric(self,reader,readerlist,label,multiple=False):
    257         '''Call the requested import reader or all of the appropriate
    258         import readers in response to a menu item
     257        '''Used to import Phases, powder dataset or single
     258        crystal datasets (structure factor tables) using reader objects
     259        subclassed from GSASIIIO.ImportPhase, GSASIIIO.ImportStructFactor
     260        or GSASIIIO.ImportPowderData. If a reader is specified, only
     261        that will be attempted, but if no reader is specified, every one
     262        that is potentially compatible (by file extension) will
     263        be tried on the selected file(s).
     264
     265        :param readerobject reader: This will be a reference to
     266          a particular object to be used to read a file or None,
     267          if every appropriate reader should be used.
     268
     269        :param list readerlist: a list of reader objects appropriate for
     270          the current read attempt. At present, this will be either
     271          self.ImportPhaseReaderlist, self.ImportSfactReaderlist or
     272          self.ImportPowderReaderlist (defined in _init_Imports from
     273          the files found in the path), but in theory this list could
     274          be tailored. Used only when reader is None.
     275
     276        :param str label: string to place on the open file dialog:
     277          Open `label` input file
     278
     279        :param bool multiple: True if multiple files can be selected
     280          in the file dialog. False is default. At present True is used
     281          only for reading of powder data.
     282         
     283        :returns: a list of reader objects (rd_list) that were able
     284          to read the specified file(s). This list may be empty.
    259285        '''
    260286        self.lastimport = ''
     
    436462
    437463    def OnImportPhase(self,event):
     464        '''Called in response to an Import/Phase/... menu item
     465        to read phase information.
     466        dict self.ImportMenuId is used to look up the specific
     467        reader item associated with the menu item, which will be
     468        None for the last menu item, which is the "guess" option
     469        where all appropriate formats will be tried.
     470        '''
    438471        # look up which format was requested
    439472        reqrdr = self.ImportMenuId.get(event.GetId())
     
    485518
    486519    def OnImportSfact(self,event):
     520        '''Called in response to an Import/Structure Factor/... menu item
     521        to read single crystal datasets.
     522        dict self.ImportMenuId is used to look up the specific
     523        reader item associated with the menu item, which will be
     524        None for the last menu item, which is the "guess" option
     525        where all appropriate formats will be tried.
     526        '''
    487527        # look up which format was requested
    488528        reqrdr = self.ImportMenuId.get(event.GetId())
     
    535575           
    536576    def ReadPowderInstprm(self,instfile):       #fix the write routine for [inst1,inst2] style
    537         '''Read a GSAS-II (new) instrument parameter file'''
     577        '''Read a GSAS-II (new) instrument parameter file
     578
     579        :param str instfile: name of instrument parameter file
     580
     581        '''
    538582        if os.path.splitext(instfile)[1].lower() != '.instprm': # invalid file
    539583            return None           
     
    563607       
    564608    def ReadPowderIparm(self,instfile,bank,databanks,rd):
    565         '''Read a GSAS (old) instrument parameter file'''
     609        '''Read a GSAS (old) instrument parameter file
     610
     611        :param str instfile: name of instrument parameter file
     612
     613        :param int bank: the bank number read in the raw data file
     614
     615        :param int databanks: the number of banks in the raw data file.
     616          If the number of banks in the data and instrument parameter files
     617          agree, then the sets of banks are assumed to match up and bank
     618          is used to select the instrument parameter file. If not, the user
     619          is asked to make a selection.
     620
     621        :param obj rd: the raw data (histogram) data object. This
     622          sets rd.instbank.
     623
     624        '''
    566625        if not os.path.exists(instfile): # no such file
    567626            return {}
     
    610669        '''Open and read an instrument parameter file for a data file
    611670        Returns the list of parameters used in the data tree
     671
     672        :param obj rd: the raw data (histogram) data object.
     673
     674        :param str prevIparm: not used
     675
     676        :param str lastIparmfile: Name of last instrument parameter
     677          file that was read, or a empty string.
     678
     679        :param str lastdatafile: Name of last data file that was read.
     680
    612681        '''
    613682        def SetPowderInstParms(Iparm, rd):
     
    837906
    838907    def OnImportPowder(self,event):
    839         '''reads powder data using a variety of formats
    840         reads an instrument parameter file for each dataset
     908        '''Called in response to an Import/Powder Data/... menu item
     909        to read a powder diffraction data set.
     910        dict self.ImportMenuId is used to look up the specific
     911        reader item associated with the menu item, which will be
     912        None for the last menu item, which is the "guess" option
     913        where all appropriate formats will be tried.
     914
     915        Also reads an instrument parameter file for each dataset.
    841916        '''
    842917        reqrdr = self.ImportMenuId.get(event.GetId())  # look up which format was requested
     
    11171192
    11181193    def OnSize(self,event):
     1194        'Called when the main window is resized. Not sure why'
    11191195        w,h = self.GetClientSizeTuple()
    11201196        self.mainPanel.SetSize(wx.Size(w,h))
     
    11221198                       
    11231199    def OnPatternTreeSelChanged(self, event):
     1200        '''Called when a data tree item is selected'''
    11241201        if self.TreeItemDelete:
    11251202            self.TreeItemDelete = False
     
    11351212       
    11361213    def OnPatternTreeItemCollapsed(self, event):
     1214        'Called when a tree item is collapsed'
    11371215        event.Skip()
    11381216
    11391217    def OnPatternTreeItemExpanded(self, event):
     1218        'Called when a tree item is expanded'
    11401219        event.Skip()
    11411220       
    11421221    def OnPatternTreeItemDelete(self, event):
     1222        'Called when a tree item is deleted -- not sure what this does'
    11431223        self.TreeItemDelete = True
    11441224
    11451225    def OnPatternTreeItemActivated(self, event):
     1226        'Called when a tree item is activated'
    11461227        event.Skip()
    11471228       
    11481229    def OnPatternTreeKeyDown(self,event):
     1230        'Not sure what this does'
    11491231        key = event.GetKeyCode()
    11501232        item = self.PickId
     
    11581240               
    11591241    def OnReadPowderPeaks(self,event):
     1242        'Bound to menu Data/Read Powder Peaks -- still needed?'
    11601243        Cuka = 1.54052
    11611244        self.CheckNotebook()
     
    11831266           
    11841267    def OnImageRead(self,event):
     1268        'Called to read in an image in any known format'
    11851269        self.CheckNotebook()
    11861270        dlg = wx.FileDialog(
     
    12691353
    12701354    def CheckNotebook(self):
    1271         '''Make sure the data tree has the minimally expected controls
     1355        '''Make sure the data tree has the minimally expected controls.
    12721356        (BHT) correct?
    12731357        '''
     
    12951379               
    12961380    class CopyDialog(wx.Dialog):
     1381        '''Creates a dialog for copying control settings between
     1382        data tree items'''
    12971383        def __init__(self,parent,title,text,data):
    12981384            wx.Dialog.__init__(self,parent,-1,title,
     
    13461432       
    13471433    class SumDialog(wx.Dialog):
     1434        'Allows user to supply scale factor(s) when summing data'
    13481435        def __init__(self,parent,title,text,dataType,data):
    13491436            wx.Dialog.__init__(self,parent,-1,title,
     
    14861573           
    14871574    def OnPwdrSum(self,event):
     1575        'Sum together powder data(?)'
    14881576        TextList = []
    14891577        DataList = []
     
    15821670
    15831671    def OnImageSum(self,event):
     1672        'Sum together image data(?)'
    15841673        TextList = []
    15851674        DataList = []
     
    16841773                     
    16851774    def OnAddPhase(self,event):
     1775        'Add a new, empty phase to the tree. Called by Data/Add Phase menu'
    16861776        if not G2gd.GetPatternTreeItemId(self,self.root,'Phases'):
    16871777            sub = self.PatternTree.AppendItem(parent=self.root,text='Phases')
     
    16991789       
    17001790    def OnDeletePhase(self,event):
     1791        'Delete a phase from the tree. Called by Data/Delete Phase menu'
    17011792        #Hmm, also need to delete this phase from Reflection Lists for each PWDR histogram
    17021793        if self.dataFrame:
     
    17431834               
    17441835    def OnRenameData(self,event):
     1836        'Renames an existing phase. Called by Data/Rename Phase menu'
    17451837        name = self.PatternTree.GetItemText(self.PickId)     
    17461838        if 'PWDR' in name or 'HKLF' in name or 'IMG' in name:
     
    17551847       
    17561848    def GetFileList(self,fileType,skip=None):        #potentially useful?
     1849        'Appears unused. Note routine of same name in GSASIIpwdGUI'
    17571850        fileList = []
    17581851        Source = ''
     
    17721865           
    17731866    def OnDataDelete(self, event):
     1867        '''Delete one or more histograms from data tree. Called by the
     1868        Data/DeleteData menu
     1869        '''
    17741870        TextList = ['All Data']
    17751871        DelList = []
     
    18211917
    18221918    def OnFileOpen(self, event):
     1919        '''Reads in a GSAS-II .gpx project file in response to the
     1920        File/Open Project menu button
     1921        '''
    18231922        result = ''
    18241923        Id = 0
     
    18731972
    18741973    def OnFileClose(self, event):
     1974        '''Clears the data tree in response to the
     1975        File/Close Project menu button. User is given option to save
     1976        the project.
     1977        '''
    18751978        if self.dataFrame:
    18761979            self.dataFrame.Clear()
     
    18921995
    18931996    def OnFileSave(self, event):
     1997        '''Save the current project in response to the
     1998        File/Save Project menu button
     1999        '''
    18942000       
    18952001        if self.GSASprojectfile:
     
    19002006
    19012007    def OnFileSaveas(self, event):
     2008        '''Save the current project in response to the
     2009        File/Save as menu button
     2010        '''
    19022011        dlg = wx.FileDialog(self, 'Choose GSAS-II project file name', '.', '',
    19032012            'GSAS-II project file (*.gpx)|*.gpx',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR)
     
    19152024
    19162025    def ExitMain(self, event):
     2026        '''Called if the main window is closed'''
    19172027        if self.undofile:
    19182028            os.remove(self.undofile)
     
    19202030       
    19212031    def OnFileExit(self, event):
     2032        '''Called in response to the File/Quit menu button'''
    19222033        if self.dataFrame:
    19232034            self.dataFrame.Clear()
     
    20192130
    20202131    def OnMakePDFs(self,event):
     2132        '''Calculates PDFs
     2133        '''
    20212134        tth2q = lambda t,w:4.0*math.pi*sind(t/2.0)/w
    20222135        TextList = ['All PWDR']
     
    20632176    def GetPWDRdatafromTree(self,PWDRname):
    20642177        ''' Returns powder data from GSASII tree
    2065         input:
    2066             PWDRname = powder histogram name as obtained from GetHistogramNames
    2067         return:
    2068             PWDRdata = powder data dictionary with:
    2069                 Data - powder data arrays, Limits, Instrument Parameters, Sample Parameters           
     2178
     2179        :param str PWDRname: a powder histogram name as obtained from
     2180          :mod:`GSASIIstruct.GetHistogramNames`
     2181
     2182        :returns: PWDRdata = powder data dictionary with
     2183          Powder data arrays, Limits, Instrument Parameters,
     2184          Sample Parameters           
    20702185        '''
    20712186        PWDRdata = {}
     
    20872202    def GetHKLFdatafromTree(self,HKLFname):
    20882203        ''' Returns single crystal data from GSASII tree
    2089         input:
    2090             HKLFname = single crystal histogram name as obtained from GetHistogramNames
    2091         return:
    2092             HKLFdata = single crystal data list of reflections: for each reflection:
    2093                 HKLF =
     2204
     2205        :param str HKLFname: a single crystal histogram name as obtained
     2206          from
     2207          :mod:`GSASIIstruct.GetHistogramNames`
     2208
     2209        :returns: HKLFdata = single crystal data list of reflections
     2210
    20942211        '''
    20952212        HKLFdata = {}
     
    21032220       
    21042221    def GetPhaseData(self):
     2222        '''Returns a list of defined phases. Used only in GSASIIgrid
     2223        Note routine :mod:`GSASIIstruct.GetPhaseData` also exists.
     2224        '''
    21052225        phaseData = {}
    21062226        if G2gd.GetPatternTreeItemId(self,self.root,'Phases'):
     
    21222242        ''' Returns all histograms that are found in any phase
    21232243        and any phase that uses a histogram
    2124         return:
    2125             Histograms = dictionary of histograms as {name:data,...}
    2126             Phases = dictionary of phases that use histograms
     2244        :returns: two dicts:
     2245
     2246            * Histograms = dictionary of histograms as {name:data,...}
     2247            * Phases = dictionary of phases that use histograms
    21272248        '''
    21282249        phaseData = self.GetPhaseData()
     
    21532274       
    21542275    class ViewParmDialog(wx.Dialog):
     2276        '''Window to show all parameters in the refinement.
     2277        Called from :mod:`OnViewLSParms`
     2278        '''
    21552279        def __init__(self,parent,title,parmDict):
    21562280            wx.Dialog.__init__(self,parent,-1,title,size=(300,430),
     
    21732297                           
    21742298    def OnViewLSParms(self,event):
     2299        '''Displays a window showing all parameters in the refinement.
     2300        Called from the Calculate/View LS Parms menu.
     2301        '''
    21752302        parmDict = {}
    21762303        Histograms,Phases = self.GetUsedHistogramsAndPhasesfromTree()
     
    22062333       
    22072334    def OnRefine(self,event):
     2335        '''Perform a refinement.
     2336        Called from the Calculate/Refine menu.
     2337        '''       
    22082338        self.OnFileSave(event)
    22092339        # check that constraints are OK here
     
    22712401
    22722402    def OnSeqRefine(self,event):
     2403        '''Perform a sequential refinement.
     2404        Called from the Calculate/Sequential refine menu.
     2405        '''       
    22732406        Id = G2gd.GetPatternTreeItemId(self,self.root,'Sequental results')
    22742407        if not Id:
     
    23242457       
    23252458    def ErrorDialog(self,title,message,parent=None, wtype=wx.OK):
     2459        'Display an error message'
    23262460        result = None
    23272461        if parent is None:
Note: See TracChangeset for help on using the changeset viewer.