Changeset 1199 for trunk/GSASIIIO.py


Ignore:
Timestamp:
Jan 16, 2014 3:55:36 PM (8 years ago)
Author:
vondreele
Message:

1st import of small angle data, create SASD data from image.
Work on proper plotting of SASD data
work on image GUI stuff for small angle data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r1198 r1199  
    835835    Id = G2frame.PatternTree.GetItemParent(PickId)
    836836    name = G2frame.PatternTree.GetItemText(Id)
    837     name = name.replace('IMG ','PWDR ')
     837    name = name.replace('IMG ',data['type']+' ')
    838838    Comments = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Comments'))
    839     names = ['Type','Lam','Zero','Polariz.','U','V','W','X','Y','SH/L','Azimuth']
    840     codes = [0 for i in range(12)]
     839    if 'PWDR' in name:
     840        names = ['Type','Lam','Zero','Polariz.','U','V','W','X','Y','SH/L','Azimuth']
     841        codes = [0 for i in range(11)]
     842    elif 'SASD' in name:
     843        names = ['Type','Lam','Zero','Azimuth']
     844        codes = [0 for i in range(4)]
    841845    LRazm = data['LRazimuth']
    842846    Azms = []
     
    854858                Id = item
    855859            item, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie)
    856         parms = ['PXC',data['wavelength'],0.0,0.99,1.0,-0.10,0.4,0.30,1.0,0.0001,Azms[i]]    #set polarization for synchrotron radiation!
     860        if 'PWDR' in name:
     861            parms = ['PXC',data['wavelength'],0.0,0.99,1.0,-0.10,0.4,0.30,1.0,0.0001,Azms[i]]    #set polarization for synchrotron radiation!
     862        elif 'SASD' in name:   
     863            parms = ['LXC',data['wavelength'],0.0,Azms[i]]           
    857864        Y = G2frame.Integrate[0][i]
    858865        W = 1./Y                    #probably not true
     
    865872            G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Comments'),Comments)                   
    866873            G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Limits'),[tuple(Xminmax),Xminmax])
    867             G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Background'),[['chebyschev',1,3,1.0,0.0,0.0],
    868                             {'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
     874            if 'PWDR' in name:
     875                G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Background'),[['chebyschev',1,3,1.0,0.0,0.0],
     876                    {'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
    869877            inst = [dict(zip(names,zip(parms,parms,codes))),{}]
    870878            for item in inst[0]:
    871879                inst[0][item] = list(inst[0][item])
    872880            G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Instrument Parameters'),inst)
    873             G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Peak List'),[])
    874             G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Index Peak List'),[])
    875             G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Unit Cells List'),[])             
    876             G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Reflection Lists'),{})             
     881            if 'PWDR' in name:
     882                G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Peak List'),[])
     883                G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Index Peak List'),[])
     884                G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Unit Cells List'),[])             
     885                G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Reflection Lists'),{})             
    877886        else:
    878887            Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text=name+" Azm= %.2f"%(Azms[i]))
    879888            G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Comments'),Comments)                   
    880889            G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Limits'),[tuple(Xminmax),Xminmax])
    881             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Background'),[['chebyschev',1,3,1.0,0.0,0.0],
    882                             {'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
     890            if 'PWDR' in name:
     891                G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Background'),[['chebyschev',1,3,1.0,0.0,0.0],
     892                    {'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
    883893            inst = [dict(zip(names,zip(parms,parms,codes))),{}]
    884894            for item in inst[0]:
     
    886896            G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Instrument Parameters'),inst)
    887897            G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Sample Parameters'),Sample)
    888             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Peak List'),[])
    889             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Index Peak List'),[])
    890             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Unit Cells List'),[])
    891             G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Reflection Lists'),{})
     898            if 'PWDR' in name:
     899                G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Peak List'),[])
     900                G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Index Peak List'),[])
     901                G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Unit Cells List'),[])
     902                G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Reflection Lists'),{})
    892903            valuesdict = {
    893904                'wtFactor':1.0,
     
    16661677        self.instdict = {} # place items here that will be transferred to the instrument parameters
    16671678######################################################################
     1679class ImportSmallAngleData(ImportBaseclass):
     1680    '''Defines a base class for the reading of files with small angle data.
     1681    See :ref:`Writing a Import Routine<Import_Routines>`
     1682    for an explanation on how to use this class.
     1683    '''
     1684    def __init__(self,formatName,longFormatName=None,extensionlist=[],
     1685        strictExtension=False,):
     1686           
     1687        ImportBaseclass.__init__(self,formatName,longFormatName,extensionlist,
     1688            strictExtension)
     1689        self.smallangleentry = ['',None,None] #  (filename,Pos,Bank)
     1690        self.smallangledata = [] # SASD dataset
     1691        '''A small angle data set is a list with items [x,y,w,yc,yd]:
     1692                np.array(x), # x-axis values
     1693                np.array(y), # powder pattern intensities
     1694                np.array(w), # 1/sig(intensity)^2 values (weights)
     1695                np.array(yc), # calc. intensities (zero)
     1696                np.array(yd), # obs-calc profiles
     1697        '''                           
     1698        self.comments = []
     1699        self.idstring = ''
     1700        self.Sample = G2pdG.SetDefaultSample()
     1701        self.GSAS = None     # used in TOF
     1702        self.clockWd = None  # used in TOF
     1703        self.numbanks = 1
     1704        self.instdict = {} # place items here that will be transferred to the instrument parameters
     1705######################################################################
    16681706class ExportBaseclass(object):
    16691707    '''Defines a base class for the exporting of GSAS-II results
Note: See TracChangeset for help on using the changeset viewer.