Changeset 5150


Ignore:
Timestamp:
Jan 21, 2022 1:37:39 PM (7 months ago)
Author:
toby
Message:

add CSV seq exports; fix multiphase seq CIF exports

Location:
trunk/exports
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/exports/G2export_CIF.py

    r5142 r5150  
    25942594                histlist = []
    25952595                for hist in self.Phases[phasenam]['Histograms']:
    2596                     if self.Phases[phasenam]['Histograms'][hist]['Use']:
    2597                         if phasebyhistDict.get(hist):
    2598                             phasebyhistDict[hist].append(phasenam)
    2599                         else:
    2600                             phasebyhistDict[hist] = [phasenam,]
     2596                    # if self.Phases[phasenam]['Histograms'][hist]['Use']:
     2597                    #     if phasebyhistDict.get(hist):
     2598                    #         phasebyhistDict[hist].append(phasenam)
     2599                    #     else:
     2600                    #         phasebyhistDict[hist] = [phasenam,]
    26012601                        blockid = datablockidDict.get(hist)
    26022602                        if not blockid:
     
    27122712                histlist = []
    27132713                for hist in self.Phases[phasenam]['Histograms']:
    2714                     if self.Phases[phasenam]['Histograms'][hist]['Use']:
    2715                         if phasebyhistDict.get(hist):
    2716                             phasebyhistDict[hist].append(phasenam)
    2717                         else:
    2718                             phasebyhistDict[hist] = [phasenam,]
     2714                    # if self.Phases[phasenam]['Histograms'][hist]['Use']:
     2715                    #     if phasebyhistDict.get(hist):
     2716                    #         phasebyhistDict[hist].append(phasenam)
     2717                    #     else:
     2718                    #         phasebyhistDict[hist] = [phasenam,]
    27192719                        blockid = datablockidDict.get(hist)
    27202720                        if not blockid:
     
    38373837                s += '.'
    38383838        self.CIFname = s
    3839         phasebyhistDict = {} # a cross-reference to phases by histogram -- sequential fits
     3839        phasebyhistDict = {} # a cross-reference to phases by histogram -- used in sequential fits
     3840        for phasenam in self.Phases:
     3841            for hist in self.Phases[phasenam]['Histograms']:
     3842                if self.Phases[phasenam]['Histograms'][hist]['Use']:
     3843                    if phasebyhistDict.get(hist):
     3844                        phasebyhistDict[hist].append(phasenam)
     3845                    else:
     3846                        phasebyhistDict[hist] = [phasenam,]
    38403847        #=================================================================
    38413848        # write quick CIFs
     
    43104317                                sig = -0.0001
    43114318                            WriteCIFitem(self.fp, "  "+ s + " " + phaseBlockName[pId] + "  " + G2mth.ValEsd(wtFr,sig))
     4319                            datablockidDict[phasenam] = phaseBlockName[pId]
    43124320                        PP = FormatInstProfile(histblk["Instrument Parameters"],histblk['hId'])
    43134321                        PP += '\n'
  • trunk/exports/G2export_csv.py

    r4549 r5150  
    175175        self.multiple = True
    176176
    177     def Writer(self,TreeName,filename=None):
     177    def Writer(self,TreeName,filename=None,mode='w'):
    178178        #print filename
    179         self.OpenFile(filename)
     179        self.OpenFile(filename,mode=mode)
     180        self.Write('"Histogram","'+TreeName+'"')
    180181        histblk = self.Histograms[TreeName]
    181182        Parms = self.Histograms[TreeName]['Instrument Parameters'][0]
     
    215216#                line += G2py3.FormatValue(val,digits)
    216217            self.Write(line)
     218        if mode == 'w':
     219            print('Powder data written to CSV file '+self.fullpath)
    217220        self.CloseFile()
    218221       
     
    299302        super(self.__class__,self).__init__( # fancy way to say <parentclass>.__init__
    300303            G2frame=G2frame,
    301             formatName = 'reflection list as CSV',
     304            formatName = 'reflection list CSV file',
    302305            extension='.csv',
    303306            longFormatName = 'Export powder reflection list as a comma-separated (csv) file'
     
    306309        self.multiple = False # only allow one histogram to be selected
    307310
    308     def Writer(self,TreeName,filename=None):
    309         print(filename)
    310         self.OpenFile(filename)
     311    def Writer(self,TreeName,filename=None,mode='w'):
     312        self.OpenFile(filename,mode=mode)
    311313        histblk = self.Histograms[TreeName]
    312314        self.write(TreeName,histblk)
    313315        self.CloseFile()
    314         print(TreeName+' reflections written to file '+self.fullpath)
     316        if mode == "w": print(TreeName+' reflections written to file '+self.fullpath)
    315317       
    316318    def Exporter(self,event=None):
     
    329331       
    330332    def write(self,hist,histblk):
    331         self.Write('"Histogram"')
    332         self.Write('"'+hist+'"')
     333        self.Write('"Histogram","'+hist+'"')
    333334        self.Write('')
    334335        # table of phases
Note: See TracChangeset for help on using the changeset viewer.