def compute_junction_angles(self, weight=None): """ Computes the angle at nodes where only three links are connected. Directions must be assigned before angles can be computed. Also defines each 3-link node as 'confluence' or 'bifurcation' and appends this designation to the nodes dictionary. Parameters ---------- weight : str [None], 'exp' (exponential), or 'lin' (linear) to determine the decay of the weights the contributions of pixels as we move away from the junction node. """ if 'certain' not in self.links.keys(): print( 'Junction angles cannot be computed before link directions are set.' ) else: self.nodes = lnu.junction_angles(self.links, self.nodes, self.imshape, self.pixlen, weight=weight)
def test_junction_angles_linear(known_net): """Testing junction_angles with linear weighting.""" nodes = known_net.nodes links = known_net.links imshape = known_net.imshape pixlen = known_net.pixlen # pop junction keys out of nodes before recreating them _ = nodes.pop('jtype') _ = nodes.pop('int_ang') _ = nodes.pop('width_ratio') nodes = ln_utils.junction_angles(links, nodes, imshape, pixlen, weight='linear') assert ('jtype' in nodes.keys()) is True assert ('int_ang' in nodes.keys()) is True assert ('width_ratio' in nodes.keys()) is True
def test_junction_angles(test_river): """Raise KeyError due to lack of flow directions.""" test_river.compute_network() with pytest.raises(KeyError): ln_utils.junction_angles(test_river.links, test_river.nodes, test_river.Iskel.shape, 5)