From 94febbd2595c3f17c199fd8157e255dbfa0af9d0 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 28 Feb 2024 14:35:15 -0900 Subject: [PATCH 1/3] adds nisar dataset, platform, and product type --- asf_search/CMR/datasets.py | 132 +++++++++++++++++++++++--- asf_search/Products/NISARProduct.py | 69 ++++++++++++++ asf_search/Products/__init__.py | 1 + asf_search/search/search_generator.py | 4 +- 4 files changed, 191 insertions(+), 15 deletions(-) create mode 100644 asf_search/Products/NISARProduct.py diff --git a/asf_search/CMR/datasets.py b/asf_search/CMR/datasets.py index 15569e32..cad194c5 100644 --- a/asf_search/CMR/datasets.py +++ b/asf_search/CMR/datasets.py @@ -2,6 +2,46 @@ dataset_collections = { + "NISAR": { + "NISAR_UR_L0B_RRSD": ["C1258125097-ASFDEV", "C1258836794-ASF"], + "NISAR_UR_L1": ["C1258290319-ASFDEV", "C1258836797-ASF", "C1258290319-ASF"], + "NISAR_UR_L2": ["C1258301530-ASFDEV", "C1258836800-ASF"], + "NISAR_STUF": ["C1256535568-ASFDEV", "C1257349089-ASF", "C2727913056-ASF"], + "NISAR_OE": ["C1256574227-ASFDEV", "C1257349088-ASF", "C2727908375-ASF"], + "NISAR_RP": ["C1256579794-ASFDEV", "C1257349083-ASF", "C2727912431-ASF"], + "NISAR_COP": ["C1256535570-ASFDEV", "C1257349082-ASF", "C2727904608-ASF"], + "NISAR_ANTPAT": ["C1256583888-ASFDEV", "C1257349081-ASF", "C2727903976-ASF"], + "NISAR_BFPQ": ["C1257088418-ASFDEV", "C1257349079-ASF", "C2727904134-ASF"], + "NISAR_OROST": ["C1256578011-ASFDEV", "C1257349074-ASF", "C2727911748-ASF"], + "NISAR_TFDB": ["C1256583659-ASFDEV", "C1257349073-ASF", "C2727913362-ASF"], + "NISAR_LDF": ["C1256737727-ASFDEV", "C1257349072-ASF", "C2727907155-ASF"], + "NISAR_LRCLK": ["C1256729502-ASFDEV", "C1257349067-ASF", "C2727907520-ASF"], + "NISAR_L_CHAN_DATA": [ + "C1256832018-ASFDEV", + "C1257349066-ASF", + "C2727908129-ASF", + ], + "NISAR_SM_STATIC": ["C1256944038-ASFDEV", "C1257349065-ASF", "C2727912739-ASF"], + "NISAR_TEC": ["C1256802323-ASFDEV", "C1257349063-ASF", "C2727913160-ASF"], + "NISAR_DC_RADAR": ["C1256938783-ASFDEV", "C1257349059-ASF", "C2727904769-ASF"], + "NISAR_FT_WAVEFORM": [ + "C1256621478-ASFDEV", + "C1257349054-ASF", + "C2727905298-ASF", + ], + "NISAR_FT_PARAM": ["C1256622937-ASFDEV", "C1257349053-ASF", "C2727905020-ASF"], + "NISAR_LSAR_EXT_CAL": [ + "C1256983900-ASFDEV", + "C1257349048-ASF", + "C2727904288-ASF", + ], + "NISAR_LSAR_INT_CAL": [ + "C1256984645-ASFDEV", + "C1257349023-ASF", + "C2727907902-ASF", + ], + "NISAR_ANC_AUX": ["C1261630276-ASFDEV"], + }, "SENTINEL-1": { "SENTINEL-1A_SLC": ["C1214470488-ASF", "C1205428742-ASF", "C1234413245-ASFDEV"], "SENTINEL-1B_SLC": ["C1327985661-ASF", "C1216244348-ASF", "C1234413263-ASFDEV"], @@ -230,7 +270,7 @@ "SENTINEL-1_INTERFEROGRAMS_UNWRAPPED_PHASE": [ "C1595765183-ASF", "C1225776659-ASF", - ] + ], }, "SMAP": { "SPL1A_RO_METADATA_003": ["C1243122884-ASF", "C1233103964-ASF"], @@ -735,6 +775,72 @@ "C1210599503-ASF", "C1210599673-ASF", ], + "NISAR": [ # TEST ASFDEV + "C1258125097-ASFDEV", + "C1258290319-ASFDEV", + "C1258301530-ASFDEV", + "C1256535568-ASFDEV", + "C1256574227-ASFDEV", + "C1256579794-ASFDEV", + "C1256535570-ASFDEV", + "C1256583888-ASFDEV", + "C1257088418-ASFDEV", + "C1256578011-ASFDEV", + "C1256583659-ASFDEV", + "C1256737727-ASFDEV", + "C1256729502-ASFDEV", + "C1256832018-ASFDEV", + "C1256944038-ASFDEV", + "C1256802323-ASFDEV", + "C1256938783-ASFDEV", + "C1256621478-ASFDEV", + "C1256622937-ASFDEV", + "C1256983900-ASFDEV", + "C1256984645-ASFDEV", + "C1261630276-ASFDEV", + "C1258290319-ASFDEV", + # TEST + "C1258836794-ASF", + "C1258836797-ASF", + "C1258836800-ASF", + "C1257349089-ASF", + "C1257349088-ASF", + "C1257349083-ASF", + "C1257349082-ASF", + "C1257349081-ASF", + "C1257349079-ASF", + "C1257349074-ASF", + "C1257349073-ASF", + "C1257349072-ASF", + "C1257349067-ASF", + "C1257349066-ASF", + "C1257349065-ASF", + "C1257349063-ASF", + "C1257349059-ASF", + "C1257349054-ASF", + "C1257349053-ASF", + "C1257349048-ASF", + "C1257349023-ASF", + # PROD + "C2727913056-ASF", + "C2727908375-ASF", + "C2727912431-ASF", + "C2727904608-ASF", + "C2727903976-ASF", + "C2727904134-ASF", + "C2727911748-ASF", + "C2727913362-ASF", + "C2727907155-ASF", + "C2727907520-ASF", + "C2727908129-ASF", + "C2727912739-ASF", + "C2727913160-ASF", + "C2727904769-ASF", + "C2727905298-ASF", + "C2727905020-ASF", + "C2727904288-ASF", + "C2727907902-ASF", + ], } @@ -896,14 +1002,8 @@ "C1595765183-ASF", "C1225776659-ASF", ], - "CSLC-STATIC": [ - "C1259982010-ASF", - "C2795135668-ASF" - ], - "RTC-STATIC": [ - "C1259981910-ASF", - "C2795135174-ASF" - ], + "CSLC-STATIC": ["C1259982010-ASF", "C2795135668-ASF"], + "RTC-STATIC": ["C1259981910-ASF", "C2795135174-ASF"], "GRD": [ "C1661710583-ASF", "C1661710586-ASF", @@ -1077,13 +1177,14 @@ #################### Helper Methods #################### + def get_concept_id_alias(param_list: List[str], collections_dict: dict) -> List[str]: """ param: param_list (List[str]): list of search values to alias param: collections_dict (dict): The search value to concept-id dictionary to read from returns List[str]: Returns a list of concept-ids that correspond to the given list of search values - If any of the search values are not keys in the collections_dict, this will instead returns an empty list. + If any of the search values are not keys in the collections_dict, this will instead returns an empty list. """ concept_id_aliases = [] for param in param_list: @@ -1091,9 +1192,10 @@ def get_concept_id_alias(param_list: List[str], collections_dict: dict) -> List[ concept_id_aliases.extend(alias) else: return [] - + return concept_id_aliases + def get_dataset_concept_ids(datasets: List[str]) -> List[str]: """ Returns concept-ids for provided dataset(s) @@ -1108,6 +1210,8 @@ def get_dataset_concept_ids(datasets: List[str]) -> List[str]: for concept_ids in collections_by_short_name.values(): output.extend(concept_ids) else: - raise ValueError(f'Could not find dataset named "{dataset}" provided for dataset keyword.') - - return output \ No newline at end of file + raise ValueError( + f'Could not find dataset named "{dataset}" provided for dataset keyword.' + ) + + return output diff --git a/asf_search/Products/NISARProduct.py b/asf_search/Products/NISARProduct.py new file mode 100644 index 00000000..b18ccb92 --- /dev/null +++ b/asf_search/Products/NISARProduct.py @@ -0,0 +1,69 @@ +from typing import Dict, Union +from asf_search import ASFSearchOptions, ASFSession, ASFStackableProduct +from asf_search.CMR.translate import try_parse_float, try_parse_int, try_round_float +from asf_search.constants import PRODUCT_TYPE + + +class NISARProduct(ASFStackableProduct): + """ + Used for NISAR dataset products + + ASF Dataset Documentation Page: https://asf.alaska.edu/nisar/ + """ + _base_properties = { + 'pgeVersion': {'path': ['PGEVersionClass', 'PGEVersion']} + } + + def __init__(self, args: Dict = {}, session: ASFSession = ASFSession()): + super().__init__(args, session) + + accessUrls = [] + + if related_data_urls := self.umm_get(self.umm, 'RelatedUrls', ('Type', [('GET DATA', 'URL')]), 0): + accessUrls.extend(related_data_urls) + if related_metadata_urls := self.umm_get(self.umm, 'RelatedUrls', ('Type', [('EXTENDED METADATA', 'URL')]), 0): + accessUrls.extend(related_metadata_urls) + + self.properties['additionalUrls'] = sorted([ + url for url in list(set(accessUrls)) if not url.endswith('.md5') + and not url.startswith('s3://') + and 's3credentials' not in url + and not url.endswith('.png') + and url != self.properties['url'] + ]) + + if self.properties.get('groupID') is None: + self.properties['groupID'] = self.properties['sceneName'] + + @staticmethod + def get_default_baseline_product_type() -> Union[str, None]: + """ + Returns the product type to search for when building a baseline stack. + """ + return None + + def is_valid_reference(self): + return False + + def get_stack_opts(self, opts: ASFSearchOptions = None) -> ASFSearchOptions: + """ + Build search options that can be used to find an insar stack for this product + + :return: ASFSearchOptions describing appropriate options for building a stack from this product + """ + return None + + @staticmethod + def get_property_paths() -> Dict: + return { + **ASFStackableProduct.get_property_paths(), + **NISARProduct._base_properties + } + + def get_sort_keys(self): + keys = super().get_sort_keys() + + if keys[0] is None: + return (self.properties.get('processingDate', ''), keys[1]) + + return keys diff --git a/asf_search/Products/__init__.py b/asf_search/Products/__init__.py index dbdad6fe..7317c7cd 100644 --- a/asf_search/Products/__init__.py +++ b/asf_search/Products/__init__.py @@ -11,3 +11,4 @@ from .S1BurstProduct import S1BurstProduct from .OPERAS1Product import OPERAS1Product from .ARIAS1GUNWProduct import ARIAS1GUNWProduct +from .NISARProduct import NISARProduct \ No newline at end of file diff --git a/asf_search/search/search_generator.py b/asf_search/search/search_generator.py index 090182db..75e8a751 100644 --- a/asf_search/search/search_generator.py +++ b/asf_search/search/search_generator.py @@ -315,5 +315,7 @@ def _get_product_type_key(item: Dict) -> str: 'DC-8': ASFProductType.AIRSARProduct, 'SEASAT': ASFProductType.SEASATProduct, - 'SEASAT 1': ASFProductType.SEASATProduct + 'SEASAT 1': ASFProductType.SEASATProduct, + + 'NISAR': ASFProductType.NISARProduct } From a180edca4e4e85d7e13ff292fd5075743a7fb1dc Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 28 Feb 2024 14:35:58 -0900 Subject: [PATCH 2/3] adds nisar platform and dataset constants --- asf_search/constants/DATASET.py | 3 ++- asf_search/constants/PLATFORM.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/asf_search/constants/DATASET.py b/asf_search/constants/DATASET.py index 902210a6..fb705b95 100644 --- a/asf_search/constants/DATASET.py +++ b/asf_search/constants/DATASET.py @@ -12,4 +12,5 @@ ERS = 'ERS' JERS_1 = 'JERS-1' AIRSAR = 'AIRSAR' -SEASAT = 'SEASAT' \ No newline at end of file +SEASAT = 'SEASAT' +NISAR = 'NISAR' diff --git a/asf_search/constants/PLATFORM.py b/asf_search/constants/PLATFORM.py index 350933fb..fab0e644 100644 --- a/asf_search/constants/PLATFORM.py +++ b/asf_search/constants/PLATFORM.py @@ -12,3 +12,4 @@ SEASAT = 'SEASAT 1' SMAP = 'SMAP' UAVSAR = 'UAVSAR' +NISAR = 'NISAR' From aaf673fdb59ab495f6ad2d7779d261959a480eaa Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 28 Feb 2024 16:09:39 -0900 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4526737..53c72247 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,11 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - --> +------ +## [v7.0.5](https://github.com/asfadmin/Discovery-asf_search/compare/v7.0.4...v7.0.5) +### Added +- Adds basic NISAR dataset search and product functionality for test data + ------ ## [v7.0.4](https://github.com/asfadmin/Discovery-asf_search/compare/v7.0.3...v7.0.4) ### Changed