Example #1
0
def cbers_parse_scene_id(sceneid):
    """Parse CBERS scene id"""

    if not re.match('^CBERS_4_MUX_[0-9]{8}_[0-9]{3}_[0-9]{3}_L[0-9]$',
                    sceneid):
        raise InvalidCBERSSceneId('Could not match {}'.format(sceneid))

    cbers_pattern = (r'(?P<sensor>\w{5})'
                     r'_'
                     r'(?P<satellite>[0-9]{1})'
                     r'_'
                     r'(?P<intrument>\w{3})'
                     r'_'
                     r'(?P<acquisitionYear>[0-9]{4})'
                     r'(?P<acquisitionMonth>[0-9]{2})'
                     r'(?P<acquisitionDay>[0-9]{2})'
                     r'_'
                     r'(?P<path>[0-9]{3})'
                     r'_'
                     r'(?P<row>[0-9]{3})'
                     r'_'
                     r'(?P<processingCorrectionLevel>L[0-9]{1})$')

    meta = None
    match = re.match(cbers_pattern, sceneid, re.IGNORECASE)
    if match:
        meta = match.groupdict()

    path = meta['path']
    row = meta['row']
    meta['key'] = 'CBERS4/MUX/{}/{}/{}'.format(path, row, sceneid)

    meta['scene'] = sceneid

    return meta
Example #2
0
def cbers_parse_scene_id(sceneid):
    """Parse CBERS scene id."""
    if not re.match(r"^CBERS_4_\w+_[0-9]{8}_[0-9]{3}_[0-9]{3}_L[0-9]$",
                    sceneid):
        raise InvalidCBERSSceneId("Could not match {}".format(sceneid))

    cbers_pattern = (r"(?P<satellite>\w+)_"
                     r"(?P<mission>[0-9]{1})"
                     r"_"
                     r"(?P<instrument>\w+)"
                     r"_"
                     r"(?P<acquisitionYear>[0-9]{4})"
                     r"(?P<acquisitionMonth>[0-9]{2})"
                     r"(?P<acquisitionDay>[0-9]{2})"
                     r"_"
                     r"(?P<path>[0-9]{3})"
                     r"_"
                     r"(?P<row>[0-9]{3})"
                     r"_"
                     r"(?P<processingCorrectionLevel>L[0-9]{1})$")

    meta = None
    match = re.match(cbers_pattern, sceneid, re.IGNORECASE)
    if match:
        meta = match.groupdict()

    path = meta["path"]
    row = meta["row"]
    instrument = meta["instrument"]
    meta["key"] = "CBERS4/{}/{}/{}/{}".format(instrument, path, row, sceneid)

    meta["scene"] = sceneid

    instrument_params = {
        "MUX": {
            "reference_band": "6",
            "bands": ["5", "6", "7", "8"],
            "rgb": (7, 6, 5)
        },
        "AWFI": {
            "reference_band": "14",
            "bands": ["13", "14", "15", "16"],
            "rgb": (15, 14, 13),
        },
        "PAN10M": {
            "reference_band": "4",
            "bands": ["2", "3", "4"],
            "rgb": (3, 4, 2)
        },
        "PAN5M": {
            "reference_band": "1",
            "bands": ["1"],
            "rgb": (1, 1, 1)
        },
    }
    meta["reference_band"] = instrument_params[instrument]["reference_band"]
    meta["bands"] = instrument_params[instrument]["bands"]
    meta["rgb"] = instrument_params[instrument]["rgb"]

    return meta
Example #3
0
def cbers_parser(sceneid: str) -> Dict:
    """Parse CBERS scene id.

    Attributes
    ----------
        sceneid : str
            CBERS sceneid.

    Returns
    -------
        out : dict
            dictionary with metadata constructed from the sceneid.

    """
    if not re.match(r"^CBERS_4_\w+_[0-9]{8}_[0-9]{3}_[0-9]{3}_L[0-9]$",
                    sceneid):
        raise InvalidCBERSSceneId("Could not match {}".format(sceneid))

    cbers_pattern = (r"(?P<satellite>\w+)_"
                     r"(?P<mission>[0-9]{1})"
                     r"_"
                     r"(?P<instrument>\w+)"
                     r"_"
                     r"(?P<acquisitionYear>[0-9]{4})"
                     r"(?P<acquisitionMonth>[0-9]{2})"
                     r"(?P<acquisitionDay>[0-9]{2})"
                     r"_"
                     r"(?P<path>[0-9]{3})"
                     r"_"
                     r"(?P<row>[0-9]{3})"
                     r"_"
                     r"(?P<processingCorrectionLevel>L[0-9]{1})$")

    meta: Dict[str, Any] = re.match(cbers_pattern, sceneid,
                                    re.IGNORECASE).groupdict()
    meta["scene"] = sceneid

    instrument = meta["instrument"]
    instrument_params = {
        "MUX": {
            "reference_band": "6",
            "bands": ("5", "6", "7", "8"),
            "rgb": ("7", "6", "5"),
        },
        "AWFI": {
            "reference_band": "14",
            "bands": ("13", "14", "15", "16"),
            "rgb": ("15", "14", "13"),
        },
        "PAN10M": {
            "reference_band": "4",
            "bands": ("2", "3", "4"),
            "rgb": ("3", "4", "2"),
        },
        "PAN5M": {
            "reference_band": "1",
            "bands": ("1"),
            "rgb": ("1", "1", "1")
        },
    }
    meta["reference_band"] = instrument_params[instrument]["reference_band"]
    meta["bands"] = instrument_params[instrument]["bands"]
    meta["rgb"] = instrument_params[instrument]["rgb"]

    meta["scheme"] = "s3"
    meta["bucket"] = "cbers-pds"
    meta["prefix"] = "CBERS4/{instrument}/{path}/{row}/{scene}".format(**meta)

    return meta
Example #4
0
def _cbers_parse_scene_id(sceneid):
    """Parse CBERS scene id.

    Attributes
    ----------
    sceneid : str
        CBERS sceneid.

    Returns
    -------
    out : dict
        dictionary with metadata constructed from the sceneid.

        e.g:
        _cbers_parse_scene_id('CBERS_4_PAN5M_20171121_057_094_L2')
        {
            "acquisitionDay": "21",
            "acquisitionMonth": "11",
            "acquisitionYear": "2017",
            "instrument": "PAN5M",
            "key": "CBERS4/PAN5M/057/094/CBERS_4_PAN5M_20171121_057_094_L2",
            "path": "057",
            "processingCorrectionLevel": "L2",
            "row": "094",
            "mission": "4",
            "scene": "CBERS_4_PAN5M_20171121_057_094_L2",
            "reference_band": "1",
            "bands": ["1"],
            "rgb": ("1", "1", "1"),
            "satellite": "CBERS",
        }

    """
    if not re.match(r"^CBERS_4_\w+_[0-9]{8}_[0-9]{3}_[0-9]{3}_L[0-9]$",
                    sceneid):
        raise InvalidCBERSSceneId("Could not match {}".format(sceneid))

    cbers_pattern = (r"(?P<satellite>\w+)_"
                     r"(?P<mission>[0-9]{1})"
                     r"_"
                     r"(?P<instrument>\w+)"
                     r"_"
                     r"(?P<acquisitionYear>[0-9]{4})"
                     r"(?P<acquisitionMonth>[0-9]{2})"
                     r"(?P<acquisitionDay>[0-9]{2})"
                     r"_"
                     r"(?P<path>[0-9]{3})"
                     r"_"
                     r"(?P<row>[0-9]{3})"
                     r"_"
                     r"(?P<processingCorrectionLevel>L[0-9]{1})$")

    meta = None
    match = re.match(cbers_pattern, sceneid, re.IGNORECASE)
    if match:
        meta = match.groupdict()

    path = meta["path"]
    row = meta["row"]
    instrument = meta["instrument"]
    meta["key"] = "CBERS4/{}/{}/{}/{}".format(instrument, path, row, sceneid)

    meta["scene"] = sceneid

    instrument_params = {
        "MUX": {
            "reference_band": "6",
            "bands": ["5", "6", "7", "8"],
            "rgb": ("7", "6", "5"),
        },
        "AWFI": {
            "reference_band": "14",
            "bands": ["13", "14", "15", "16"],
            "rgb": ("15", "14", "13"),
        },
        "PAN10M": {
            "reference_band": "4",
            "bands": ["2", "3", "4"],
            "rgb": ("3", "4", "2"),
        },
        "PAN5M": {
            "reference_band": "1",
            "bands": ["1"],
            "rgb": ("1", "1", "1")
        },
    }
    meta["reference_band"] = instrument_params[instrument]["reference_band"]
    meta["bands"] = instrument_params[instrument]["bands"]
    meta["rgb"] = instrument_params[instrument]["rgb"]

    return meta
Example #5
0
def cbers_parse_scene_id(sceneid):
    """Parse CBERS scene id"""

    if not re.match('^CBERS_4_\w+_[0-9]{8}_[0-9]{3}_[0-9]{3}_L[0-9]$',
                    sceneid):
        raise InvalidCBERSSceneId('Could not match {}'.format(sceneid))

    cbers_pattern = (r'(?P<satellite>\w+)_'
                     r'(?P<mission>[0-9]{1})'
                     r'_'
                     r'(?P<instrument>\w+)'
                     r'_'
                     r'(?P<acquisitionYear>[0-9]{4})'
                     r'(?P<acquisitionMonth>[0-9]{2})'
                     r'(?P<acquisitionDay>[0-9]{2})'
                     r'_'
                     r'(?P<path>[0-9]{3})'
                     r'_'
                     r'(?P<row>[0-9]{3})'
                     r'_'
                     r'(?P<processingCorrectionLevel>L[0-9]{1})$')

    meta = None
    match = re.match(cbers_pattern, sceneid, re.IGNORECASE)
    if match:
        meta = match.groupdict()

    path = meta['path']
    row = meta['row']
    instrument = meta['instrument']
    meta['key'] = 'CBERS4/{}/{}/{}/{}'.format(instrument, path, row, sceneid)

    meta['scene'] = sceneid

    instrument_params = {
        'MUX': {
            'reference_band': '6',
            'bands': ['5', '6', '7', '8'],
            'rgb': (7, 6, 5)
        },
        'AWFI': {
            'reference_band': '14',
            'bands': ['13', '14', '15', '16'],
            'rgb': (15, 14, 13)
        },
        'PAN10M': {
            'reference_band': '4',
            'bands': ['2', '3', '4'],
            'rgb': (3, 4, 2)
        },
        'PAN5M': {
            'reference_band': '1',
            'bands': ['1'],
            'rgb': (1, 1, 1)
        }
    }
    meta['reference_band'] = instrument_params[instrument]['reference_band']
    meta['bands'] = instrument_params[instrument]['bands']
    meta['rgb'] = instrument_params[instrument]['rgb']

    return meta