Changeset 2083


Ignore:
Timestamp:
Dec 5, 2015 1:49:31 PM (6 years ago)
Author:
toby
Message:

Export multiple masks/controls

Location:
trunk
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2077 r2083  
    7373import GSASIIpwdGUI as G2pdG
    7474import GSASIIphsGUI as G2phsG
     75import GSASIIimgGUI as G2imG
    7576import GSASIIspc as G2spc
    7677import GSASIIstrMain as G2stMn
     
    20272028                self.Bind(wx.EVT_MENU, obj.Exporter, id=item.GetId())
    20282029                self.ExportLookup[item.GetId()] = typ # lookup table for submenu item
    2029                
    2030         #code to debug an Exporter. hard-coded the routine below, to allow a reload before use
     2030        item = imagemenu.Append(wx.ID_ANY,
     2031                        help='Export image controls and masks for multiple images',
     2032                        kind=wx.ITEM_NORMAL,
     2033                        text='Multiple image controls and masks')
     2034        self.Bind(wx.EVT_MENU, self.OnSaveMultipleImg, id=item.GetId())
     2035        #code to debug an Exporter. hard-code the routine below, to allow a reload before use
    20312036        # def DebugExport(event):
    20322037        #      print 'start reload'
     
    36783683            dlg.Destroy()
    36793684        return result
    3680 
     3685   
     3686    def OnSaveMultipleImg(self,event):
     3687        '''Select and save multiple image parameter and mask files
     3688        '''
     3689        G2IO.SaveMultipleImg(self)
     3690       
    36813691class GSASIImain(wx.App):
    36823692    '''Defines a wxApp for GSAS-II
  • trunk/GSASIIIO.py

    r2071 r2083  
    3636import GSASIIlattice as G2lat
    3737import GSASIIpwdGUI as G2pdG
     38import GSASIIimgGUI as G2imG
    3839import GSASIIimage as G2img
    3940import GSASIIElem as G2el
     
    506507        return []
    507508        #raise Exception('No image read')   
     509
     510def SaveMultipleImg(G2frame):
     511    if not G2frame.PatternTree.GetCount():
     512        print 'no images!'
     513        return
     514    choices = G2gd.GetPatternTreeDataNames(G2frame,['IMG ',])
     515    if len(choices) == 1:
     516        names = choices
     517    else:
     518        dlg = G2G.G2MultiChoiceDialog(G2frame,'Stress/Strain fitting','Select images to fit:',choices)
     519        dlg.SetSelections([])
     520        names = []
     521        if dlg.ShowModal() == wx.ID_OK:
     522            names = [choices[sel] for sel in dlg.GetSelections()]
     523        dlg.Destroy()
     524    if not names: return
     525    for name in names:
     526        Id = G2gd.GetPatternTreeItemId(G2frame, G2frame.root, name)
     527        Npix,imagefile,imagetag = G2frame.PatternTree.GetImageLoc(Id)
     528        imroot = os.path.splitext(imagefile)[0]
     529        if imagetag:
     530            imroot += '_' + str(imagetag)
     531        Data = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Image Controls'))
     532        print('Writing '+imroot+'.imctrl')
     533        File = open(imroot+'.imctrl','w')
     534        keys = ['type','wavelength','calibrant','distance','center',
     535                    'tilt','rotation','azmthOff','fullIntegrate','LRazimuth',
     536                    'IOtth','outChannels','outAzimuths','invert_x','invert_y','DetDepth',
     537                    'calibskip','pixLimit','cutoff','calibdmin','chisq','Flat Bkg',
     538                    'binType','SampleShape','PolaVal','SampleAbs','dark image','background image']
     539        for key in keys:
     540            if key not in Data: continue    #uncalibrated!
     541            File.write(key+':'+str(Data[key])+'\n')
     542        File.close()
     543        mask = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id, 'Masks'))
     544        G2imG.CleanupMasks(mask)
     545        print('Writing '+imroot+'.immask')
     546        File = open(imroot+'.immask','w')
     547        for key in ['Points','Rings','Arcs','Polygons','Frames','Thresholds']:
     548            File.write(key+':'+str(mask[key])+'\n')
     549        File.close()
    508550       
    509551def PutG2Image(filename,Comments,Data,Npix,image):
  • trunk/GSASIIimgGUI.py

    r2082 r2083  
    304304                filename = os.path.splitext(filename)[0]+'.imctrl'
    305305                File = open(filename,'w')
    306                 save = {}
    307306                keys = ['type','wavelength','calibrant','distance','center',
    308307                    'tilt','rotation','azmthOff','fullIntegrate','LRazimuth',
     
    11901189                filename = os.path.splitext(filename)[0]+'.immask'
    11911190                File = open(filename,'w')
    1192                 save = {}
    11931191                keys = ['Points','Rings','Arcs','Polygons','Frames','Thresholds']
    11941192                for key in keys:
Note: See TracChangeset for help on using the changeset viewer.