Example #1
0
 def evaluate(self, x, y, z):
     v1 = self.sfield1.evaluate(x, y, z)
     v2 = self.sfield2.evaluate(x, y, z)
     v3 = self.sfield3.evaluate(x, y, z)
     if self.coords == 'XYZ':
         return np.array((v1, v2, v3))
     elif self.coords == 'CYL':
         return np.array(from_cylindrical(v1, v2, v3, mode='radians'))
     else: # SPH:
         return np.array(from_spherical(v1, v2, v3, mode='radians'))
Example #2
0
 def evaluate_grid(self, xs, ys, zs):
     v1s = self.sfield1.evaluate_grid(xs, ys, zs)
     v2s = self.sfield2.evaluate_grid(xs, ys, zs)
     v3s = self.sfield3.evaluate_grid(xs, ys, zs)
     if self.coords == 'XYZ':
         return v1s, v2s, v3s
     elif self.coords == 'CYL':
         vectors = np.stack((v1s, v2s, v3s)).T
         vectors = np.apply_along_axis(lambda v: np.array(from_cylindrical(*tuple(v), mode='radians')), 1, vectors).T
         return vectors[0], vectors[1], vectors[2]
     else: # SPH:
         vectors = np.stack((v1s, v2s, v3s)).T
         vectors = np.apply_along_axis(lambda v: np.array(from_spherical(*tuple(v), mode='radians')), 1, vectors).T
         return vectors[0], vectors[1], vectors[2]
Example #3
0
 def out_coordinates(rho, phi, z):
     return from_cylindrical(rho, phi, z, mode='radians')
Example #4
0
def icosahedron(r):
    vertices, edges, faces = icosahedron_cylindrical(r)
    vertices = [
        from_cylindrical(rho, phi, z, 'radians') for rho, phi, z in vertices
    ]
    return vertices, edges, faces
Example #5
0
def cylindrical(rho, phi, z, mode):
    return from_cylindrical(rho, phi, z, mode)