Changeset 3333


Ignore:
Timestamp:
Apr 2, 2018 11:17:03 AM (4 years ago)
Author:
vondreele
Message:

add new Parm menu item Load Multi Contols for load image controls for a suite of images based on 2-theta setting for detector position.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r3332 r3333  
    326326        Data['type'] = 'PWDR'
    327327        Data['color'] = GSASIIpath.GetConfigValue('Contour_color','Paired')
    328         if 'tilt' not in Data:          #preset in e.g. Bruker importer?
     328        if 'tilt' not in Data:          #defaults if not preset in e.g. Bruker importer
    329329            Data['tilt'] = 0.0
    330330            Data['rotation'] = 0.0
  • trunk/GSASIIdataGUI.py

    r3331 r3333  
    23842384            kind=wx.ITEM_NORMAL,text='Replay log')
    23852385        self.Bind(wx.EVT_MENU, log.ReplayLog, item)
     2386       
     2387# End of logging ##############################################################
    23862388
    23872389    def _init_Exports(self,menu):
     
    50415043        G2G.Define_wxId('wxID_IMCALIBRATE', 'wxID_IMRECALIBRATE', 'wxID_IMINTEGRATE', 'wxID_IMCLEARCALIB', 'wxID_IMRECALIBALL',
    50425044            'wxID_IMCOPYCONTROLS', 'wxID_INTEGRATEALL', 'wxID_IMSAVECONTROLS', 'wxID_IMLOADCONTROLS', 'wxID_IMAUTOINTEG',
    5043             'wxID_IMCOPYSELECTED', 'wxID_SAVESELECTEDCONTROLS', 'wxID_IMXFERCONTROLS', 'wxID_IMRESETDIST',)
     5045            'wxID_IMCOPYSELECTED', 'wxID_SAVESELECTEDCONTROLS', 'wxID_IMXFERCONTROLS', 'wxID_IMRESETDIST',
     5046            'wxID_LOADELECTEDCONTROLS')
    50445047        self.ImageMenu = wx.MenuBar()
    50455048        self.PrefillDataMenu(self.ImageMenu)
     
    50645067        ImageParams.Append(G2G.wxID_SAVESELECTEDCONTROLS,'Save Multiple Controls','Save controls from selected images to file')
    50655068        ImageParams.Append(G2G.wxID_IMLOADCONTROLS,'Load Controls','Load image controls from file')
     5069        ImageParams.Append(G2G.wxID_LOADELECTEDCONTROLS,'Load Multiple Controls','Load multiple image controls from multiple files')
    50665070        ImageParams.Append(G2G.wxID_IMXFERCONTROLS,'Xfer angles','Transfer integration range for other detector distances')
    50675071        ImageParams.Append(G2G.wxID_IMRESETDIST,'Reset dist','Reset all detector dist to set dist')
  • trunk/GSASIIimgGUI.py

    r3326 r3333  
    411411            'calibskip','pixLimit','cutoff','calibdmin','Flat Bkg','varyList',
    412412            'binType','SampleShape','PolaVal','SampleAbs','dark image','background image',
    413             ]
     413            'twoth']
    414414        for key in keys:
    415415            if key not in data:     #uncalibrated!
     
    465465            WriteControls(filename,data)
    466466           
    467     def OnLoadControls(event):
     467    def LoadControls(Slines,data):
    468468        cntlList = ['wavelength','distance','tilt','invert_x','invert_y','type','Oblique',
    469469            'fullIntegrate','outChannels','outAzimuths','LRazimuth','IOtth','azmthOff','DetDepth',
    470470            'calibskip','pixLimit','cutoff','calibdmin','Flat Bkg','varyList','setdist',
    471             'PolaVal','SampleAbs','dark image','background image']
     471            'PolaVal','SampleAbs','dark image','background image','twoth']
     472        save = {}
     473        for S in Slines:
     474            if S[0] == '#':
     475                continue
     476            [key,val] = S.strip().split(':',1)
     477            if key in ['type','calibrant','binType','SampleShape',]:    #strings
     478                save[key] = val
     479            elif key in ['varyList',]:
     480                save[key] = eval(val)   #dictionary
     481            elif key in ['rotation']:
     482                save[key] = float(val)
     483            elif key in ['center',]:
     484                if ',' in val:
     485                    save[key] = eval(val)
     486                else:
     487                    vals = val.strip('[] ').split()
     488                    save[key] = [float(vals[0]),float(vals[1])]
     489            elif key in cntlList:
     490                save[key] = eval(val)
     491        data.update(save)
     492        # next line removed. Previous updates tree contents. The next
     493        # makes a copy of data, puts it into tree and "disconnects" data
     494        # from tree contents (later changes to data are lost!)
     495        #G2frame.GPXtree.SetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.Image, 'Image Controls'),copy.deepcopy(data))
     496       
     497           
     498    def OnLoadControls(event):
    472499        pth = G2G.GetImportPath(G2frame)
    473500        if not pth: pth = '.'
     
    478505                filename = dlg.GetPath()
    479506                File = open(filename,'r')
    480                 save = {}
    481                 S = File.readline()
    482                 while S:
    483                     if S[0] == '#':
    484                         S = File.readline()
    485                         continue
    486                     [key,val] = S.strip().split(':',1)
    487                     if key in ['type','calibrant','binType','SampleShape',]:    #strings
    488                         save[key] = val
    489                     elif key in ['varyList',]:
    490                         save[key] = eval(val)   #dictionary
    491                     elif key in ['rotation']:
    492                         save[key] = float(val)
    493                     elif key in ['center',]:
    494                         if ',' in val:
    495                             save[key] = eval(val)
    496                         else:
    497                             vals = val.strip('[] ').split()
    498                             save[key] = [float(vals[0]),float(vals[1])]
    499                     elif key in cntlList:
    500                         save[key] = eval(val)
    501                     S = File.readline()
    502                 data.update(save)
    503                 # next line removed. Previous updates tree contents. The next
    504                 # makes a copy of data, puts it into tree and "disconnects" data
    505                 # from tree contents (later changes to data are lost!)
    506                 #G2frame.GPXtree.SetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.Image, 'Image Controls'),copy.deepcopy(data))
     507                Slines = File.readlines()
    507508                File.close()
     509                LoadControls(Slines,data)
    508510        finally:
    509511            dlg.Destroy()
     
    512514        G2plt.PlotExposedImage(G2frame,event=event)
    513515        wx.CallLater(100,UpdateImageControls,G2frame,data,masks)
     516       
     517    def OnLoadMultiControls(event):         #TODO: how read in multiple image controls & match them by 'twoth' tag?
     518        pth = G2G.GetImportPath(G2frame)
     519        if not pth: pth = '.'
     520        controlsDict = {}
     521        dlg = wx.FileDialog(G2frame, 'Choose image control files', pth, '',
     522            'image control files (*.imctrl)|*.imctrl',wx.FD_OPEN|wx.FD_MULTIPLE)
     523        try:
     524            if dlg.ShowModal() == wx.ID_OK:
     525                filelist = dlg.GetPaths()
     526                if len(filelist) == 0: return
     527                for filename in filelist:
     528                    File = open(filename,'r')
     529                    Slines = File.readlines()
     530                    for S in Slines:
     531                        if S.find('twoth') == 0:
     532                            indx = S.split(':')[1][:-1]     #remove '\n'!
     533                    controlsDict[indx] = Slines
     534                    File.close()
     535        finally:
     536            dlg.Destroy()
     537        if not len(controlsDict):
     538            return
     539        Names = G2gd.GetGPXtreeDataNames(G2frame,['IMG ',])
     540        dlg = G2G.G2MultiChoiceDialog(G2frame,'Select images','Select images for updating controls:',
     541            Names)
     542        try:
     543            if dlg.ShowModal() == wx.ID_OK:
     544                images = dlg.GetSelections()
     545                if not len(images):
     546                    return
     547                for image in images:
     548                    Id = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,Names[image])
     549                    imctrls = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id,'Image Controls'))
     550                    Slines = controlsDict[imctrls['twoth']]
     551                    LoadControls(Slines,imctrls)
     552        finally:
     553            dlg.Destroy()
    514554       
    515555    def OnTransferAngles(event):
     
    12371277    G2frame.Bind(wx.EVT_MENU, OnSaveMultiControls, id=G2G.wxID_SAVESELECTEDCONTROLS)
    12381278    G2frame.Bind(wx.EVT_MENU, OnLoadControls, id=G2G.wxID_IMLOADCONTROLS)
     1279    G2frame.Bind(wx.EVT_MENU, OnLoadMultiControls, id=G2G.wxID_LOADELECTEDCONTROLS)
    12391280    G2frame.Bind(wx.EVT_MENU, OnTransferAngles, id=G2G.wxID_IMXFERCONTROLS)
    12401281    G2frame.Bind(wx.EVT_MENU, OnResetDist, id=G2G.wxID_IMRESETDIST)
  • trunk/imports/G2img_SFRM.py

    r3332 r3333  
    117117    print ('import time: %.3f'%(time.time()-time0))
    118118    data = {'pixelSize':pixSize,'wavelength':wave,'distance':dist,'center':cent,
    119             'size':sizexy,'target':target,'tilt':-twoth,'rotation':90.}
     119            'size':sizexy,'target':target,'tilt':-twoth,'rotation':90.,'twoth':str(round(twoth,1))}
    120120    data['pixLimit'] = 5
    121121    data['calibdmin'] = 1.0
Note: See TracChangeset for help on using the changeset viewer.