コード例 #1
0
 def _reflamp(self):
     #calc_q = self.probe.calc_Q
     #return calc_q,calc_q
     key = 'calc_r'
     if key not in self._cache:
         slabs = self._render_slabs()
         w = slabs.w
         rho,irho = slabs.rho, slabs.irho
         sigma = slabs.sigma
         #sigma = slabs.sigma
         calc_q = self.probe.calc_Q
         #print("calc Q", self.probe.calc_Q)
         if slabs.ismagnetic:
             rhoM, thetaM = slabs.rhoM, slabs.thetaM
             Aguide = self.probe.Aguide
             calc_r = reflmag(-calc_q/2, depth=w, rho=rho[0], irho=irho[0],
                              rhoM=rhoM, thetaM=thetaM, Aguide=Aguide)
         else:
             calc_r = reflamp(-calc_q/2, depth=w, rho=rho, irho=irho,
                              sigma=sigma)
         if False and numpy.isnan(calc_r).any():
             print("w %s",w)
             print("rho",rho)
             print("irho",irho)
             print("sigma",sigma)
             print("kz",self.probe.calc_Q/2)
             print("R",abs(calc_r**2))
             pars = parameter.unique(self.parameters())
             fitted = parameter.varying(pars)
             print(parameter.summarize(fitted))
             print("===")
         self._cache[key] = calc_q,calc_r
         #if numpy.isnan(calc_q).any(): print("calc_Q contains NaN")
         #if numpy.isnan(calc_r).any(): print("calc_r contains NaN")
     return self._cache[key]
コード例 #2
0
 def _reflamp(self):
     #calc_q = self.probe.calc_Q
     #return calc_q, calc_q
     key = 'calc_r'
     if key not in self._cache:
         slabs = self._render_slabs()
         w = slabs.w
         rho, irho = slabs.rho, slabs.irho
         sigma = slabs.sigma
         #sigma = slabs.sigma
         calc_q = self.probe.calc_Q
         #print("calc Q", self.probe.calc_Q)
         if slabs.ismagnetic:
             rhoM, thetaM = slabs.rhoM, slabs.thetaM
             Aguide = self.probe.Aguide.value
             H = self.probe.H.value
             calc_r = reflmag(-calc_q / 2,
                              depth=w,
                              rho=rho[0],
                              irho=irho[0],
                              rhoM=rhoM,
                              thetaM=thetaM,
                              Aguide=Aguide,
                              H=H,
                              sigma=sigma)
         else:
             calc_r = reflamp(-calc_q / 2,
                              depth=w,
                              rho=rho,
                              irho=irho,
                              sigma=sigma)
         if False and np.isnan(calc_r).any():
             print("w", w)
             print("rho", rho)
             print("irho", irho)
             if slabs.ismagnetic:
                 print("rhoM", rhoM)
                 print("thetaM", thetaM)
                 print("Aguide", Aguide, "H", H)
             print("sigma", sigma)
             print("kz", self.probe.calc_Q / 2)
             print("R", abs(np.asarray(calc_r)**2))
             pars = parameter.unique(self.parameters())
             fitted = parameter.varying(pars)
             print(parameter.summarize(fitted))
             print("===")
         self._cache[key] = calc_q, calc_r
         #if np.isnan(calc_q).any(): print("calc_Q contains NaN")
         #if np.isnan(calc_r).any(): print("calc_r contains NaN")
     return self._cache[key]
コード例 #3
0
ファイル: stajconvert.py プロジェクト: agreen991/refl1d
def fit_all(M, pmp=20):
    """
    Set all non-zero parameters to fitted parameters inside the model.
    """

    # Exclude unlikely fitting parameters
    exclude = set((M.sample[0].thickness,
               M.sample[-1].thickness,
               M.sample[-1].interface,
               M.probe.back_absorption,
               ))
    if M.probe.intensity.value == 1:
        exclude.add(M.probe.intensity)
    if M.probe.background.value < 2e-10:
        exclude.add(M.probe.background.value)

    # Fit everything else using a range of +/- pmp %
    for p in parameter.unique(M.parameters()):
        if p in exclude: continue
        if p.value != 0: p.pmp(pmp)
コード例 #4
0
ファイル: stajconvert.py プロジェクト: igresh/refl1d
def fit_all(M, pmp=20):
    """
    Set all non-zero parameters to fitted parameters inside the model.
    """

    # Exclude unlikely fitting parameters
    exclude = set((
        M.sample[0].thickness,
        M.sample[-1].thickness,
        M.sample[-1].interface,
        M.probe.back_absorption,
    ))
    if M.probe.intensity.value == 1:
        exclude.add(M.probe.intensity)
    if M.probe.background.value < 2e-10:
        exclude.add(M.probe.background.value)

    # Fit everything else using a range of +/- pmp %
    for p in parameter.unique(M.parameters()):
        if p in exclude: continue
        if p.value != 0: p.pmp(pmp)