from datetime import datetime


def meta_from_pid(product_id):
    """Extract metadata contained in a Landsat Product Identifier."""
    meta = {}
    parts = product_id.split("_")
    meta["product_id"] = product_id
    meta["sensor"], meta["correction"] = parts[0], parts[1]
    meta["path"], meta["row"] = int(parts[2][:3]), int(parts[2][3:])
    meta["acquisition_date"] = datetime.strptime(parts[3], "%Y%m%d")
    meta["processing_date"] = datetime.strptime(parts[4], "%Y%m%d")
    meta["collection"], meta["tier"] = int(parts[5]), parts[6]
    return meta