Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions sar_pipeline/aws/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,12 +660,16 @@ def make_rtc_opera_stac_and_upload_bursts(
f"Making STAC metadata for burst {i+1} of {len(burst_folders)} : {burst_folder}"
)

logger.info(f"Renaming all files so 'v' is not in the product version number ")
logger.info(
f"Renaming all files so 'v' is not in the product version number, and version is '-' separated "
)
for product_file in burst_folder.iterdir():
if product_file.is_file():
new_path = product_file.with_name(
re.sub(r"v(?=\d)", "", product_file.name)
)
# step 1: remove 'v' before version numbers
name = re.sub(r"v(?=\d)", "", product_file.name)
# step 2: replace version pattern digits.digits.digits → digits-digits-digits
name = re.sub(r"(\d+)\.(\d+)\.(\d+)", r"\1-\2-\3", name)
new_path = product_file.with_name(name)
if new_path != product_file:
logger.info(f"Renaming: {product_file.name} -> {new_path.name}")
product_file.rename(new_path)
Expand Down Expand Up @@ -761,9 +765,18 @@ def make_rtc_opera_stac_and_upload_bursts(
# create the XML file from the existing metadata files
if xml_filepath:
logger.info("Creating the XML file from the stac and .h5 metadata files")
XML = XMLMapper(stac_path=stac_filepath, h5_path=burst_h5_filepath)
XML = XMLMapper(
stac_path=stac_filepath,
h5_path=burst_h5_filepath,
polarisations=burst_stac_manager.polarisations,
backscatter_convention=backscatter_convention,
)
logger.info("Populating the XML template using the mapping file")
XML.populate_xml()
logger.info(
f"Adding special mappings to XML template. e.g. multiple backscatter pols"
)
XML.populate_special_xml_mappings()
logger.info(f"Saving XML file to : {xml_filepath}")
XML.save_xml(xml_filepath)

Expand All @@ -773,7 +786,7 @@ def make_rtc_opera_stac_and_upload_bursts(
else:
# re-check that the files don't already exist in S3. This will help protect against
# simultaneous runs of the same product. E.g. the product did not exist at the
# start of the run and was created by another process during this run
# start of the run and was created by another process during this runtime
logger.info(
f"Checking if product already exist before uploading for burst : {burst_stac_manager.burst_id}"
)
Expand Down
18 changes: 10 additions & 8 deletions sar_pipeline/aws/metadata/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def add_properties_from_h5(self):
# add product stac extension properties
self.item.properties["product:type"] = self.product
# remove timeliness as not required. May re-add if approach is determined.
# self.item.properties["product:timeliness"] = "TODO"
# self.item.properties["product:timeliness"] = ""
# self.item.properties["product:timeliness_category"] = (
# self._get_product_timeliness_category(self.start_dt, self.processed_dt)
# )
Expand All @@ -272,9 +272,9 @@ def add_properties_from_h5(self):
# add projection (proj) stac extension properties
self.item.properties["proj:code"] = f"EPSG:{self.projection_epsg}"
self.item.properties["proj:bbox"] = self.h5.search_value("boundingBox")
self.item.properties["proj:wkt2"] = pyproj.CRS.from_epsg(
self.projection_epsg
).to_wkt()
# self.item.properties["proj:wkt2"] = pyproj.CRS.from_epsg(
# self.projection_epsg
# ).to_wkt() # causing issues in explorer, value set in XML

# add the sar stac extension properties
self.item.properties["sar:frequency_band"] = self.h5.search_value("radarBand")
Expand Down Expand Up @@ -330,7 +330,9 @@ def add_properties_from_h5(self):
}

# proposed sarard stac extension properties
self.item.properties["sarard:source_id"] = self.h5.search_value("l1SlcGranules")
self.item.properties["sarard:source_id"] = self.h5.search_value(
"l1SlcGranules"
)[0]
self.item.properties["sarard:source_geometry"] = "slant range"
self.item.properties["sarard:scene_id"] = self.h5.search_value("l1SlcGranules")[
0
Expand All @@ -344,9 +346,9 @@ def add_properties_from_h5(self):
self.item.properties["sarard:far_range_incidence_angle"] = (
self.h5.search_value("farRangeIncidenceAngle")
)
self.item.properties["sarard:orbit_files"] = self.h5.search_value(
"orbitFiles"
) # Link to a file containing the orbit state vectors.
self.item.properties["sarard:orbit_file"] = self.h5.search_value("orbitFiles")[
0
] # Link to a file containing the orbit state vectors.
self.item.properties["sarard:UL_longitude"] = self.bbox_4326[0] # min_lon
self.item.properties["sarard:UL_latitude"] = self.bbox_4326[3] # max_lat
self.item.properties["sarard:LR_longitude"] = self.bbox_4326[2] # max_lon
Expand Down
22 changes: 11 additions & 11 deletions sar_pipeline/aws/metadata/templates/s1nrb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@
<DemSource type="URL"></DemSource>
</AuxiliaryData>
<ProductSampleSpacing>
<ProductColumnSpacing units="meter">
<ProductColumnSpacing units="m">
</ProductColumnSpacing>
<ProductRowSpacing units="meter">
<ProductRowSpacing units="m">
</ProductRowSpacing>
</ProductSampleSpacing>
<ProductENL>
</ProductENL>
<ProductResolution>
<ProductResolutionColumn unit="meter"></ProductResolutionColumn>
<ProductResolutionRow unit="meter"></ProductResolutionRow>
<ProductResolutionColumn unit="m"></ProductResolutionColumn>
<ProductResolutionRow unit="m"></ProductResolutionRow>
</ProductResolution>
<Filtering>
<FilterApplied>
Expand Down Expand Up @@ -149,7 +149,7 @@
</CoordinateReferenceSystem>
<PerPixelMetadata>
<DataMask>
<FileName>
<FileName type="URL">
</FileName>
<SampleType>
</SampleType>
Expand Down Expand Up @@ -179,7 +179,7 @@
</BitValues>
</DataMask>
<LocalIncAngle>
<FileName>
<FileName type="URL">
</FileName>
<SampleType units="deg">
</SampleType>
Expand All @@ -193,7 +193,7 @@
</ByteOrder>
</LocalIncAngle>
<EllipsoidIncAngle>
<FileName>
<FileName type="URL">
</FileName>
<SampleType units="deg">
</SampleType>
Expand All @@ -209,7 +209,7 @@
</EllipsoidName>
</EllipsoidIncAngle>
<GammaToSigmaRatio>
<FileName>
<FileName type="URL">
</FileName>
<SampleType units="Ratio">
</SampleType>
Expand All @@ -232,7 +232,7 @@
</BackscatterConversionEq>
<Polarization>
</Polarization>
<FileName>
<FileName type="URL">
</FileName>
<DataFormat>
</DataFormat>
Expand All @@ -256,6 +256,8 @@
<GeometricCorrection>
<GeoCorrAlgorithm type="DOI">
</GeoCorrAlgorithm>
<GriddingConvention>
</GriddingConvention>
<DigitalElevationModel dem="Surface">
<DEMReference type="URL">
</DEMReference>
Expand All @@ -275,7 +277,5 @@
</GeoAccuracyReference>
</GeoCorrAccuracy>
</GeometricCorrection>
<GridName>
</GridName>
</CEOS-ARDProductAttributes>
</Product>
Loading