File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,7 @@ class DataGranule(CustomDict):
211211 "TemporalExtent" ,
212212 "RelatedUrls" ,
213213 "DataGranule" ,
214+ "GranuleUR" ,
214215 ]
215216
216217 def __init__ (
@@ -356,3 +357,12 @@ def dataviz_links(self) -> List[str]:
356357 """
357358 links = self ._filter_related_links ("GET RELATED VISUALIZATION" )
358359 return links
360+
361+ def granule_ID (self ) -> str :
362+ """Get the granule ID
363+
364+ Returns:
365+ str: Granule ID
366+ """
367+
368+ return self ['umm' ]['GranuleUR' ]
Original file line number Diff line number Diff line change @@ -954,6 +954,20 @@ def granules(self, value: list):
954954 def granules (self ):
955955 del self ._granules
956956
957+ @property
958+ def granule_ids (self ) -> list [str ]:
959+ """List of granule IDs for each granule in results
960+
961+ Returns:
962+ list: Granule ID for each granule in results
963+ """
964+
965+ gran_ids = []
966+ for gran in self .granules :
967+ gran_ids .append (gran .granule_ID ())
968+
969+ return gran_ids
970+
957971 def __iter__ (self ):
958972 return iter (self .granules )
959973
@@ -979,9 +993,16 @@ def __eq__(self, other: 'DataGranules'):
979993 return self .graunles == other .granules
980994
981995 # TODO: display methods
982- def __repr__ (self ):
996+ def __repr__ (self ) -> str :
983997
984998 if (count := len (self )) > 0 :
985999 return f'DataGranules().parameters({ self .params } ).load({ count } )'
9861000
9871001 return f'DataGranules().parameters({ self .params } )'
1002+
1003+ def __str__ (self ) -> str :
1004+
1005+ return "Granule Count: {0} \n Granule IDs: {1}" .format (
1006+ len (self ),
1007+ self .granule_ids ,
1008+ )
You can’t perform that action at this time.
0 commit comments