Exemplo n.º 1
0
def test_metadata_valid_default(monkeypatch):
    """Should work as expected.

    Get bounds and get histogram cuts values for all bands

    """
    monkeypatch.setattr(cbers, "CBERS_BUCKET", CBERS_BUCKET)

    meta = cbers.metadata(CBERS_MUX_SCENE)
    assert meta["sceneid"] == CBERS_MUX_SCENE
    assert len(meta["bounds"]["value"]) == 4
    assert len(meta["statistics"].items()) == 4
    assert meta["statistics"]["5"]["pc"] == [28, 93]

    meta = cbers.metadata(CBERS_AWFI_SCENE)
    assert meta["sceneid"] == CBERS_AWFI_SCENE
    assert len(meta["bounds"]["value"]) == 4
    assert len(meta["statistics"].items()) == 4

    meta = cbers.metadata(CBERS_PAN10M_SCENE)
    assert meta["sceneid"] == CBERS_PAN10M_SCENE
    assert len(meta["bounds"]["value"]) == 4
    assert len(meta["statistics"].items()) == 3

    meta = cbers.metadata(CBERS_PAN5M_SCENE)
    assert meta["sceneid"] == CBERS_PAN5M_SCENE
    assert len(meta["bounds"]["value"]) == 4
    assert len(meta["statistics"].items()) == 1
Exemplo n.º 2
0
def test_metadata_valid_custom(monkeypatch):
    """
    Should work as expected (get bounds and get histogram cuts values
    for all bands)
    """

    monkeypatch.setattr(cbers, 'CBERS_BUCKET', CBERS_BUCKET)

    meta = cbers.metadata(CBERS_MUX_SCENE, pmin=5, pmax=95)
    assert meta.get('sceneid') == CBERS_MUX_SCENE
    assert len(meta.get('bounds')) == 4
    assert meta.get('rgbMinMax')

    meta = cbers.metadata(CBERS_AWFI_SCENE, pmin=5, pmax=95)
    assert meta.get('sceneid') == CBERS_AWFI_SCENE
    assert len(meta.get('bounds')) == 4
    assert meta.get('rgbMinMax')

    meta = cbers.metadata(CBERS_PAN10M_SCENE, pmin=5, pmax=95)
    assert meta.get('sceneid') == CBERS_PAN10M_SCENE
    assert len(meta.get('bounds')) == 4
    assert meta.get('rgbMinMax')

    meta = cbers.metadata(CBERS_PAN5M_SCENE, pmin=5, pmax=95)
    assert meta.get('sceneid') == CBERS_PAN5M_SCENE
    assert len(meta.get('bounds')) == 4
    assert meta.get('rgbMinMax')
Exemplo n.º 3
0
def metadata(scene, pmin=2, pmax=98):
    """Handle metadata requests."""
    pmin = float(pmin) if isinstance(pmin, str) else pmin
    pmax = float(pmax) if isinstance(pmax, str) else pmax

    info = cbers.metadata(scene, pmin, pmax)
    return ("OK", "application/json", json.dumps(info))
Exemplo n.º 4
0
def metadata(scene: str,
             pmin: Union[str, float] = 2.,
             pmax: Union[str, float] = 98.) -> Tuple[str, str, str]:
    """Handle metadata requests."""
    pmin = float(pmin) if isinstance(pmin, str) else pmin
    pmax = float(pmax) if isinstance(pmax, str) else pmax
    info = cbers.metadata(scene, pmin, pmax)
    return ("OK", "application/json", json.dumps(info))
Exemplo n.º 5
0
def test_metadata_valid_default(monkeypatch):
    """
    Should work as expected (get bounds and get histogram cuts values
    for all bands)
    """

    monkeypatch.setattr(cbers, 'CBERS_BUCKET', CBERS_BUCKET)

    meta = cbers.metadata(CBERS_SCENE)
    assert meta.get('sceneid') == 'CBERS_4_MUX_20171121_057_094_L2'
    assert len(meta.get('bounds')) == 4
    assert meta.get('rgbMinMax')
Exemplo n.º 6
0
def test_metadata_valid_custom(monkeypatch):
    """
    Should work as expected (get bounds and get histogram cuts values
    for all bands)
    """

    monkeypatch.setattr(cbers, "CBERS_BUCKET", CBERS_BUCKET)

    meta = cbers.metadata(CBERS_MUX_SCENE, pmin=5, pmax=95)
    assert meta.get("sceneid") == CBERS_MUX_SCENE
    assert len(meta["bounds"]["value"]) == 4
    assert meta["statistics"]["5"]["pc"] == [29, 59]
Exemplo n.º 7
0
def metadata(scene):
    """Handle metadata requests
    """
    query_args = APP.current_request.query_params
    query_args = query_args if isinstance(query_args, dict) else {}

    pmin = query_args.get('pmin', 2)
    pmin = float(pmin) if isinstance(pmin, str) else pmin

    pmax = query_args.get('pmax', 98)
    pmax = float(pmax) if isinstance(pmax, str) else pmax

    info = cbers.metadata(scene, pmin, pmax)
    return ('OK', 'application/json', json.dumps(info))