Exemple #1
0
def test_cat_item_stacking_dims_of_different_type_raises_error(stac_item_obj):
    item = StacItem(stac_item_obj)
    list_of_bands = ['B1', 'ANG']
    with pytest.raises(
            ValueError,
            match=('ANG not found in list of eo:bands in collection')):
        item.stack_bands(list_of_bands)
Exemple #2
0
def test_cat_item_stacking_dims_of_different_type_raises_error(stac_item_obj):
    items = StacItem(stac_item_obj)
    list_of_bands = ["B1", "ANG"]
    with pytest.raises(
            ValueError,
            match=("ANG not found in list of eo:bands in collection")):
        items.stack_bands(list_of_bands)
Exemple #3
0
def test_cat_item_stacking_dims_of_different_size_raises_error_by_default(
    stac_item_obj, ):  # noqa: E501
    items = StacItem(stac_item_obj)
    list_of_bands = ["B1", "B8"]
    B1_da = items.B1.to_dask()
    assert B1_da.shape == (1, 7801, 7641)
    B8_da = items.B8.to_dask()
    assert B8_da.shape == (1, 15601, 15281)
    with pytest.raises(ValueError, match="B8 has different ground sampling"):
        items.stack_bands(list_of_bands)
Exemple #4
0
def test_cat_item_stacking_path_as_pattern(pystac_item):
    item = StacItem(pystac_item)
    list_of_bands = ['B1', 'B2']
    new_entry = item.stack_bands(list_of_bands, path_as_pattern='{}{band:2}.TIF')
    assert isinstance(new_entry, CombinedAssets)
    new_da = new_entry().to_dask()
    assert (new_da.band == ['B1', 'B2']).all()
Exemple #5
0
def test_cat_item_stacking_using_common_name(stac_item_obj):
    items = StacItem(stac_item_obj)
    list_of_bands = ["coastal", "blue"]
    new_entry = items.stack_bands(list_of_bands)
    assert new_entry.description == "Band 1 (coastal), Band 2 (blue)"
    assert new_entry.name == "coastal_blue"
    new_da = new_entry.to_dask()
    assert sorted([dim for dim in new_da.dims]) == ["band", "x", "y"]
    assert (new_da.band == ["B1", "B2"]).all()
Exemple #6
0
def test_cat_item_stacking_using_common_name(pystac_item):
    item = StacItem(pystac_item)
    list_of_bands = ['coastal', 'blue']
    new_entry = item.stack_bands(list_of_bands)
    assert isinstance(new_entry, CombinedAssets)
    assert new_entry._description == 'B1, B2'
    assert new_entry.name == 'coastal_blue'
    new_da = new_entry().to_dask()
    assert sorted([dim for dim in new_da.dims]) == ['band', 'x', 'y']
def test_cat_item_stacking_using_common_name(stac_item_obj):
    items = StacItem(stac_item_obj)
    list_of_bands = ['coastal', 'blue']
    new_entry = items.stack_bands(list_of_bands)
    assert new_entry.description == 'Band 1 (coastal), Band 2 (blue)'
    assert new_entry.name == 'coastal_blue'
    new_da = new_entry.to_dask()
    assert sorted([dim for dim in new_da.dims]) == ['band', 'x', 'y']
    assert (new_da.band == ['B1', 'B2']).all()
Exemple #8
0
def test_cat_item_stacking_using_common_name(stac_item_obj):
    item = StacItem(stac_item_obj)
    list_of_bands = ['coastal', 'blue']
    new_entry = item.stack_bands(list_of_bands)
    assert isinstance(new_entry, StacEntry)
    assert new_entry._description == 'B1, B2'
    assert new_entry.name == 'coastal_blue'
    new_da = new_entry().to_dask()
    assert sorted([dim for dim in new_da.dims]) == ['band', 'x', 'y']
    assert (new_da.band == ['B1', 'B2']).all()
Exemple #9
0
def test_cat_item_stacking_dims_of_different_size_regrids(pystac_item):
    item = StacItem(pystac_item)
    list_of_bands = ['B1', 'B8']
    B1_da = item.B1.to_dask()
    assert B1_da.shape == (1, 7791, 7651)
    B8_da = item.B8.to_dask()
    assert B8_da.shape == (1, 15581, 15301)
    new_entry = item.stack_bands(list_of_bands)
    new_da = new_entry().to_dask()
    assert new_da.shape == (2, 15581, 15301)
    assert sorted([dim for dim in new_da.dims]) == ['band', 'x', 'y']
Exemple #10
0
def test_cat_item_stacking_dims_of_different_size_regrids(stac_item_obj):
    items = StacItem(stac_item_obj)
    list_of_bands = ["B1", "B8"]
    B1_da = items.B1.to_dask()
    assert B1_da.shape == (1, 7801, 7641)
    B8_da = items.B8.to_dask()
    assert B8_da.shape == (1, 15601, 15281)
    new_entry = items.stack_bands(list_of_bands, regrid=True)
    new_da = new_entry.to_dask()
    assert new_da.shape == (2, 15601, 15281)
    assert sorted([dim for dim in new_da.dims]) == ["band", "x", "y"]
    assert (new_da.band == list_of_bands).all()
Exemple #11
0
def test_cat_item_stacking_dims_with_nonexistent_band_raises_error(
    stac_item_obj, ):  # noqa: E501
    item = StacItem(stac_item_obj)
    list_of_bands = ['B1', 'foo']
    with pytest.raises(ValueError, match="'B8', 'B9', 'blue', 'cirrus'"):
        item.stack_bands(list_of_bands)