Changeset 2867 for trunk/exports


Ignore:
Timestamp:
Jun 18, 2017 4:09:14 PM (4 years ago)
Author:
toby
Message:

fix sequential exports

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exports/G2export_CIF.py

    r2819 r2867  
    6565            return True
    6666                     
    67     def _Exporter(self,event=None,phaseOnly=None,histOnly=None):
     67    def _Exporter(self,event=None,phaseOnly=None,histOnly=None,IncludeOnlyHist=None):
    6868        '''Basic code to export a CIF. Export can be full or simple, as set by
    6969        phaseOnly and histOnly which skips distances & angles, etc.
     70
     71          phaseOnly: used to export only one phase
     72          histOnly: used to export only one histogram
     73          IncludeOnlyHist: used for a full CIF that includes only one of the
     74            histograms (from a sequential fit) TODO: needs lots of work!
    7075        '''
    7176
     
    16521657        if phaseOnly: #====Phase only CIF ================================
    16531658            print('Writing CIF output to file '+self.filename)
    1654             self.OpenFile()
     1659            #self.OpenFile()
    16551660            oneblock = True
    16561661            self.quickmode = True
     
    16611666            # report the phase info
    16621667            WritePhaseInfo(phaseOnly)
    1663             self.CloseFile()
     1668            #self.CloseFile()
    16641669            return
    16651670        elif histOnly: #====Histogram only CIF ================================
    16661671            print('Writing CIF output to file '+self.filename)
    1667             self.OpenFile()
     1672            #self.OpenFile()
    16681673            hist = histOnly
    1669             histname = histOnly.replace(' ','')
     1674            #histname = histOnly.replace(' ','')
    16701675            oneblock = True
    16711676            self.quickmode = True
     
    17041709            #writeCIFtemplate(histblk,'powder',histblk['InstrName']) # write powder template
    17051710            WritePowderData(hist)
    1706             self.CloseFile()
     1711            #self.CloseFile()
    17071712            return
     1713        #elif IncludeOnlyHist is not None: # truncate histogram list to only selected (for sequential export)
     1714        #    self.Histograms = {IncludeOnlyHist:self.Histograms[IncludeOnlyHist]}
     1715       
    17081716        #===============================================================================
    17091717        # the export process for a full CIF starts here
     
    17601768                invalid += 1
    17611769        if invalid:
    1762             msg = ""
    1763             if invalid > 3: msg = (
    1764                 "\n\nNote: it may be faster to set the name for\n"
    1765                 "one histogram for each instrument and use the\n"
    1766                 "File/Copy option to duplicate the name"
    1767                 )
     1770            #msg = ""
     1771            #if invalid > 3: msg = (
     1772            #    "\n\nNote: it may be faster to set the name for\n"
     1773            #    "one histogram for each instrument and use the\n"
     1774            #    "File/Copy option to duplicate the name"
     1775            #    )
    17681776            if not EditInstNames(): return
    17691777           
     
    18411849        #======================================================================
    18421850        print('Writing CIF output to file '+self.filename+"...")
    1843         self.OpenFile()
     1851        #self.OpenFile()
    18441852        if self.currentExportType == 'single' or self.currentExportType == 'powder':
    18451853            #======Data only CIF (powder/xtal) ====================================
     
    20172025
    20182026        WriteCIFitem('#--' + 15*'eof--' + '#')
    2019         self.CloseFile()
     2027        #self.CloseFile()
    20202028        print("...export completed")
    20212029        print('file '+self.fullpath)
     
    20372045       
    20382046    def Exporter(self,event=None):
     2047        self.OpenFile()
    20392048        self._Exporter(event=event)
    2040 
    2041     def Writer(self,hist,mode='w'):
    2042         # set the project file name
    2043         self.CIFname = os.path.splitext(
    2044             os.path.split(self.G2frame.GSASprojectfile)[1]
    2045             )[0]+'_'+hist
    2046         self.CIFname = self.CIFname.replace(' ','')
    2047         self.OpenFile(mode=mode)
    2048         self._Exporter(histOnly=hist)
    2049         if mode == 'w':
    2050             print('CIF written to file '+self.fullpath)
    20512049        self.CloseFile()
     2050
     2051    # def Writer(self,hist,mode='w'):
     2052    #     '''Used for full project CIF export of a sequential fit.
     2053    #     TODO: Needs extensive work
     2054    #     '''
     2055    #     # set the project file name
     2056    #     self.CIFname = os.path.splitext(
     2057    #         os.path.split(self.G2frame.GSASprojectfile)[1]
     2058    #         )[0]+'_'+hist
     2059    #     self.CIFname = self.CIFname.replace(' ','')
     2060    #     self.OpenFile(mode=mode)
     2061    #     self._Exporter(IncludeOnlyHist=hist)
     2062    #     if mode == 'w':
     2063    #         print('CIF written to file '+self.fullpath)
     2064    #     self.CloseFile()
    20522065       
    20532066class ExportPhaseCIF(ExportCIF):
     
    20802093        self.currentExportType = 'phase'
    20812094        if self.ExportSelect('ask'): return
     2095        self.OpenFile()
    20822096        self._Exporter(event=event,phaseOnly=self.phasenam[0])
     2097        self.CloseFile()
    20832098
    20842099    def Writer(self,hist,phasenam,mode='w'):
     
    21242139        self._Exporter(event=event,histOnly=self.histnam[0])
    21252140
     2141    def Writer(self,hist,mode='w'):
     2142        '''Used for histogram CIF export of a sequential fit.
     2143        '''
     2144        # set the project file name
     2145        self.CIFname = os.path.splitext(
     2146            os.path.split(self.G2frame.GSASprojectfile)[1]
     2147            )[0]+'_'+hist
     2148        self.CIFname = self.CIFname.replace(' ','')
     2149        self.OpenFile(mode=mode)
     2150        self._Exporter(histOnly=hist)
     2151        if mode == 'w':
     2152            print('CIF written to file '+self.fullpath)
     2153        self.CloseFile()
     2154       
    21262155class ExportHKLCIF(ExportCIF):
    21272156    '''Used to create a simple CIF containing diffraction data only. Uses exact same code as
Note: See TracChangeset for help on using the changeset viewer.