Changeset 2376 for trunk/exports/G2export_FIT2D.py
- Timestamp:
- Jul 13, 2016 3:01:31 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/exports/G2export_FIT2D.py
r2152 r2376 71 71 self.Writer(hist) 72 72 print('Histogram '+str(hist)+' written to file '+str(self.fullpath)) 73 74 class ExportPowderQCHI(G2IO.ExportBaseclass): 75 '''Used to create a q-binned CHI file for a powder data set 76 77 :param wx.Frame G2frame: reference to main GSAS-II frame 78 ''' 79 def __init__(self,G2frame): 80 super(self.__class__,self).__init__( # fancy way to say <parentclass>.__init__ 81 G2frame=G2frame, 82 formatName = 'Fit2D q-bin chi file', 83 extension='.chi', 84 longFormatName = 'Export powder data as q-bin Fit2D .chi file' 85 ) 86 self.exporttype = ['powder'] 87 self.multiple = True 88 89 def Writer(self,TreeName,filename=None): 90 import GSASIIlattice as G2lat 91 self.OpenFile(filename) 92 histblk = self.Histograms[TreeName] 93 inst = histblk['Instrument Parameters'][0] 94 self.Write(str(TreeName)[5:]) # drop 'PWDR ' 95 self.Write("Q") 96 self.Write("Intensity") 97 self.Write(" "+str(len(histblk['Data'][0]))) 98 for X,Y in zip(histblk['Data'][0],histblk['Data'][1]): 99 line = " %5.7e" % (2.*np.pi/G2lat.Pos2dsp(inst,X)) 100 line += " %5.7e" % Y 101 self.Write(line) 102 self.CloseFile() 103 104 def Exporter(self,event=None): 105 '''Export a set of powder data as a q-bin Fit2D .chi file 106 ''' 107 # the export process starts here 108 self.InitExport(event) 109 # load all of the tree into a set of dicts 110 self.loadTree() 111 if self.ExportSelect( # set export parameters 112 AskFile='single' # get a file name/directory to save in 113 ): return 114 filenamelist = [] 115 for hist in self.histnam: 116 # multiple files: create a unique name from the histogram 117 fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(hist),filenamelist) 118 # create an instrument parameter file 119 self.filename = os.path.join(self.dirname,fileroot + self.extension) 120 self.Writer(hist) 121 print('Histogram '+str(hist)+' written to file '+str(self.fullpath))
Note: See TracChangeset
for help on using the changeset viewer.