Пример #1
0
def calculate_and_plot_end_to_end_distance(path):
    '''Calculate and plot the end-to-end distance vs the number of segments for
    an increasingly larger part of a given path.

    Note that the plots are not very meaningful for bifurcating trees.'''
    end_to_end_distance = [morphmath.point_dist(segment[1], path.value)
                           for segment in tree.val_iter(tree.isegment(path))]
    make_end_to_end_distance_plot(np.arange(len(end_to_end_distance)) + 1, end_to_end_distance,
                                  path.type)
Пример #2
0
def i_section_radial_dist(tree, pos=None, use_start_point=False):
    '''Return an iterator of radial distances of tree sections to a given point

    The radial distance is the euclidian distance between the either the
    end-point or rhe start point of the section and the point in question.

    Parameters:
        tree: tree object
        pos: origin to which distances are measured. It must have at least 3\
            components. The first 3 components are (x, y, z).\
            (default tree origin)

        use_start_point: If true, calculate distance from section start point,\
            else from end-point (default, False)

    '''
    pos = tree.value if pos is None else pos
    sec_idx = 0 if use_start_point else -1
    return tr.imap_val(lambda s: mm.point_dist(s[sec_idx], pos), tr.isection(tree))
Пример #3
0
def i_section_radial_dist(tree, pos=None, use_start_point=False):
    '''Return an iterator of radial distances of tree sections to a given point

    The radial distance is the euclidian distance between the either the
    end-point or rhe start point of the section and the point in question.

    Parameters:
        tree: tree object
        pos: origin to which distances are measured. It must have at least 3\
            components. The first 3 components are (x, y, z).\
            (default tree origin)

        use_start_point: If true, calculate distance from section start point,\
            else from end-point (default, False)

    '''
    pos = tree.value if pos is None else pos
    sec_idx = 0 if use_start_point else -1
    return tr.imap_val(lambda s: mm.point_dist(s[sec_idx], pos),
                       tr.isection(tree))
Пример #4
0
 def _dist(section):
     '''Hacky closure'''
     return mm.point_dist(pos, section[sec_idx])
Пример #5
0
def test_point_dist():
    p1 = Point(3.0, 4.0, 5.0, 3.0, 1)
    p2 = Point(4.0, 5.0, 6.0, 3.0, 1)
    dist = point_dist(p1,p2)
    nt.ok_(dist==sqrt(3))
Пример #6
0
def test_segment_radial_dist():
    seg = ((11,11,11), (33, 33, 33))
    nt.assert_almost_equal(segment_radial_dist(seg, (0,0,0)),
                           point_dist((0,0,0), (22,22,22)))
Пример #7
0
def path_end_to_end_distance(path):
    '''Calculate and return end-to-end-distance of a given path.'''
    trunk = path.value
    return max(morphmath.point_dist(l, trunk) for l in tree.val_iter(tree.ileaf(path)))