Changeset 1518


Ignore:
Timestamp:
Oct 6, 2014 10:16:26 AM (8 years ago)
Author:
vondreele
Message:

Add metadata file processing for Image stress/strain data - reads sample load & sample phi from text file.
Correction to PWDR metadata file processing

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r1517 r1518  
    105105] = [wx.NewId() for item in range(8)]
    106106
    107 [ wxID_STRSTACOPY, wxID_STRSTAFIT, wxID_STRSTASAVE, wxID_STRSTALOAD,wxID_APPENDDZERO,
    108     wxID_STRSTAALLFIT,wxID_UPDATEDZERO,
    109 ] = [wx.NewId() for item in range(7)]
     107[ wxID_STRSTACOPY, wxID_STRSTAFIT, wxID_STRSTASAVE, wxID_STRSTALOAD,wxID_STRSTSAMPLE,
     108    wxID_APPENDDZERO,wxID_STRSTAALLFIT,wxID_UPDATEDZERO,
     109] = [wx.NewId() for item in range(8)]
    110110
    111111[ wxID_BACKCOPY,wxID_LIMITCOPY, wxID_SAMPLECOPY, wxID_SAMPLECOPYSOME, wxID_BACKFLAGCOPY, wxID_SAMPLEFLAGCOPY,
     
    32723272        self.SampleEdit.Append(id=wxID_SAMPLE1VAL, kind=wx.ITEM_NORMAL,text='Set one value',
    32733273            help='Set one sample parameter value across multiple histograms')
    3274         self.SampleEdit.Append(id=wxID_ALLSAMPLELOAD, kind=wx.ITEM_NORMAL,text='Load all samples',
     3274        self.SampleEdit.Append(id=wxID_ALLSAMPLELOAD, kind=wx.ITEM_NORMAL,text='Load all',
    32753275            help='Load sample parmameters over multiple histograms')
    32763276
     
    34553455        self.StrStaEdit.Append(help='Load stress/strain data from file',
    34563456            id=wxID_STRSTALOAD, kind=wx.ITEM_NORMAL,text='Load stress/strain')
     3457        self.StrStaEdit.Append(help='Load sample data from file',
     3458            id=wxID_STRSTSAMPLE, kind=wx.ITEM_NORMAL,text='Load sample data')
    34573459        self.PostfillDataMenu()
    34583460           
  • trunk/GSASIIimgGUI.py

    r1472 r1518  
    4242##### Image Data
    4343################################################################################
     44
    4445def UpdateImageData(G2frame,data):
    4546   
     
    15001501        finally:
    15011502            dlg.Destroy()
    1502 
     1503           
     1504    def OnStrStaSample(event):
     1505        filename = ''
     1506        dlg = wx.FileDialog(G2frame, 'Choose multihistogram metadata text file', '.', '',
     1507            'metadata file (*.*)|*.*',wx.OPEN|wx.CHANGE_DIR)
     1508        try:
     1509            if dlg.ShowModal() == wx.ID_OK:
     1510                filename = dlg.GetPath()
     1511                File = open(filename,'r')
     1512                S = File.readline()
     1513                newItems = []
     1514                itemNames = []
     1515                Comments = []
     1516                while S:
     1517                    if S[0] == '#':
     1518                        Comments.append(S)
     1519                        S = File.readline()
     1520                        continue
     1521                    S = S.replace(',',' ').replace('\t',' ')
     1522                    Stuff = S[:-1].split()
     1523                    itemNames.append(Stuff[0])
     1524                    newItems.append(Stuff[1:])
     1525                    S = File.readline()               
     1526                File.close()
     1527        finally:
     1528            dlg.Destroy()
     1529        if not filename:
     1530            G2frame.ErrorDialog('Nothing to do','No file selected')
     1531            return
     1532        dataDict = dict(zip(itemNames,newItems))
     1533        ifany = False
     1534        Names = [' ','Sample phi','Sample z','Sample load']
     1535        dlg = G2gd.G2ColumnIDDialog( G2frame,' Choose multihistogram metadata columns:',
     1536            'Select columns',Comments,Names,np.array(newItems).T)
     1537        try:
     1538            if dlg.ShowModal() == wx.ID_OK:
     1539                colNames,newData = dlg.GetSelection()
     1540                dataDict = dict(zip(itemNames,newData.T))
     1541                for item in colNames:
     1542                    if item != ' ':
     1543                        ifany = True
     1544        finally:
     1545            dlg.Destroy()
     1546        if not ifany:
     1547            G2frame.ErrorDialog('Nothing to do','No columns identified')
     1548            return
     1549        histList = []
     1550        item, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root)       
     1551        while item:
     1552            name = G2frame.PatternTree.GetItemText(item)
     1553            if name.startswith('IMG'):
     1554                histList.append(name)
     1555            item, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie)
     1556        colIds = {}
     1557        for i,name in enumerate(colNames):
     1558            if name != ' ':
     1559                colIds[name] = i
     1560        for hist in histList:
     1561            name = hist.split()[1]  #this is file name
     1562            if name in dataDict:
     1563                newItems = {}
     1564                for item in colIds:
     1565                    newItems[item] = float(dataDict[name][colIds[item]])
     1566                Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,hist)
     1567                stsrData = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Stress/Strain'))
     1568                stsrData.update(newItems)       
     1569        UpdateStressStrain(G2frame,data)       
     1570   
    15031571    def OnFitStrSta(event):
    15041572        Controls = G2frame.PatternTree.GetItemPyData(
     
    17451813    G2frame.dataFrame.Bind(wx.EVT_MENU, OnCopyStrSta, id=G2gd.wxID_STRSTACOPY)
    17461814    G2frame.dataFrame.Bind(wx.EVT_MENU, OnLoadStrSta, id=G2gd.wxID_STRSTALOAD)
    1747     G2frame.dataFrame.Bind(wx.EVT_MENU, OnSaveStrSta, id=G2gd.wxID_STRSTASAVE)   
     1815    G2frame.dataFrame.Bind(wx.EVT_MENU, OnSaveStrSta, id=G2gd.wxID_STRSTASAVE)
     1816    G2frame.dataFrame.Bind(wx.EVT_MENU, OnStrStaSample, id=G2gd.wxID_STRSTSAMPLE)       
    17481817    if not G2frame.dataFrame.GetStatusBar():
    17491818        Status = G2frame.dataFrame.CreateStatusBar()
  • trunk/GSASIIpwdGUI.py

    r1515 r1518  
    16061606                        S = File.readline()
    16071607                        continue
    1608                     S.replace(',',' ')
    1609                     S.replace('\t',' ')
    1610                     Stuff = S[:-1].split(' ')
     1608                    S = S.replace(',',' ').replace('\t',' ')
     1609                    Stuff = S[:-1].split()
    16111610                    itemNames.append(Stuff[0])
    16121611                    newItems.append(Stuff[1:])
Note: See TracChangeset for help on using the changeset viewer.