示例#1
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)
示例#2
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)
示例#3
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()
示例#4
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()
示例#5
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']
示例#6
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()
示例#7
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()
示例#8
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)
示例#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']
示例#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()
示例#11
0
def test_asset_describe(pystac_item):
    item = StacItem(pystac_item)
    key = 'B1'
    asset = item[key]
    d = asset.describe()

    assert d['name'] == key
    assert d['container'] == 'xarray'
    assert d['plugin'] == ['rasterio']
    assert d['args']['urlpath'] == asset.urlpath
    assert d['description'] == asset.description
示例#12
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)
示例#13
0
def test_cat_from_item(stac_item_obj):
    cat = StacItem(stac_item_obj)
    # weird, why is this different than the name above?
    assert 'B5' in cat
示例#14
0
def test_cat_from_item(pystac_item):
    cat = StacItem(pystac_item)
    assert 'B5' in cat