Skip to content

Commit 0da719f

Browse files
committed
WIP remove granules.place_order in favor of granules.place_harmon_subset_order
separate concerns
1 parent 2cacbd7 commit 0da719f

File tree

2 files changed

+39
-59
lines changed

2 files changed

+39
-59
lines changed

icepyx/core/granules.py

Lines changed: 34 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,37 @@ def get_avail(
283283
len(self.avail) > 0
284284
), "Your search returned no results; try different search parameters"
285285

286-
def _place_harmony_subset_order(
286+
def place_harmony_subset_order(
287287
self,
288-
request_params,
288+
# TODO: remove `CMRparams` from this function. This should only take subset params.
289+
CMRparams,
289290
subsetparams,
291+
# TODO: support passing in a geometry filepath
292+
geom_filepath=None,
290293
) -> list[str]:
294+
"""
295+
Place a harmony subset order.
296+
297+
Parameters
298+
----------
299+
CMRparams :
300+
Dictionary of properly formatted CMR search parameters.
301+
subsetparams : dictionary
302+
Dictionary of properly formatted subsetting parameters. An empty dictionary
303+
is passed as input here when subsetting is set to False in query methods.
304+
geom_filepath : string, default None
305+
String of the full filename and path when the spatial input is a file.
306+
307+
Notes
308+
-----
309+
This function is used by query.Query.order_granules(), which automatically
310+
feeds in the required parameters.
311+
312+
See Also
313+
--------
314+
query.Query.order_granules
315+
"""
316+
request_params = apifmt.combine_params(CMRparams, subsetparams)
291317
concept_id = get_concept_id(
292318
product=request_params["short_name"],
293319
version=request_params["version"],
@@ -347,55 +373,20 @@ def _place_harmony_subset_order(
347373

348374
return self.orderIDs
349375

350-
def _place_non_subset_order(
376+
def place_non_subset_order(
351377
self,
352378
CMRparams: CMRParams,
353-
):
354-
# TODO: use e.g., `earthaccess` to download files un-processed by harmony.
355-
raise NotImplementedError("Support for non-subset orders is not implemented.")
356-
self.get_avail(CMRparams)
357-
request_params = apifmt.combine_params(CMRparams, {"agent": "NO"})
358-
359-
# DevNote: currently, default subsetting DOES NOT include variable subsetting,
360-
# only spatial and temporal
361-
# DevGoal: add kwargs to allow subsetting and more control over request options.
362-
def place_order(
363-
self,
364-
CMRparams: CMRParams,
365-
subsetparams,
366-
verbose,
367-
subset=True,
368-
geom_filepath=None,
369379
):
370380
"""
371-
Place an order for the available granules for the query object.
372-
Adds the list of zipped files (orders) to the granules data object (which is
373-
stored as the `granules` attribute of the query object).
374-
You must be logged in to Earthdata to use this function.
381+
Place an order for data files with `earthaccess`.
375382
376383
Parameters
377384
----------
378385
CMRparams :
379386
Dictionary of properly formatted CMR search parameters.
380-
reqparams :
381-
Dictionary of properly formatted parameters required for searching, ordering,
382-
or downloading from NSASA (via harmony).
383387
subsetparams : dictionary
384388
Dictionary of properly formatted subsetting parameters. An empty dictionary
385389
is passed as input here when subsetting is set to False in query methods.
386-
verbose : boolean, default False
387-
Print out all feedback available from the order process.
388-
Progress information is automatically printed regardless of the value of verbose.
389-
subset : boolean, default True
390-
Apply subsetting to the data order from the NSIDC, returning only data that meets the
391-
subset parameters.
392-
Spatial and temporal subsetting based on the input parameters happens
393-
by default when subset=True, but additional subsetting options are available.
394-
Spatial subsetting returns all data that are within the area of interest
395-
(but not complete granules.
396-
This eliminates false-positive granules returned by the metadata-level search)
397-
geom_filepath : string, default None
398-
String of the full filename and path when the spatial input is a file.
399390
400391
Notes
401392
-----
@@ -406,17 +397,10 @@ def place_order(
406397
--------
407398
query.Query.order_granules
408399
"""
409-
if subset is False:
410-
self._place_non_subset_order(CMRparams)
411-
else:
412-
# TODO: why are we combining these like this? We could just pass in
413-
# these values separately. Eventually would like to collapse this
414-
# down into just one `HarmonySubsetParams`.
415-
request_params = apifmt.combine_params(CMRparams, subsetparams)
416-
return self._place_harmony_subset_order(
417-
request_params,
418-
subsetparams,
419-
)
400+
# TODO: use e.g., `earthaccess` to download files un-processed by harmony.
401+
raise NotImplementedError("Support for non-subset orders is not implemented.")
402+
self.get_avail(CMRparams)
403+
request_params = apifmt.combine_params(CMRparams, {"agent": "NO"})
420404

421405
def download(self, verbose, path, restart=False):
422406
"""

icepyx/core/query.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ def order_granules(
10161016
Print out all feedback available from the order process.
10171017
Progress information is automatically printed regardless of the value of verbose.
10181018
subset :
1019-
Apply subsetting to the data order from the NSIDC, returning only data that meets the
1019+
Apply subsetting to the data order from Harmony, returning only data that meets the
10201020
subset parameters. Spatial and temporal subsetting based on the input parameters happens
10211021
by default when subset=True, but additional subsetting options are available.
10221022
Spatial subsetting returns all data that are within the area of interest (but not complete
@@ -1048,8 +1048,8 @@ def order_granules(
10481048
.
10491049
Retry request status is: complete
10501050
"""
1051-
# breakpoint()
1052-
# raise RefactoringException
1051+
if not subset:
1052+
raise NotImplementedError
10531053

10541054
# This call ensures that `self._cmr_reqparams` is set.
10551055
self.cmr_reqparams
@@ -1097,20 +1097,16 @@ def order_granules(
10971097
)
10981098
for gran in gran_name_list:
10991099
tempCMRparams["readable_granule_name[]"] = gran
1100-
self.granules.place_order(
1100+
self.granules.place_subset_order(
11011101
tempCMRparams,
11021102
self.subsetparams(granule_name=gran, **kwargs),
1103-
verbose,
1104-
subset,
11051103
geom_filepath=self._spatial._geom_file,
11061104
)
11071105

11081106
else:
1109-
self.granules.place_order(
1107+
self.granules.place_subset_order(
11101108
cmr_params,
11111109
self.subsetparams(**kwargs),
1112-
verbose,
1113-
subset,
11141110
geom_filepath=self._spatial._geom_file,
11151111
)
11161112

0 commit comments

Comments
 (0)