-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update metadata with frame_id
, version
and temporal_baseline_days
#102
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
6a72fce
update metadata w/ frame_id and secondary dt
cmarshak 9b68415
update changelog; fix version num
cmarshak 70ccb38
add frame-id to test data
cmarshak 07ddf91
Update delivery_prep.py
cmarshak 5a4617b
temporal baseline and frame id
cmarshak add751c
Merge branch 'dev' into frame-metadata
cmarshak dff9012
Merge branch 'fix_variable_name_error' into frame-metadata
cmarshak f28b198
fix datetime types
cmarshak 8bf78a7
remove duplicate SET line
cmarshak 772abf2
merge dev
cmarshak 257c7b8
ensure start time is earliest
cmarshak 6e1cc3b
split url and download cells
cmarshak 47a52d7
ensure midnight crossing is correctly handled per DB
cmarshak a989999
Merge branch 'dev' into frame-metadata
cmarshak 7c72c95
increase dataset version 3.0.0, include version in cmr metadata, and …
cmarshak cf387a7
dynamically update dataset version for test
cmarshak fd73e06
lint
cmarshak 4b8019a
andrews suggestion
cmarshak 7ccb526
revert localized data
cmarshak 65f6c9d
Merge branch 'dev' into frame-metadata
cmarshak 98dadaf
Update __main__.py with water mask
cmarshak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import numpy as np | ||
import rasterio | ||
from PIL import Image | ||
from dateparser import parse | ||
from matplotlib import cm | ||
|
||
from isce2_topsapp.packaging import DATASET_VERSION | ||
|
@@ -113,37 +114,36 @@ 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: | ||
|
||
now = datetime.datetime.now() | ||
label = nc_path.name[:-3] # removes suffix .nc | ||
geojson = all_metadata['gunw_geo'].__geo_interface__ | ||
|
||
ref_props = all_metadata['reference_properties'][0] | ||
sec_props = all_metadata['secondary_properties'][0] | ||
ref_props_all = sorted(all_metadata['reference_properties'], | ||
key=lambda prop: prop['startTime']) | ||
ref_props_first = ref_props_all[0] | ||
sec_props_all = sorted(all_metadata['secondary_properties'], | ||
key=lambda prop: prop['startTime']) | ||
sec_props_first = sec_props_all[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"]) | ||
ref_start_times = [parse(props['startTime']) for props in ref_props_all] | ||
ref_stop_times = [parse(props['stopTime']) for props in ref_props_all] | ||
sec_start_times = [parse(props['startTime']) for props in sec_props_all] | ||
|
||
ref_start_time = ref_start_times[0] | ||
ref_stop_time = ref_stop_times[-1] | ||
sec_start_time = sec_start_times[0] | ||
|
||
# The %f is miliseconds zero-padded with 6 decimals - just as we need! | ||
ref_start_time_formatted = ref_start_time.strftime('%Y-%m-%dT%H:%M:%S.%fZ') | ||
ref_stop_time_formatted = ref_stop_time.strftime('%Y-%m-%dT%H:%M:%S.%fZ') | ||
|
||
# We want the nearest day (dt.days takes a floor) so we use total seconds and then round | ||
temporal_baseline_seconds = (ref_start_time - sec_start_time).total_seconds() | ||
temporal_baseline_days = round(temporal_baseline_seconds / 60 / 60 / 24) | ||
|
||
metadata = {} | ||
# get 4 corners of bounding box of the geometry; default is 5 returning | ||
|
@@ -152,18 +152,20 @@ def format_metadata(nc_path: Path, | |
metadata.update({"ogr_bbox": ogr_bbox, | ||
"reference_scenes": all_metadata['reference_scenes'], | ||
"secondary_scenes": all_metadata['secondary_scenes'], | ||
"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']], | ||
"beam_mode": ref_props['beamModeType'], | ||
"orbit_direction": ref_props['flightDirection'].lower(), | ||
"sensing_start": ref_start_time_formatted, | ||
"sensing_stop": ref_stop_time_formatted, | ||
"version": DATASET_VERSION, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are also adding this to the metadata. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"temporal_baseline_days": temporal_baseline_days, | ||
"orbit_number": [int(ref_props_first['orbit']), | ||
int(sec_props_first['orbit'])], | ||
"platform": [ref_props_first['platform'], sec_props_first['platform']], | ||
"beam_mode": ref_props_first['beamModeType'], | ||
"orbit_direction": ref_props_first['flightDirection'].lower(), | ||
"dataset_type": 'slc', | ||
"product_type": 'interferogram', | ||
"polarization": "HH", | ||
"polarization": "VV", | ||
"look_direction": 'right', | ||
"track_number": int(ref_props['pathNumber']), | ||
"track_number": int(ref_props_first['pathNumber']), | ||
"perpendicular_baseline": round(float(b_perp), 4) | ||
}) | ||
|
||
|
@@ -173,6 +175,9 @@ def format_metadata(nc_path: Path, | |
"version": DATASET_VERSION, | ||
"metadata": metadata} | ||
|
||
if all_metadata['frame_id'] != -1: | ||
metadata['frame_number'] = all_metadata['frame_id'] | ||
|
||
return data | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Providing some context for @dbekaert important comments about obtaining an accurate temporal baseline in days. We expect this temporal baseline in days to be a multiple of 6 based on S1's repeat pass frequency.
Suppose the temporal baseline (in days) is for example 5.999999. If
delta
is adatetime.timedelta
object, thendelta.days
will be 5 (not 6). Therefore, we want to do the rounding usingtotal_seconds()
. This resolves David's concerns.Here is an example:
Will be
5
.To be clear, this concern can occur anywhere and anytime, not just at pairs in which acquisitions are close to midnight in UTC.