Changeset 4009


Ignore:
Timestamp:
May 31, 2019 3:25:20 PM (3 years ago)
Author:
toby
Message:

add convariance to recalibrate all, so esd's are computed properly seq. ref. table

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r3999 r4009  
    136136    return cent,phi,radii
    137137
    138 def FitDetector(rings,varyList,parmDict,Print=True):
    139     'Needs a doc string'
     138def FitDetector(rings,varyList,parmDict,Print=True,covar=False):
     139    '''Fit detector calibration paremeters
     140
     141    :param np.array rings: vector of ring positions
     142    :param list varyList: calibration parameters to be refined
     143    :param dict parmDict: all calibration parameters
     144    :param bool Print: set to True (default) to print the results
     145    :param bool covar: set to True to return the covariance matrix (default is False)
     146    :returns: [chisq,vals,sigList] unless covar is True, then
     147        [chisq,vals,sigList,coVarMatrix] is returned
     148    '''
    140149       
    141150    def CalibPrint(ValSig,chisq,Npts):
     
    210219    if Print:
    211220        CalibPrint(ValSig,chisq,rings.shape[0])
    212     return [chisq,vals,sigList]
     221    if covar:
     222        return [chisq,vals,sigList,result[1]]
     223    else:
     224        return [chisq,vals,sigList]
    213225
    214226def ImageLocalMax(image,w,Xpix,Ypix):
     
    551563    :param dict data: the Controls dict for the image
    552564    :param dict masks: a dict with masks
    553     :returns: a list containing vals,varyList,sigList,parmDict
     565    :returns: a list containing vals,varyList,sigList,parmDict,covar
    554566    '''
    555567    import ImageCalibrants as calFile
     
    619631       
    620632    rings = np.concatenate((data['rings']),axis=0)
    621     [chisq,vals,sigList] = FitDetector(rings,varyList,parmDict)
     633    [chisq,vals,sigList,covar] = FitDetector(rings,varyList,parmDict,True,True)
    622634    data['wavelength'] = parmDict['wave']
    623635    data['distance'] = parmDict['dist']
     
    635647    if G2frame:
    636648        G2plt.PlotImage(G2frame,newImage=True)       
    637     return [vals,varyList,sigList,parmDict]
    638            
     649    return [vals,varyList,sigList,parmDict,covar]
     650
    639651def ImageCalibrate(G2frame,data):
    640652    '''Called to perform an initial image calibration after points have been
  • trunk/GSASIIimgGUI.py

    r3980 r4009  
    222222                        print('calibrant missing from local image calibrants files')
    223223                        return
    224                     vals,varyList,sigList,parmDict = result
     224                    vals,varyList,sigList,parmDict,covar = result
    225225                    sigList = list(sigList)
    226226                    if 'dist' not in varyList:
     
    229229                        sigList.append(None)
    230230                    vals.append(Data.get('setdist',Data['distance']))
     231                    # add setdist to varylist etc. so that it is displayed in Seq Res table
    231232                    varyList.append('setdist')
    232233                    sigList.append(None)
    233                     vals.append(Data.get('samplechangerpos',Data['samplechangerpos']))
    234                     varyList.append('chgrpos')
    235                     sigList.append(None)
     234                    covar = np.lib.pad(covar, (0,1), 'constant')
     235#                    vals.append(Data.get('samplechangerpos',Data['samplechangerpos']))
     236#                    varyList.append('chgrpos')
     237#                    sigList.append(None)
    236238                   
    237239                    SeqResult[name] = {'variables':vals,'varyList':varyList,'sig':sigList,'Rvals':[],
    238                         'covMatrix':np.eye(len(varyList)),'title':name,'parmDict':parmDict}
     240                        'covMatrix':covar,'title':name,'parmDict':parmDict}
    239241                SeqResult['histNames'] = Names               
    240242                G2frame.GPXtree.SetItemPyData(Id,SeqResult)
  • trunk/GSASIIstrMain.py

    r3913 r4009  
    122122        printFile.write(' Number of function calls: %d No. of observations: %d No. of parameters: %d User rejected: %d Sp. gp. extinct: %d\n'%  \
    123123            (result[2]['nfev'],Histograms['Nobs'],len(varyList),Histograms['Nrej'],Histograms['Next']))
    124         printFile.write(' Refinement time = %8.3fs, %8.3fs/cycle, for %d cycles\n'%(runtime,runtime/ncyc,ncyc))
     124        if ncyc:
     125            printFile.write(' Refinement time = %8.3fs, %8.3fs/cycle, for %d cycles\n'%(runtime,runtime/ncyc,ncyc))
    125126        printFile.write(' wR = %7.2f%%, chi**2 = %12.6g, GOF = %6.2f\n'%(Rvals['Rwp'],Rvals['chisq'],Rvals['GOF']))
    126127        sig = len(varyList)*[None,]
Note: See TracChangeset for help on using the changeset viewer.