Skip to content

Commit 7a3c324

Browse files
authored
Merge pull request #91 from GeoscienceAustralia/upgrade/product_formatting
STAC and product name updates
2 parents c829cc8 + 354a2fd commit 7a3c324

6 files changed

Lines changed: 40 additions & 17 deletions

File tree

docs/workflows/aws_isce3_rtc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ The AWS pipeline runs using a docker container. At runtime, the script [run_aws_
8383
--backscatter_convention=gamma0 # gamma0, sigma0 or beta0
8484
--s3_bucket="deant-data-public-dev"
8585
--s3_project_folder="baseline"
86-
--collection_number=1
86+
--collection_number=0
8787
--make_existing_products=false
8888
--skip_upload_to_s3=false
8989
--scene_data_source=("AUS_COP_HUB" "ASF" "CDSE")
@@ -94,7 +94,7 @@ The AWS pipeline runs using a docker container. At runtime, the script [run_aws_
9494
--link_static_layers=false
9595
--linked_static_layers_s3_bucket="deant-data-public-dev"
9696
--linked_static_layers_s3_project_folder="baseline"
97-
--linked_static_layers_collection_number="s1_rtc_static_c1"
97+
--linked_static_layers_collection_number=0
9898
```
9999
- `scene` -> A valid sentinel-1 IW scene (e.g. S1A_IW_SLC__1SSH_20220101T124744_20220101T124814_041267_04E7A2_1DAD)
100100
- `burst_id_list` -> A list of burst id's corresponding to the scene. If not provided, all will be processed. Can be space separated list or line separated .txt file.

sar_pipeline/aws/cli.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def get_data_for_scene_and_make_run_config(
501501
# check if the collection_number passed in aligns with the
502502
# product_version specified in the config
503503
prod_version = RTC_RUN_CONFIG.get(f"{gk}.product_group.product_version")
504-
prod_version_collection_number = int(prod_version.split(".")[0])
504+
prod_version_collection_number = int(re.split(r"[-.]", prod_version)[0])
505505
if prod_version_collection_number != collection_number:
506506
logger.warning(
507507
f"The specified collection_number is {collection_number}. However, "
@@ -649,11 +649,26 @@ def make_rtc_opera_stac_and_upload_bursts(
649649
"""
650650

651651
# iterate through the burst directory and create STAC metadata
652+
logger.info(
653+
f"Iterating through the burst folders to reformat files and create STAC metadata"
654+
)
652655
burst_folders = [x for x in results_folder.iterdir() if x.is_dir()]
656+
653657
for i, burst_folder in enumerate(burst_folders):
654658
logger.info(
655659
f"Making STAC metadata for burst {i+1} of {len(burst_folders)} : {burst_folder}"
656660
)
661+
662+
logger.info(f"Renaming all files so 'v' is not in the product version number ")
663+
for product_file in burst_folder.iterdir():
664+
if product_file.is_file():
665+
new_path = product_file.with_name(
666+
re.sub(r"v(?=\d)", "", product_file.name)
667+
)
668+
if new_path != product_file:
669+
logger.info(f"Renaming: {product_file.name} -> {new_path.name}")
670+
product_file.rename(new_path)
671+
657672
# load in the .h5 file containing metadata for each burst
658673
burst_h5_files = list(burst_folder.glob("*.h5"))
659674
if len(burst_h5_files) != 1:
@@ -665,15 +680,15 @@ def make_rtc_opera_stac_and_upload_bursts(
665680

666681
# get the product name common to files from the .h5
667682
# e.g. ga_s1_nrb-static_v0.1.0_T070-149815-IW3_20140403
668-
burst_product_name = burst_h5_filepath.stem.replace(".metadata", "")
683+
burst_product_name = burst_h5_filepath.stem.replace("_metadata", "")
669684

670685
# rename the .h5 file to conform with ga naming conventions
671686
burst_h5_filepath = burst_h5_filepath.rename(
672-
burst_folder / f"{burst_product_name}.metadata.h5"
687+
burst_folder / f"{burst_product_name}_metadata.h5"
673688
)
674689
# copy the run config file to the burst folder and rename to conform with ga naming conventions
675690
burst_run_config_filepath = (
676-
burst_folder / f"{burst_product_name}.proc-config.yaml"
691+
burst_folder / f"{burst_product_name}_proc-config.yaml"
677692
)
678693
shutil.copy(run_config_path, burst_run_config_filepath)
679694

@@ -711,7 +726,7 @@ def make_rtc_opera_stac_and_upload_bursts(
711726
burst_stac_manager.add_linked_static_layers_as_assets_to_stac()
712727
# add additional links to metadata files. e.g. stac, xml, proc config
713728
logging.info(f"Adding links to metadata files and self")
714-
stac_filepath = burst_folder / f"{burst_product_name}.stac-item.json"
729+
stac_filepath = burst_folder / f"{burst_product_name}_stac-item.json"
715730
burst_stac_manager.add_metadata_links(
716731
stac_filepath=stac_filepath,
717732
h5_filepath=burst_h5_filepath,

sar_pipeline/aws/metadata/odc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def make_rtc_s1_s3_subpath(
6565
odc_product_name = get_odc_product_name(
6666
"RTC_S1", collection_number, burst_polarisations
6767
)
68-
return f"{s3_project_folder}/{odc_product_name}/{burst_id}/{year}/{month}/{day}"
68+
return f"{s3_project_folder}/{odc_product_name}/{burst_id}/{year}/{month:02d}/{day:02d}"
6969

7070

7171
def make_rtc_s1_static_s3_subpath(

sar_pipeline/aws/metadata/stac.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ def add_properties_from_h5(self):
322322
self.item.properties["processing:software"] = {
323323
"isce3": self.h5.search_value("algorithms/isce3Version"),
324324
"s1Reader": self.h5.search_value("algorithms/s1ReaderVersion"),
325-
"OPERA-adt/RTC": self.h5.search_value("algorithms/softwareVersion"),
325+
"GeoscienceAustralia/RTC": self.h5.search_value(
326+
"algorithms/softwareVersion"
327+
),
326328
"sar-pipeline": sar_pipeline.__version__,
327329
"dem-handler": dem_handler.__version__,
328330
}
@@ -399,12 +401,11 @@ def add_properties_from_h5(self):
399401

400402
# add the storage stac extension properties
401403
self.item.properties["storage:schemes"] = {
402-
"aws-std": {
404+
"aws": {
403405
"type": "aws-s3",
404406
"platform": "https://{bucket}.s3.{region}.amazonaws.com",
405407
"bucket": f"{self.s3_bucket}",
406408
"region": f"{self.s3_region}",
407-
"requester_pays": True,
408409
}
409410
}
410411

@@ -416,6 +417,7 @@ def add_fixed_links(self):
416417
pystac.Link(
417418
rel="geoid-source",
418419
target="https://aria-geoid.s3.us-west-2.amazonaws.com/us_nga_egm2008_1_4326__agisoft.tif",
420+
media_type=pystac.media_type.MediaType.GEOTIFF,
419421
)
420422
)
421423

@@ -446,6 +448,7 @@ def add_dynamic_links_from_h5(self):
446448
pystac.Link(
447449
rel="dem-source",
448450
target=self._extract_http_link(self.h5.search_value("demSource")),
451+
media_type=pystac.media_type.MediaType.HTML,
449452
)
450453
)
451454

@@ -458,6 +461,7 @@ def add_dynamic_links_from_h5(self):
458461
pystac.Link(
459462
rel="rtc-algorithm",
460463
target=self._extract_doi_link(ref_text),
464+
media_type=pystac.media_type.MediaType.HTML,
461465
)
462466
)
463467

@@ -467,6 +471,7 @@ def add_dynamic_links_from_h5(self):
467471
pystac.Link(
468472
rel="geocoding-algorithm",
469473
target=self._extract_doi_link(ref_text),
474+
media_type=pystac.media_type.MediaType.HTML,
470475
)
471476
)
472477

@@ -477,6 +482,7 @@ def add_dynamic_links_from_h5(self):
477482
pystac.Link(
478483
rel="noise-correction",
479484
target=self._extract_http_link(ref_text),
485+
media_type=pystac.media_type.MediaType.PDF,
480486
)
481487
)
482488

@@ -524,7 +530,7 @@ def add_metadata_links(
524530
pystac.Link(
525531
rel="processing-config",
526532
target=f"{self.base_href}/{Path(runconfig_filepath).name}",
527-
media_type=pystac.media_type.MediaType.HDF5,
533+
media_type="application/yaml",
528534
)
529535
)
530536

@@ -533,7 +539,7 @@ def add_metadata_links(
533539
pystac.Link(
534540
rel="browse",
535541
target=f"{self.browse_href}",
536-
media_type=pystac.media_type.MediaType.JSON,
542+
media_type=pystac.media_type.MediaType.HTML,
537543
)
538544
)
539545

@@ -543,7 +549,7 @@ def add_metadata_links(
543549
pystac.Link(
544550
rel="self",
545551
target=f"{self.base_href}/{Path(stac_filepath).name}",
546-
media_type=pystac.media_type.MediaType.JSON,
552+
media_type=pystac.media_type.STAC_JSON,
547553
)
548554
)
549555

@@ -583,7 +589,7 @@ def add_collection_link(
583589
pystac.Link(
584590
rel="collection",
585591
target=stac_href,
586-
media_type=pystac.media_type.MediaType.JSON,
592+
media_type=pystac.media_type.STAC_JSON,
587593
)
588594
)
589595

@@ -821,6 +827,7 @@ def add_linked_static_layers_as_assets_to_stac(
821827
pystac.Link(
822828
rel="static-layers-stac-item",
823829
target=burst_static_layer_stac_url,
830+
media_type=pystac.media_type.STAC_JSON,
824831
)
825832
)
826833

@@ -834,6 +841,7 @@ def add_linked_static_layers_as_assets_to_stac(
834841
pystac.Link(
835842
rel="static-layers-browse",
836843
target=static_layer_browse_url,
844+
media_type=pystac.media_type.MediaType.HTML,
837845
)
838846
)
839847

sar_pipeline/configs/ISCE3-RTC/S1_RTC.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ runconfig:
4242
# <collection_number>.<minor_version>.<patch_version>
4343
# note the collection_number is set by the pipeline script
4444
# at runtime and should align to this value
45-
product_version: 0.1.0
45+
product_version: 0-1-0
4646

4747
# Directory where PGE will place results
4848
product_path: .

sar_pipeline/configs/ISCE3-RTC/S1_RTC_STATIC.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ runconfig:
4343
# <collection_number>.<minor_version>.<patch_version>
4444
# note the collection_number is set by the pipeline script
4545
# at runtime and should align to this value
46-
product_version: 0.1.0
46+
product_version: 0-1-0
4747

4848
# Directory where PGE will place results
4949
product_path: .

0 commit comments

Comments
 (0)