Changeset 923
- Timestamp:
- May 17, 2013 4:25:32 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIElemGUI.py
r903 r923 1 1 # -*- coding: utf-8 -*- 2 """ElementGUI: class defn. for element GUIs3 Copyright: 2008, Robert B. Von Dreele & Brian H. Toby (Argonne National Laboratory)4 """5 2 ########### SVN repository information ################### 6 3 # $Date$ … … 10 7 # $Id$ 11 8 ########### SVN repository information ################### 9 ''' 10 *GSASIIElemGUI: GUI to select and delete element lists* 11 ------------------------------------------------------- 12 13 Module to select elements from a periodic table and 14 to 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 12 20 import wx 13 21 import os … … 37 45 38 46 def __init__(self, parent,oneOnly=False,ifNone=False): 47 'Needs a doc string' 39 48 self.oneOnly = oneOnly 40 49 self.ifNone = ifNone … … 42 51 43 52 def ElButton(self, name, pos, tip, color): 53 'Needs a doc string' 44 54 Black = wx.Colour(0,0,0) 45 55 if not self.ifNone and name[0] == 'None': … … 91 101 92 102 def ElButton(self, id, name, pos): 103 'Needs a doc string' 93 104 White = wx.Colour(255, 255, 255) 94 105 El = wscs.ColourSelect(label=name, parent=self, colour = White, -
trunk/GSASIIIO.py
r905 r923 1 1 # -*- coding: utf-8 -*- 2 """GSASIIIO: functions for IO of data3 Copyright: 2008, Robert B. Von Dreele (Argonne National Laboratory)4 """5 2 ########### SVN repository information ################### 6 3 # $Date$ … … 10 7 # $Id$ 11 8 ########### SVN repository information ################### 9 ''' 10 *GSASIIIO: Misc I/O routines* 11 ============================= 12 13 Module with miscellaneous routines for input and output. Many 14 are GUI routines to interact with user. 15 16 Includes support for image reading. 17 18 Also 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 """ 12 24 import wx 13 25 import math … … 27 39 28 40 def sfloat(S): 41 'Convert a string to float. An empty field is treated as zero' 29 42 if S.strip(): 30 43 return float(S) … … 33 46 34 47 def sint(S): 48 'Convert a string to int. An empty field is treated as zero' 35 49 if S.strip(): 36 50 return int(S) … … 46 60 47 61 def FileDlgFixExt(dlg,file): 48 #this is needed to fix a problem in linux wx.FileDialog62 'this is needed to fix a problem in linux wx.FileDialog' 49 63 ext = dlg.GetWildcard().split('|')[2*dlg.GetFilterIndex()+1].strip('*') 50 64 if ext not in file: … … 53 67 54 68 def GetPowderPeaks(fileName): 69 'Read powder peaks from a file' 55 70 sind = lambda x: math.sin(x*math.pi/180.) 56 71 asind = lambda x: 180.*math.asin(x)/math.pi … … 92 107 93 108 def 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 ''' 94 120 if not ospath.exists(imagefile): 95 121 dlg = wx.FileDialog(G2frame, 'Bad image file name; choose name', '.', '',\ … … 112 138 return imagefile 113 139 114 def GetImageData(G2frame,imagefile,imageOnly=False): 140 def 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 ''' 115 155 ext = ospath.splitext(imagefile)[1] 116 156 Comments = [] … … 134 174 135 175 def PutG2Image(filename,Comments,Data,Npix,image): 176 'Write an image as a python pickle' 136 177 File = open(filename,'wb') 137 178 cPickle.dump([Comments,Data,Npix,image],File,1) … … 140 181 141 182 def GetG2Image(filename): 183 'Read an image as a python pickle' 142 184 File = open(filename,'rb') 143 185 Comments,Data,Npix,image = cPickle.load(File) … … 146 188 147 189 def GetEdfData(filename,imageOnly=False): 190 'Read European detector data edf file' 148 191 import struct as st 149 192 import array as ar … … 197 240 198 241 def GetGEsumData(filename,imageOnly=False): 242 'Read SUM file as produced at 1-ID from G.E. images' 199 243 import struct as st 200 244 import array as ar … … 234 278 235 279 def GetImgData(filename,imageOnly=False): 280 'Read an ADSC image file' 236 281 import struct as st 237 282 import array as ar … … 284 329 285 330 def GetMAR345Data(filename,imageOnly=False): 331 'Read a MAR-345 image plate image' 286 332 import array as ar 287 333 import struct as st … … 341 387 342 388 def 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 ''' 343 393 import struct as st 344 394 import array as ar … … 640 690 # 641 691 def ProjFileOpen(G2frame): 692 'Read a GSAS-II project file' 642 693 file = open(G2frame.GSASprojectfile,'rb') 643 694 print 'load from file: ',G2frame.GSASprojectfile … … 686 737 687 738 def ProjFileSave(G2frame): 739 'Save a GSAS-II project file' 688 740 if not G2frame.PatternTree.IsEmpty(): 689 741 file = open(G2frame.GSASprojectfile,'wb') … … 709 761 710 762 def SaveIntegration(G2frame,PickId,data): 763 'Save image integration results as powder pattern(s)' 711 764 azms = G2frame.Integrate[1] 712 765 X = G2frame.Integrate[2][:-1] … … 776 829 777 830 def powderFxyeSave(G2frame,exports,powderfile): 831 'Save a powder histogram as a GSAS FXYE file' 778 832 head,tail = ospath.split(powderfile) 779 833 name,ext = tail.split('.') … … 815 869 816 870 def powderXyeSave(G2frame,exports,powderfile): 871 'Save a powder histogram as a Topas XYE file' 817 872 head,tail = ospath.split(powderfile) 818 873 name,ext = tail.split('.') … … 831 886 print 'powder pattern file '+filename+' written' 832 887 833 def PDFSave(G2frame,exports): 888 def PDFSave(G2frame,exports): 889 'Save a PDF G(r) and S(Q) in column formats' 834 890 for export in exports: 835 891 PickId = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, export) … … 856 912 857 913 def PeakListSave(G2frame,file,peaks): 914 'Save powder peaks to a data file' 858 915 print 'save peak list to file: ',G2frame.peaklistfile 859 916 if not peaks: … … 870 927 871 928 def IndexPeakListSave(G2frame,peaks): 929 'Save powder peaks from the indexing list' 872 930 file = open(G2frame.peaklistfile,'wa') 873 931 print 'save index peak list to file: ',G2frame.peaklistfile … … 889 947 890 948 def 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' 891 950 phaseData = { 892 951 'ranId':ran.randint(0,sys.maxint), … … 918 977 919 978 def 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 ''' 920 982 shModels = ['cylindrical','none','shear - 2/m','rolling - mmm'] 921 983 textureData = {'Order':0,'Model':'cylindrical','Sample omega':[False,0.0], … … 1042 1104 1043 1105 def ReadPDBPhase(filename): 1106 '''Read a phase from a PDB file. 1107 Called in the PDB phase import routine (see imports/G2phase.py) 1108 ''' 1044 1109 EightPiSq = 8.*math.pi**2 1045 1110 file = open(filename, 'Ur') … … 1128 1193 1129 1194 class MultipleChoicesDialog(wx.Dialog): 1130 '''A dialog that offers a series of choices, each with a title and a wx.Choice1131 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. 1132 1197 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 1135 1202 selections are placed in self.chosen when OK is pressed 1136 1203 ''' … … 1190 1257 confirmoverwrite=True, parent=None, 1191 1258 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 1207 1282 ''' 1208 1283 import zipfile # do this now, since we can save startup time by doing this only on need … … 1360 1435 def MultipleBlockSelector(self, ChoiceList, ParentFrame=None, 1361 1436 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 1365 1442 ''' 1366 1443 dlg = wx.MultiChoiceDialog(ParentFrame,title, header,ChoiceList+['Select all'], … … 1381 1458 def MultipleChoicesDialog(self, choicelist, headinglist, ParentFrame=None, **kwargs): 1382 1459 '''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 1387 1466 optional keyword parameters are: head (window title) and title 1388 1467 returns a list of selected indicies for each choice (or None) -
trunk/GSASIIconstrGUI.py
r906 r923 8 8 # $Id: GSASIIconstrGUI.py 810 2012-12-05 21:38:26Z vondreele $ 9 9 ########### SVN repository information ################### 10 ''' 11 *GSASIIconstrGUI: Constraint GUI routines* 12 ------------------------------------------ 13 14 Used to define constraints and rigid bodies. 15 16 ''' 10 17 import sys 11 18 import wx … … 27 34 28 35 class MultiIntegerDialog(wx.Dialog): 29 36 '''Input a series of integers based on prompts 37 ''' 30 38 def __init__(self,parent,title,prompts,values): 31 39 wx.Dialog.__init__(self,parent,-1,title, -
trunk/GSASIIddataGUI.py
r912 r923 10 10 ''' 11 11 *GSASIIddataGUI: Phase Diffraction Data GUI* 12 ============================================ 12 -------------------------------------------- 13 13 14 Module to create the GUI for display of diffraction data * phase 14 15 information that is shown in the data display window -
trunk/GSASIIgrid.py
r914 r923 10 10 ''' 11 11 *GSASIIgrid: Basic GUI routines* 12 ================================ 12 -------------------------------- 13 13 14 14 15 ''' … … 1951 1952 1952 1953 def UpdatePWHKPlot(G2frame,kind,item): 1953 '''N ot sure what this does1954 '''Needs a doc string 1954 1955 ''' 1955 1956 … … 1997 1998 1998 1999 def UpdateHKLControls(G2frame,data): 1999 '''N ot sure what this does2000 '''Needs a doc string 2000 2001 ''' 2001 2002 … … 2092 2093 2093 2094 def GetPatternTreeDataNames(G2frame,dataTypes): 2094 '''N ot sure what this does2095 '''Needs a doc string 2095 2096 ''' 2096 2097 names = [] … … 2104 2105 2105 2106 def GetPatternTreeItemId(G2frame, parentId, itemText): 2106 '''N ot sure what this does2107 '''Needs a doc string 2107 2108 ''' 2108 2109 item, cookie = G2frame.PatternTree.GetFirstChild(parentId) … … 2114 2115 2115 2116 def MovePatternTreeToGrid(G2frame,item): 2116 '''N ot sure what this does2117 '''Needs a doc string 2117 2118 ''' 2118 2119 -
trunk/GSASIIimage.py
r893 r923 8 8 # $Id$ 9 9 ########### SVN repository information ################### 10 ''' 11 *GSASIIimage: Image calc module* 12 ================================ 13 14 Ellipse fitting & image integration 15 16 needs some minor refactoring to remove wx code 17 ''' 18 10 19 import math 11 20 import wx -
trunk/GSASIIimgGUI.py
r892 r923 8 8 # $Id$ 9 9 ########### SVN repository information ################### 10 ''' 11 *GSASIIimgGUI: Image GUI* 12 ------------------------- 13 14 Control image display and processing 15 16 ''' 10 17 import wx 11 18 import matplotlib as mpl … … 34 41 ################################################################################ 35 42 def UpdateImageControls(G2frame,data,masks): 43 '''Shows and handles the controls on the "Image Controls" 44 data tree entry 45 ''' 36 46 import ImageCalibrants as calFile 37 47 #patch … … 819 829 820 830 def UpdateMasks(G2frame,data): 831 '''Shows and handles the controls on the "Masks" 832 data tree entry 833 ''' 821 834 822 835 def OnTextMsg(event): … … 1136 1149 1137 1150 def UpdateStressStrain(G2frame,data): 1151 '''Shows and handles the controls on the "Stress/Strain" 1152 data tree entry 1153 ''' 1138 1154 1139 1155 def OnAppendDzero(event): -
trunk/GSASIIindex.py
r792 r923 9 9 # $Id$ 10 10 ########### SVN repository information ################### 11 ''' 12 *GSASIIindex: Cell Indexing Module* 13 =================================== 14 15 Cell indexing program: variation on that of A. Coehlo 16 includes cell refinement from peak positions (not zero as yet) 17 18 This needs a bit of refactoring to remove the little bit of GUI 19 code referencing wx 20 ''' 21 11 22 import math 12 23 import wx -
trunk/GSASIIpwdGUI.py
r904 r923 1 1 # -*- coding: utf-8 -*- 2 #GSASII -data display routines2 #GSASIIpwdGUI - powder data display routines 3 3 ########### SVN repository information ################### 4 4 # $Date$ … … 8 8 # $Id$ 9 9 ########### SVN repository information ################### 10 ''' 11 *GSASIIpwdGUI: Powder Pattern GUI routines* 12 ------------------------------------------- 13 14 Used to define GUI controls for the routines that interact 15 with the powder histogram (PWDR) data tree items. 16 17 ''' 10 18 import sys 11 19 import os.path … … 39 47 40 48 def IsHistogramInAnyPhase(G2frame,histoName): 49 'Needs a doc string' 41 50 phases = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Phases') 42 51 if phases: … … 53 62 54 63 def SetDefaultSample(): 64 'Needs a doc string' 55 65 return {'ranId':ran.randint(0,sys.maxint), 56 66 'Scale':[1.0,True],'Type':'Debye-Scherrer','Absorption':[0.0,False], … … 65 75 66 76 def UpdatePeakGrid(G2frame, data): 77 '''respond to selection of PWDR powder peaks data tree item. 78 ''' 67 79 if G2frame.dataDisplay: 68 80 G2frame.dataFrame.Clear() … … 318 330 319 331 def UpdateBackground(G2frame,data): 332 '''respond to selection of PWDR background data tree item. 333 ''' 320 334 if len(data) < 2: #add Debye diffuse & peaks scattering here 321 335 data.append({'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}) … … 588 602 589 603 def UpdateLimitsGrid(G2frame, data): 604 '''respond to selection of PWDR Limits data tree item. 605 ''' 590 606 if G2frame.dataDisplay: 591 607 G2frame.dataFrame.Clear() … … 643 659 644 660 def UpdateInstrumentGrid(G2frame,data): 645 661 '''respond to selection of PWDR Instrument Parameters 662 data tree item. 663 ''' 646 664 def keycheck(keys): 647 665 good = [] … … 1036 1054 1037 1055 def UpdateSampleGrid(G2frame,data): 1038 1056 '''respond to selection of PWDR Sample Parameters 1057 data tree item. 1058 ''' 1039 1059 def SetCopyNames(histName,addNames=[]): 1040 1060 copyNames = ['Scale',] … … 1318 1338 1319 1339 def UpdateIndexPeaksGrid(G2frame, data): 1340 '''respond to selection of PWDR Index Peak List data 1341 tree item. 1342 ''' 1320 1343 IndexId = G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Index Peak List') 1321 1344 Inst = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters'))[0] … … 1415 1438 1416 1439 def UpdateUnitCellsGrid(G2frame, data): 1440 '''respond to selection of PWDR Unit Cells data tree item. 1441 ''' 1417 1442 UnitCellsId = G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Unit Cells List') 1418 1443 SPGlist = G2spc.spglist … … 1905 1930 1906 1931 def UpdateReflectionGrid(G2frame,data,HKLF=False,Name=''): 1932 '''respond to selection of PWDR Reflections data tree item. 1933 ''' 1907 1934 if not data: 1908 1935 print 'No phases, no reflections' … … 1971 1998 1972 1999 def UpdatePDFGrid(G2frame,data): 2000 '''respond to selection of PWDR PDF data tree item. 2001 ''' 1973 2002 global inst 1974 2003 tth2q = lambda t,w:4.0*math.pi*sind(t/2.0)/w -
trunk/GSASIIrestrGUI.py
r919 r923 8 8 # $Id: GSASIIrestrGUI.py 810 2012-12-05 21:38:26Z vondreele $ 9 9 ########### SVN repository information ################### 10 ''' 11 *GSASIIrestrGUI: Restraint GUI routines* 12 ---------------------------------------- 13 14 Used to define restraints. 15 16 ''' 10 17 import wx 11 18 import wx.grid as wg … … 30 37 31 38 def 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 32 45 if not len(Phases): 33 46 print 'There are no phases to form restraints'
Note: See TracChangeset
for help on using the changeset viewer.