Exemple #1
0
def cartesian(x, y=None, z=None):

    max_dim = 1
    for val in (x, y, z):
        if is_array(type(val)):
            if val.size > max_dim:
                max_dim = val.size

    if max_dim != 1:
        if is_scalar(type(x)) or (is_array(type(x)) and x.shape == (1, )):
            x = ones(max_dim) * x
        if is_scalar(type(y)) or (is_array(type(y)) and y.shape == (1, )):
            y = ones(max_dim) * y
        if is_scalar(type(z)) or (is_array(type(z)) and z.shape == (1, )):
            z = ones(max_dim) * z

    if type(x) == type(None):
        x = zeros(max_dim)
    if type(y) == type(None):
        y = zeros(max_dim)
    if type(z) == type(None):
        z = zeros(max_dim)

    if x.ndim == y.ndim == z.ndim == 1:
        if x.shape == y.shape == z.shape:
            return vstack((x, y, z)).T

    print 'EE: CoordinateSystem.cartesian() - This should not happen!'
Exemple #2
0
def cartesian(x, y=None, z=None):
   
   max_dim = 1
   for val in (x, y, z):
      if is_array(type(val)):
         if val.size > max_dim:
            max_dim = val.size
   
   if max_dim != 1:
      if is_scalar(type(x)) or (is_array(type(x)) and x.shape == (1,)):
         x = ones(max_dim)*x
      if is_scalar(type(y)) or (is_array(type(y)) and y.shape == (1,)):
         y = ones(max_dim)*y
      if is_scalar(type(z)) or (is_array(type(z)) and z.shape == (1,)):
         z = ones(max_dim)*z
         
   if type(x) == type(None):
      x = zeros(max_dim)
   if type(y) == type(None):
      y = zeros(max_dim)
   if type(z) == type(None):
      z = zeros(max_dim)
      
   if x.ndim == y.ndim == z.ndim == 1:
      if x.shape == y.shape == z.shape:
         return vstack((x,y,z)).T

   print 'EE: CoordinateSystem.cartesian() - This should not happen!'
Exemple #3
0
def spherical(r, theta=None, phi=None):
   
#   def repetiveStuff():
#      self.type   = 'spherical'
#      self.shape  = self.p.shape
   
   max_dim = 1
   for val in (r, theta, phi):
      if is_array(type(val)):
         if val.size > max_dim:
            max_dim = val.size
   
   if max_dim != 1:
      if is_scalar(type(r)) or (is_array(type(r)) and r.shape == (1,)):
         r = ones(max_dim)*r
      if is_scalar(type(theta)) or (is_array(type(theta)) and theta.shape == (1,)):
         theta = ones(max_dim)*theta
      if is_scalar(type(phi)) or (is_array(type(phi)) and phi.shape == (1,)):
         phi = ones(max_dim)*phi
         
   if type(r) == type(None):
      r = zeros(max_dim)
   if type(theta) == type(None):
      theta = zeros(max_dim)
   if type(phi) == type(None):
      phi = zeros(max_dim)
      
   if r.ndim == theta.ndim == phi.ndim == 1:
      if r.shape == theta.shape == phi.shape:
         p = vstack((r,theta,phi)).T

#            repetiveStuff()
         return p
   
   print 'EE: CoordinateSystem.spherical() - This should not happen!'
Exemple #4
0
def spherical(r, theta=None, phi=None):

    #   def repetiveStuff():
    #      self.type   = 'spherical'
    #      self.shape  = self.p.shape

    max_dim = 1
    for val in (r, theta, phi):
        if is_array(type(val)):
            if val.size > max_dim:
                max_dim = val.size

    if max_dim != 1:
        if is_scalar(type(r)) or (is_array(type(r)) and r.shape == (1, )):
            r = ones(max_dim) * r
        if is_scalar(type(theta)) or (is_array(type(theta))
                                      and theta.shape == (1, )):
            theta = ones(max_dim) * theta
        if is_scalar(type(phi)) or (is_array(type(phi))
                                    and phi.shape == (1, )):
            phi = ones(max_dim) * phi

    if type(r) == type(None):
        r = zeros(max_dim)
    if type(theta) == type(None):
        theta = zeros(max_dim)
    if type(phi) == type(None):
        phi = zeros(max_dim)

    if r.ndim == theta.ndim == phi.ndim == 1:
        if r.shape == theta.shape == phi.shape:
            p = vstack((r, theta, phi)).T

            #            repetiveStuff()
            return p

    print 'EE: CoordinateSystem.spherical() - This should not happen!'