Changeset 1236 for trunk/exports


Ignore:
Timestamp:
Mar 5, 2014 1:51:53 PM (8 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

Location:
trunk/exports
Files:
1 added
2 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):
  • trunk/exports/G2export_examples.py

    r1127 r1236  
    2424GSASIIpath.SetVersionNumber("$Revision$")
    2525import GSASIIIO as G2IO
     26import GSASIIpy3 as G2py3
    2627#import GSASIIgrid as G2gd
    2728#import GSASIIstrIO as G2stIO
     
    145146        hist = self.histnam[0] # there should only be one histogram, in any case take the 1st
    146147        histblk = self.Histograms[hist]
    147         fmt = 2*"{:12.3f} " + "{:12.5f} " + 2*"{:12.3f} "
    148         hfmt = 5*"{:>12s} "
     148        hfmt = 5*"{:12s} "
     149        digitList = 2*((13,3),) + ((13,5),) + 2*((13,3),)
     150       
    149151        self.Write(hfmt.format("x","y_obs","weight","y_calc","y_bkg"))
    150         for x,yobs,yw,ycalc,ybkg,obsmcalc in zip(histblk['Data'][0],
    151                                                  histblk['Data'][1],
    152                                                  histblk['Data'][2],
    153                                                  histblk['Data'][3],
    154                                                  histblk['Data'][4],
    155                                                  histblk['Data'][5],
    156                                                  ):
    157             self.Write(fmt.format(x,yobs,yw,ycalc,ybkg))
    158         self.CloseFile()
    159         print(str(hist)+' written to file '+str(self.filename))                       
     152        for vallist in zip(histblk['Data'][0],
     153                           histblk['Data'][1],
     154                           histblk['Data'][2],
     155                           histblk['Data'][3],
     156                           histblk['Data'][4],
     157                           #histblk['Data'][5],
     158                           ):
     159            strg = ''
     160            for val,digits in zip(vallist,digitList):
     161                strg += G2py3.FormatPadValue(val,digits)
     162            self.Write(strg)
     163        self.CloseFile()
     164        print(str(hist)+' written to file '+str(self.filename))
     165       
    160166class ExportPowderReflText(G2IO.ExportBaseclass):
    161167    '''Used to create a text file of reflections from a powder data set
Note: See TracChangeset for help on using the changeset viewer.