Changeset 1236 for trunk/exports/G2export_csv.py
- Timestamp:
- Mar 5, 2014 1:51:53 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/exports/G2export_csv.py
r1191 r1236 21 21 GSASIIpath.SetVersionNumber("$Revision$") 22 22 import GSASIIIO as G2IO 23 #import GSASIIgrid as G2gd 24 #import GSASIIstrIO as G2stIO 23 import GSASIIpy3 as G2py3 24 import GSASIIobj as G2obj 25 25 import GSASIImath as G2mth 26 #import GSASIIlattice as G2lat27 #import GSASIIspc as G2spc28 #import GSASIIphsGUI as G2pg29 #import GSASIIstrMain as G2stMn30 26 31 27 def WriteList(obj,headerItems): … … 128 124 ) 129 125 self.exporttype = ['powder'] 130 self.multiple = False # only allow one histogram to be selected 126 #self.multiple = False # only allow one histogram to be selected 127 self.multiple = True 131 128 132 129 def Exporter(self,event=None): … … 138 135 self.loadTree() 139 136 if self.ExportSelect( # set export parameters 140 AskFile=False # use the default file name 141 ): return 142 self.OpenFile() 143 hist = self.histnam[0] # there should only be one histogram, in any case take the 1st 144 histblk = self.Histograms[hist] 145 WriteList(self,("x","y_obs","weight","y_calc","y_bkg")) 146 fmt = 2*"{:.3f}," + "{:.5f}," + 2*"{:.3f}," 147 for x,yobs,yw,ycalc,ybkg,obsmcalc in zip(histblk['Data'][0], 148 histblk['Data'][1], 149 histblk['Data'][2], 150 histblk['Data'][3], 151 histblk['Data'][4], 152 histblk['Data'][5], 153 ): 154 self.Write(fmt.format(x,yobs,yw,ycalc,ybkg)) 155 self.CloseFile() 156 print(str(hist)+' written to file '+str(self.filename)) 137 AskFile=False # use the default file name, which is ignored 138 ): return 139 filenamelist = [] 140 for hist in self.histnam: 141 fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(hist),filenamelist) 142 self.filename = fileroot + self.extension 143 self.OpenFile() 144 histblk = self.Histograms[hist] 145 WriteList(self,("x","y_obs","weight","y_calc","y_bkg")) 146 digitList = 2*((13,3),) + ((13,5),) + 2*((13,3),) 147 for vallist in zip(histblk['Data'][0], 148 histblk['Data'][1], 149 histblk['Data'][2], 150 histblk['Data'][3], 151 histblk['Data'][4], 152 #histblk['Data'][5], 153 ): 154 line = "" 155 for val,digits in zip(vallist,digitList): 156 if line: line += ',' 157 line += G2py3.FormatValue(val,digits) 158 self.Write(line) 159 self.CloseFile() 160 print('Histogram '+str(hist)+' written to file '+str(self.filename)) 157 161 158 162 class ExportPowderReflCSV(G2IO.ExportBaseclass):
Note: See TracChangeset
for help on using the changeset viewer.