Ignore:
Timestamp:
Mar 5, 2014 1:51:53 PM (10 years ago)
Author:
toby
Message:

Add FXYE & XYE exporters; allow multiple powder exports; fix formatting of float32 intensities (which should be gone); minor sequential refinement changes; remove old export patterns items; new padded format routine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exports/G2export_csv.py

    r1191 r1236  
    2121GSASIIpath.SetVersionNumber("$Revision$")
    2222import GSASIIIO as G2IO
    23 #import GSASIIgrid as G2gd
    24 #import GSASIIstrIO as G2stIO
     23import GSASIIpy3 as G2py3
     24import GSASIIobj as G2obj
    2525import GSASIImath as G2mth
    26 #import GSASIIlattice as G2lat
    27 #import GSASIIspc as G2spc
    28 #import GSASIIphsGUI as G2pg
    29 #import GSASIIstrMain as G2stMn
    3026
    3127def WriteList(obj,headerItems):
     
    128124            )
    129125        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
    131128
    132129    def Exporter(self,event=None):
     
    138135        self.loadTree()
    139136        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))
    157161
    158162class ExportPowderReflCSV(G2IO.ExportBaseclass):
Note: See TracChangeset for help on using the changeset viewer.