Changeset 2152


Ignore:
Timestamp:
Feb 18, 2016 1:01:27 PM (6 years ago)
Author:
vondreele
Message:

all PWDR exporters will make file name from histogram name
allow read of multibank data
alert user to duplicate histograms (by name)
rename data will not change Bank or Azm part of histogram name
fix L&R plotting commands for TOF data

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2151 r2152  
    441441            filelist1.append(filename)
    442442        filelist = filelist1
     443        Start = True    #1st time read - clear selections below
    443444        for filename in filelist:
    444445            # is this a zip file?
     
    476477            errorReport = ''
    477478            for rd in primaryReaders+secondaryReaders:
     479                if Start:   #clear old bank selections to allow new ones to be selected by user
     480                    rd.selections = []
     481                    Start = False
    478482                rd.ReInitialize() # purge anything from a previous read
    479483                fp.seek(0)  # rewind
     
    948952        return lines       
    949953           
    950     def ReadPowderInstprm(self,instLines,bank):
     954    def ReadPowderInstprm(self,instLines,bank,databanks,rd):
    951955        '''Read lines from a GSAS-II (new) instrument parameter file
    952956        similar to G2pwdGUI.OnLoad
     
    11491153                s = Iparm['INS   FPATH1'].split()
    11501154                fltPath0 = G2IO.sfloat(s[0])
     1155                if 'INS  1BNKPAR' not in Iparm:     #bank missing from Iparm file
     1156                    return []
    11511157                s = Iparm['INS  1BNKPAR'].split()
    11521158                fltPath1 = G2IO.sfloat(s[0])
     
    12511257                        prompts=['Total FP','2-theta',],values=[25.0,150.,],
    12521258                            limits=[[6.,200.],[5.,175.],],formats=['%6.2f','%6.1f',])
    1253                     if dlg.ShowModal() == wx.ID_OK:
     1259                    if dlg.ShowModal() == wx.ID_OK: #strictly empirical approx.
    12541260                        FP,tth = dlg.GetValues()
    1255                         difC = 252.816*2.*FP*sind(tth/2.)
     1261                        difC = 505.632*FP*sind(tth/2.)
    12561262                        sig1 = 50.+2.5e-6*(difC/tand(tth/2.))**2
     1263                        bet1 = .00226+7.76e+11/difC**4
    12571264                        rd.instmsg = 'default: '+dI.defaultIparm_lbl[res]
    12581265                        Inst = self.ReadPowderInstprm(dI.defaultIparms[res],bank)
    12591266                        Inst[0]['difC'] = [difC,difC,0]
    12601267                        Inst[0]['sig-1'] = [sig1,sig1,0]
     1268                        Inst[0]['beta-1'] = [bet1,bet1,0]
    12611269                        return Inst    #this is [Inst1,Inst2] a pair of dicts
    12621270                    dlg.Destroy()
     
    12821290            if 'instprm' in instfile:
    12831291                Lines = self.OpenPowderInstprm(instfile)
    1284                 instParmList = self.ReadPowderInstprm(Lines,bank)    #this is [Inst1,Inst2] a pair of dicts
     1292                instParmList = self.ReadPowderInstprm(Lines,bank,numbanks,rd)    #this is [Inst1,Inst2] a pair of dicts
    12851293                if 'list' in str(type(instParmList)):
    12861294                    rd.instfile = instfile
     
    13031311        #2nd priority: is there an instrument parameter file defined for the current data set?
    13041312        # or if this is a read on a set of set of files, use the last one again
    1305         #if rd.instparm or (lastdatafile == filename and lastIparmfile):
     1313        #if rd.instparm as found in data file header or (lastdatafile == filename and lastIparmfile):
    13061314        if rd.instparm or lastIparmfile:
    13071315            if rd.instparm:
     
    13181326                    Lines = self.OpenPowderInstprm(instfile)
    13191327                    if Lines is not None:
    1320                         instParmList = self.ReadPowderInstprm(Lines,bank)   #this is [Inst1,Inst2] a pair of dicts
     1328                        instParmList = self.ReadPowderInstprm(Lines,bank,numbanks,rd)   #this is [Inst1,Inst2] a pair of dicts
    13211329                else:   #old GSAS style iparm file - could be named anything!
    13221330                    Iparm = self.ReadPowderIparm(instfile,bank,numbanks,rd)
     
    13861394                Lines = self.OpenPowderInstprm(instfile)
    13871395                if Lines is not None:
    1388                     instParmList = self.ReadPowderInstprm(Lines,bank)    #this is [Inst1,Inst2] a pair of dicts
     1396                    instParmList = self.ReadPowderInstprm(Lines,bank,numbanks,rd)    #this is [Inst1,Inst2] a pair of dicts
    13891397                if 'list' in str(type(instParmList)):
    13901398                    rd.instfile = instfile
     
    14371445        for rd in rdlist:
    14381446            if 'Instrument Parameters' not in rd.pwdparms:
    1439                 # get instrument parameters for each dataset, unless already set
    1440                 Iparm1,Iparm2 = self.GetPowderIparm(rd, Iparm, lastIparmfile, lastdatafile)
     1447                # get instrument parameters for each dataset, unless already set
     1448                Iparms = self.GetPowderIparm(rd, Iparm, lastIparmfile, lastdatafile)
     1449                if not Iparms:
     1450                    continue
     1451                Iparm1,Iparm2 = Iparms
    14411452                if rd.repeat_instparm:
    14421453                    lastIparmfile = rd.instfile
     
    14511462            HistName = 'PWDR '+HistName
    14521463            # make new histogram names unique
     1464            if HistName in PWDRlist:
     1465                dlg = wx.MessageDialog(self,'Skip %s?'%(HistName),'Duplicate data name',wx.YES_NO)
     1466                try:
     1467                    if dlg.ShowModal() == wx.ID_YES:
     1468                        Id = 0
     1469                        continue
     1470                finally:
     1471                    dlg.Destroy()
    14531472            HistName = G2obj.MakeUniqueLabel(HistName,PWDRlist)
    14541473            print 'Read powder data '+str(HistName)+ \
     
    15281547            Controls.update(rd.Controls)
    15291548            newHistList.append(HistName)
     1549            rd.repeat_instparm = False  #clear the iparm reuse flag
    15301550        else:
    15311551            self.EnablePlot = True
    1532             self.PatternTree.Expand(Id)
    1533             self.PatternTree.SelectItem(Id)
    1534            
     1552            if Id:
     1553                self.PatternTree.Expand(Id)
     1554                self.PatternTree.SelectItem(Id)
     1555
    15351556        if not newHistList: return # somehow, no new histograms
    15361557        # make a list of phase names
     
    29472968        name = self.PatternTree.GetItemText(self.PickId)     
    29482969        if 'PWDR' in name or 'HKLF' in name or 'IMG' in name:
    2949             dataType = name[:name.index(' ')+1]                 #includes the ' '
    2950             dlg = wx.TextEntryDialog(self,'Data name: '+dataType,'Change data name',
    2951                 defaultValue=name[name.index(' ')+1:])
     2970            if 'Bank' in name:
     2971                names = name.split('Bank')
     2972                names[1] = ' Bank'+names[1]
     2973            elif 'Azm' in name:
     2974                names = name.split('Azm')
     2975                names[1] = ' Azm'+names[1]
     2976            else:
     2977                names = [name,'']
     2978            dataType = names[0][:names[0].index(' ')+1]                 #includes the ' '
     2979            dlg = wx.TextEntryDialog(self,'Data name: '+name,'Change data name',
     2980                defaultValue=names[0][names[0].index(' ')+1:])
    29522981            try:
    29532982                if dlg.ShowModal() == wx.ID_OK:
    2954                     self.PatternTree.SetItemText(self.PickId,dataType+dlg.GetValue())
     2983                    name = dataType+dlg.GetValue()+names[1]
     2984                    self.PatternTree.SetItemText(self.PickId,name)
    29552985            finally:
    29562986                dlg.Destroy()
  • trunk/GSASIIIO.py

    r2150 r2152  
    13221322    SGData = None
    13231323P1SGData = SGData
     1324######################################################################
    13241325class ImportBaseclass(object):
    13251326    '''Defines a base class for the reading of input files (diffraction
     
    13371338   
    13381339    UseReader = True  # in __init__ set value of self.UseReader to False to skip use of current importer
    1339     def __init__(self,
    1340                  formatName,
    1341                  longFormatName=None,
    1342                  extensionlist=[],
    1343                  strictExtension=False,
    1344                  ):
     1340    def __init__(self,formatName,longFormatName=None,
     1341                 extensionlist=[],strictExtension=False,):
    13451342        self.formatName = formatName # short string naming file type
    13461343        if longFormatName: # longer string naming file type
     
    13741371        self.readfilename = '?'
    13751372
    1376     def BlockSelector(self, ChoiceList, ParentFrame=None,
    1377                       title='Select a block',
    1378                       size=None, header='Block Selector',
    1379                       useCancel=True):
     1373    def BlockSelector(self, ChoiceList, ParentFrame=None,title='Select a block',
     1374        size=None, header='Block Selector',useCancel=True):
    13801375        ''' Provide a wx dialog to select a block if the file contains more
    13811376        than one set of data and one must be selected
     
    15081503                return False
    15091504
     1505######################################################################
    15101506class ImportPhase(ImportBaseclass):
    15111507    '''Defines a base class for the reading of files with coordinates
     
    15331529            size,header)
    15341530
     1531######################################################################
    15351532class ImportStructFactor(ImportBaseclass):
    15361533    '''Defines a base class for the reading of files with tables
     
    16011598    for an explanation on how to use this class.
    16021599    '''
    1603     def __init__(self,
    1604                  formatName,
    1605                  longFormatName=None,
    1606                  extensionlist=[],
    1607                  strictExtension=False,
    1608                  ):
    1609         ImportBaseclass.__init__(self,formatName,
    1610                                             longFormatName,
    1611                                             extensionlist,
    1612                                             strictExtension)
     1600    def __init__(self,formatName,longFormatName=None,
     1601        extensionlist=[],strictExtension=False,):
     1602        ImportBaseclass.__init__(self,formatName,longFormatName,
     1603            extensionlist,strictExtension)
    16131604        self.clockWd = None  # used in TOF
    16141605        self.ReInitialize()
     
    17641755    file without invoking any GUI objects.
    17651756    '''
    1766     def __init__(self,
    1767                  G2frame,
    1768                  formatName,
    1769                  extension,
    1770                  longFormatName=None,
    1771                  ):
     1757    def __init__(self,G2frame,formatName,extension,longFormatName=None,):
    17721758        self.G2frame = G2frame
    17731759        self.formatName = formatName # short string naming file type
  • trunk/GSASIIplot.py

    r2140 r2152  
    17341734                X *= (1.01)**(offsetX*N)
    17351735            else:
    1736                 X += offsetX*.005*N
     1736                xlim = Plot.get_xlim()
     1737                DX = xlim[1]-xlim[0]
     1738                X += 0.002*offsetX*DX*N
    17371739            Xum = ma.getdata(X)
    17381740            DifLine = ['']
  • trunk/exports/G2export_FIT2D.py

    r2133 r2152  
    6565        filenamelist = []
    6666        for hist in self.histnam:
    67             fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(self.histnam[0]),filenamelist)
     67            # multiple files: create a unique name from the histogram
     68            fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(hist),filenamelist)
     69            # create an instrument parameter file
    6870            self.filename = os.path.join(self.dirname,fileroot + self.extension)
    6971            self.Writer(hist)
  • trunk/exports/G2export_csv.py

    r2132 r2152  
    127127
    128128    def Writer(self,TreeName,filename=None):
     129        print filename
    129130        self.OpenFile(filename)
    130131        histblk = self.Histograms[TreeName]
     
    157158        filenamelist = []
    158159        for hist in self.histnam:
    159             #if len(self.histnam) > 1:
    160             #    # multiple files: create a unique name from the histogram
    161             #    fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(hist),filenamelist)
    162             #    # create an instrument parameter file
    163             #    self.filename = os.path.join(self.dirname,fileroot + self.extension)
     160            # multiple files: create a unique name from the histogram
     161            fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(hist),filenamelist)
     162            # create an instrument parameter file
     163            self.filename = os.path.join(self.dirname,fileroot + self.extension)
    164164            self.Writer(hist)
    165165            print('Histogram '+str(hist)+' written to file '+str(self.fullpath))
  • trunk/exports/G2export_pwdr.py

    r2026 r2152  
    9797        filenamelist = []
    9898        for hist in self.histnam:
    99             if len(self.histnam) > 1:
    100                 # multiple files: create a unique name from the histogram
    101                 fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(hist),filenamelist)
    102                 # create an instrument parameter file
    103                 self.filename = os.path.join(self.dirname,fileroot + self.extension)
    104             else:
    105                 # use the supplied name, but force the extension
    106                 self.filename= os.path.splitext(self.filename)[0] + self.extension
    107 
     99            # multiple files: create a unique name from the histogram
     100            fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(hist),filenamelist)
     101            # create an instrument parameter file
     102            self.filename = os.path.join(self.dirname,fileroot + self.extension)
    108103            histblk = self.Histograms[hist]
    109104            prmname = self.WriteInstFile(hist,histblk['Instrument Parameters'][0])
    110105            self.Writer(hist,prmname=prmname)
    111106            print('Histogram '+str(hist)+' written to file '+str(self.fullpath))
    112 
    113107
    114108class ExportPowderXYE(G2IO.ExportBaseclass):
     
    157151        filenamelist = []
    158152        for hist in self.histnam:
    159             if len(self.histnam) > 1:
    160                 # multiple files: create a unique name from the histogram
    161                 fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(hist),filenamelist)
    162                 # create an instrument parameter file
    163                 self.filename = os.path.join(self.dirname,fileroot + self.extension)
    164             else:
    165                 # use the supplied name, but force the extension
    166                 self.filename= os.path.splitext(self.filename)[0] + self.extension
    167 
     153            # multiple files: create a unique name from the histogram
     154            fileroot = G2obj.MakeUniqueLabel(self.MakePWDRfilename(hist),filenamelist)
     155            # create an instrument parameter file
     156            self.filename = os.path.join(self.dirname,fileroot + self.extension)
    168157            self.Writer(hist)
    169158            print('Histogram '+str(hist)+' written to file '+str(self.fullpath))
  • trunk/imports/G2pwd_fxye.py

    r1878 r2152  
    2525    def __init__(self):
    2626        super(self.__class__,self).__init__( # fancy way to self-reference
    27             extensionlist=('.fxye','.raw','.gsas','.gda','gsa.','.RAW','.GSAS','.GDA','.GSA'),
     27            extensionlist=('.fxye','.raw','.gsas','.gda','.gsa','.gss','.RAW','.GSAS','.GDA','.GSA'),
    2828            strictExtension=False,
    2929            formatName = 'GSAS powder data',
     
    258258        title = ''
    259259        comments = None
    260 #        selections = None
    261 
    262         # reload previously saved values
     260
     261        # reload previously saved values - used for multibank reads
    263262        if self.repeat and rdbuffer is not None:
    264263            Banks = rdbuffer.get('Banks')
Note: See TracChangeset for help on using the changeset viewer.