Skip to content

Documentation for Collection Results

Bases: CustomDict

Dictionary-like object to represent a data collection from CMR.

Source code in earthaccess/results.py
def __init__(
    self,
    collection: Dict[str, Any],
    fields: Optional[List[str]] = None,
    cloud_hosted: bool = False,
):
    super().__init__(collection)
    self.cloud_hosted = cloud_hosted
    self.uuid = str(uuid.uuid4())

    self.render_dict: Any
    if fields is None:
        self.render_dict = self
    elif fields[0] == "basic":
        self.render_dict = self._filter_fields_(self._basic_umm_fields_)
    else:
        self.render_dict = self._filter_fields_(fields)

abstract()

Returns:

Type Description
str

The abstract of a collection

Source code in earthaccess/results.py
def abstract(self) -> str:
    """
    Returns:
        The abstract of a collection
    """
    if "Abstract" in self["umm"]:
        return self["umm"]["Abstract"]
    return ""

concept_id()

Returns:

Type Description
str

A collection's concept_id. This id is the most relevant search field on granule queries.

Source code in earthaccess/results.py
def concept_id(self) -> str:
    """
    Returns:
        A collection's `concept_id`.
            This id is the most relevant search field on granule queries.
    """
    return self["meta"]["concept-id"]

data_type()

Returns:

Type Description
str

The collection data type, i.e. HDF5, CSV etc., if available.

Source code in earthaccess/results.py
def data_type(self) -> str:
    """
    Returns:
        The collection data type, i.e. HDF5, CSV etc., if available.
    """
    if "ArchiveAndDistributionInformation" in self["umm"]:
        return str(
            self["umm"]["ArchiveAndDistributionInformation"][
                "FileDistributionInformation"
            ]
        )
    return ""

get_data()

Returns:

Type Description
List[str]

The GET DATA links (usually a landing page link, a DAAC portal, or an FTP location).

Source code in earthaccess/results.py
def get_data(self) -> List[str]:
    """
    Returns:
        The GET DATA links (usually a landing page link, a DAAC portal, or an FTP location).
    """
    links = self._filter_related_links("GET DATA")
    return links

get_umm(umm_field)

Parameters:

Name Type Description Default
umm_field str

Valid UMM item, i.e. TemporalExtent

required

Returns:

Type Description
Union[str, Dict[str, Any]]

The value of a given field inside the UMM (Unified Metadata Model).

Source code in earthaccess/results.py
def get_umm(self, umm_field: str) -> Union[str, Dict[str, Any]]:
    """
    Parameters:
        umm_field: Valid UMM item, i.e. `TemporalExtent`

    Returns:
        The value of a given field inside the UMM (Unified Metadata Model).
    """
    if umm_field in self["umm"]:
        return self["umm"][umm_field]
    return ""

landing_page()

Returns:

Type Description
str

The first landing page for the collection (can be many), if available.

Source code in earthaccess/results.py
def landing_page(self) -> str:
    """
    Returns:
        The first landing page for the collection (can be many), if available.
    """
    links = self._filter_related_links("LANDING PAGE")
    if len(links) > 0:
        return links[0]
    return ""

s3_bucket()

Returns:

Type Description
Dict[str, Any]

The S3 bucket information if the collection has it. (cloud hosted collections only)

Source code in earthaccess/results.py
def s3_bucket(self) -> Dict[str, Any]:
    """
    Returns:
        The S3 bucket information if the collection has it.
            (**cloud hosted collections only**)
    """
    if "DirectDistributionInformation" in self["umm"]:
        return self["umm"]["DirectDistributionInformation"]
    return {}

summary()

Summary containing short_name, concept-id, file-type, and cloud-info (if cloud-hosted).

Returns:

Type Description
Dict[str, Any]

A summary of the collection metadata.

Source code in earthaccess/results.py
def summary(self) -> Dict[str, Any]:
    """Summary containing short_name, concept-id, file-type, and cloud-info (if cloud-hosted).

    Returns:
        A summary of the collection metadata.
    """
    # we can print only the concept-id

    summary_dict: Dict[str, Any]
    summary_dict = {
        "short-name": self.get_umm("ShortName"),
        "concept-id": self.concept_id(),
        "version": self.version(),
        "file-type": self.data_type(),
        "get-data": self.get_data(),
    }
    if "Region" in self.s3_bucket():
        summary_dict["cloud-info"] = self.s3_bucket()
    return summary_dict

version()

Returns:

Type Description
str

The collection's version.

Source code in earthaccess/results.py
def version(self) -> str:
    """
    Returns:
        The collection's version.
    """
    if "Version" in self["umm"]:
        return self["umm"]["Version"]
    return ""