1515from .asf_opts import process_baseline_request , process_search_request , process_wkt_request
1616from .health import get_cmr_health
1717from .models import BaselineSearchOptsModel , SearchOptsModel
18- from .output import as_output , get_asf_search_script , make_filename
18+ from .output import as_output , get_asf_search_script
1919from .files_to_wkt import FilesToWKT
2020from . import constants
2121from .SearchAPISession import SearchAPISession
22- from .search import get_aria_groups_for_frame , stack_aria_gunw
23- import time
2422from asf_search .ASFSearchOptions .config import config as asf_config
2523
2624asf_config ['session' ] = SearchAPISession ()
@@ -98,19 +96,8 @@ async def query_baseline(searchOptions: BaselineSearchOptsModel = Depends(proces
9896 reference = searchOptions .reference
9997 request_method = searchOptions .request_method
10098
101- if searchOptions .opts .dataset is not None :
102- if searchOptions .opts .dataset [0 ] == asf .DATASET .ARIA_S1_GUNW :
103- if output .lower () == 'count' :
104- return Response (
105- content = str (len (get_aria_groups_for_frame (reference )[1 ])),
106- status_code = 200 ,
107- media_type = 'text/html; charset=utf-8' ,
108- headers = constants .DEFAULT_HEADERS
109- )
110-
111- stack = stack_aria_gunw (reference )
112- response_info = as_output (stack , output = output )
113- return Response (** response_info )
99+ is_frame_based = searchOptions .opts .dataset is not None
100+
114101 # Load the reference scene:
115102
116103 if output .lower () == 'python' :
@@ -125,15 +112,24 @@ async def query_baseline(searchOptions: BaselineSearchOptsModel = Depends(proces
125112 'Content-Disposition' : f"attachment; filename={ file_name } " ,
126113 }
127114 )
128- try :
129- reference_product = asf .granule_search (granule_list = [reference ], opts = opts )[0 ]
130- except (KeyError , IndexError , ValueError ) as exc :
131- raise HTTPException (detail = f"Reference scene not found: { reference } " , status_code = 400 ) from exc
115+
116+ # reference_product = None
117+ if is_frame_based and opts .dataset [0 ] == asf .DATASET .ARIA_S1_GUNW :
118+ try :
119+ reference_product = asf .search (frame = int (reference ), opts = opts , maxResults = 1 )[0 ]
120+ except (KeyError , IndexError , ValueError ) as exc :
121+ raise HTTPException (detail = f"Reference scene not found with frame: { reference } " , status_code = 400 ) from exc
122+
123+ else :
124+ try :
125+ reference_product = asf .granule_search (granule_list = [reference ], opts = opts )[0 ]
126+ except (KeyError , IndexError , ValueError ) as exc :
127+ raise HTTPException (detail = f"Reference scene not found: { reference } " , status_code = 400 ) from exc
132128
133129 try :
134130 if reference_product .get_stack_opts () is None :
135131 reference_product = asf .ASFStackableProduct (args = {'umm' : reference_product .umm , 'meta' : reference_product .meta }, session = reference_product .session )
136- if not reference_product .has_baseline () or not reference_product .is_valid_reference ():
132+ if ( not reference_product .has_baseline () or not reference_product .is_valid_reference () or not reference_product . has_baseline ()) and not is_frame_based :
137133 raise asf .exceptions .ASFBaselineError (f"Requested reference scene has no baseline" )
138134 except (asf .exceptions .ASFBaselineError , ValueError ) as exc :
139135 raise HTTPException (detail = f"Search failed to find results: { exc } " , status_code = 400 )
0 commit comments