def test_stupid_shaped_hole(sink_grid4): """Tests inclined fill into a surface with a deliberately awkward shape.""" fr = FlowRouter(sink_grid4) hf = SinkFiller(sink_grid4, apply_slope=True) hf.fill_pits() hole1 = np.array( [ 4.00007692, 4.00015385, 4.00023077, 4.00030769, 4.00038462, 4.00046154, 4.00053846, 4.00061538, 4.00069231, 4.00076923, 4.00084615, ] ) hole2 = np.array([7.4, 7.2, 7.6]) assert_array_almost_equal( sink_grid4.at_node["topographic__elevation"][sink_grid4.lake1], hole1 ) assert_array_almost_equal( sink_grid4.at_node["topographic__elevation"][sink_grid4.lake2], hole2 ) fr.route_flow() assert sink_grid4.at_node["flow__sink_flag"][sink_grid4.core_nodes].sum() == 0
def test_filler_inclined2(): """ Tests an inclined fill into an inclined surface, with two holes. """ z_init = z.copy() hf = SinkFiller(mg, apply_slope=True) hf.fill_pits() hole1 = np.array([ 4.00009091, 4.00018182, 4.00027273, 4.00036364, 4.00045455, 4.00054545, 4.00063636, 4.00072727, 4.00081818, ]) hole2 = np.array([7.16666667, 7.33333333, 7.5, 7.66666667]) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2) fr.route_flow() assert_equal(mg.at_node['flow__sink_flag'][mg.core_nodes].sum(), 0)
def test_filler_inclined2(sink_grid3): """ Tests an inclined fill into an inclined surface, with two holes. """ z_init = sink_grid3.at_node["topographic__elevation"].copy() fr = FlowRouter(sink_grid3) hf = SinkFiller(sink_grid3, apply_slope=True) hf.fill_pits() hole1 = np.array( [ 4.00009091, 4.00018182, 4.00027273, 4.00036364, 4.00045455, 4.00054545, 4.00063636, 4.00072727, 4.00081818, ] ) hole2 = np.array([7.16666667, 7.33333333, 7.5, 7.66666667]) assert_array_almost_equal( sink_grid3.at_node["topographic__elevation"][sink_grid3.lake1], hole1 ) assert_array_almost_equal( sink_grid3.at_node["topographic__elevation"][sink_grid3.lake2], hole2 ) fr.route_flow() assert sink_grid3.at_node["flow__sink_flag"][sink_grid3.core_nodes].sum() == 0
def test_filler_inclined(): """ Tests a flat fill into an inclined surface, with two holes. """ hf = SinkFiller(mg) hf.fill_pits() assert_array_equal(mg.at_node['topographic__elevation'][lake1], np.ones(9, dtype=float) * 4.) assert_array_equal(mg.at_node['topographic__elevation'][lake2], np.ones(4, dtype=float) * 7.)
def test_filler_inclined(): """ Tests a flat fill into an inclined surface, with two holes. """ hf = SinkFiller(mg) hf.fill_pits() assert_array_equal(mg.at_node['topographic__elevation'][lake1], np.ones(9, dtype=float)*4.) assert_array_equal(mg.at_node['topographic__elevation'][lake2], np.ones(4, dtype=float)*7.)
def test_filler_flat(sink_grid2): """ Very simple, though possibly degerate, case, filling a 3x3 hole up to the flat surface surrounding it. """ hf = SinkFiller(sink_grid2) hf.fill_pits() assert_array_equal(hf._elev[sink_grid2.lake], np.ones(9, dtype=float)) assert_array_equal( sink_grid2.at_node["topographic__elevation"][sink_grid2.lake], np.ones(9, dtype=float), )
def test_filler_inclined(sink_grid3): """ Tests a flat fill into an inclined surface, with two holes. """ hf = SinkFiller(sink_grid3) hf.fill_pits() assert_array_equal( sink_grid3.at_node["topographic__elevation"][sink_grid3.lake1], np.ones(9, dtype=float) * 4., ) assert_array_equal( sink_grid3.at_node["topographic__elevation"][sink_grid3.lake2], np.ones(4, dtype=float) * 7., )
def test_D4_filling(): """ Tests inclined fill into a surface with a deliberately awkward shape. This is testing D4 without inclining the surface. """ hf = SinkFiller(mg, routing='D4') hf.fill_pits() hole1 = 4. * np.ones_like(lake1, dtype=float) hole1[-1] += 0.001 hole2 = 7. * np.ones_like(lake2, dtype=float) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2)
def test_D4_filling(): """ Tests inclined fill into a surface with a deliberately awkward shape. This is testing D4 without inclining the surface. """ hf = SinkFiller(mg, routing='D4') hf.fill_pits() hole1 = 4.*np.ones_like(lake1, dtype=float) hole1[-1] += 0.001 hole2 = 7.*np.ones_like(lake2, dtype=float) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2)
def test_filler_inclined2(): """ Tests an inclined fill into an inclined surface, with two holes. """ z_init = z.copy() hf = SinkFiller(mg, apply_slope=True) hf.fill_pits() hole1 = np.array([4.00009091, 4.00018182, 4.00027273, 4.00036364, 4.00045455, 4.00054545, 4.00063636, 4.00072727, 4.00081818,]) hole2 = np.array([7.16666667, 7.33333333, 7.5, 7.66666667]) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2) fr.route_flow() assert_equal(mg.at_node['flow__sink_flag'][mg.core_nodes].sum(), 0)
def test_D4_filling(): """ Tests inclined fill into a surface with a deliberately awkward shape. This is testing D4 without inclining the surface. """ hf = SinkFiller(mg, routing='D4') hf.fill_pits() hole1 = 4.*np.ones_like(lake1, dtype=float) hole1[-1] += 0.001 hole2 = 7.*np.ones_like(lake2, dtype=float) # np.array([34, 35, 36, 44, 45, 46, 54, 55, 56, 65, 74]) # print this to check out the funky drainage arrangement... # print(mg.at_node['topographic__elevation'].reshape((10, 10))[3:8, 4:7]) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2)
def test_stupid_shaped_hole(): """ Tests inclined fill into a surface with a deliberately awkward shape. """ hf = SinkFiller(mg, apply_slope=True) hf.fill_pits() hole1 = np.array([4.00007692, 4.00015385, 4.00023077, 4.00030769, 4.00038462, 4.00046154, 4.00053846, 4.00061538, 4.00069231, 4.00076923, 4.00084615]) hole2 = np.array([7.4, 7.2, 7.6]) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2) fr.route_flow() assert_equal(mg.at_node['flow__sink_flag'][mg.core_nodes].sum(), 0)
def test_D4_filling(): """ Tests inclined fill into a surface with a deliberately awkward shape. This is testing D4 without inclining the surface. """ hf = SinkFiller(mg, routing='D4') hf.fill_pits() hole1 = 4. * np.ones_like(lake1, dtype=float) hole1[-1] += 0.001 hole2 = 7. * np.ones_like(lake2, dtype=float) # np.array([34, 35, 36, 44, 45, 46, 54, 55, 56, 65, 74]) # print this to check out the funky drainage arrangement... # print(mg.at_node['topographic__elevation'].reshape((10, 10))[3:8, 4:7]) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2)
def test_stupid_shaped_hole(): """ Tests inclined fill into a surface with a deliberately awkward shape. """ hf = SinkFiller(mg, apply_slope=True) hf.fill_pits() hole1 = np.array([4.00007692, 4.00015385, 4.00023077, 4.00053846, 4.00038462, 4.00030769, 4.00069231, 4.00061538, 4.00046154, 4.00076923, 4.00084615]) hole2 = np.array([7.4, 7.2, 7.6]) # print this to check out the funky drainage arrangement... # print(mg.at_node['topographic__elevation'].reshape((10, 10))[3:8, 4:7]) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2) fr.route_flow() assert_equal(mg.at_node['flow_sinks'][mg.core_nodes].sum(), 0)
def test_stupid_shaped_hole(): """ Tests inclined fill into a surface with a deliberately awkward shape. """ hf = SinkFiller(mg, apply_slope=True) hf.fill_pits() hole1 = np.array([ 4.00007692, 4.00015385, 4.00023077, 4.00030769, 4.00038462, 4.00046154, 4.00053846, 4.00061538, 4.00069231, 4.00076923, 4.00084615 ]) hole2 = np.array([7.4, 7.2, 7.6]) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2) fr.route_flow() assert_equal(mg.at_node['flow__sink_flag'][mg.core_nodes].sum(), 0)
def test_stupid_shaped_hole(): """ Tests inclined fill into a surface with a deliberately awkward shape. """ hf = SinkFiller(mg, apply_slope=True) hf.fill_pits() hole1 = np.array([ 4.00007692, 4.00015385, 4.00023077, 4.00053846, 4.00038462, 4.00030769, 4.00069231, 4.00061538, 4.00046154, 4.00076923, 4.00084615 ]) hole2 = np.array([7.4, 7.2, 7.6]) # print this to check out the funky drainage arrangement... # print(mg.at_node['topographic__elevation'].reshape((10, 10))[3:8, 4:7]) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2) fr.route_flow() assert_equal(mg.at_node['flow_sinks'][mg.core_nodes].sum(), 0)
def test_D4_routing(): """ Tests inclined fill into a surface with a deliberately awkward shape. This is testing D4 routing. """ hf = SinkFiller(mg, routing='D4', apply_slope=True) hf.fill_pits() hole1 = np.array([4.00016667, 4.00025, 4.00033333, 4.00008333, 4.00041667, 4.0005, 4.00083333, 4.00066667, 4.00058333, 4.00075, 4.334]) hole2 = np.array([7.6, 7.2, 7.4]) # np.array([34, 35, 36, 44, 45, 46, 54, 55, 56, 65, 74]) # print this to check out the funky drainage arrangement... # print(mg.at_node['topographic__elevation'].reshape((10, 10))[3:8, 4:7]) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2) fr.route_flow(method='D4') assert_equal(mg.at_node['flow_sinks'][mg.core_nodes].sum(), 0)
def test_D4_routing(): """ Tests inclined fill into a surface with a deliberately awkward shape. This is testing D4 routing. """ hf = SinkFiller(mg, routing='D4', apply_slope=True) hf.fill_pits() hole1 = np.array([ 4.00016667, 4.00025, 4.00033333, 4.00008333, 4.00041667, 4.0005, 4.00083333, 4.00066667, 4.00058333, 4.00075, 4.334 ]) hole2 = np.array([7.6, 7.2, 7.4]) # np.array([34, 35, 36, 44, 45, 46, 54, 55, 56, 65, 74]) # print this to check out the funky drainage arrangement... # print(mg.at_node['topographic__elevation'].reshape((10, 10))[3:8, 4:7]) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2) fr.route_flow(method='D4') assert_equal(mg.at_node['flow_sinks'][mg.core_nodes].sum(), 0)
def test_D4_routing(): """ Tests inclined fill into a surface with a deliberately awkward shape. This is testing D4 routing. """ hf = SinkFiller(mg, routing='D4', apply_slope=True) hf.fill_pits() # hole1 = np.array([4.00016667, 4.00025, 4.00033333, 4.00008333, 4.00041667, # 4.0005, 4.00066667, 4.00058333, 4.00075, # 4.334]) hole1 = np.array([4.00016667, 4.00033333, 4.0005, 4.00008333, 4.00025, 4.00041667, 4.000833, 4.00066667, 4.00058333, 4.00075, 4.334]) hole2 = np.array([7.6, 7.2, 7.4]) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2) fr.route_flow(method='D4') assert_equal(mg.at_node['flow__sink_flag'][mg.core_nodes].sum(), 0)
def test_D4_routing(): """ Tests inclined fill into a surface with a deliberately awkward shape. This is testing D4 routing. """ hf = SinkFiller(mg, routing='D4', apply_slope=True) hf.fill_pits() # hole1 = np.array([4.00016667, 4.00025, 4.00033333, 4.00008333, 4.00041667, # 4.0005, 4.00066667, 4.00058333, 4.00075, # 4.334]) hole1 = np.array([ 4.00016667, 4.00033333, 4.0005, 4.00008333, 4.00025, 4.00041667, 4.000833, 4.00066667, 4.00058333, 4.00075, 4.334 ]) hole2 = np.array([7.6, 7.2, 7.4]) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake1], hole1) assert_array_almost_equal(mg.at_node['topographic__elevation'][lake2], hole2) fr.route_flow(method='D4') assert_equal(mg.at_node['flow__sink_flag'][mg.core_nodes].sum(), 0)
def test_D4_routing(sink_grid5): """ Tests inclined fill into a surface with a deliberately awkward shape. This is testing D4 routing. """ fr = FlowRouter(sink_grid5) hf = SinkFiller(sink_grid5, routing="D4", apply_slope=True) hf.fill_pits() # hole1 = np.array([4.00016667, 4.00025, 4.00033333, 4.00008333, 4.00041667, # 4.0005, 4.00066667, 4.00058333, 4.00075, # 4.334]) hole1 = np.array( [ 4.00016667, 4.00033333, 4.0005, 4.00008333, 4.00025, 4.00041667, 4.000833, 4.00066667, 4.00058333, 4.00075, 4.334, ] ) hole2 = np.array([7.6, 7.2, 7.4]) assert_array_almost_equal( sink_grid5.at_node["topographic__elevation"][sink_grid5.lake1], hole1 ) assert_array_almost_equal( sink_grid5.at_node["topographic__elevation"][sink_grid5.lake2], hole2 ) fr.route_flow(method="D4") assert sink_grid5.at_node["flow__sink_flag"][sink_grid5.core_nodes].sum() == 0