Exemplo n.º 1
0
def test_error_for_to_many_with_depression():
    """Check that an error is thrown when to_many methods started DF."""

    mg0 = RasterModelGrid((10, 10), xy_spacing=(1, 1))
    mg0.add_field("topographic__elevation",
                  mg0.node_x**2 + mg0.node_y**2,
                  at="node")

    mg1 = RasterModelGrid((10, 10), xy_spacing=(1, 1))
    mg1.add_field("topographic__elevation",
                  mg1.node_x**2 + mg1.node_y**2,
                  at="node")

    with pytest.raises(NotImplementedError):
        LossyFlowAccumulator(mg0,
                             flow_director="MFD",
                             depression_finder="DepressionFinderAndRouter")
    with pytest.raises(NotImplementedError):
        LossyFlowAccumulator(mg0,
                             flow_director="DINF",
                             depression_finder="DepressionFinderAndRouter")

    fa0 = LossyFlowAccumulator(mg0, flow_director="MFD")
    fa0.run_one_step()
    with pytest.raises(NotImplementedError):
        DepressionFinderAndRouter(mg0)

    fa1 = LossyFlowAccumulator(mg1, flow_director="DINF")
    fa1.run_one_step()
    with pytest.raises(NotImplementedError):
        DepressionFinderAndRouter(mg1)
Exemplo n.º 2
0
def test_instantiated_depression_finder_with_kwargs():
    mg = RasterModelGrid((5, 5), xy_spacing=(1, 1))
    mg.add_field("topographic__elevation", mg.node_x + mg.node_y, at="node")
    df = DepressionFinderAndRouter(mg)
    with pytest.raises(ValueError):
        LossyFlowAccumulator(mg,
                             flow_director="D8",
                             depression_finder=df,
                             routing="eggs")
Exemplo n.º 3
0
def test_specifying_routing_method_wrong():
    """Test specifying incorrect method for routing compatability with DepressionFinderAndRouter."""
    mg = RasterModelGrid((10, 10), xy_spacing=(1, 1))
    mg.add_field("topographic__elevation", mg.node_x + mg.node_y, at="node")

    with pytest.raises(ValueError):
        LossyFlowAccumulator(mg,
                             flow_director="D4",
                             depression_finder="DepressionFinderAndRouter")

    df = DepressionFinderAndRouter(mg)
    with pytest.raises(ValueError):
        LossyFlowAccumulator(mg, flow_director="D4", depression_finder=df)
Exemplo n.º 4
0
def test_depression_finder_as_instance():
    mg = RasterModelGrid((5, 5), xy_spacing=(1, 1))
    mg.add_field("topographic__elevation", mg.node_x + mg.node_y, at="node")
    df = DepressionFinderAndRouter(mg)
    LossyFlowAccumulator(mg, flow_director="D8", depression_finder=df)