Changeset 5610
- Timestamp:
- Jun 8, 2023 9:23:45 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASIIplot.py ¶
r5572 r5610 202 202 plotOpt['fmtChoices'] = {} 203 203 plotOpt['lineWid'] = '1' 204 204 plotOpt['saveCSV'] = False 205 plotOpt['CSVfile'] = None 206 205 207 def Write2csv(fil,dataItems,header=False): 206 208 '''Write a line to a CSV file … … 2321 2323 KeyItem[1]() 2322 2324 break 2325 elif event.key == 'v' and 'PWDR' in plottype and G2frame.SinglePlot: 2326 plotOpt['CSVfile'] = G2G.askSaveFile(G2frame,'','.csv', 2327 'Comma separated variable file') 2328 if plotOpt['CSVfile']: plotOpt['saveCSV'] = True 2323 2329 else: 2324 2330 #print('no binding for key',event.key) … … 3299 3305 else: 3300 3306 Page.Choice = Page.Choice+ ['p: toggle partials (if available)',] 3307 if G2frame.SinglePlot: 3308 Page.Choice += ['v: CSV output of plot'] 3301 3309 elif plottype in ['SASD','REFD']: 3302 3310 Page.Choice = [' key press', … … 3631 3639 # limit lines 3632 3640 Lines.append(Plot.axvline(lims[0][0],color='g',dashes=(5,5),picker=True,pickradius=3.)) 3633 Lines.append(Plot.axvline(lims[0][1],color='r',dashes=(5,5),picker=True,pickradius=3.)) 3641 Lines.append(Plot.axvline(lims[0][1],color='r',dashes=(5,5),picker=True,pickradius=3.)) 3634 3642 # excluded region lines 3635 3643 for i,item in enumerate(lims[1:]): … … 3830 3838 picker=True,pickradius=1.,label=incCptn('diff')) #Io-Ic 3831 3839 Plot.axhline(0.,color='k',label='_zero') 3840 # write a .csv file; not fully tested, but probably works where allowed 3841 if 'PWDR' in plottype and G2frame.SinglePlot and plotOpt['saveCSV']: 3842 plotOpt['saveCSV'] = False 3843 fp = open(plotOpt['CSVfile'],'w') 3844 Write2csv(fp,['"limits"',lims[0][0],lims[0][1]]) 3845 l = [] 3846 PeakId = G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Peak List') 3847 peaks = G2frame.GPXtree.GetItemPyData(PeakId) 3848 for i,item in enumerate(peaks['peaks']): 3849 if type(item) is dict: continue 3850 pos = item[0] 3851 if Page.plotStyle['qPlot']: 3852 l.append(2.*np.pi/G2lat.Pos2dsp(Parms,pos)) 3853 elif Page.plotStyle['dPlot']: 3854 l.append(G2lat.Pos2dsp(Parms,pos)) 3855 else: 3856 l.append(pos) 3857 if l: Write2csv(fp,['"peaks"']+l) 3858 peaks['LaueFringe'] = peaks.get('LaueFringe',{}) 3859 l = [] 3860 for pos in peaks['LaueFringe'].get('satellites',[]): 3861 if Page.plotStyle['qPlot']: 3862 l.append(2.*np.pi/G2lat.Pos2dsp(Parms,pos)) 3863 elif Page.plotStyle['dPlot']: 3864 l.append(G2lat.Pos2dsp(Parms,pos)) 3865 else: 3866 l.append(pos) 3867 if l: Write2csv(fp,['"satellites"']+l) 3868 3869 Write2csv(fp,['masked X','X','obs','calc','bkg','diff'],header=True) 3870 for i in range(len(X)): 3871 Write2csv(fp,[X[i],X.data[i],Y[i],Z[i],W[i],D[i]],header=False) 3872 fp.close() 3873 print('file',plotOpt['CSVfile'],'written') 3874 3832 3875 Page.SetToolTipString('') 3833 3876 if PickId:
Note: See TracChangeset
for help on using the changeset viewer.