Skip to content

Commit

Permalink
Debug Issue #8
Browse files Browse the repository at this point in the history
  • Loading branch information
Malcolm White committed Aug 14, 2020
1 parent 1abf2e7 commit 2ed410d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pykonal/__version__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__major_version__ = 0
__minor_version__ = 3
__patch__ = 2
__release__ = "b1"
__release__ = "b2"
__version_tuple__ = (
__major_version__,
__minor_version__,
Expand Down
9 changes: 8 additions & 1 deletion pykonal/fields.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,14 @@ cdef class Field3D(object):
:rtype: numpy.ndarray(shape=(N0,N1,N2,3), dtype=numpy.float)
"""
if self.coord_sys == "spherical" and coord_sys.lower() == "spherical":
return (transformations.sph2sph(self.nodes, origin))
force_phi_positive = self.min_coords[2] >= 0
return (
transformations.sph2sph(
self.nodes,
origin,
force_phi_positive=force_phi_positive
)
)
elif self.coord_sys == "cartesian" and coord_sys.lower() == "spherical":
return (transformations.xyz2sph(self.nodes, origin))
elif self.coord_sys == "spherical" and coord_sys.lower() == "cartesian":
Expand Down
5 changes: 4 additions & 1 deletion pykonal/solver.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,10 @@ class PointSourceSolver(EikonalSolver):
origin = (r0, t0, p0)
# Transform the coordinates of the near-field grid nodes to the
# far-field coordinate system.
nodes = self.near_field.vv.transform_coordinates(self.coord_sys, origin)
nodes = self.near_field.vv.transform_coordinates(
self.coord_sys,
origin
)
# Find the indices of the near-field grid nodes that are inside
# the far-field grid.
bool_idx = True
Expand Down
8 changes: 6 additions & 2 deletions pykonal/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def geo2sph(nodes):
return (sph)


def sph2sph(nodes, origin=(0,0,0)):
def sph2sph(nodes, origin=(0,0,0), force_phi_positive=False):
"""
Transform spherical coordinates to new spherical coordinate system.
Expand Down Expand Up @@ -55,11 +55,13 @@ def sph2sph(nodes, origin=(0,0,0)):
tt = np.arccos(xyz[...,2] / rr)
np.seterr(**old)
pp = np.arctan2(xyz[...,1], xyz[...,0])
if force_phi_positive:
pp = np.mod(pp, 2*np.pi)
rtp = np.moveaxis(np.stack([rr, tt, pp]), 0, -1)
return (rtp)


def xyz2sph(nodes, origin=(0,0,0)):
def xyz2sph(nodes, origin=(0,0,0), force_phi_positive=False):
"""
Transform Cartesian coordinates to new spherical coordinate system.
Expand All @@ -78,6 +80,8 @@ def xyz2sph(nodes, origin=(0,0,0)):
tt = np.arccos(xyz[...,2] / rr)
np.seterr(**old)
pp = np.arctan2(xyz[...,1], xyz[...,0])
if force_phi_positive:
pp = np.mod(pp, 2*np.pi)
rtp = np.moveaxis(np.stack([rr, tt, pp]), 0, -1)
return (rtp)

Expand Down

0 comments on commit 2ed410d

Please sign in to comment.