Example #1
0
 def y(self):
     """
     Define the function in terms of x to return some value
     """
     Rc = self.params['Rc'].value
     D = self.params['D'].value
     Zo = self.params['Zo'].value
     cov = self.params['cov'].value
     sig = self.params['roughness'].value
     xi = self.params['decay'].value
     rhoc = self.params['rhoc'].value
     qoff = self.params['qoff'].value
     rhos = [self.rho_up, self.rho_down]
     lam = self.lam
     z = np.arange(self.zmin, self.zmax, self.dz)
     d = np.ones_like(z) * self.dz
     edp = self.decayNp(z,
                        Rc=Rc,
                        z0=Zo,
                        xi=xi,
                        cov=cov,
                        rhos=rhos,
                        rhoc=rhoc,
                        sig=sig,
                        D=D)
     self.output_params['EDP'] = {'x': z, 'y': edp}
     beta = np.zeros_like(z)
     rho = np.array(edp, dtype='float')
     refq, r2 = parratt(self.x + qoff, lam, d, rho, beta)
     if self.rrf > 0:
         ref, r2 = parratt(self.x + qoff, lam, [0.0, 1.0], rhos, [0.0, 0.0])
         refq = refq / ref
     return refq
Example #2
0
 def y(self):
     """
     Define the function in terms of x to return some value
     """
     self.output_params = {}
     self.calcProfile()
     x = self.x + self.qoff
     lam = 6.62607004e-34 * 2.99792458e8 * 1e10 / self.E / 1e3 / 1.60217662e-19
     refq, r2 = parratt(x, lam, self.__d__, self.__rho__,
                        np.zeros_like(self.__rho__))
     if self.rrf > 0:
         rhos = [self.__rho__[0], self.__rho__[-1]]
         betas = [0, 0]
         ref, r2 = parratt(x, lam, [0.0, 1.0], rhos, betas)
         refq = refq / ref
     return refq
Example #3
0
def refCalFun(d,rho,mu,sigma,syspara,x,rrf=True):

    if sigma[0] <= 0: sigma[0] = 1e-5 # eliminate zero
    sigma = sigma[0] * np.ones(len(sigma)) # fixed sigma

    qoff = syspara[0]
    yscale = syspara[1]
    qres = syspara[2]
    erad = e_radius
    slab=0.25
    k0=2*np.pi*float(energy)/12.3984 # wave vector
    theta=x/2/k0   # convert q to theta
   
    # total length of inner slabs plus 4 times roughness for both sides
    length = np.sum(d) + 4* (sigma[0]+sigma[-1])
    steps=int(length/slab) # each sliced box has thickness of ~ 0.25 A
    xsld=np.linspace(-4*sigma[0],np.sum(d)+4*sigma[-1],steps) # get the z-axis for sld
  
   
    sd=length/steps # thickness for each slab
    intrho=sldCalFun(d,rho,sigma,xsld) # rho for all the steps
    intmu=sldCalFun(d,mu,sigma,xsld) # mu for all the steps
    

    sdel=[]
    sbet=[]
    sdel.append(erad*2.0*np.pi/k0/k0*rho[0]) # delta for the top phase
    sbet.append(mu[0]/2/k0/1e8)        # beta for the top phase
    # add delta for the interface
    sdel=sdel+[intrho[i]*erad*2.0*np.pi/k0/k0 for i in range(len(intrho))] 
    sbet=sbet+[intmu[i]/2/k0/1e8 for i in range(len(intmu))] # add beta for the interface
    sdel.append(erad*2.0*np.pi/k0/k0*rho[-1])  # delta for the bottom phase
    sbet.append(mu[-1]/2/k0/1e8)    # beta for the bottom phase         
    
    d=slab*np.ones_like(sdel)
    lamda=2*np.pi/k0
    fdel=erad*2.0*np.pi/k0/k0
    sdelf=np.array(sdel)/fdel

    ref,refr=xr.parratt(x+qoff,lamda,d,sdelf,sbet)
    frsnll,frsnl1=xr.parratt(x,lamda,[0,1],[sdelf[0],sdelf[-1]],[sbet[0],sbet[-1]]) 
    if rrf == True:
        return yscale*ref/frsnll
    else:
        return yscale*ref
Example #4
0
 def y(self):
     """
     Define the function in terms of x to return some value
     """
     self.output_params = {'scaler_parameters': {}}
     rhos=(self.rho_up,self.rho_down)
     lam=self.lam
     z=np.arange(self.zmin,self.zmax,self.dz)
     d=np.ones_like(z)*self.dz
     edp=self.decayNp(tuple(z),Rc=self.Rc,z0=self.Zo,xi=self.decay,cov=self.cov,rhos=rhos,rhoc=self.rhoc,sig=self.roughness,D=self.D)
     if not self.__fit__:
         self.output_params['EDP']={'x':z,'y':edp}
     beta=np.zeros_like(z)
     rho=np.array(edp,dtype='float')
     refq,r2=parratt(self.x+self.qoff,lam,d,rho,beta)
     if self.rrf:
         ref,r2=parratt(self.x,lam,[0.0,1.0],rhos,[0.0,0.0])
         refq=refq/ref
     return refq
Example #5
0
 def y(self):
     """
     Define the function in terms of x to return some value
     """
     n = self.calcProfile()
     x = self.x + self.qoff
     lam = 6.62607004e-34 * 2.99792458e8 * 1e10 / self.E / 1e3 / 1.60217662e-19
     refq, r2 = parratt(x, lam, self.__d__, self.__rho__, self.__beta__)
     if self.rrf > 0:
         rhos = [
             self.params['__rho__000'].value,
             self.params['__rho__%03d' % (n - 1)].value
         ]
         betas = [
             self.params['__beta__000'].value,
             self.params['__beta__%03d' % (n - 1)].value
         ]
         ref, r2 = parratt(x, lam, [0.0, 1.0], rhos, betas)
         refq = refq / ref
     return refq
Example #6
0
 def py_parratt(self, x, lam, d, rho, beta):
     return parratt(np.array(x), lam, np.array(d), np.array(rho),
                    np.array(beta))
Example #7
0
 def py_parratt(self, x, lam, d, rho, beta):
     return parratt(x, lam, d, rho, beta)
Example #8
0
    sbet=[]
    sdel.append(erad*2.0*np.pi/k0/k0*rho[0]) # delta for the top phase
    sbet.append(mu[0]/2/k0/1e8)        # beta for the top phase
    # add delta for the interface
    sdel=sdel+[intrho[i]*erad*2.0*np.pi/k0/k0 for i in range(len(intrho))] 
    sbet=sbet+[intmu[i]/2/k0/1e8 for i in range(len(intmu))] # add beta for the interface
    sdel.append(erad*2.0*np.pi/k0/k0*rho[-1])  # delta for the bottom phase
    sbet.append(mu[-1]/2/k0/1e8)    # beta for the bottom phase         
    
    d=slab*np.ones_like(sdel)
    lamda=2*np.pi/k0
    fdel=erad*2.0*np.pi/k0/k0
    sdelf=np.array(sdel)/fdel

<<<<<<< HEAD
    ref,refr=xr.parratt(x+qoff,lamda,d,sdelf,sbet)
    frsnll,frsnl1=xr.parratt(x,lamda,[0,1],[sdelf[0],sdelf[-1]],[sbet[0],sbet[-1]]) 
    if rrf == True:
        return yscale*ref/frsnll
    else:
        return yscale*ref
=======
    ref,refr=xr.parratt(x,lamda,d,sdelf,sbet)
    frsnll,frsnl1=xr.parratt(x,lamda,[0,1],[sdelf[0],sdelf[-1]],[sbet[0],sbet[-1]]) 
    if rrf == True:
        return ref/frsnll
    else:
        return ref
>>>>>>> master

def ref2min(params,x,y,yerr,fit=True):