Skip to content

Commit

Permalink
Merge pull request #83 from ACCESS-Cloud-Based-InSAR/dev
Browse files Browse the repository at this point in the history
Fix Ingest due ASF_Search Updates
  • Loading branch information
cmarshak authored Dec 7, 2022
2 parents 87e6486 + 00ae563 commit 6cfca41
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.1]

* Fixes write of start/stop sensing times due to changes in ASF Search v5.0.0 (see #79)


## [0.2.0]

Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies:
- python>=3.8,<3.10
- pip
- affine
- asf_search>=3.0.4
- asf_search>=5.0.0
- boto3
- dateparser
- flake8
Expand Down
25 changes: 23 additions & 2 deletions isce2_topsapp/delivery_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ def gen_browse_imagery(nc_path: Path,
return out_path


def format_time_string(time_str: str) -> str:
"""Generates formatted string for ingest schema using built in python manipulations.
New ASF API provides time string as 2022-05-20T07:11:01.000Z and we need 6 decimal places
at end of string, specifically, 2022-05-20T07:11:01.000000Z
"""
assert time_str[-1] == 'Z'

# removes Z at end and focuses in on decimal
temp = time_str[:-1].split('.')

# update the split string with required decimals
temp[-1] = f'{int(temp[-1]):06d}'

# rejoin and return
formatted_time_str = '.'.join(temp)
return f'{formatted_time_str}Z'


def format_metadata(nc_path: Path,
all_metadata: dict) -> dict:

Expand All @@ -124,15 +142,18 @@ def format_metadata(nc_path: Path,
sec_props = all_metadata['secondary_properties'][0]
b_perp = read_baseline_perp(nc_path).mean()

startTime_f = format_time_string(ref_props["startTime"])
stopTime_f = format_time_string(ref_props["stopTime"])

metadata = {}
# get 4 corners of bounding box of the geometry; default is 5 returning
# to start point
ogr_bbox = all_metadata['intersection_geo'].envelope.exterior.coords[:4]
metadata.update({"ogr_bbox": ogr_bbox,
"reference_scenes": all_metadata['reference_scenes'],
"secondary_scenes": all_metadata['secondary_scenes'],
"sensing_start": f'{ref_props["startTime"]}Z',
"sensing_stop": f'{ref_props["stopTime"]}Z',
"sensing_start": startTime_f,
"sensing_stop": stopTime_f,
"orbit_number": [int(ref_props['orbit']),
int(sec_props['orbit'])],
"platform": [ref_props['platform'], sec_props['platform']],
Expand Down
16 changes: 8 additions & 8 deletions tests/sample_loc_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
"processingLevel": "SLC",
"sceneName": "S1B_IW_SLC__1SDV_20210723T014947_20210723T015014_027915_0354B4_B3A9",
"sensor": "C-SAR",
"startTime": "2021-07-23T01:49:47.000000",
"stopTime": "2021-07-23T01:50:14.000000",
"startTime": "2021-07-23T01:49:47.00000Z",
"stopTime": "2021-07-23T01:50:14.00000Z",
"url": "https://datapool.asf.alaska.edu/SLC/SB/S1B_IW_SLC__1SDV_20210723T014947_20210723T015014_027915_0354B4_B3A9.zip"
}
],
Expand Down Expand Up @@ -129,8 +129,8 @@
"processingLevel": "SLC",
"sceneName": "S1B_IW_SLC__1SDV_20210711T015011_20210711T015038_027740_034F80_376C",
"sensor": "C-SAR",
"startTime": "2021-07-11T01:50:11.000000",
"stopTime": "2021-07-11T01:50:38.000000",
"startTime": "2021-07-11T01:50:11.000Z",
"stopTime": "2021-07-11T01:50:38.000Z",
"url": "https://datapool.asf.alaska.edu/SLC/SB/S1B_IW_SLC__1SDV_20210711T015011_20210711T015038_027740_034F80_376C.zip"
},
{
Expand All @@ -156,8 +156,8 @@
"processingLevel": "SLC",
"sceneName": "S1B_IW_SLC__1SDV_20210711T014947_20210711T015013_027740_034F80_D404",
"sensor": "C-SAR",
"startTime": "2021-07-11T01:49:47.000000",
"stopTime": "2021-07-11T01:50:13.000000",
"startTime": "2021-07-11T01:49:47.000Z",
"stopTime": "2021-07-11T01:50:13.000Z",
"url": "https://datapool.asf.alaska.edu/SLC/SB/S1B_IW_SLC__1SDV_20210711T014947_20210711T015013_027740_034F80_D404.zip"
},
{
Expand All @@ -183,8 +183,8 @@
"processingLevel": "SLC",
"sceneName": "S1B_IW_SLC__1SDV_20210711T014922_20210711T014949_027740_034F80_859D",
"sensor": "C-SAR",
"startTime": "2021-07-11T01:49:22.000000",
"stopTime": "2021-07-11T01:49:49.000000",
"startTime": "2021-07-11T01:49:22.000Z",
"stopTime": "2021-07-11T01:49:49.000Z",
"url": "https://datapool.asf.alaska.edu/SLC/SB/S1B_IW_SLC__1SDV_20210711T014922_20210711T014949_027740_034F80_859D.zip"
}
],
Expand Down

0 comments on commit 6cfca41

Please sign in to comment.