diff --git a/CHANGELOG.md b/CHANGELOG.md index 3670a95..5920a8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,14 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - --> +------ +## [1.0.9](https://github.com/asfadmin/Discovery-SearchAPI-v3/compare/v1.0.8...v1.0.9) +### Fixed +- Fixed bug with ARIA-S1 GUNW stacking over areas without pre-existing ARIA-S1-Frames + +### Changed +- bump asf-search to v10.1.2 (Sentinel-1C in ARIA stacking, NISAR L0B science product aliasing) + ------ ## [1.0.8](https://github.com/asfadmin/Discovery-SearchAPI-v3/compare/v1.0.7...v1.0.8) ### Changed diff --git a/requirements.txt b/requirements.txt index de9c4c4..7352056 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,7 +22,7 @@ ujson==5.7.0 uvicorn==0.21.1 watchfiles==0.19.0 -asf-search[asf-enumeration]==10.1.1 +asf-search[asf-enumeration]==10.1.2 python-json-logger==2.0.7 pyshp==2.1.3 diff --git a/src/SearchAPI/application/application.py b/src/SearchAPI/application/application.py index 825924d..a29fbac 100644 --- a/src/SearchAPI/application/application.py +++ b/src/SearchAPI/application/application.py @@ -1,3 +1,4 @@ +from copy import copy import json import os @@ -19,6 +20,7 @@ from . import constants from .SearchAPISession import SearchAPISession from asf_search.ASFSearchOptions.config import config as asf_config +from asf_enumeration import aria_s1_gunw asf_config['session'] = SearchAPISession() @@ -115,18 +117,13 @@ async def query_baseline(searchOptions: BaselineSearchOptsModel = Depends(proces } ) - # reference_product = None if is_frame_based and opts.dataset[0] == asf.DATASET.ARIA_S1_GUNW: - try: - reference_product = asf.search(frame=int(reference), opts=opts, maxResults=1)[0] - except (KeyError, IndexError, ValueError) as exc: - raise HTTPException(detail=f"Reference scene not found with frame: {reference}", status_code=400) from exc + return _get_aria_baseline_stack(reference=reference, opts=opts, output=output) - else: - try: - reference_product = asf.granule_search(granule_list=[reference], opts=opts)[0] - except (KeyError, IndexError, ValueError) as exc: - raise HTTPException(detail=f"Reference scene not found: {reference}", status_code=400) from exc + try: + reference_product = asf.granule_search(granule_list=[reference], opts=opts)[0] + except (KeyError, IndexError, ValueError) as exc: + raise HTTPException(detail=f"Reference scene not found: {reference}", status_code=400) from exc try: if reference_product.get_stack_opts() is None: @@ -270,6 +267,23 @@ def validate_wkt(wkt: str): 'repairs': repairs } +def _get_aria_baseline_stack(reference: str, opts: asf.ASFSearchOptions, output: str): + if output.lower() == 'count': + stack_opts = asf.Products.ARIAS1GUNWProduct.get_stack_opts_for_frame(int(reference), opts=opts) + count=asf.search_count(opts=stack_opts) + return Response( + content=str(count), + status_code=200, + media_type='text/html; charset=utf-8', + headers=constants.DEFAULT_HEADERS + ) + try: + stack = asf.stack_from_id(reference, opts=opts) + response_info = as_output(stack, output) + return Response(**response_info) + except (KeyError, IndexError, ValueError) as exc: + raise HTTPException(detail=f"Reference scene not found with frame: {reference}", status_code=400) from exc + @router.get('/', response_class=JSONResponse) @router.get('/health', response_class=JSONResponse)