Changeset 3959


Ignore:
Timestamp:
May 6, 2019 4:16:16 PM (2 years ago)
Author:
toby
Message:

Bugs from Ivo: scripting & seq. table plotting; script addition for image integration

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r3958 r3959  
    63286328        Plot.clear()
    63296329        colors=['b','g','r','c','m','k']
    6330         uselist = Page.seqTableGet(0)[1]
     6330        uselist = G2frame.SeqTable.GetColValues(1)
    63316331        if G2frame.seqXaxis is not None:   
    63326332            xName,X,Xsig = Page.seqTableGet(G2frame.seqXaxis)
  • trunk/GSASIIpwd.py

    r3906 r3959  
    15451545    return True
    15461546           
    1547 def DoPeakFit(FitPgm,Peaks,Background,Limits,Inst,Inst2,data,fixback,prevVaryList=[],oneCycle=False,controls=None,dlg=None):
     1547def DoPeakFit(FitPgm,Peaks,Background,Limits,Inst,Inst2,data,fixback=None,prevVaryList=[],oneCycle=False,controls=None,dlg=None):
    15481548    '''Called to perform a peak fit, refining the selected items in the peak
    15491549    table as well as selected items in the background.
     
    18201820        Ftol = 1.0
    18211821    x,y,w,yc,yb,yd = data   #these are numpy arrays - remove masks!
     1822    if fixback is None:
     1823        fixback = np.zeros_like(y)
    18221824    yc *= 0.                            #set calcd ones to zero
    18231825    yb *= 0.
  • trunk/GSASIIscriptable.py

    r3857 r3959  
    745745exportersByExtension = {}
    746746'''Specifies the list of extensions that are supported for Powder data export'''
     747npsind = lambda x: np.sin(x*np.pi/180.)
    747748
    748749def LoadG2fil():
     
    10711072        import matplotlib as mpl
    10721073        python_library_versions = G2fil.get_python_versions([mpl, np, sp])
    1073     except ModuleNotFoundError:
     1074    except ImportError:
    10741075        python_library_versions = G2fil.get_python_versions([np, sp])
    10751076
     
    13581359            imagefile = dImgObj.data['data'][1]
    13591360            ImageTag = None # fix this for multiimage files
    1360             darkImg = G2fil.RereadImageData(ImageReaderlist,imagefile,ImageTag=ImageTag,FormatName=formatName)
     1361            darkImage = G2fil.RereadImageData(ImageReaderlist,imagefile,ImageTag=ImageTag,FormatName=formatName)
    13611362            if darkImg is None:
    13621363                raise Exception('Error reading dark image {}'.format(imagefile))
     
    13691370            imagefile = bImgObj.data['data'][1]
    13701371            ImageTag = None # fix this for multiimage files
    1371             backImg = G2fil.RereadImageData(ImageReaderlist,imagefile,ImageTag=ImageTag,FormatName=formatName)
     1372            backImage = G2fil.RereadImageData(ImageReaderlist,imagefile,ImageTag=ImageTag,FormatName=formatName)
    13721373            if backImage is None:
    13731374                raise Exception('Error reading background image {}'.format(imagefile))
     
    24052406            return self.data['Controls']['data'][control]
    24062407        elif control == 'seqCopy':
    2407             self.data['Controls']['data']['Copy2Next'] = bool(value)
     2408            return self.data['Controls']['data']['Copy2Next']
    24082409        else:
    24092410            print('Defined Controls:',self.data['Controls']['data'].keys())
     
    30373038        print ('Instrument parameters saved to: '+filename)
    30383039
    3039     def LoadProfile(self,filename):
    3040         '''Reads a GSAS-II (new style) .instprm file and overwrites the current parameters
     3040    def LoadProfile(self,filename,bank=0):
     3041        '''Reads a GSAS-II (new style) .instprm file and overwrites the current
     3042        parameters
     3043
     3044        :param str filename: instrument parameter file name, extension ignored if not
     3045          .instprm
     3046        :param int bank: bank number to read, defaults to zero
    30413047        '''
    30423048        filename = os.path.splitext(filename)[0]+'.instprm'         # make sure extension is .instprm
     
    37983804            self.data['Image Controls'][key] = [imgNam,mult]
    37993805
    3800     def loadControls(self,filename):
     3806    def loadControls(self,filename=None,imgDict=None):
    38013807        '''load controls from a .imctrl file
    38023808
    38033809        :param str filename: specifies a file to be read, which should end
    3804           with .imctrl
     3810          with .imctrl (defaults to None, meaning parameters are input
     3811          with imgDict.)
     3812        :param dict imgDict: contains a set of image parameters (defaults to
     3813          None, meaning parameters are input with filename.)
    38053814        '''
    3806         File = open(filename,'r')
    3807         Slines = File.readlines()
    3808         File.close()
    3809         G2fil.LoadControls(Slines,self.data['Image Controls'])
    3810         print('file {} read into {}'.format(filename,self.name))
     3815        if filename:
     3816            File = open(filename,'r')
     3817            Slines = File.readlines()
     3818            File.close()
     3819            G2fil.LoadControls(Slines,self.data['Image Controls'])
     3820            print('file {} read into {}'.format(filename,self.name))
     3821        elif imgDict:
     3822            self.data['Image Controls'].update(imgDict)
     3823            print('Image controls set')
     3824        else:
     3825            raise Exception("loadControls called without imgDict or filename specified")
    38113826
    38123827    def saveControls(self,filename):
     
    39603975                        except:
    39613976                            pass
    3962                 if 'label_prm' in item.lower():
    3963                     for num in ('1','2','3'):
    3964                         if 'label_prm'+num in item.lower():
    3965                             Controls['FreePrm'+num] = item.split('=')[1].strip()
     3977                # if 'label_prm' in item.lower():
     3978                #     for num in ('1','2','3'):
     3979                #         if 'label_prm'+num in item.lower():
     3980                #             Controls['FreePrm'+num] = item.split('=')[1].strip()
    39663981            if 'PWDR' in Aname:
    39673982                if 'target' in data:    #from lab x-ray 2D imaging data
     3983                    waves = {'CuKa':[1.54051,1.54433],'TiKa':[2.74841,2.75207],'CrKa':[2.28962,2.29351],
     3984                                 'FeKa':[1.93597,1.93991],'CoKa':[1.78892,1.79278],'MoKa':[0.70926,0.713543],
     3985                                 'AgKa':[0.559363,0.563775]}
    39683986                    wave1,wave2 = waves[data['target']]
    39693987                    parms = ['PXC',wave1,wave2,0.5,0.0,polariz,290.,-40.,30.,6.,-14.,0.0,0.0001,Azms[i]]
     
    40104028                histItems += [section]
    40114029                HistDict[section] = {}
    4012             elif 'SASD' in Aname:             
    4013                 section = 'Substances'
    4014                 histItems += [section]
    4015                 HistDict[section] = G2pdG.SetDefaultSubstances()  # this needs to be moved
    4016                 section = 'Sample Parameters'
    4017                 histItems += [section]
    4018                 HistDict[section] = Sample
    4019                 section = 'Models'
    4020                 histItems += [section]
    4021                 HistDict[section] = G2pdG.SetDefaultSASDModel() # this needs to be moved
     4030            # elif 'SASD' in Aname:             
     4031            #     section = 'Substances'
     4032            #     histItems += [section]
     4033            #     HistDict[section] = G2pdG.SetDefaultSubstances()  # this needs to be moved
     4034            #     section = 'Sample Parameters'
     4035            #     histItems += [section]
     4036            #     HistDict[section] = Sample
     4037            #     section = 'Models'
     4038            #     histItems += [section]
     4039            #     HistDict[section] = G2pdG.SetDefaultSASDModel() # this needs to be moved
    40224040            valuesdict = {
    40234041                'wtFactor':1.0,'Dummy':False,'ranId':ran.randint(0,sys.maxsize),'Offset':[0.0,0.0],'delOffset':0.02*Ymax,
     
    40754093
    40764094    """
    4077     proj = G2Project(gpxname=args.filename)
     4095    proj = G2Project(gpxfile=args.filename)
    40784096
    40794097    hist_objs = []
Note: See TracChangeset for help on using the changeset viewer.