Changeset 906 for trunk/GSASII.py
- Timestamp:
- May 15, 2013 6:18:22 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r903 r906 255 255 256 256 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. 259 285 ''' 260 286 self.lastimport = '' … … 436 462 437 463 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 ''' 438 471 # look up which format was requested 439 472 reqrdr = self.ImportMenuId.get(event.GetId()) … … 485 518 486 519 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 ''' 487 527 # look up which format was requested 488 528 reqrdr = self.ImportMenuId.get(event.GetId()) … … 535 575 536 576 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 ''' 538 582 if os.path.splitext(instfile)[1].lower() != '.instprm': # invalid file 539 583 return None … … 563 607 564 608 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 ''' 566 625 if not os.path.exists(instfile): # no such file 567 626 return {} … … 610 669 '''Open and read an instrument parameter file for a data file 611 670 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 612 681 ''' 613 682 def SetPowderInstParms(Iparm, rd): … … 837 906 838 907 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. 841 916 ''' 842 917 reqrdr = self.ImportMenuId.get(event.GetId()) # look up which format was requested … … 1117 1192 1118 1193 def OnSize(self,event): 1194 'Called when the main window is resized. Not sure why' 1119 1195 w,h = self.GetClientSizeTuple() 1120 1196 self.mainPanel.SetSize(wx.Size(w,h)) … … 1122 1198 1123 1199 def OnPatternTreeSelChanged(self, event): 1200 '''Called when a data tree item is selected''' 1124 1201 if self.TreeItemDelete: 1125 1202 self.TreeItemDelete = False … … 1135 1212 1136 1213 def OnPatternTreeItemCollapsed(self, event): 1214 'Called when a tree item is collapsed' 1137 1215 event.Skip() 1138 1216 1139 1217 def OnPatternTreeItemExpanded(self, event): 1218 'Called when a tree item is expanded' 1140 1219 event.Skip() 1141 1220 1142 1221 def OnPatternTreeItemDelete(self, event): 1222 'Called when a tree item is deleted -- not sure what this does' 1143 1223 self.TreeItemDelete = True 1144 1224 1145 1225 def OnPatternTreeItemActivated(self, event): 1226 'Called when a tree item is activated' 1146 1227 event.Skip() 1147 1228 1148 1229 def OnPatternTreeKeyDown(self,event): 1230 'Not sure what this does' 1149 1231 key = event.GetKeyCode() 1150 1232 item = self.PickId … … 1158 1240 1159 1241 def OnReadPowderPeaks(self,event): 1242 'Bound to menu Data/Read Powder Peaks -- still needed?' 1160 1243 Cuka = 1.54052 1161 1244 self.CheckNotebook() … … 1183 1266 1184 1267 def OnImageRead(self,event): 1268 'Called to read in an image in any known format' 1185 1269 self.CheckNotebook() 1186 1270 dlg = wx.FileDialog( … … 1269 1353 1270 1354 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. 1272 1356 (BHT) correct? 1273 1357 ''' … … 1295 1379 1296 1380 class CopyDialog(wx.Dialog): 1381 '''Creates a dialog for copying control settings between 1382 data tree items''' 1297 1383 def __init__(self,parent,title,text,data): 1298 1384 wx.Dialog.__init__(self,parent,-1,title, … … 1346 1432 1347 1433 class SumDialog(wx.Dialog): 1434 'Allows user to supply scale factor(s) when summing data' 1348 1435 def __init__(self,parent,title,text,dataType,data): 1349 1436 wx.Dialog.__init__(self,parent,-1,title, … … 1486 1573 1487 1574 def OnPwdrSum(self,event): 1575 'Sum together powder data(?)' 1488 1576 TextList = [] 1489 1577 DataList = [] … … 1582 1670 1583 1671 def OnImageSum(self,event): 1672 'Sum together image data(?)' 1584 1673 TextList = [] 1585 1674 DataList = [] … … 1684 1773 1685 1774 def OnAddPhase(self,event): 1775 'Add a new, empty phase to the tree. Called by Data/Add Phase menu' 1686 1776 if not G2gd.GetPatternTreeItemId(self,self.root,'Phases'): 1687 1777 sub = self.PatternTree.AppendItem(parent=self.root,text='Phases') … … 1699 1789 1700 1790 def OnDeletePhase(self,event): 1791 'Delete a phase from the tree. Called by Data/Delete Phase menu' 1701 1792 #Hmm, also need to delete this phase from Reflection Lists for each PWDR histogram 1702 1793 if self.dataFrame: … … 1743 1834 1744 1835 def OnRenameData(self,event): 1836 'Renames an existing phase. Called by Data/Rename Phase menu' 1745 1837 name = self.PatternTree.GetItemText(self.PickId) 1746 1838 if 'PWDR' in name or 'HKLF' in name or 'IMG' in name: … … 1755 1847 1756 1848 def GetFileList(self,fileType,skip=None): #potentially useful? 1849 'Appears unused. Note routine of same name in GSASIIpwdGUI' 1757 1850 fileList = [] 1758 1851 Source = '' … … 1772 1865 1773 1866 def OnDataDelete(self, event): 1867 '''Delete one or more histograms from data tree. Called by the 1868 Data/DeleteData menu 1869 ''' 1774 1870 TextList = ['All Data'] 1775 1871 DelList = [] … … 1821 1917 1822 1918 def OnFileOpen(self, event): 1919 '''Reads in a GSAS-II .gpx project file in response to the 1920 File/Open Project menu button 1921 ''' 1823 1922 result = '' 1824 1923 Id = 0 … … 1873 1972 1874 1973 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 ''' 1875 1978 if self.dataFrame: 1876 1979 self.dataFrame.Clear() … … 1892 1995 1893 1996 def OnFileSave(self, event): 1997 '''Save the current project in response to the 1998 File/Save Project menu button 1999 ''' 1894 2000 1895 2001 if self.GSASprojectfile: … … 1900 2006 1901 2007 def OnFileSaveas(self, event): 2008 '''Save the current project in response to the 2009 File/Save as menu button 2010 ''' 1902 2011 dlg = wx.FileDialog(self, 'Choose GSAS-II project file name', '.', '', 1903 2012 'GSAS-II project file (*.gpx)|*.gpx',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) … … 1915 2024 1916 2025 def ExitMain(self, event): 2026 '''Called if the main window is closed''' 1917 2027 if self.undofile: 1918 2028 os.remove(self.undofile) … … 1920 2030 1921 2031 def OnFileExit(self, event): 2032 '''Called in response to the File/Quit menu button''' 1922 2033 if self.dataFrame: 1923 2034 self.dataFrame.Clear() … … 2019 2130 2020 2131 def OnMakePDFs(self,event): 2132 '''Calculates PDFs 2133 ''' 2021 2134 tth2q = lambda t,w:4.0*math.pi*sind(t/2.0)/w 2022 2135 TextList = ['All PWDR'] … … 2063 2176 def GetPWDRdatafromTree(self,PWDRname): 2064 2177 ''' 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 2070 2185 ''' 2071 2186 PWDRdata = {} … … 2087 2202 def GetHKLFdatafromTree(self,HKLFname): 2088 2203 ''' 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 2094 2211 ''' 2095 2212 HKLFdata = {} … … 2103 2220 2104 2221 def GetPhaseData(self): 2222 '''Returns a list of defined phases. Used only in GSASIIgrid 2223 Note routine :mod:`GSASIIstruct.GetPhaseData` also exists. 2224 ''' 2105 2225 phaseData = {} 2106 2226 if G2gd.GetPatternTreeItemId(self,self.root,'Phases'): … … 2122 2242 ''' Returns all histograms that are found in any phase 2123 2243 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 2127 2248 ''' 2128 2249 phaseData = self.GetPhaseData() … … 2153 2274 2154 2275 class ViewParmDialog(wx.Dialog): 2276 '''Window to show all parameters in the refinement. 2277 Called from :mod:`OnViewLSParms` 2278 ''' 2155 2279 def __init__(self,parent,title,parmDict): 2156 2280 wx.Dialog.__init__(self,parent,-1,title,size=(300,430), … … 2173 2297 2174 2298 def OnViewLSParms(self,event): 2299 '''Displays a window showing all parameters in the refinement. 2300 Called from the Calculate/View LS Parms menu. 2301 ''' 2175 2302 parmDict = {} 2176 2303 Histograms,Phases = self.GetUsedHistogramsAndPhasesfromTree() … … 2206 2333 2207 2334 def OnRefine(self,event): 2335 '''Perform a refinement. 2336 Called from the Calculate/Refine menu. 2337 ''' 2208 2338 self.OnFileSave(event) 2209 2339 # check that constraints are OK here … … 2271 2401 2272 2402 def OnSeqRefine(self,event): 2403 '''Perform a sequential refinement. 2404 Called from the Calculate/Sequential refine menu. 2405 ''' 2273 2406 Id = G2gd.GetPatternTreeItemId(self,self.root,'Sequental results') 2274 2407 if not Id: … … 2324 2457 2325 2458 def ErrorDialog(self,title,message,parent=None, wtype=wx.OK): 2459 'Display an error message' 2326 2460 result = None 2327 2461 if parent is None:
Note: See TracChangeset
for help on using the changeset viewer.