Changeset 4892


Ignore:
Timestamp:
Apr 24, 2021 12:49:41 PM (6 months ago)
Author:
toby
Message:

missed inage change; FPA: as per Cline, 5 line (4 w/mono) now default; rename tails width; tube-tails only w/o mono; max window height=850

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r4802 r4892  
    314314    Imax = np.amax(Image)
    315315    if G2frame.imageDefault:
    316         Data = copy.copy(G2frame.imageDefault)
     316        Data.update(copy.deepcopy(G2frame.imageDefault))
    317317        Data['showLines'] = True
    318318        Data['ring'] = []
     
    762762                Data = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id,'Image Controls'))
    763763                if Data['setDefault']:
    764                     G2frame.imageDefault = Data               
     764                    G2frame.imageDefault = Data
     765                    G2frame.imageDefault['setDefault'] = False
     766                    if 'formatName' in G2frame.imageDefault: del G2frame.imageDefault['formatName']
    765767        if LastSavedUsing:
    766768            print('GPX load successful. Last saved with GSAS-II revision '+LastSavedUsing)
  • trunk/GSASIIfpaGUI.py

    r4594 r4892  
    2020import os.path
    2121import numpy as np
     22import copy
    2223
    2324import wx
     
    3839'''
    3940
    40 parmDict = {'numWave':2}
     41parmDict = {}
    4142'''Parameter dict used for reading Topas-style values. These are
    4243converted to SI units and placed into :data:`NISTparms`
     
    6061    ('sample_thickness', 1., 'Depth of sample (mm)'),
    6162    ('convolution_steps', 8, 'Number of Fourier-space bins per two-theta step'),
    62     ('tube-tails_width', 0.04,'Tube filament width, in projection at takeoff angle (mm)'),
     63    ('source_width', 0.04,'Tube filament width, in projection at takeoff angle (mm)'),
    6364    ('tube-tails_L-tail', -1.,'Left-side tube tails width, in projection (mm)'),   
    6465    ('tube-tails_R-tail', 1.,'Right-side tube tails width, in projection (mm)'),
     
    112113    parmDict['int'] = {i:v for i,v in enumerate((0.653817, 0.346183))}
    113114    parmDict['lwidth'] = {i:v for i,v in enumerate((0.501844,0.626579))}
    114 SetCu2Wave() # use these as default
    115 
     115
     116def SetCu5Wave():
     117    '''Set the parameters to the five-line (4 for incident beam mono)
     118    Cu K alpha spectrum
     119    '''
     120    parmDict['wave'] = {i:v for i,v in enumerate((1.534753,1.540596,1.541058,1.54441,1.544721))}
     121    parmDict['int'] = {i:v for i,v in enumerate((0.0159, 0.5791, 0.0762, 0.2417, 0.0871))}
     122    parmDict['lwidth'] = {i:v for i,v in enumerate((3.6854, 0.437, 0.6, 0.52, 0.62))}
     123
     124def SetMonoWave():
     125    '''Eliminates the short-wavelength line from the five-line Cu K
     126    alpha spectrum when incident beam mono; resets it to 5 if no mono
     127    '''
     128    if IBmono and len(parmDict['wave']) == 5:
     129        for key in 'wave','int','lwidth':
     130            if 0 in parmDict[key]: del parmDict[key][0]
     131    if (not IBmono) and len(parmDict['wave']) == 4:
     132        SetCu5Wave()
     133   
     134#SetCu2Wave() # use these as default
     135SetCu5Wave() # use these as default
     136SetMonoWave()
    116137
    117138def FillParmSizer():
     
    122143    prmSizer = prmPnl.GetSizer()
    123144    prmSizer.Clear(True)
     145    if IBmono:
     146        itemList = [i for i in BraggBrentanoParms if not i[0].startswith('tube-tails')]
     147    else:
     148        itemList = copy.deepcopy(BraggBrentanoParms)
    124149    if DetMode == 'BBpoint':
    125         itemList = BraggBrentanoParms+BBPointDetector
     150        itemList += BBPointDetector
    126151    elif DetMode == 'BBPSD':
    127         itemList = BraggBrentanoParms+BBPSDDetector
     152        itemList += BBPSDDetector
    128153    else:
    129154        raise Exception('Unknown DetMode in FillParmSizer: '+DetMode)
    130155    if IBmono:
    131          itemList += IBmonoParms   
     156        itemList += IBmonoParms   
    132157    text = wx.StaticText(prmPnl,wx.ID_ANY,'label',style=wx.ALIGN_CENTER,
    133158                size=(170,-1)) # make just a bit bigger than largest item in column
     
    172197        FPdlg.Destroy()
    173198    def _onAddWave(event):
    174         parmDict['numWave'] += 1
     199        newkey = max(parmDict['wave'].keys())+1
     200        for key,defVal in zip(
     201            ('wave','int','lwidth'),
     202            (0.0,   1.0,   0.1),
     203            ):
     204            parmDict[key][newkey] = defVal
    175205        wx.CallAfter(MakeTopasFPASizer,G2frame,FPdlg,SetButtonStatus)
    176206    def _onRemWave(event):
    177         parmDict['numWave'] -= 1
     207        lastkey = max(parmDict['wave'].keys())
     208        for key in ('wave','int','lwidth'):
     209            if lastkey in parmDict[key]:
     210                del parmDict[key][lastkey]
    178211        wx.CallAfter(MakeTopasFPASizer,G2frame,FPdlg,SetButtonStatus)
    179212    def _onSetCu5Wave(event):
    180         parmDict['wave'] = {i:v for i,v in enumerate((1.534753,1.540596,1.541058,1.54441,1.544721))}
    181         parmDict['int'] = {i:v for i,v in enumerate((0.0159, 0.5791, 0.0762, 0.2417, 0.0871))}
    182         parmDict['lwidth'] = {i:v for i,v in enumerate((3.6854, 0.437, 0.6, 0.52, 0.62))}
    183         parmDict['numWave'] = 5
     213        SetCu5Wave()
     214        SetMonoWave()
    184215        wx.CallAfter(MakeTopasFPASizer,G2frame,FPdlg,SetButtonStatus)
    185216    def _onSetCu2Wave(event):
    186217        SetCu2Wave()
    187         parmDict['numWave'] = 2
    188218        wx.CallAfter(MakeTopasFPASizer,G2frame,FPdlg,SetButtonStatus)
    189219    def _onSetDetBtn(event):
     
    198228        global IBmono
    199229        IBmono = not monoBtn1.GetValue()
    200         wx.CallAfter(FillParmSizer)
     230        SetMonoWave()
     231        #wx.CallAfter(FillParmSizer)
     232        wx.CallAfter(MakeTopasFPASizer,G2frame,FPdlg,SetButtonStatus)
    201233    def PlotTopasFPA(event):
    202234        XferFPAsettings(parmDict)
     
    236268
    237269    if FPdlg.GetSizer(): FPdlg.GetSizer().Clear(True)
    238     numWave = parmDict['numWave']   
    239270    MainSizer = wx.BoxSizer(wx.VERTICAL)
    240271    MainSizer.Add((-1,5))
    241     waveSizer = wx.FlexGridSizer(cols=numWave+1,hgap=3,vgap=5)
     272    waveSizer = wx.FlexGridSizer(cols=len(parmDict['wave'])+1,hgap=3,vgap=5)
    242273    for lbl,prm,defVal in zip(
    243274            (u'Wavelength (\u212b)','Rel. Intensity',u'Lorentz Width\n(\u212b/1000)'),
     
    249280        waveSizer.Add(text,0,wx.EXPAND)
    250281        if prm not in parmDict: parmDict[prm] = {}
    251         for i in range(numWave):
     282        for i in parmDict['wave'].keys():
    252283            if i not in parmDict[prm]: parmDict[prm][i] = defVal
    253284            ctrl = G2G.ValidatedTxtCtrl(FPdlg,parmDict[prm],i,size=(90,-1))
     
    334365    px,py = prmSizer.GetSize()
    335366    dx,dy = FPdlg.GetSize()
    336     FPdlg.SetMinSize((dx,dy+200)) # leave a min of 200 points for scroll panel   
     367    FPdlg.SetMinSize((dx,dy+200)) # leave a min of 200 points for scroll panel
     368    FPdlg.SetMaxSize((max(dx,700),850))
    337369    FPdlg.SetSize((max(dx,px+20),min(750,dy+py+30))) # 20 for scroll bar, 30 for a bit of room at bottom
    338370   
     
    345377    :returns: a nested dict with global parameters and those for each convolution
    346378    '''
    347     wavenums = range(InpParms['numWave'])
    348     source_wavelengths_m = 1.e-10 * np.array([InpParms['wave'][i] for i in wavenums])
    349     la = [InpParms['int'][i] for i in wavenums]
     379    # cleanup old stuff
     380    for key in "tube_tails","absorption","si_psd","displacement","receiver_slit":
     381        if key in NISTparms:
     382            del NISTparms[key]
     383   
     384    keys = list(InpParms['wave'].keys())
     385    source_wavelengths_m = 1.e-10 * np.array([InpParms['wave'][i] for i in keys])
     386    la = [InpParms['int'][i] for i in keys]
    350387    source_intensities = np.array(la)/max(la)
    351     source_lor_widths_m = 1.e-10 * 1.e-3 * np.array([InpParms['lwidth'][i] for i in wavenums])
    352     source_gauss_widths_m = 1.e-10 * 1.e-3 * np.array([0.001 for i in wavenums])
     388    source_lor_widths_m = 1.e-10 * 1.e-3 * np.array([InpParms['lwidth'][i] for i in keys])
     389    source_gauss_widths_m = 1.e-10 * 1.e-3 * np.array([0.001 for i in keys])
    353390   
    354391    NISTparms["emission"] = {'emiss_wavelengths' : source_wavelengths_m,
     
    364401        for i in  ('passband_mistune','passband_shoulder','two_theta_mono'):
    365402            NISTparms["emission"][i] = InpParms[i]
     403    elif InpParms.get('source_width', 0) > 0 and InpParms.get(
     404            'tube-tails_rel-I',0) > 0:
     405        NISTparms["tube_tails"] = {
     406            'main_width' : 1e-3 * InpParms.get('source_width', 0.),
     407            'tail_left' : -1e-3 * InpParms.get('tube-tails_L-tail',0.),
     408            'tail_right' : 1e-3 * InpParms.get('tube-tails_R-tail',0.),
     409            'tail_intens' : InpParms.get('tube-tails_rel-I',0.),}
    366410   
    367411    if InpParms['filament_length'] == InpParms['receiving_slit_length']: # workaround:
     
    380424            'sample_thickness': 1e-3 * InpParms['sample_thickness'],
    381425            }
    382     elif "absorption" in NISTparms:
    383         del NISTparms["absorption"]
    384426
    385427    if InpParms.get('lpsd_equitorial_divergence',0) > 0 and InpParms.get(
    386             'lpsd_th2_angular_range',0) > 0:
     428            'lpsd_th2_angular_range',0) > 0 and DetMode == 'BBPSD':
    387429        PSDdetector_length_mm=np.arcsin(np.pi*InpParms['lpsd_th2_angular_range']/180.
    388430                                            )*InpParms['Rs'] # mm
     
    391433            'si_psd_window_bounds': (0.,PSDdetector_length_mm/1000.)
    392434            }
    393     elif "si_psd" in NISTparms:
    394         del NISTparms["si_psd"]
    395        
     435
    396436    if InpParms.get('Specimen_Displacement'):
    397437        NISTparms["displacement"] = {'specimen_displacement': 1e-3 * InpParms['Specimen_Displacement']}
    398     elif "displacement" in NISTparms:
    399         del NISTparms["displacement"]
    400438
    401439    if InpParms.get('receiving_slit_width'):
    402440        NISTparms["receiver_slit"] = {'slit_width':1e-3*InpParms['receiving_slit_width']}
    403     elif "receiver_slit" in NISTparms:
    404         del NISTparms["receiver_slit"]
    405 
    406     if InpParms.get('tube-tails_width', 0) > 0 and InpParms.get(
    407             'tube-tails_rel-I',0) > 0:
    408         NISTparms["tube_tails"] = {
    409             'main_width' : 1e-3 * InpParms.get('tube-tails_width', 0.),
    410             'tail_left' : -1e-3 * InpParms.get('tube-tails_L-tail',0.),
    411             'tail_right' : 1e-3 * InpParms.get('tube-tails_R-tail',0.),
    412             'tail_intens' : InpParms.get('tube-tails_rel-I',0.),}
    413     elif "tube_tails" in NISTparms:
    414         del NISTparms["tube_tails"]
    415441
    416442    # set Global parameters
     
    422448        'oversampling' : InpParms['convolution_steps'],
    423449        }
     450
    424451def setupFPAcalc():
    425452    '''Create a peak profile object using the NIST XRD Fundamental
     
    707734            ('maxTT',123.,'Location of last peak in 2theta (deg)'),
    708735            ('step',0.01,'Pattern step size (deg 2theta)'),
    709             ('npeaks',13.,'Number of peaks'),
     736            ('npeaks',13,'Number of peaks'),
    710737            ('calcwid',2.,'Range to compute each peak (deg 2theta)'),
    711738            ):
Note: See TracChangeset for help on using the changeset viewer.