Example #1
0
 def render(self, probe, slabs):
     Pw,Pz = slabs.microslabs(self.thickness.value)
     if len(Pw)== 0: return
     kw = dict((k,getattr(self,k).value) for k in self._parameters)
     #print kw
     phi = asarray(self.profile(Pz,**kw))
     if phi.shape != Pz.shape:
         raise TypeError("profile function '%s' did not return array phi(z)"
                         %self.profile.__name__)
     Pw,phi = util.merge_ends(Pw, phi, tol=self.tol)
     #P = M*phi + S*(1-phi)
     slabs.extend(rho = [real(phi)], irho = [imag(phi)], w = Pw)
Example #2
0
 def render(self, probe, slabs):
     Pw,Pz = slabs.microslabs(self.thickness.value)
     if len(Pw)== 0: return
     #print kw
     # TODO: always return rho, irho from profile function
     # return value may be a constant for rho or irho
     phi = asarray(self.profile(Pz,**self._fpars()))
     if phi.shape != Pz.shape:
         raise TypeError("profile function '%s' did not return array phi(z)"
                         %self.profile.__name__)
     Pw,phi = util.merge_ends(Pw, phi, tol=self.tol)
     #P = M*phi + S*(1-phi)
     slabs.extend(rho = [real(phi)], irho = [imag(phi)], w = Pw)
Example #3
0
 def render(self, probe, slabs):
     Pw, Pz = slabs.microslabs(self.thickness.value)
     if len(Pw) == 0:
         return
     #print kw
     # TODO: always return rho, irho from profile function
     # return value may be a constant for rho or irho
     phi = asarray(self.profile(Pz, **self._fpars()))
     if phi.shape != Pz.shape:
         raise TypeError(
             "profile function '%s' did not return array phi(z)" %
             self.profile.__name__)
     Pw, phi = util.merge_ends(Pw, phi, tol=self.tol)
     #P = M*phi + S*(1-phi)
     slabs.extend(rho=[real(phi)], irho=[imag(phi)], w=Pw)
Example #4
0
 def render(self, probe, slabs, thickness, anchor, sigma):
     Pw,Pz = slabs.microslabs(thickness)
     if len(Pw)== 0: return
     kw = dict((k,getattr(self,k).value) for k in self._parameters)
     #print kw
     P = self.profile(Pz,**kw)
     try: rhoM, thetaM = P
     except: rhoM, thetaM = P, Pz*0
     rhoM, thetaM = [asarray(v) for v in rhoM,thetaM]
     if rhoM.shape != Pz.shape or thetaM.shape != Pz.shape:
         raise TypeError("profile function '%s' did not return array rhoM(z)"
                         %self.profile.__name__)
     P = rhoM + thetaM*0.001j  # combine rhoM/thetaM so they can be merged
     Pw,P = util.merge_ends(Pw, P, tol=self.tol)
     rhoM,thetaM = P.real,P.imag*1000  # split out rhoM,thetaM again
     slabs.add_magnetism(anchor=anchor,
                         w=Pw,rhoM=rhoM,thetaM=thetaM,
                         sigma=sigma)
Example #5
0
    def render(self, probe, slabs, thickness, anchor, sigma):
        Pw, Pz = slabs.microslabs(thickness)
        if len(Pw) == 0:
            return
        kw = dict((k, getattr(self, k).value) for k in self._parameters)
        P = self.profile(Pz, **kw)

        rhoM, thetaM = P if isinstance(P, tuple) else (P, DEFAULT_THETA_M)
        try:
            # rhoM or thetaM may be constant, lists or arrays (but not tuples!)
            rhoM, thetaM = [broadcast_to(v, Pz.shape) for v in (rhoM, thetaM)]
        except ValueError:
            raise TypeError(
                "profile function '%s' did not return array rhoM(z)" %
                self.profile.__name__)
        P = rhoM + thetaM * 0.001j  # combine rhoM/thetaM so they can be merged
        Pw, P = util.merge_ends(Pw, P, tol=self.tol)
        rhoM, thetaM = P.real, P.imag * 1000  # split out rhoM,thetaM again
        slabs.add_magnetism(anchor=anchor,
                            w=Pw,
                            rhoM=rhoM,
                            thetaM=thetaM,
                            sigma=sigma)
Example #6
0
 def render(self, probe, slabs, thickness, anchor, sigma):
     Pw, Pz = slabs.microslabs(thickness)
     if len(Pw) == 0: return
     kw = dict((k, getattr(self, k).value) for k in self._parameters)
     P = self.profile(Pz, **kw)
     # TODO: always return rhoM, thetaM from profile function
     # rhoM or thetaM may be constant
     try:
         rhoM, thetaM = P
     except Exception:
         rhoM, thetaM = P, Pz * 0
     rhoM, thetaM = [asarray(v) for v in (rhoM, thetaM)]
     if rhoM.shape != Pz.shape or thetaM.shape != Pz.shape:
         raise TypeError(
             "profile function '%s' did not return array rhoM(z)" %
             self.profile.__name__)
     P = rhoM + thetaM * 0.001j  # combine rhoM/thetaM so they can be merged
     Pw, P = util.merge_ends(Pw, P, tol=self.tol)
     rhoM, thetaM = P.real, P.imag * 1000  # split out rhoM,thetaM again
     slabs.add_magnetism(anchor=anchor,
                         w=Pw,
                         rhoM=rhoM,
                         thetaM=thetaM,
                         sigma=sigma)