Changeset 4345


Ignore:
Timestamp:
Mar 6, 2020 3:05:22 PM (4 years ago)
Author:
toby
Message:

Add more image settings to preferences; prevent save of config.py after "no save"

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/G2compare.py

    r4339 r4345  
    278278        wx.CallAfter(oldmenu.Destroy)
    279279        if self.getMode() == "Histogram":
    280             pass
     280            item = modeMenu.Append(wx.ID_ANY,'Prince test')
     281            self.Bind(wx.EVT_MENU, self.onHistPrinceTest, id=item.GetId())
    281282        elif self.getMode() == "Phase":
    282283            pass
     
    568569            item, cookie = self.GPXtree.GetNextChild(self.root, cookie)
    569570        if len(items) < 2:
    570             G2G.G2MessageBox(self,'F-test requires two more more projects','Need more projects')
     571            G2G.G2MessageBox(self,'F-test requires two projects','Need more projects')
    571572            return
    572573        elif len(items) == 2:
     
    666667        msg += postmsg
    667668        G2G.G2MessageBox(self,msg,'F-test result')
    668    
     669       
     670    def onHistPrinceTest(self,event):
     671        '''Compare two histograms (selected here if more than two are present)
     672        using the statistical test proposed by Ted Prince in
     673        Acta Cryst. B35 1099-1100. (1982). Also see Int. Tables Vol. C
     674        (1st Ed.) chapter 8.4, 618-621 (1995).
     675        '''
     676        items = []
     677        item, cookie = self.GPXtree.GetFirstChild(self.root)
     678        while item:
     679            items.append(item)
     680            item, cookie = self.GPXtree.GetNextChild(self.root, cookie)
     681
     682        if len(items) < 2:
     683            G2G.G2MessageBox(self,'Prince test requires two histograms','Need more')
     684            return
     685        elif len(items) == 2:
     686            s0,s1 = items
     687        else:
     688            # need to make selection here
     689            sel = []
     690            for i in items:
     691                sel.append(self.GPXtree.GetItemText(i))
     692            dlg = G2G.G2SingleChoiceDialog(self,'Select one refinement',
     693                                             'Choose refinement',sel)
     694            if dlg.ShowModal() == wx.ID_OK:
     695                s0 = dlg.GetSelection()
     696                dlg.Destroy()
     697            else:
     698                dlg.Destroy()
     699                return
     700            inds = list(range(len(items)))
     701            del sel[s0]
     702            del inds[s0]
     703            dlg = G2G.G2SingleChoiceDialog(self,'Select comparison refinement',
     704                                             'Choose refinement',sel)
     705            if dlg.ShowModal() == wx.ID_OK:
     706                s1 = dlg.GetSelection()
     707                s1 = inds[s1]
     708                dlg.Destroy()
     709            else:
     710                dlg.Destroy()
     711                return
     712        model0 = self.GPXtree.GetItemPyData(s0)
     713        data0 = model0[1]
     714        model1 = self.GPXtree.GetItemPyData(s1)
     715        data1 = model1[1]
     716        if len(data0[0]) != len(data1[0]):
     717            G2G.G2MessageBox(self,'Unable to test: differing numbers of data points','Comparison not valid')
     718            return
     719        if max(abs((data0[0]-data1[0])/data0[0])) > 0.01:
     720            G2G.G2MessageBox(self,'Unable to use test: "X" values differ','Comparison not valid')
     721            return
     722        X = data0[3] - data1[3]
     723        #Z = np.sqrt(data0[3]) * (data0[1] - (data0[3] + data1[3])/2)
     724        X = (data0[3] - data1[3]) / np.sqrt(data0[1])
     725        Z = (data0[1] - (data0[3] + data1[3])/2) / np.sqrt(data0[1])
     726        lam = np.sum(X*Z) / np.sum(X)
     727        sig = np.sqrt(
     728            (np.sum(Z*Z) - lam*lam*np.sum(X*X)) /
     729            ((len(data0[0]) - 1) * np.sum(X*X))
     730            )
     731           
     732    0 the x-postions (two-theta in degrees),
     733    1 the intensity values (Yobs),
     734    2 the weights for each Yobs value
     735    3 the computed intensity values (Ycalc)
     736    4 the background values
     737    5 Yobs-Ycalc
     738       
     739        GSASIIpath.IPyBreak_base()
     740               
     741#======================================================================   
    669742if __name__ == '__main__':
    670743    #if sys.platform == "darwin":
  • trunk/GSASIIIO.py

    r4343 r4345  
    345345        Data['calibrant'] = ''
    346346        Data['IOtth'] = [5.0,50.0]
     347        if GSASIIpath.GetConfigValue('Image_2theta_min'):
     348            try:
     349                Data['IOtth'][0] = float(GSASIIpath.GetConfigValue('Image_2theta_min'))
     350            except:
     351                pass
     352        if GSASIIpath.GetConfigValue('Image_2theta_max'):
     353            try:
     354                Data['IOtth'][1] = float(GSASIIpath.GetConfigValue('Image_2theta_max'))
     355            except:
     356                pass
    347357        Data['LRazimuth'] = [0.,180.]
    348358        Data['azmthOff'] = 0.0
  • trunk/GSASIIautoInt.py

    r4343 r4345  
     1#!/usr/bin/env python
     2# -*- coding: utf-8 -*-
     3#GSAS-II autointegration routines
     4########### SVN repository information ###################
     5# $Date: $
     6# $Author: $
     7# $Revision: $
     8# $URL: $
     9# $Id: $
     10########### SVN repository information ###################
    111'''
    212*GSASIIautoint: autointegration routines*
  • trunk/GSASIIctrlGUI.py

    r4330 r4345  
    10701070    :param wx.Panel parent: the parent to the :class:`~wxpython.ComboBox` (usually a
    10711071      frame or panel)
    1072     :param dict dct: a dict (or list) to contain the value set
     1072    :param dct: a dict or list to contain the value set
    10731073      for the :class:`~wxpython.ComboBox`.
    10741074    :param item: the dict key (or list index) where ``dct[item]`` will
     
    10941094      The default for :data:`values` is to use the same list as
    10951095      specified for :data:`choices`.
     1096    :param function onChange: an optional routine that will be called
     1097      when the 
     1098      :class:`~wxpython.ComboBox` can be specified.
    10961099    :param (other): additional keyword arguments accepted by
    10971100      :class:`~wxpython.ComboBox` can be specified.
    10981101    '''
    1099     def __init__(self,parent,dct,item,choices,values=None,**kw):
     1102    def __init__(self,parent,dct,item,choices,values=None,OnChange=None,**kw):
    11001103        if values is None:
    11011104            values = choices
     
    11131116        self.dct = dct
    11141117        self.item = item
     1118        self.OnChange = OnChange
    11151119        self.Bind(wx.EVT_COMBOBOX, self.onSelection)
    11161120    def onSelection(self,event):
     
    11201124        else:
    11211125            self.dct[self.item] = self.values[0] # unknown
     1126        if self.OnChange: self.OnChange(event)
    11221127
    11231128################################################################################
     
    47074712    return d
    47084713
     4714inhibitSave = False
    47094715def SaveConfigVars(vars,parent=None):
    47104716    '''Write the current config variable values to config.py
     
    47164722    :returns: True if unable to write the file, None otherwise
    47174723    '''
     4724    if inhibitSave:
     4725        if GSASIIpath.GetConfigValue('debug'):
     4726            print('inhibitSave prevents saving configuration')
     4727        return
     4728
    47184729    # try to write to where an old config file is located
    47194730    try:
     
    48784889        GSASIIpath.SetConfigValue(self.vars)
    48794890        self.EndModal(wx.ID_OK)
     4891        global inhibitSave
     4892        if event is not None: inhibitSave = True
    48804893        import GSASIImpsubs as G2mp
    48814894        G2mp.ResetMP()
     
    48854898        as the current settings
    48864899        '''
     4900        global inhibitSave
     4901        inhibitSave = False
    48874902        if not SaveConfigVars(self.vars,parent=self):
    48884903            self.OnApplyChanges() # force a reload of the config settings
     
    49634978                    style=wx.CB_READONLY|wx.CB_DROPDOWN)
    49644979                self.colSel.Bind(wx.EVT_COMBOBOX, OnNewColorBar)
     4980                self.varsizer.Add(self.colSel, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     4981            elif var == 'Image_calibrant':
     4982                import ImageCalibrants as calFile
     4983                calList = sorted([m for m in calFile.Calibrants.keys()],
     4984                                     key=lambda s: s.lower())
     4985                self.colSel = EnumSelector(self,self.vars[var],1,calList,
     4986                                               OnChange=self.OnChange)       
    49654987                self.varsizer.Add(self.colSel, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
    49664988            else:
  • trunk/GSASIIimgGUI.py

    r4343 r4345  
    13371337        comboSizer = wx.BoxSizer(wx.HORIZONTAL)   
    13381338        comboSizer.Add(wx.StaticText(parent=G2frame.dataWindow,label=' Calibrant '),0,WACV)
     1339        if (GSASIIpath.GetConfigValue('Image_calibrant') and
     1340                    GSASIIpath.GetConfigValue('Image_calibrant') in calList and
     1341                    not data['calibrant']):
     1342            data['calibrant'] = GSASIIpath.GetConfigValue('Image_calibrant')
    13391343        calSel = wx.ComboBox(parent=G2frame.dataWindow,value=data['calibrant'],choices=calList,
    13401344            style=wx.CB_READONLY|wx.CB_DROPDOWN)
  • trunk/config_example.py

    r4085 r4345  
    127127
    128128Autoscale_ParmNames = ['userComment2',r'extraInputs\1\extraInputs','Ion_Chamber_I0',]
     129'''Gives the possible selection of incident monitor names as found in an image metadata file.
     130Used in AutoIntegration
     131'''
    129132DefaultAutoScale = "userComment2"
    130 '''Gives the possible selection of incident monitor names as found in an image metadata file.
    131 DefaultAutoScale must be one of the AutoScale_ParmNames
     133'''DefaultAutoScale selects one of the AutoScale_ParmNames.
    132134Used in AutoIntegration
    133135'''
     
    204206'''A list of previously used .gpx files
    205207'''
     208
     209Image_calibrant = ''
     210''' Specifies a default calibrant material for images. Will be applied for
     211newly-read images, but if changed the specified material will be saved.
     212'''
     213
     214Image_2theta_min = 5.0
     215''' Specifies a default 2-theta minimum used for calibration and integration
     216as the Inner 2-theta value. Will be applied for
     217newly-read images, but if changed the new value will be saved.
     218'''
     219
     220Image_2theta_max = 50.0
     221''' Specifies a default 2-theta maximum used for calibration and integration
     222as the Outer 2-theta value. Will be applied for
     223newly-read images, but if changed the new value will be saved.
     224'''
Note: See TracChangeset for help on using the changeset viewer.