コード例 #1
0
def test_extractBox_dict(box, concat_wrap, result):
    x = xr.DataArray(
        np.array([0, 1, 2, 3]),
        dims=["x"],
        coords={"x": (["x"], np.array([0, 1, 2, 3]))},
    )
    y = xr.DataArray(
        np.array([10, 20, 30, 40, 50]),
        dims=["y"],
        coords={"y": (["y"], np.array(range(5)))},
    )
    c = x * y
    box_cut = extractBox_dict(c, box, concat_wrap=concat_wrap)
    assert_allclose(box_cut.data, result)

    c = c.chunk({"x": 1})
    box_cut_dask = extractBox_dict(c, box, concat_wrap=concat_wrap)
    assert isinstance(box_cut_dask.data, dsa.Array)
    assert_allclose(box_cut_dask.data, result)
コード例 #2
0
def test_extractBox(box, concat_wrap, result):
    x = xr.DataArray(np.array([0, 1, 2, 3]),
                     dims=['x'],
                     coords={'x': ([
                         'x',
                     ], np.array([0, 1, 2, 3]))})
    y = xr.DataArray(np.array([10, 20, 30, 40, 50]),
                     dims=['y'],
                     coords={'y': ([
                         'y',
                     ], np.array(range(5)))})
    c = x * y
    box_cut = extractBox_dict(c, box, concat_wrap=concat_wrap)
    assert_allclose(box_cut.data, result)