Exemple #1
0
def distance(phi, dx=1.0, self_test=False, order=2):
    """
    Return the distance from the zero contour of the array phi.

    Parameters
    ----------
    phi : array-like
          the zero contour of this array is the boundary location for
          the distance calculation. Phi can of 1,2,3 or higher
          dimension and can be a masked array.

    dx  : float or an array-like of shape len(phi), optional
          the cell length in each dimension.

    self_test : bool, optional
                if True consistency checks are made on the binary min
                heap during the calculation. This is used in testing and
                results in a slower calculation.

    order : int, optional
            order of computational stencil to use in updating points during
            the fast marching method. Must be 1 or 2, the default is 2.

    Returns
    -------
    d : an array the same shape as phi
        contains the distance from the zero contour (zero level set)
        of phi to each point in the array.
    """
    phi, dx, flag, ext_mask = pre_process_args(phi, dx)
    d = cFastMarcher(phi, dx, flag, None, ext_mask,
                     int(self_test), DISTANCE, order)
    d = post_process_result(d)
    return d
Exemple #2
0
def distance(phi, dx=1.0, self_test=False, order=2):
    """
    Return the distance from the zero contour of the array phi.

    Parameters
    ----------
    phi : array-like
          the zero contour of this array is the boundary location for
          the distance calculation. Phi can of 1,2,3 or higher
          dimension and can be a masked array.

    dx  : float or an array-like of shape len(phi), optional
          the cell length in each dimension.

    self_test : bool, optional
                if True consistency checks are made on the binary min
                heap during the calculation. This is used in testing and
                results in a slower calculation.

    order : int, optional
            order of computational stencil to use in updating points during
            the fast marching method. Must be 1 or 2, the default is 2.

    Returns
    -------
    d : an array the same shape as phi
        contains the distance from the zero contour (zero level set)
        of phi to each point in the array.
    """
    phi, dx, flag, ext_mask = pre_process_args(phi, dx)
    d = cFastMarcher(phi, dx, flag, None, ext_mask, int(self_test), DISTANCE,
                     order)
    d = post_process_result(d)
    return d
Exemple #3
0
def extension_velocities(phi,
                         speed,
                         dx=1.0,
                         self_test=False,
                         order=2,
                         ext_mask=None):
    """
    Extend the velocities defined at the zero contour of phi to the
    rest of the domain. Extend the velocities such that
    grad f_ext dot grad d = 0 where where f_ext is the
    extension velocity and d is the signed distance function.

    Parameters
    ----------
    phi : array-like
          the zero contour of this array is the boundary location for
          the travel time calculation. Phi can of 1,2,3 or higher
          dimension and can be a masked array.

    speed : array-like, the same shape as phi
            contains the speed of interface propagation at each point
            in the domain.

    dx  : float or an array-like of shape len(phi), optional
          the cell length in each dimension.

    self_test : bool, optional
                if True consistency checks are made on the binary min
                heap during the calculation. This is used in testing and
                results in a slower calculation.

    order : int, optional
            order of computational stencil to use in updating points during
            the fast marching method. Must be 1 or 2, the default is 2.

    ext_mask : array-like, the same shape as phi, optional
               enables initial front values to be eliminated when
               calculating the value at the interface before the
               values are extended away from the interface.

    Returns
    -------
    (d, f_ext) : tuple
        a tuple containing the signed distance function d and the
        extension velocities f_ext.
    """
    phi, dx, flag, ext_mask = pre_process_args(phi, dx, ext_mask)

    distance, f_ext = cFastMarcher(phi, dx, flag, speed, ext_mask,
                                   int(self_test), EXTENSION_VELOCITY, order)
    distance = post_process_result(distance)
    f_ext = post_process_result(f_ext)

    return distance, f_ext
Exemple #4
0
def extension_velocities(phi, speed, dx=1.0, self_test=False, order=2, ext_mask=None):
    """
    Extend the velocities defined at the zero contour of phi to the
    rest of the domain. Extend the velocities such that
    grad f_ext dot grad d = 0 where where f_ext is the
    extension velocity and d is the signed distance function.

    Parameters
    ----------
    phi : array-like
          the zero contour of this array is the boundary location for
          the travel time calculation. Phi can of 1,2,3 or higher
          dimension and can be a masked array.

    speed : array-like, the same shape as phi
            contains the speed of interface propagation at each point
            in the domain.

    dx  : float or an array-like of shape len(phi), optional
          the cell length in each dimension.

    self_test : bool, optional
                if True consistency checks are made on the binary min
                heap during the calculation. This is used in testing and
                results in a slower calculation.

    order : int, optional
            order of computational stencil to use in updating points during
            the fast marching method. Must be 1 or 2, the default is 2.

    ext_mask : array-like, the same shape as phi, optional
               enables initial front values to be eliminated when
               calculating the value at the interface before the
               values are extended away from the interface.

    Returns
    -------
    (d, f_ext) : tuple
        a tuple containing the signed distance function d and the
        extension velocities f_ext.
    """
    phi, dx, flag, ext_mask = pre_process_args(phi, dx, ext_mask)

    distance, f_ext = cFastMarcher(phi, dx, flag, speed, ext_mask,
                                   int(self_test), EXTENSION_VELOCITY, order)
    distance = post_process_result(distance)
    f_ext    = post_process_result(f_ext)

    return distance, f_ext
Exemple #5
0
def distance(phi, dx=1.0, self_test=False):
    """
    Return the distance from the zero contour of the array phi.

    :param phi: an N dimensional array containing the boundary condition for    the distance calculation. Phi can be a masked array.

    :param dx: a double or an array of shape len(phi) which describes the cell length.

    :param self_test: if True consistency checks are made on the binary min heap during the calculation. This is used in testing and results in a slower calculation.

    :rtype: an array the same shape as phi which contains the distance from the zero contour (zero level set) of phi to each point in the array.
    """
    phi, dx, flag = pre_process_args(phi, dx)
    d = cFastMarcher(phi, dx, flag, None, int(self_test))
    d = post_process_result(d)
    return d
Exemple #6
0
def travel_time(phi, speed, dx=1.0, self_test=False):
    """
    Return the travel from the zero contour of the array phi given the
    scalar velocity field speed.

    :parameter phi: an N-dimensional array containing the boundary condition for the travel time calculation. phi can be a masked array.

    :parameter speed: an N-dimensional array, the same shape as phi, which contains the speed of interface propagation at each point in the domain.

    :parameter dx: a double or an array of shape len(phi) which describes the cell length.

    :param self_test: if True consistency checks are made on the binary min heap during the calculation. This is used in testing and results in a slower calculation.

    :rtype: an array the same shape as phi which contains the travel time from the zero contour (zero level set) of phi to each point in the array given the scalar velocity field speed. If the input array speed has values less than or equal to zero the return value will be a masked array.
    """
    phi, dx, flag = pre_process_args(phi, dx)
    t = cFastMarcher(phi, dx, flag, speed, int(self_test))
    t = post_process_result(t)
    return t
Exemple #7
0
def travel_time(phi, speed, dx=1.0, self_test=False, order=2):
    """
    Return the travel from the zero contour of the array phi given the
    scalar velocity field speed.

    Parameters
    ----------
    phi : array-like
          the zero contour of this array is the boundary location for
          the travel time calculation. Phi can of 1,2,3 or higher
          dimension and can be a masked array.

    speed : array-like, the same shape as phi
            contains the speed of interface propagation at each point
            in the domain.

    dx  : float or an array-like of shape len(phi), optional
          the cell length in each dimension.

    self_test : bool, optional
                if True consistency checks are made on the binary min
                heap during the calculation. This is used in testing and
                results in a slower calculation.

    order : int, optional
            order of computational stencil to use in updating points during
            the fast marching method. Must be 1 or 2, the default is 2.

    Returns
    -------
    t : an array the same shape as phi
        contains the travel time from the zero contour (zero level
        set) of phi to each point in the array given the scalar
        velocity field speed. If the input array speed has values less
        than or equal to zero the return value will be a masked array.
    """
    phi, dx, flag, ext_mask = pre_process_args(phi, dx)
    t = cFastMarcher(phi, dx, flag, speed, ext_mask, int(self_test),
                     TRAVEL_TIME, order)
    t = post_process_result(t)
    return t
Exemple #8
0
def travel_time(phi, speed, dx=1.0, self_test=False, order=2):
    """
    Return the travel from the zero contour of the array phi given the
    scalar velocity field speed.

    Parameters
    ----------
    phi : array-like
          the zero contour of this array is the boundary location for
          the travel time calculation. Phi can of 1,2,3 or higher
          dimension and can be a masked array.

    speed : array-like, the same shape as phi
            contains the speed of interface propagation at each point
            in the domain.

    dx  : float or an array-like of shape len(phi), optional
          the cell length in each dimension.

    self_test : bool, optional
                if True consistency checks are made on the binary min
                heap during the calculation. This is used in testing and
                results in a slower calculation.

    order : int, optional
            order of computational stencil to use in updating points during
            the fast marching method. Must be 1 or 2, the default is 2.

    Returns
    -------
    t : an array the same shape as phi
        contains the travel time from the zero contour (zero level
        set) of phi to each point in the array given the scalar
        velocity field speed. If the input array speed has values less
        than or equal to zero the return value will be a masked array.
    """
    phi, dx, flag, ext_mask = pre_process_args(phi, dx)
    t = cFastMarcher(phi, dx, flag, speed, ext_mask,
                     int(self_test), TRAVEL_TIME, order)
    t = post_process_result(t)
    return t