Changeset 1840


Ignore:
Timestamp:
May 7, 2015 11:40:53 AM (7 years ago)
Author:
vondreele
Message:

Add an export routine (NB: not in exports!) for Unit Cell results as csv file (request by Angus Lawson)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r1831 r1840  
    114114
    115115[  wxID_INDXRELOAD, wxID_INDEXPEAKS, wxID_REFINECELL, wxID_COPYCELL, wxID_MAKENEWPHASE,
    116 ] = [wx.NewId() for item in range(5)]
     116    wxID_EXPORTCELLS,
     117] = [wx.NewId() for item in range(6)]
    117118
    118119[ wxID_CONSTRAINTADD,wxID_EQUIVADD,wxID_HOLDADD,wxID_FUNCTADD,
     
    887888        self.MakeNewPhase = self.IndexEdit.Append( id=wxID_MAKENEWPHASE, kind=wx.ITEM_NORMAL,
    888889            text='Make new phase',help='Make new phase from selected unit cell')
     890        self.ExportCells = self.IndexEdit.Append( id=wxID_EXPORTCELLS, kind=wx.ITEM_NORMAL,
     891            text='Export cell list',help='Export cell list to csv file')
    889892        self.PostfillDataMenu()
    890893        self.IndexPeaks.Enable(False)
  • trunk/GSASIIpwdGUI.py

    r1834 r1840  
    24342434        OnHklShow(event)
    24352435       
     2436    def OnExportCells(event):
     2437        dlg = wx.FileDialog(G2frame, 'Choose Indexing Result csv file', '.', '',
     2438            'indexing result file (*.csv)|*.csv',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR)
     2439        try:
     2440            if dlg.ShowModal() == wx.ID_OK:
     2441                filename = dlg.GetPath()
     2442                filename = os.path.splitext(filename)[0]+'.csv'
     2443                File = open(filename,'w')
     2444                names = 'M20,X20,Bravais,a,b,c,alpha,beta,gamma,volume\n'
     2445                File.write(names)
     2446                fmt = '%d,%d,%s,%.4f,%.4f,%.4f,%.2f,%.2f,%.2f,%.3f\n'
     2447                for cell in cells:
     2448                    File.write(fmt%(cell[0],cell[1],bravaisSymb[cell[2]], cell[3],cell[4],cell[5], cell[6],cell[7],cell[8],cell[9]))
     2449                File.close()
     2450        finally:
     2451            dlg.Destroy()
     2452       
    24362453    def OnCellChange(event):
    24372454        Obj = event.GetEventObject()
     
    27092726    G2frame.Bind(wx.EVT_MENU, CopyUnitCell, id=G2gd.wxID_COPYCELL)
    27102727    G2frame.Bind(wx.EVT_MENU, RefineCell, id=G2gd.wxID_REFINECELL)
    2711     G2frame.Bind(wx.EVT_MENU, MakeNewPhase, id=G2gd.wxID_MAKENEWPHASE)   
     2728    G2frame.Bind(wx.EVT_MENU, MakeNewPhase, id=G2gd.wxID_MAKENEWPHASE)
     2729    G2frame.Bind(wx.EVT_MENU, OnExportCells, id=G2gd.wxID_EXPORTCELLS)
     2730       
    27122731    controls,bravais,cells,dmin,ssopt = data
    27132732    if len(controls) < 13:              #add cell volume if missing
     
    27392758    G2frame.dataFrame.CopyCell.Enable(False)
    27402759    G2frame.dataFrame.MakeNewPhase.Enable(False)       
     2760    G2frame.dataFrame.ExportCells.Enable(False)
    27412761    if cells:
    27422762        G2frame.dataFrame.CopyCell.Enable(True)
    2743         G2frame.dataFrame.MakeNewPhase.Enable(True)       
     2763        G2frame.dataFrame.MakeNewPhase.Enable(True)
     2764        G2frame.dataFrame.ExportCells.Enable(True)
    27442765    mainSizer = wx.BoxSizer(wx.VERTICAL)
    27452766    mainSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Indexing controls: '),0,WACV)
Note: See TracChangeset for help on using the changeset viewer.