Skip to content

Commit

Permalink
changes _properties_paths back to _base_properties
Browse files Browse the repository at this point in the history
  • Loading branch information
kim committed Aug 2, 2024
1 parent abcbc0d commit fde4224
Show file tree
Hide file tree
Showing 18 changed files with 66 additions and 55 deletions.
17 changes: 2 additions & 15 deletions asf_search/ASFProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ASFProduct:
def get_classname(cls):
return cls.__name__

_properties_paths = {
_base_properties = {
# min viable product
'centerLat': {'path': ['AdditionalAttributes', ('Name', 'CENTER_LAT'), 'Values', 0], 'cast': try_parse_float},
'centerLon': {'path': ['AdditionalAttributes', ('Name', 'CENTER_LON'), 'Values', 0], 'cast': try_parse_float},
Expand All @@ -67,7 +67,7 @@ def get_classname(cls):
'sensor': {'path': [ 'Platforms', 0, 'Instruments', 0, 'ShortName'], },
}
"""
_properties_paths dictionary, mapping readable property names to paths and optional type casting
_base_properties dictionary, mapping readable property names to paths and optional type casting
entries are organized as such:
- `PROPERTY_NAME`: The name the property should be called in `ASFProduct.properties`
Expand Down Expand Up @@ -282,19 +282,6 @@ def translate_product(self, item: Dict) -> Dict:

return {'geometry': geometry, 'properties': properties, 'type': 'Feature'}

# ASFProduct subclasses define extra/override param key + UMM pathing here
@staticmethod
def get_property_paths() -> Dict:
"""
Returns _base_properties of class, subclasses such as `S1Product` (or user provided subclasses) can override this to
define which properties they want in their subclass's properties dict.
(See `S1Product.get_property_paths()` for example of combining _base_properties of multiple classes)
:returns dictionary, {`PROPERTY_NAME`: {'path': [umm, path, to, value], 'cast (optional)': Callable_to_cast_value}, ...}
"""
return ASFProduct._base_properties

def get_sort_keys(self) -> Tuple[str, str]:
"""
Returns tuple of primary and secondary date values used for sorting final search results
Expand Down
22 changes: 0 additions & 22 deletions asf_search/CMR/subquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,28 +137,6 @@ def format_query_params(params) -> List[List[dict]]:


def translate_param(param_name, param_val) -> List[dict]:
# param_list = []

# cmr_input_map = field_map

# param_input_map = cmr_input_map[param_name]
# cmr_param = param_input_map['key']
# cmr_format_str = param_input_map['fmt']

# if not isinstance(param_val, list):
# param_val = [param_val]

# for l in param_val:
# format_val = l

# if isinstance(l, list):
# format_val = ','.join([f'{t}' for t in l])

# param_list.append({
# cmr_param: cmr_format_str.format(format_val)
# })

# return param_list
param_list = []

if not isinstance(param_val, list):
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/AIRSARProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AIRSARProduct(ASFProduct):
"""
ASF Dataset Overview Page: https://asf.alaska.edu/data-sets/sar-data-sets/airsar/
"""
_properties_paths = {
_base_properties = {
**ASFProduct._properties_paths,
'frameNumber': {'path': ['AdditionalAttributes', ('Name', 'CENTER_ESA_FRAME'), 'Values', 0], 'cast': try_parse_int},
'groupID': {'path': [ 'AdditionalAttributes', ('Name', 'GROUP_ID'), 'Values', 0]},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/ALOSProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ALOSProduct(ASFStackableProduct):
ASF Dataset Documentation Page: https://asf.alaska.edu/datasets/daac/alos-palsar/
"""
_properties_paths = {
_base_properties = {
**ASFStackableProduct._properties_paths,
'frameNumber': {'path': ['AdditionalAttributes', ('Name', 'FRAME_NUMBER'), 'Values', 0], 'cast': try_parse_int},
'faradayRotation': {'path': ['AdditionalAttributes', ('Name', 'FARADAY_ROTATION'), 'Values', 0], 'cast': try_parse_float},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/ARIAS1GUNWProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ARIAS1GUNWProduct(S1Product):
ASF Dataset Documentation Page: https://asf.alaska.edu/data-sets/derived-data-sets/sentinel-1-interferograms/
"""
_properties_paths = {
_base_properties = {
**S1Product._properties_paths,
'perpendicularBaseline': {'path': ['AdditionalAttributes', ('Name', 'PERPENDICULAR_BASELINE'), 'Values', 0], 'cast': try_parse_float},
'orbit': {'path': ['OrbitCalculatedSpatialDomains']},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/ERSProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ERSProduct(ASFStackableProduct):
ASF ERS-1 Dataset Documentation Page: https://asf.alaska.edu/datasets/daac/ers-1/
ASF ERS-2 Dataset Documentation Page: https://asf.alaska.edu/datasets/daac/ers-2/
"""
_properties_paths = {
_base_properties = {
**ASFStackableProduct._properties_paths,
'frameNumber': {'path': ['AdditionalAttributes', ('Name', 'FRAME_NUMBER'), 'Values', 0]},
'bytes': {'path': ['AdditionalAttributes', ('Name', 'BYTES'), 'Values', 0], 'cast': try_round_float},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/JERSProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class JERSProduct(ASFStackableProduct):
"""
ASF Dataset Documentation Page: https://asf.alaska.edu/datasets/daac/jers-1/
"""
_properties_paths = {
_base_properties = {
**ASFStackableProduct._properties_paths,
'browse': {'path': ['RelatedUrls', ('Type', [('GET RELATED VISUALIZATION', 'URL')])]},
'groupID': {'path': ['AdditionalAttributes', ('Name', 'GROUP_ID'), 'Values', 0]},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/NISARProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class NISARProduct(ASFStackableProduct):
ASF Dataset Documentation Page: https://asf.alaska.edu/nisar/
"""
_properties_paths = {
_base_properties = {
**ASFStackableProduct._properties_paths,
'pgeVersion': {'path': ['PGEVersionClass', 'PGEVersion']}
}
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/OPERAS1Product.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class OPERAS1Product(S1Product):
"""
ASF Dataset Documentation Page: https://asf.alaska.edu/datasets/daac/opera/
"""
_properties_paths = {
_base_properties = {
**S1Product._properties_paths,
'centerLat': {'path': []}, # Opera products lacks these fields
'centerLon': {'path': []},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/RADARSATProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RADARSATProduct(ASFStackableProduct):
"""
ASF Dataset Documentation Page: https://asf.alaska.edu/datasets/daac/radarsat-1/
"""
_properties_paths = {
_base_properties = {
**ASFStackableProduct._properties_paths,
'faradayRotation': {'path': ['AdditionalAttributes', ('Name', 'FARADAY_ROTATION'), 'Values', 0], 'cast': try_parse_float},
'md5sum': {'path': ['AdditionalAttributes', ('Name', 'MD5SUM'), 'Values', 0]},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/S1BurstProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class S1BurstProduct(S1Product):
ASF Dataset Documentation Page: https://asf.alaska.edu/datasets/data-sets/derived-data-sets/sentinel-1-bursts/
"""
_properties_paths = {
_base_properties = {
**S1Product._properties_paths,
'bytes': {'path': ['AdditionalAttributes', ('Name', 'BYTE_LENGTH'), 'Values', 0]},
'absoluteBurstID': {'path': ['AdditionalAttributes', ('Name', 'BURST_ID_ABSOLUTE'), 'Values', 0], 'cast': try_parse_int},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/S1Product.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class S1Product(ASFStackableProduct):
ASF Dataset Overview Page: https://asf.alaska.edu/datasets/daac/sentinel-1/
"""

_properties_paths = {
_base_properties = {
**ASFStackableProduct._properties_paths,
'frameNumber': {'path': ['AdditionalAttributes', ('Name', 'FRAME_NUMBER'), 'Values', 0], 'cast': try_parse_int}, #Sentinel and ALOS product alt for frameNumber (ESA_FRAME)
'groupID': {'path': ['AdditionalAttributes', ('Name', 'GROUP_ID'), 'Values', 0]},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/SEASATProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SEASATProduct(ASFProduct):
"""
ASF Dataset Documentation Page: https://asf.alaska.edu/data-sets/sar-data-sets/seasat/
"""
_properties_paths = {
_base_properties = {
**ASFProduct._properties_paths,
'bytes': {'path': [ 'AdditionalAttributes', ('Name', 'BYTES'), 'Values', 0], 'cast': try_round_float},
'insarStackId': {'path': [ 'AdditionalAttributes', ('Name', 'INSAR_STACK_ID'), 'Values', 0]},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/SIRCProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class SIRCProduct(ASFProduct):
"""
Dataset Documentation Page: https://eospso.nasa.gov/missions/spaceborne-imaging-radar-c
"""
_properties_paths = {
_base_properties = {
**ASFProduct._properties_paths,
'groupID': {'path': [ 'AdditionalAttributes', ('Name', 'GROUP_ID'), 'Values', 0]},
'md5sum': {'path': [ 'AdditionalAttributes', ('Name', 'MD5SUM'), 'Values', 0]},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/SMAPProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SMAPProduct(ASFProduct):
"""
ASF Dataset Documentation Page: https://asf.alaska.edu/data-sets/sar-data-sets/soil-moisture-active-passive-smap-mission/
"""
_properties_paths = {
_base_properties = {
**ASFProduct._properties_paths,
'groupID': {'path': [ 'AdditionalAttributes', ('Name', 'GROUP_ID'), 'Values', 0]},
'insarStackId': {'path': [ 'AdditionalAttributes', ('Name', 'INSAR_STACK_ID'), 'Values', 0]},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/Products/UAVSARProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class UAVSARProduct(ASFProduct):
"""
ASF Dataset Documentation Page: https://asf.alaska.edu/datasets/daac/uavsar/
"""
_properties_paths = {
_base_properties = {
**ASFProduct._properties_paths,
'groupID': {'path': [ 'AdditionalAttributes', ('Name', 'GROUP_ID'), 'Values', 0]},
'insarStackId': {'path': [ 'AdditionalAttributes', ('Name', 'INSAR_STACK_ID'), 'Values', 0]},
Expand Down
2 changes: 1 addition & 1 deletion asf_search/search/baseline_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _cast_to_subclass(product: ASFProduct, subclass: Type[ASFProduct]) -> ASFPro
example:
```
class MyCustomClass(ASFProduct):
_properties_paths = {
_base_properties = {
**ASFProduct._properties_paths,
'some_unique_property': {'path': ['AdditionalAttributes', 'UNIQUE_PROPERTY', ...]}
}
Expand Down
52 changes: 49 additions & 3 deletions examples/5-Download.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "db06fa80-4ac3-40b5-9787-256b422d49e6",
"metadata": {
"tags": []
Expand Down Expand Up @@ -52,7 +52,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "38a2c671-0789-4e7c-b758-5b48745b2877",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -322,6 +322,52 @@
"listdir('./downloads3')"
]
},
{
"cell_type": "markdown",
"id": "30760f6f",
"metadata": {},
"source": [
"***\n",
"## S3 URIs\n",
"Some products have S3 URIs available (SENTINEL-1, OPERA, and NISAR)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "dd4a81ed",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['s3://asf-cumulus-prod-opera-browse/OPERA_L2_CSLC-S1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1_BROWSE.png.md5',\n",
" 's3://asf-cumulus-prod-opera-browse/OPERA_L2_CSLC-S1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1_BROWSE_low-res.png.md5',\n",
" 's3://asf-cumulus-prod-opera-browse/OPERA_L2_CSLC-S1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1_BROWSE_thumbnail.png.md5',\n",
" 's3://asf-cumulus-prod-opera-products/OPERA_L2_CSLC-S1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1.h5',\n",
" 's3://asf-cumulus-prod-opera-products/OPERA_L2_CSLC-S1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1.h5.md5',\n",
" 's3://asf-cumulus-prod-opera-products/OPERA_L2_CSLC-S1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1.iso.xml',\n",
" 's3://asf-cumulus-prod-opera-products/OPERA_L2_CSLC-S1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1/OPERA_L2_CSLC-S1_T113-241605-IW3_20240610T110743Z_20240611T073356Z_S1A_VV_v1.1.iso.xml.md5']"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"opera_product = asf.search(dataset=asf.DATASET.OPERA_S1, maxResults=1)[0]\n",
"opera_product.properties['s3Urls']"
]
},
{
"cell_type": "markdown",
"id": "159b5eb8",
"metadata": {},
"source": [
"From there authorized users can use their prefered method for authentication and downloading s3 objects."
]
},
{
"cell_type": "markdown",
"id": "8aed3b7c-a557-4cbb-878e-aa9fe8330646",
Expand Down Expand Up @@ -394,7 +440,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.11.5"
},
"toc-autonumbering": false,
"toc-showtags": false
Expand Down

0 comments on commit fde4224

Please sign in to comment.