Ignore:
Timestamp:
Aug 18, 2016 5:42:08 PM (5 years ago)
Author:
toby
Message:

update for sequential export

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exports/G2export_csv.py

    r2152 r2433  
    5353        self.multiple = True # allow multiple phases to be selected
    5454
     55    def Writer(self,hist,phasenam,mode='w'):
     56        self.OpenFile(mode=mode)
     57        # test for aniso atoms
     58        aniso = False
     59        AtomsList = self.GetAtoms(phasenam)
     60        for lbl,typ,mult,xyz,td in AtomsList:
     61            if len(td) != 1:
     62                aniso = True
     63                break
     64        if mode == 'w':
     65            lbllist = ['hist','phase','a','b','c','alpha','beta','gamma','volume']
     66            lbllist += ["atm label","elem","mult","x","y","z","frac","Uiso"]
     67            if aniso: lbllist += ['U11','U22','U33','U12','U13','U23']
     68            WriteList(self,lbllist)
     69           
     70        cellList,cellSig = self.GetCell(phasenam)
     71        line = '"' + str(hist)+ '","' + str(phasenam) + '"'
     72        for defsig,val in zip(
     73            3*[-0.00001] + 3*[-0.001] + [-0.01], # sets sig. figs.
     74            cellList
     75            ):
     76            txt = G2mth.ValEsd(val,defsig)
     77            if line: line += ','
     78            line += txt
     79        self.Write(line)
     80
     81        # get atoms and print separated by commas
     82        AtomsList = self.GetAtoms(phasenam)
     83        for lbl,typ,mult,xyz,td in AtomsList:
     84            line = ",,,,,,,,,"
     85            line += '"' + lbl + '","' + typ + '",' + str(mult) + ','
     86            for val,sig in xyz:
     87                line += G2mth.ValEsd(val,-abs(sig))
     88                line += ","
     89            if len(td) == 1:
     90                line += G2mth.ValEsd(td[0][0],-abs(td[0][1]))
     91            else:
     92                line += ","
     93                for val,sig in td:
     94                    line += G2mth.ValEsd(val,-abs(sig))
     95                    line += ","
     96            self.Write(line)
     97
     98        if mode == 'w':
     99            print('Phase '+str(phasenam)+' written to file '+str(self.fullpath))
     100        self.CloseFile()
     101   
    55102    def Exporter(self,event=None):
    56103        '''Export a phase as a csv file
     
    64111        if self.ExportSelect(): return # set export parameters; get file name
    65112        self.OpenFile()
    66         # if more than one format is selected, put them into a single file
     113        # if more than one phase is selected, put them into a single file
    67114        for phasenam in self.phasenam:
    68115            phasedict = self.Phases[phasenam] # pointer to current phase info           
     
    127174
    128175    def Writer(self,TreeName,filename=None):
    129         print filename
     176        #print filename
    130177        self.OpenFile(filename)
    131178        histblk = self.Histograms[TreeName]
Note: See TracChangeset for help on using the changeset viewer.