Esempio n. 1
0
def overview(event, context):
    """Handle overview requests."""
    scene = event['scene']
    bands = event.get('bands')
    expression = event.get('expression')
    img_format = event.get('format', 'jpeg')
    if bands:
        bands = bands.split(',') if isinstance(bands, str) else bands
    return l8_ovr.create(scene,
                         bands=bands,
                         expression=expression,
                         img_format=img_format)
Esempio n. 2
0
def l8_overview_handler(event, context):
    '''
    '''
    logger.info(event)

    try:
        info = event.get('queryStringParameters')
        scene = info.get('scene')
        bands = info.get('bands', [4, 3, 2])
        bands = eval(bands) if isinstance(bands, str) else bands
        img_format = info.get('format', 'jpeg')

        out = l8_ovr.create(scene, bands, img_format)
        return response('OK', 'text/plain', out, True)
    except:
        return response('ERROR', 'application/json',
                        json.dumps({'ErrorMessage': 'Error'}), True)
Esempio n. 3
0
def test_create_validexpression(landsat_get_mtl, monkeypatch):
    """Should work as expected (read r,g,b bands and create JPEG image)."""
    monkeypatch.setattr(l8_ovr, "LANDSAT_BUCKET", landsat_bucket)
    landsat_get_mtl.return_value = landsat_meta
    expression = "(b5 - b4) / (b5 + b4)"
    assert l8_ovr.create(landsat_scene_c1, expression=expression)
Esempio n. 4
0
def test_create_npbandexpress(landsat_get_mtl, monkeypatch):
    """Should raise."""
    monkeypatch.setattr(l8_ovr, "LANDSAT_BUCKET", landsat_bucket)
    landsat_get_mtl.return_value = landsat_meta
    with pytest.raises(Exception):
        l8_ovr.create(landsat_scene_c1)
Esempio n. 5
0
def test_create_lessband(landsat_get_mtl, monkeypatch):
    """Should raise on not many bands."""
    monkeypatch.setattr(l8_ovr, "LANDSAT_BUCKET", landsat_bucket)
    landsat_get_mtl.return_value = landsat_meta
    with pytest.raises(Exception):
        l8_ovr.create(landsat_scene_c1, bands=[4, 2])
Esempio n. 6
0
def test_create_invalidFormat(landsat_get_mtl, monkeypatch):
    """Should raise invalid format."""
    monkeypatch.setattr(l8_ovr, "LANDSAT_BUCKET", landsat_bucket)
    landsat_get_mtl.return_value = landsat_meta
    with pytest.raises(UserWarning):
        l8_ovr.create(landsat_scene_c1, bands=[4, 3, 2], img_format="tif")
Esempio n. 7
0
def test_create_validSmall(landsat_get_mtl, monkeypatch):
    """Should work as expected (read bands and create 128x128 image)."""
    monkeypatch.setattr(l8_ovr, "LANDSAT_BUCKET", landsat_bucket)
    landsat_get_mtl.return_value = landsat_meta
    assert l8_ovr.create(landsat_scene_c1, bands=[4, 3, 2], ovrSize=128)
Esempio n. 8
0
def test_create_validPNG(landsat_get_mtl, monkeypatch):
    """Should work as expected (read r,g,b bands and create PNG image)."""
    monkeypatch.setattr(l8_ovr, "LANDSAT_BUCKET", landsat_bucket)
    landsat_get_mtl.return_value = landsat_meta
    assert l8_ovr.create(landsat_scene_c1, bands=[4, 3, 2], img_format="png")