Changeset 1191 for trunk/exports/G2export_csv.py
- Timestamp:
- Jan 10, 2014 2:46:36 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/exports/G2export_csv.py
r1127 r1191 17 17 ''' 18 18 import os.path 19 import numpy as np 19 20 import GSASIIpath 20 21 GSASIIpath.SetVersionNumber("$Revision$") … … 235 236 print(str(hist)+' written to file '+str(self.filename)) 236 237 238 class ExportStrainCSV(G2IO.ExportBaseclass): 239 '''Used to create a csv file with single crystal reflection data 240 241 :param wx.Frame G2frame: reference to main GSAS-II frame 242 ''' 243 def __init__(self,G2frame): 244 super(self.__class__,self).__init__( # fancy way to say <parentclass>.__init__ 245 G2frame=G2frame, 246 formatName = 'Strain CSV file', 247 extension='.csv', 248 longFormatName = 'Export strain results as a comma-separated (csv) file' 249 ) 250 self.exporttype = ['image'] 251 self.multiple = False # only allow one histogram to be selected 252 253 def Exporter(self,event=None): 254 '''Export a set of single crystal data as a csv file 255 ''' 256 # the export process starts here 257 self.InitExport(event) 258 # load all of the tree into a set of dicts 259 self.loadTree() 260 if self.ExportSelect( # set export parameters 261 AskFile=True # use the default file name 262 ): return 263 self.OpenFile() 264 hist = self.histnam[0] # there should only be one histogram, in any case take the 1st 265 histblk = self.Histograms[hist] 266 StrSta = histblk['Stress/Strain'] 267 WriteList(self,("Dset","Dcalc","e11","sig(e11)","e12","sig(e12)","e22","sig(e22)")) 268 fmt = 2*"{:.5f},"+6*"{:.0f}," 269 fmt1 = "{:.5f}" 270 fmt2 = "{:.2f},{:.5f},{:.5f}" 271 for item in StrSta['d-zero']: 272 Emat = item['Emat'] 273 Esig = item['Esig'] 274 self.Write(fmt.format(item['Dset'],item['Dcalc'],Emat[0],Esig[0],Emat[1],Esig[1],Emat[2],Esig[2])) 275 for item in StrSta['d-zero']: 276 WriteList(self,("Azm","dobs","dcalc","Dset="+fmt1.format(item['Dset']))) 277 ring = np.vstack((item['ImtaObs'],item['ImtaCalc'])) 278 for dat in ring.T: 279 self.Write(fmt2.format(dat[1],dat[0],dat[2])) 280 self.CloseFile() 281 print(str(hist)+' written to file '+str(self.filename)) 282
Note: See TracChangeset
for help on using the changeset viewer.