Skip to content

Commit

Permalink
Update search.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Sherwin-14 committed Jun 6, 2024
1 parent 17ffb90 commit 7cc9bbb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
33 changes: 22 additions & 11 deletions earthaccess/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,16 @@ def get_umm(self, umm_field: str) -> Union[str, Dict[str, Any]]:
def concept_id(self) -> str:
"""Placeholder.
Returns: A collection's `concept_id`.This id is the most relevant search field on granule queries.
Returns:
A collection's `concept_id`.This id is the most relevant search field on granule queries.
"""
return self["meta"]["concept-id"]

def data_type(self) -> str:
"""Placeholder.
Returns: The collection data type, i.e. HDF5, CSV etc., if available.
Returns:
The collection data type, i.e. HDF5, CSV etc., if available.
"""
if "ArchiveAndDistributionInformation" in self["umm"]:
return str(
Expand All @@ -129,7 +131,8 @@ def data_type(self) -> str:
def version(self) -> str:
"""Placeholder.
Returns: The collection's version.
Returns:
The collection's version.
"""
if "Version" in self["umm"]:
return self["umm"]["Version"]
Expand All @@ -138,7 +141,8 @@ def version(self) -> str:
def abstract(self) -> str:
"""Placeholder.
Returns:The abstract of a collection.
Returns:
The abstract of a collection.
"""
if "Abstract" in self["umm"]:
return self["umm"]["Abstract"]
Expand All @@ -147,7 +151,8 @@ def abstract(self) -> str:
def landing_page(self) -> str:
"""Placeholder.
Returns: The first landing page for the collection (can be many), if available.
Returns:
The first landing page for the collection (can be many), if available.
"""
links = self._filter_related_links("LANDING PAGE")
if len(links) > 0:
Expand All @@ -157,15 +162,17 @@ def landing_page(self) -> str:
def get_data(self) -> List[str]:
"""Placeholder.
Returns: The GET DATA links (usually a landing page link, a DAAC portal, or an FTP location).
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

def s3_bucket(self) -> Dict[str, Any]:
"""Placeholder.
Returns: The S3 bucket information if the collection has it.(**cloud hosted collections only**).
Returns:
The S3 bucket information if the collection has it (**cloud hosted collections only**).
"""
if "DirectDistributionInformation" in self["umm"]:
return self["umm"]["DirectDistributionInformation"]
Expand Down Expand Up @@ -215,7 +222,8 @@ def __init__(
def __repr__(self) -> str:
"""Placeholder.
Returns: A basic representation of a data granule.
Returns:
A basic representation of a data granule.
"""
data_links = [link for link in self.data_links()]
rep_str = f"""
Expand All @@ -230,7 +238,8 @@ def __repr__(self) -> str:
def _repr_html_(self) -> str:
"""Placeholder.
Returns: A rich representation for a data granule if we are in a Jupyter notebook.
Returns:
A rich representation for a data granule if we are in a Jupyter notebook.
"""
granule_html_repr = _repr_granule_html(self)
return granule_html_repr
Expand All @@ -244,7 +253,8 @@ def get_s3_credentials_endpoint(self) -> Union[str, None]:
def size(self) -> float:
"""Placeholder.
Returns: The total size for the granule in MB.
Returns:
The total size for the granule in MB.
"""
try:
data_granule = self["umm"]["DataGranule"]
Expand Down Expand Up @@ -328,7 +338,8 @@ def data_links(
def dataviz_links(self) -> List[str]:
"""Placeholder.
Returns: The data visualization links, usually the browse images.
Returns:
The data visualization links, usually the browse images.
"""
links = self._filter_related_links("GET RELATED VISUALIZATION")
return links
2 changes: 1 addition & 1 deletion earthaccess/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get_results(

class DataCollections(CollectionQuery):
"""Placeholder.
???+ Info
The DataCollection class queries against
https://cmr.earthdata.nasa.gov/search/collections.umm_json,
Expand Down

0 comments on commit 7cc9bbb

Please sign in to comment.