Changeset 1134


Ignore:
Timestamp:
Nov 2, 2013 9:26:50 AM (10 years ago)
Author:
vondreele
Message:

add MemoryError? check to StructureFactor2
allow inversion of x & y axes on image plot
these are saved
fix missing stuff in save/restore image controls

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimgGUI.py

    r1131 r1134  
    200200                keys = ['type','wavelength','calibrant','distance','center',
    201201                    'tilt','rotation','azmthOff','fullIntegrate','LRazimuth',
    202                     'IOtth','outAzimuths']
     202                    'IOtth','outAzimuths','invert_x','invert_y']
    203203                for key in keys:
    204204                    if key in ['rotation']:
     
    211211       
    212212    def OnLoadControls(event):
    213         cntlList = ['wavelength','distance','tilt','rotation',
    214             'fullIntegrate','outAzimuths','LRazimuth','IOtth']
     213        cntlList = 'wavelength','distance','tilt','invert_x','invert_y',
     214            'fullIntegrate','outAzimuths','LRazimuth','IOtth','azmthOff']
    215215        dlg = wx.FileDialog(G2frame, 'Choose image controls file', '.', '',
    216216            'image control files (*.imctrl)|*.imctrl',wx.OPEN|wx.CHANGE_DIR)
  • trunk/GSASIIplot.py

    r1131 r1134  
    243243        to F, F**2, etc. as requested
    244244    '''
    245     from matplotlib.patches import Circle
     245    from matplotlib.patches import Circle,CirclePolygon
    246246    global HKL,HKLF
    247247
     
    316316    HKL = []
    317317    HKLF = []
     318    time0 = time.time()
    318319    for refl in HKLref:
    319320        H = np.array(refl[:3])
     
    367368                        else:                   
    368369                            Plot.add_artist(Circle(xy,radius=radius,ec='r',fc='r'))
     370#    print 'plot time: %.3f'%(time.time()-time0)
    369371    HKL = np.array(HKL,dtype=np.int)
    370372    HKLF = np.array(HKLF)
     
    21162118    Data = G2frame.PatternTree.GetItemPyData(
    21172119        G2gd.GetPatternTreeItemId(G2frame,G2frame.Image, 'Image Controls'))
     2120# patch
     2121    if 'invert_x' not in Data:
     2122        Data['invert_x'] = False
     2123        Data['invert_y'] = True
     2124# end patch
    21182125    Masks = G2frame.PatternTree.GetItemPyData(
    21192126        G2gd.GetPatternTreeItemId(G2frame,G2frame.Image, 'Masks'))
     
    21722179               
    21732180        elif PickName == 'Image Controls':
    2174             if event.key == 'c':
     2181            if event.key in ['c',]:
    21752182                Xpos = event.xdata
    21762183                if not Xpos:            #got point out of frame
     
    21912198                else:
    21922199                    G2frame.logPlot = True
    2193         PlotImage(G2frame,newImage=True)
     2200            elif event.key in ['x',]:
     2201                if Data['invert_x']:
     2202                    Data['invert_x'] = False
     2203                else:
     2204                    Data['invert_x'] = True
     2205            elif event.key in ['y',]:
     2206                if Data['invert_y']:
     2207                    Data['invert_y'] = False
     2208                else:
     2209                    Data['invert_y'] = True
     2210        PlotImage(G2frame,newPlot=True)
    21942211           
    21952212    def OnKeyBox(event):
     
    21972214            event.key = cb.GetValue()[0]
    21982215            cb.SetValue(' key press')
    2199             if event.key in 'l':
     2216            if event.key in ['l','s','a','r','p','x','y']:
    22002217                wx.CallAfter(OnImPlotKeyPress,event)
    22012218        Page.canvas.SetFocus() # redirect the Focus from the button back to the plot
     
    24052422    try:
    24062423        if G2frame.PatternTree.GetItemText(G2frame.PickId) in ['Image Controls',]:
    2407             Page.Choice = (' key press','l: log(I) on',)
     2424            Page.Choice = (' key press','l: log(I) on','x: flip x','y: flip y',)
    24082425            if G2frame.logPlot:
    24092426                Page.Choice[1] = 'l: log(I) off'
     
    25672584        Plot.set_xlim(xlim)
    25682585        Plot.set_ylim(ylim)
    2569         Plot.invert_yaxis()
     2586        if Data['invert_x']:
     2587            Plot.invert_xaxis()
     2588        if Data['invert_y']:
     2589            Plot.invert_yaxis()
    25702590        if not newPlot and xylim:
    25712591            Page.toolbar.push_current()
  • trunk/GSASIIstrMath.py

    r1125 r1134  
    647647        refDict['ifNew'] = True           
    648648#reflection processing begins here - big arrays!
    649     refl = refDict['RefList']
    650     H = refl.T[:3]
    651     SQ = 1./(2.*refl.T[4])**2
    652     SQfactor = 4.0*SQ*twopisq
    653     Bab = np.repeat(parmDict[phfx+'BabA']*np.exp(-parmDict[phfx+'BabU']*SQfactor),len(SGT))
    654     if refDict['ifNew']:                #no form factors - 1st time thru StructureFactor
    655         for iref in range(len(refl)):
    656             if 'X' in calcControls[hfx+'histType']:
    657                 dat = G2el.getFFvalues(FFtables,SQ[iref])
    658                 refDict['FF']['FF'][iref] *= dat.values()
    659         refDict['ifNew'] = False
    660     Tindx = np.array([refDict['FF']['El'].index(El) for El in Tdata])
    661     FF = np.repeat(refDict['FF']['FF'].T[Tindx].T,len(SGT),axis=0)
    662     Uniq = np.reshape(np.inner(H.T,SGMT),(-1,3))
    663     Phi = np.inner(H.T,SGT).flatten()
    664     phase = twopi*(np.inner(Uniq,(dXdata+Xdata).T)+Phi[:,np.newaxis])
    665     sinp = np.sin(phase)
    666     cosp = np.cos(phase)
    667     biso = -SQfactor*Uisodata[:,np.newaxis]
    668     Tiso = np.repeat(np.where(biso<1.,np.exp(biso),1.0),len(SGT),axis=1).T
    669     HbH = -np.sum(Uniq.T*np.inner(bij,Uniq),axis=1)
    670     Tuij = np.where(HbH<1.,np.exp(HbH),1.0).T
    671     Tcorr = Tiso*Tuij*Mdata*Fdata/len(SGMT)
    672     fa = np.array([((FF+FP).T-Bab).T*cosp*Tcorr,-FPP*sinp*Tcorr])
    673     fa = np.reshape(fa,(2,len(refl),len(SGT),len(Mdata)))
    674     fas = np.sum(np.sum(fa,axis=2),axis=2)        #real
    675     fbs = np.zeros_like(fas)
    676     if not SGData['SGInv']:
    677         fb = np.array([((FF+FP).T-Bab).T*sinp*Tcorr,FPP*cosp*Tcorr])
    678         fb = np.reshape(fb,(2,len(refl),len(SGT),len(Mdata)))
    679         fbs = np.sum(np.sum(fb,axis=2),axis=2)
    680     fasq = fas**2
    681     fbsq = fbs**2        #imaginary
     649    try:
     650        refl = refDict['RefList']
     651        H = refl.T[:3]
     652        SQ = 1./(2.*refl.T[4])**2
     653        SQfactor = 4.0*SQ*twopisq
     654        Bab = np.repeat(parmDict[phfx+'BabA']*np.exp(-parmDict[phfx+'BabU']*SQfactor),len(SGT))
     655        if refDict['ifNew']:                #no form factors - 1st time thru StructureFactor
     656            for iref in range(len(refl)):
     657                if 'X' in calcControls[hfx+'histType']:
     658                    dat = G2el.getFFvalues(FFtables,SQ[iref])
     659                    refDict['FF']['FF'][iref] *= dat.values()
     660            refDict['ifNew'] = False
     661        Tindx = np.array([refDict['FF']['El'].index(El) for El in Tdata])
     662        FF = np.repeat(refDict['FF']['FF'].T[Tindx].T,len(SGT),axis=0)
     663        Uniq = np.reshape(np.inner(H.T,SGMT),(-1,3))
     664        Phi = np.inner(H.T,SGT).flatten()
     665        phase = twopi*(np.inner(Uniq,(dXdata+Xdata).T)+Phi[:,np.newaxis])
     666        sinp = np.sin(phase)
     667        cosp = np.cos(phase)
     668        biso = -SQfactor*Uisodata[:,np.newaxis]
     669        Tiso = np.repeat(np.where(biso<1.,np.exp(biso),1.0),len(SGT),axis=1).T
     670        HbH = -np.sum(Uniq.T*np.inner(bij,Uniq),axis=1)
     671        Tuij = np.where(HbH<1.,np.exp(HbH),1.0).T
     672        Tcorr = Tiso*Tuij*Mdata*Fdata/len(SGMT)
     673        fa = np.array([((FF+FP).T-Bab).T*cosp*Tcorr,-FPP*sinp*Tcorr])
     674        fa = np.reshape(fa,(2,len(refl),len(SGT),len(Mdata)))
     675        fas = np.sum(np.sum(fa,axis=2),axis=2)        #real
     676        fbs = np.zeros_like(fas)
     677        if not SGData['SGInv']:
     678            fb = np.array([((FF+FP).T-Bab).T*sinp*Tcorr,FPP*cosp*Tcorr])
     679            fb = np.reshape(fb,(2,len(refl),len(SGT),len(Mdata)))
     680            fbs = np.sum(np.sum(fb,axis=2),axis=2)
     681        fasq = fas**2
     682        fbsq = fbs**2        #imaginary
     683    except MemoryError:
     684        print '**** ERROR - insufficient memory for this size problem; try 64-bit version of GSAS-II****'
     685        return
    682686    refl.T[9] = np.sum(fasq,axis=0)+np.sum(fbsq,axis=0)
    683687    refl.T[10] = atan2d(fbs[0],fas[0])
Note: See TracChangeset for help on using the changeset viewer.