예제 #1
0
def test_tile_valid_default(crio, rio):
    """Should work as expected"""
    crio.open = mock_rasterio_open
    rio.open = mock_rasterio_open

    tile_z = 10
    tile_x = 664
    tile_y = 495
    data, mask = cbers.tile(CBERS_MUX_SCENE, tile_x, tile_y, tile_z)
    assert data.shape == (3, 256, 256)
    assert mask.shape == (256, 256)

    tile_z = 10
    tile_x = 401
    tile_y = 585
    data, mask = cbers.tile(CBERS_AWFI_SCENE, tile_x, tile_y, tile_z)
    assert data.shape == (3, 256, 256)
    assert mask.shape == (256, 256)

    tile_z = 10
    tile_x = 370
    tile_y = 535
    data, mask = cbers.tile(CBERS_PAN10M_SCENE, tile_x, tile_y, tile_z)
    assert data.shape == (3, 256, 256)
    assert mask.shape == (256, 256)

    tile_z = 10
    tile_x = 390
    tile_y = 547
    data, mask = cbers.tile(CBERS_PAN5M_SCENE, tile_x, tile_y, tile_z)
    assert data.shape == (3, 256, 256)
    assert mask.shape == (256, 256)
예제 #2
0
def test_tile_invalid_bounds(crio, rio):
    """Should raise an error with invalid tile."""
    crio.open = mock_rasterio_open
    rio.open = mock_rasterio_open

    tile_z = 10
    tile_x = 694
    tile_y = 495

    with pytest.raises(TileOutsideBounds):
        cbers.tile(CBERS_MUX_SCENE, tile_x, tile_y, tile_z)
예제 #3
0
def test_tile_invalid_band(crio, rio):
    """Should raise an error on invalid band name."""
    crio.open = mock_rasterio_open
    rio.open = mock_rasterio_open

    tile_z = 10
    tile_x = 390
    tile_y = 547
    bands = "21"

    with pytest.raises(InvalidBandName):
        cbers.tile(CBERS_PAN5M_SCENE, tile_x, tile_y, tile_z, bands=bands)
예제 #4
0
def test_tile_valid_custom(crio, rio):
    """Should return custom band combination tiles."""
    crio.open = mock_rasterio_open
    rio.open = mock_rasterio_open

    tile_z = 10
    tile_x = 664
    tile_y = 495
    bands = ("8", "7", "6")
    data, mask = cbers.tile(CBERS_MUX_SCENE,
                            tile_x,
                            tile_y,
                            tile_z,
                            bands=bands)
    assert data.shape == (3, 256, 256)
    assert mask.shape == (256, 256)

    tile_z = 10
    tile_x = 401
    tile_y = 585
    bands = ("16", "15", "14")
    data, mask = cbers.tile(CBERS_AWFI_SCENE, tile_x, tile_y, tile_z)
    assert data.shape == (3, 256, 256)
    assert mask.shape == (256, 256)

    tile_z = 10
    tile_x = 370
    tile_y = 535
    bands = ("4", "3", "2")
    data, mask = cbers.tile(CBERS_PAN10M_SCENE, tile_x, tile_y, tile_z)
    assert data.shape == (3, 256, 256)
    assert mask.shape == (256, 256)

    tile_z = 10
    tile_x = 390
    tile_y = 547
    bands = ("1", "1", "1")
    data, mask = cbers.tile(CBERS_PAN5M_SCENE, tile_x, tile_y, tile_z)
    assert data.shape == (3, 256, 256)
    assert mask.shape == (256, 256)
예제 #5
0
def test_tile_valid_oneband(crio, rio):
    """Test when passing a string instead of a tuple."""
    crio.open = mock_rasterio_open
    rio.open = mock_rasterio_open

    tile_z = 10
    tile_x = 390
    tile_y = 547
    bands = "1"

    data, mask = cbers.tile(CBERS_PAN5M_SCENE,
                            tile_x,
                            tile_y,
                            tile_z,
                            bands=bands)
    assert data.shape == (1, 256, 256)
    assert mask.shape == (256, 256)