def OnSimulate(self, event):
        reload(SimpleParratt)
    # --- Retrive values from panel --------------
        # self.Text1
        text=self.Text1.GetValue()
        eV0=float(text)
        eV0_min=500
        if eV0<=eV0_min:    eV0=eV0_min+10.
        # self.Text2
        film_mat=self.Text2.GetValue()
        # self.Text3
        text=self.Text3.GetValue()
        film_thick=float(text)
        # self.Text4
        text=self.Text4.GetValue()
        film_den=float(text)
        # self.Text5
        text=self.Text5.GetValue()
        film_roughness=float(text)
        # self.Text6
        subs_mat=self.Text6.GetValue()
        # self.Text7
        text=self.Text7.GetValue()
        subs_den=float(text)
        # self.cb2
        text=self.cb2.GetValue()
        use_Cr=0
        if text=='Yes': use_Cr=1
        # self.cb1
        text=self.cb1.GetValue()
        xUnit='m rad'
        xUnit=text
        # self.cb0
        text=self.cb0.GetValue()
        use_Log=False
        if text=='Yes': use_Log=True
        if use_Cr==1:
            NumLayers=2
        else:
            NumLayers=1
    # --- make lists as reflectivity calculation input ----------
        out=readf1f2a.get_delta(film_mat, film_den, eV0)  # used to be fluo.
        delta_film=out[0]
        la_film=out[2]*10000.	      # absorption length in cm, convert to microns
        thc_film=(2.*delta_film)**(0.5)*180./math.pi
        print '%s %3.4f Degrees (%3.4f m radians)' % ('critical angle for film:', thc_film, thc_film*math.pi/180.*1000.)
        th_step=0.001
        th_range=numpy.arange(0.000, thc_film*3.0, th_step)  # angular range
        depths=[0.0]  # calculate efield intensity at air/film interface
        layer_mat=[];	layer_thick=[];	 layer_den=[];	 layer_rough=[]; layer_tag=[]
        # air
        layer_mat.append('He')
        layer_thick.append(0.0)			# in Angstroms
        #layer_den.append(0.0013)		# in g/cm^2, this will make
        layer_den.append(1e-10)			 # force this to be zero for vacuum
        layer_rough.append(film_roughness)	# in Angstroms
        layer_tag.append('air')			# layer name
        # film
        layer_mat.append(film_mat)
        layer_thick.append(film_thick)		# in Angstroms
        layer_den.append(film_den)		# in g/cm^2
        layer_rough.append(film_roughness)	# in Angstroms
        layer_tag.append(film_mat+'_layer')
        # Cr underlayer if use_Cr=1
        if (NumLayers==2):
            layer_mat.append('Cr')
            layer_thick.append(50.0)
            layer_den.append(7.19)
            layer_rough.append(film_roughness)
            layer_tag.append('Cr_layer')
        # Substrate
        layer_mat.append(subs_mat)
        layer_thick.append(100000.)	    # not necessary
        layer_den.append(subs_den)
        layer_rough.append(film_roughness)  # not necessary
        layer_tag.append(subs_mat+'_substrate')
        # print critical angle and absorption length for film and substrate
        print 'energy(eV) \t layer \t critical_angle(Deg.) \t absorption_length(micron) \n'
        print '%4.1f \t %s \t %4.4f \t %4.4f\n' % (eV0, film_mat, thc_film, la_film)
        out=readf1f2a.get_delta(subs_mat, subs_den, eV0)
        delta_subs=out[0]
        la_subs=out[2]*10000.	      # absorption length in cm, convert it to microns
        thc_subs=(2.*delta_subs)**(0.5)*180./math.pi
        print '%4.1f \t %s \t %4.4f \t %4.4f\n' % (eV0, subs_mat, thc_subs, la_subs)
    # --- call reflectivity in SimpleParratt.py	 ------------------
        SimpleParratt.reflectivity(eV0, th_range, layer_mat, layer_thick, layer_den,\
            layer_rough, layer_tag, depths)
    # --- Plot ----------------------------------------------------
        if self.plot_on==1:
            print self.plot_on
            self.plot.Destroy()
            #self.frm.Destroy()
        frm = wx.Frame(self, 1, 'SimpleParratt.txt', size=(600,450))
        self.data=[]; self.data0=[]
        th0=0;	refl_half=1e6
        inputfile='SimpleParratt.txt'
        f=open(inputfile)
        lines=f.readlines()
        self.xMin=1e6; self.xMax=-1e6; self.yMin=1e6; self.yMax=-1e6
        for line in lines:
            if line.startswith('#'):	continue
            words=line.split()
            if xUnit=='m rad':
                xx=float(words[0])*math.pi/180.0*1000.	# convert deg to m rad
            if xUnit=='Deg':
                xx=float(words[0])
            if xUnit=='qz':
                ang=float(words[0])
                qz=4*math.pi*(eV0/1000.0/12.39842)*math.sin(ang*math.pi/180.0)
                xx=qz
            if self.xMin>xx: self.xMin=xx
            if self.xMax<=xx: self.xMax=xx
            yy=float(words[1])
            if self.yMin>yy: self.yMin=yy
            if self.yMax<=yy: self.yMax=yy
            self.data.append((xx, yy))
            self.data0.append((xx, 0.5))
            temp=abs(yy-0.5)
            if temp<=refl_half:
                refl_half=temp
                th0=xx
        self.yMax=1.0
        f.close()
        sample=''
        for (ii,item) in enumerate(layer_mat):
            if ii==0:
                sample='vacuum'
            else:
                sample=sample+'/'+item
        #title=str(eV0)+'eV, '+sample+', Refl.=0.5 at '+str(th0)+' m rad.'
        text0=' m rad.'
        text1='Incident angle (m rad)'
        if xUnit=='Deg':
            text0=' Deg'
            text1='Incident angle (Deg)'
        if xUnit=='qz':
            text0=' qz (1/Angstrom)'
            text1='qz (1/Agnstrom)'
        title='%4.1f, %s, %s %s %3.3f %s' % (eV0, 'eV', sample, 'Refl.=0.5 at', th0, text0)
        #------------------------------------------------
        client = plot.PlotCanvas(frm)
        # 9/1/2010: enable zooming function, double click for default size
        client.SetEnableZoom(True)
        line = plot.PolyLine(self.data, legend='', colour='red', width=1)
        line0 = plot.PolyLine(self.data0, legend='', colour='black', width=0.5)
        gc = plot.PlotGraphics([line, line0], title, text1, 'Reflectivity')
        client.setLogScale((False,False))
        if use_Log==True: client.setLogScale((False,True))
        client.Draw(gc,	 xAxis= (self.xMin,self.xMax), yAxis= (self.yMin,self.yMax))
        frm.Show(True)
        self.plot_on = 1
        self.plot=frm
        #------------------------------------------------
dataset/ETHPy150Open xraypy/xraylarch/plugins/xsw/YongsCode/SimpleParratt_Panel.py/Plot.OnSimulate/original