11import datetime as dt
2+ from functools import cached_property
23import pprint
34from typing import Optional , Union , cast
45
@@ -735,10 +736,11 @@ def order_vars(self) -> Variables:
735736
736737 return self ._order_vars
737738
738- @property
739+ @cached_property
739740 def granules (self ) -> Granules :
740741 """
741- Return the granules object, which provides the underlying functionality for searching, ordering,
742+ Return the granules object, which provides the underlying functionality
743+ hing, ordering,
742744 and downloading granules for the specified product.
743745 Users are encouraged to use the built-in wrappers
744746 rather than trying to access the granules object themselves.
@@ -752,15 +754,13 @@ def granules(self) -> Granules:
752754
753755 Examples
754756 --------
755- >>> reg_a = ipx.Query('ATL06',[-55, 68, -48, 71],['2019-02-20','2019-02-28']) # doctest: +SKIP
757+ >>> reg_a = ipx.Query('ATL06',[-55, 68, -48,
758+ 71],['2019-02-20','2019-02-28']) #
759+ +SKIP
756760 >>> reg_a.granules # doctest: +SKIP
757761 <icepyx.core.granules.Granules at [location]>
758762 """
759-
760- if not hasattr (self , "_granules" ) or self ._granules is None :
761- self ._granules = Granules ()
762-
763- return self ._granules
763+ return Granules ()
764764
765765 # ----------------------------------------------------------------------
766766 # Methods - Get and display neatly information at the product level
@@ -948,8 +948,6 @@ def avail_granules(
948948 """
949949
950950 # REFACTOR: add test to make sure there's a session
951- if not hasattr (self , "_granules" ):
952- self .granules
953951 try :
954952 self .granules .avail
955953 except AttributeError :
@@ -1044,8 +1042,6 @@ def order_granules(
10441042
10451043 # REFACTOR: add checks here to see if the granules object has been created,
10461044 # and also if it already has a list of avail granules (if not, need to create one and add session)
1047- if not hasattr (self , "_granules" ):
1048- self .granules
10491045
10501046 # Place multiple orders, one per granule, if readable_granule_name is used.
10511047 if "readable_granule_name[]" in self .CMRparams :
@@ -1057,7 +1053,7 @@ def order_granules(
10571053 )
10581054 for gran in gran_name_list :
10591055 tempCMRparams ["readable_granule_name[]" ] = gran
1060- self ._granules .place_order (
1056+ self .granules .place_order (
10611057 tempCMRparams ,
10621058 cast (EGIRequiredParamsDownload , self .reqparams ),
10631059 self .subsetparams (** kwargs ),
@@ -1067,7 +1063,7 @@ def order_granules(
10671063 )
10681064
10691065 else :
1070- self ._granules .place_order (
1066+ self .granules .place_order (
10711067 self .CMRparams ,
10721068 cast (EGIRequiredParamsDownload , self .reqparams ),
10731069 self .subsetparams (** kwargs ),
@@ -1130,19 +1126,16 @@ def download_granules(
11301126 # os.mkdir(path)
11311127 # os.chdir(path)
11321128
1133- if not hasattr (self , "_granules" ):
1134- self .granules
1135-
11361129 if restart is True :
11371130 pass
11381131 else :
11391132 if (
1140- not hasattr (self ._granules , "orderIDs" )
1141- or len (self ._granules .orderIDs ) == 0
1133+ not hasattr (self .granules , "orderIDs" )
1134+ or len (self .granules .orderIDs ) == 0
11421135 ):
11431136 self .order_granules (verbose = verbose , subset = subset , ** kwargs )
11441137
1145- self ._granules .download (verbose , path , restart = restart )
1138+ self .granules .download (verbose , path , restart = restart )
11461139
11471140 # DevGoal: add testing? What do we test, and how, given this is a visualization.
11481141 # DevGoal(long term): modify this to accept additional inputs, etc.
0 commit comments