Ejemplo n.º 1
0
def test_cbers_id_valid():
    """
    Should work as expected (parse cbers scene id)
    """

    scene = 'CBERS_4_MUX_20171121_057_094_L2'
    expected_content = {
        'acquisition_date': '20171121',
        'sensor': 'MUX',
        'key': 'CBERS4/MUX/057/094/CBERS_4_MUX_20171121_057_094_L2',
        'path': '057',
        'processing_level': 'L2',
        'row': '094',
        'version': '4',
        'scene_id': 'CBERS_4_MUX_20171121_057_094_L2',
        'satellite': 'CBERS'
    }

    assert utils.cbers_parse_scene_id(scene) == expected_content

    scene = 'CBERS_4_AWFI_20171121_057_094_L2'
    expected_content = {
        'acquisition_date': '20171121',
        'sensor': 'AWFI',
        'key': 'CBERS4/AWFI/057/094/CBERS_4_AWFI_20171121_057_094_L2',
        'path': '057',
        'processing_level': 'L2',
        'row': '094',
        'version': '4',
        'scene_id': 'CBERS_4_AWFI_20171121_057_094_L2',
        'satellite': 'CBERS'
    }

    assert utils.cbers_parse_scene_id(scene) == expected_content
Ejemplo n.º 2
0
def test_cbers_id_invalid():
    """
    Should raise an error with invalid sceneid
    """

    scene = 'CBERS_4_MUX_20171121_057_094'
    with pytest.raises(InvalidCBERSSceneId):
        utils.cbers_parse_scene_id(scene)
Ejemplo n.º 3
0
def cbers(path, row, sensor='MUX'):
    """Get CBERS scenes.

    Valid values for sensor are: 'MUX', 'AWFI', 'PAN5M' and 'PAN10M'.
    """
    path = utils.zeroPad(path, 3)
    row = utils.zeroPad(row, 3)

    prefix = f'CBERS4/{sensor}/{path}/{row}/'

    session = boto3_session(region_name=region)
    s3 = session.client('s3')

    results = aws.list_directory(cbers_bucket, prefix, s3=s3)
    scene_ids = [os.path.basename(key.strip('/')) for key in results]
    results = []
    for scene_id in scene_ids:
        info = utils.cbers_parse_scene_id(scene_id)
        scene_key = info["key"]
        preview_id = '_'.join(scene_id.split('_')[0:-1])
        info[
            'thumbURL'] = f'https://s3.amazonaws.com/{cbers_bucket}/{scene_key}/{preview_id}_small.jpeg'
        info[
            'browseURL'] = f'https://s3.amazonaws.com/{cbers_bucket}/{scene_key}/{preview_id}.jpg'
        results.append(info)

    return results