Ignore:
Timestamp:
Mar 24, 2014 5:22:41 PM (10 years ago)
Author:
toby
Message:

reorg exports to implement directory selection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exports/G2export_csv.py

    r1236 r1261  
    6161        # create a dict with refined values and their uncertainties
    6262        self.loadParmDict()
    63         if self.ExportSelect( # set export parameters
    64             AskFile=True     # prompt the user for a file name
    65             ): return
    66         self.OpenFile(self.filename)
     63        if self.ExportSelect(): return # set export parameters; get file name
     64        self.OpenFile()
    6765        # if more than one format is selected, put them into a single file
    6866        for phasenam in self.phasenam:
     
    108106                        line += ","
    109107                self.Write(line)
    110             print('Phase '+str(phasenam)+' written to file '+str(self.filename))                       
     108            print('Phase '+str(phasenam)+' written to file '+str(self.fullpath))
    111109        self.CloseFile()
    112110
     
    135133        self.loadTree()
    136134        if self.ExportSelect( # set export parameters
    137             AskFile=False # use the default file name, which is ignored
     135            AskFile='single' # get a file name/directory to save in
    138136            ): return
    139137        filenamelist = []
    140138        for hist in self.histnam:
    141             fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(hist),filenamelist)
    142             self.filename = fileroot + self.extension
     139            if len(self.histnam) > 1:
     140                # multiple files: create a unique name from the histogram
     141                fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(hist),filenamelist)
     142                # create an instrument parameter file
     143                self.filename = os.path.join(self.dirname,fileroot + self.extension)
    143144            self.OpenFile()
    144145            histblk = self.Histograms[hist]
     
    158159                self.Write(line)
    159160            self.CloseFile()
    160             print('Histogram '+str(hist)+' written to file '+str(self.filename))
     161            print('Histogram '+str(hist)+' written to file '+str(self.fullpath))
    161162
    162163class ExportPowderReflCSV(G2IO.ExportBaseclass):
     
    181182        # load all of the tree into a set of dicts
    182183        self.loadTree()
    183         if self.ExportSelect( # set export parameters
    184             AskFile=False # use the default file name
    185             ): return
     184        if self.ExportSelect(): return  # set export parameters, get file name
    186185        self.OpenFile()
    187186        hist = self.histnam[0] # there should only be one histogram, in any case take the 1st
     
    201200                self.Write(fmt.format(h,k,l,pos,Fobs,Fcalc,phase,mult,i))
    202201        self.CloseFile()
    203         print(str(hist)+'reflections written to file '+str(self.filename))
     202        print(str(hist)+'reflections written to file '+str(self.fullpath))
    204203
    205204class ExportSingleCSV(G2IO.ExportBaseclass):
     
    225224        # load all of the tree into a set of dicts
    226225        self.loadTree()
    227         if self.ExportSelect( # set export parameters
    228             AskFile=False # use the default file name
    229             ): return
     226        if self.ExportSelect(): return  # set export parameters, get file name
    230227        self.OpenFile()
    231228        hist = self.histnam[0] # there should only be one histogram, in any case take the 1st
     
    238235            self.Write(fmt.format(h,k,l,dsp,Fobs,sigFobs,Fcalc,phase,mult))
    239236        self.CloseFile()
    240         print(str(hist)+' written to file '+str(self.filename))                       
     237        print(str(hist)+' written to file '+str(self.fullname))                       
    241238
    242239class ExportStrainCSV(G2IO.ExportBaseclass):
     
    262259        # load all of the tree into a set of dicts
    263260        self.loadTree()
    264         if self.ExportSelect( # set export parameters
    265             AskFile=True # use the default file name
    266             ): return
     261        if self.ExportSelect(): return  # set export parameters, get file name
    267262        self.OpenFile()
    268263        hist = self.histnam[0] # there should only be one histogram, in any case take the 1st
     
    283278                self.Write(fmt2.format(dat[1],dat[0],dat[2]))           
    284279        self.CloseFile()
    285         print(str(hist)+' written to file '+str(self.filename))                       
    286 
     280        print(str(hist)+' written to file '+str(self.fullpath))
Note: See TracChangeset for help on using the changeset viewer.