diff --git a/CHANGELOG.md b/CHANGELOG.md index e32421e..2fa6347 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ 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.1.7] + +### Fixed + +- Fix lineage statement replacement to keep ISO XML file formatted the same as original file + ## [0.1.6] ### Added diff --git a/requirements-static.txt b/requirements-static.txt index 01b0c99..6d5c5e5 100644 --- a/requirements-static.txt +++ b/requirements-static.txt @@ -1,4 +1,4 @@ -ruff==0.12.7 +ruff==0.12.9 mypy==1.17.1 lxml-stubs types-shapely diff --git a/src/hyp3_opera_rtc/upload_rtc.py b/src/hyp3_opera_rtc/upload_rtc.py index fc23ee5..13d6ef0 100644 --- a/src/hyp3_opera_rtc/upload_rtc.py +++ b/src/hyp3_opera_rtc/upload_rtc.py @@ -70,9 +70,17 @@ def update_xml_with_asf_lineage(xml_path: Path) -> None: lineage = lineage_search[0] version = hyp3_opera_rtc.__version__ assert lineage.text is not None - lineage.text = f'{lineage.text.replace("JPL", "ASF")} via HyP3 OPERA-RTC v{version}' - iso_tree.write(str(xml_path)) + old_lineage = lineage.text + new_lineage = f'{old_lineage.replace("JPL", "ASF")} via HyP3 OPERA-RTC v{version}' + + with xml_path.open('r') as f: + xml_text = f.read() + + updated_xml = xml_text.replace(old_lineage, new_lineage) + + with xml_path.open('w') as f: + f.write(updated_xml) def main() -> None: diff --git a/tests/data/updated-opera_v1.0.iso.xml b/tests/data/updated-opera_v1.0.iso.xml new file mode 100644 index 0000000..50c0e93 --- /dev/null +++ b/tests/data/updated-opera_v1.0.iso.xml @@ -0,0 +1,1900 @@ + + + + + OPERA_L2_RTC-S1_20231204T090220Z_S1A_30_v1.0 + + + + eng + + + + utf8 + + + + dataset + + + + + + Jet Propulsion Laboratory + + + + + + + 4800 Oak Grove Drive + + + Pasadena + + + CA + + + 91109 + + + USA + + + ops@jpl.nasa.gov + + + + + + + pointOfContact + + + + + + 2023-12-04T09:02:20.0710170000Z + + + + ISO 19115-2 Geographic Information - Metadata Part 2 Extensions for imagery and gridded data + + + ISO 19115-2:2019(E) + + + + + 2 + + + + + row + + + 3305 + + + 30.0 + + + + + + + column + + + 1506 + + + -30.0 + + + + + area + + + true + + + + + + + + + + + European Petroleum Survey Group (EPSG) Geodetic Parameter Dataset + + + + + 32626 + + + + + + + + + + + + + OPERA_L2_RTC-S1_20231204T090220Z_S1A_30_v1.0 + + + Radiometric Terrain Corrected (RTC) from Sentinel-1 + + + + + + 2023-12-04T09:02:20.0710170000Z + + + creation + + + + + 1.0 + + + + + + OPERA_L2_RTC-S1_20231204T090220Z_S1A_30_v1.0 + + + gov.nasa.esdis.umm.producergranuleid + + + ProducerGranuleId + + + + + + + + 2.1.0 + + + gov.nasa.esdis.umm.otherid + + + OtherId: PGEVersionId + + + + + + + + 1.0.1 + + + gov.nasa.esdis.umm.otherid + + + OtherId: SASVersionId + + + + + + + Jet Propulsion Repository + + + + + + originator + + + + + documentDigital + + + + + The OPERA Level 2 Radiometric Terrain Corrected (L2_RTC) product is derived from the original Copernicus Sentinel-1 (S1) A/B SLC data, with a temporal product sampling coincident with the availability of Sentinel-1 A/B SLC data. Each OPERA RTC product corresponds to a single Copernicus S1 A/B burst. + + + completed + + + + + + asNeeded + + + + + + + + OPERA + + + JPL + + + RTC + + + Radiometric + + + Terrain + + + Corrected + + + project + + + + + NASA Project Keywords + + + + + + NASA + + + User Support Office + + + + + + + https://support.earthdata.nasa.gov/ + + + Earthdata Support + + + File an issue or provide feedback + + + information + + + + + + + custodian + + + + + + + + + + + + S1 + + + platform + + + + + NASA Platform Keywords + + + + + + NASA + + + User Support Office + + + + + + + https://support.earthdata.nasa.gov/ + + + Earthdata Support + + + File an issue or provide feedback + + + information + + + + + + + custodian + + + + + + + + + + + + Sentinel 1 A/B + + instrument + + + + + NASA Instrument Keywords + + + + + + NASA + + + User Support Office + + + + + + + https://support.earthdata.nasa.gov/ + + + Earthdata Support + + + File an issue or provide feedback + + + information + + + + + + + custodian + + + + + + + + + + + + + + RTC_S1_PGE + + + gov.nasa.esdis.umm.collectionshortname + + + CollectionShortName + + + + + LargerWorkCitation + + + + + + + + + + 2.1.0 + + + gov.nasa.esdis.umm.collectionversion + + + CollectionVersion + + + + + LargerWorkCitation + + + + + + + + + + OPERA Project Homepage + + + + + + + + + + https://www.jpl.nasa.gov/go/opera + + + OPERA Project Homepage + + + information + + + + + + + custodian + + + + + + + LargerWorkCitation + + + + + grid + + + + eng + + + + utf8 + + + geoscientificInformation + + + Data product generated in HDF5 format with ISO 19115 conformant metadata. + + + + + + + + -30.94886170511729 + -29.866406758810424 + 35.9176028763907 + 36.355539817138066 + + + + + + + + + 2017-05-27T19:56:54.267407Z + 2017-05-27T19:56:57.336353Z + + + + + + + + + + + + + + MeasuredParameters + + + physicalMeasurement + + + + + + + + + + + instrumentInformation + + + AbsoluteOrbitNumber + + + Absolute orbit number + + + Unitless + + + int + + + + + 16772 + + + + + + + instrumentInformation + + + AcquisitionMode + + + Acquisition Mode + + + Unitless + + + string + + + + + IW + + + + + + + instrumentInformation + + + BoundingBox + + + Bounding box of the product, in order of xmin, ymin, xmax, ymax + + + string + + + + + [143640.0, 3982020.0, 242790.0, 4027200.0] + + + + + + + instrumentInformation + + + BurstID + + + Burst identification (burst ID) + + + Unitless + + + string + + + + + t075_159159_iw1 + + + + + + + processingInformation + + + CEOSAnalysisReadyDataDocumentIdentifier + + + CEOS Analysis Ready Data Document Identifier + + + boolean + + + + + https://ceos.org/ard/files/PFS/NRB/v5.5/CARD4L-PFS_NRB_v5.5.pdf + + + + + + + processingInformation + + + CEOSAnalysisReadyDataProductType + + + CEOS Analysis Ready Data Product Type + + + string + + + + + Normalised Radar Backscatter + + + + + + + processingInformation + + + ContactInformation + + + Contact email address + + + string + + + + + operasds@jpl.nasa.gov + + + + + + + processingInformation + + + DataAccess + + + Data Access URL + + + string + + + + + https://search.asf.alaska.edu/#/?dataset=OPERA-S1&productTypes=RTC + + + + + + + instrumentInformation + + + TrackNumber + + + Track number + + + Unitless + + + int + + + + + 75 + + + + + + + contentInformation + + + ProductType + + + Product type + + + string + + + + + RTC-S1-STATIC + + + + + + + contentInformation + + + Project + + + Project name + + + string + + + + + OPERA + + + + + + + instrumentInformation + + + RadarBand + + + Acquired frequency band + + + string + + + + + C + + + + + + + processingInformation + + + SubSwathID + + + Sub Swath ID + + + string + + + + + IW1 + + + + + + + contentInformation + + + ProductVersion + + + Product version + + + string + + + + + 1.0 + + + + + + + instrumentInformation + + + LookDirection + + + Look direction can be left or right + + + string + + + + + right + + + + + + + instrumentInformation + + + OrbitPassDirection + + + Orbit direction can be ascending or descending + + + string + + + + + ascending + + + + + + + instrumentInformation + + + Platform + + + Platform name + + + string + + + + + Sentinel-1A + + + + + + + instrumentInformation + + + ZeroDopplerStartTime + + + Azimuth start time of the product + + + dateTimeString + + + + + 2017-05-27T19:56:54.267407Z + + + + + + + instrumentInformation + + + ZeroDopplerEndTime + + + Azimuth stop time of the product + + + dateTimeString + + + + + 2017-05-27T19:56:57.336353Z + + + + + + + contentInformation + + + Institution + + + Institution name + + + string + + + + + NASA JPL + + + + + + + instrumentInformation + + + InstrumentName + + + Name of the instrument used to collect the remote sensing data provided in this product + + + string + + + + + Sentinel-1A CSAR + + + + + + + contentInformation + + + IsGeocoded + + + Flag to indicate radar geometry or geocoded product + + + boolean + + + + + True + + + + + + + processingInformation + + + ProcessingDatetime + + + Processing date and time + + + string + + + + + 2023-12-04T09:13:35.170570Z + + + + + + + processingInformation + + + ProcessingType + + + NOMINAL (or) URGENT (or) CUSTOM (or) UNDEFINED + + + string + + + + + NOMINAL + + + + + + + processingInformation + + + ProductLevel + + + Product level. L0A: Unprocessed instrument data; L0B: Reformatted, unprocessed instrument data; L1: Processed instrument data in radar coordinates system; and L2: Processed instrument data in geocoded coordinates system + + + string + + + + + L2 + + + + + + + processingInformation + + + ProductSpecificationVersion + + + Product specification version which represents the schema of this product + + + string + + + + + 1.0 + + + + + + + contentInformation + + + ListOfPolarizations + + + List of processed polarization layers + + + string + + + + + ["VV"] + + + + + + + contentInformation + + + YCoordinateSpacing + + + Nominal spacing in meters between consecutive lines + + + Meters + + + float + + + + + -30.0 + + + + + + + contentInformation + + + XCoordinateSpacing + + + Nominal spacing in meters between consecutive pixels + + + Meters + + + float + + + + + 30.0 + + + + + + + processingParameter + + + Projection + + + EPSG Projection Value + + + int + + + + + 32626 + + + + + + + processingParameter + + + BistaticDelayCorrectedApplied + + + Flag to indicate if Bi-static Delay correction was applied + + + boolean + + + + + False + + + + + + + processingParameter + + + StaticTroposphericGeolocationCorrectedApplied + + + Flag to indicate if the Static Tropospheric Geolocation correction was applied + + + boolean + + + + + False + + + + + + + processingParameter + + + FilteringApplied + + + Flag to indicate if filtering was applied + + + boolean + + + + + False + + + + + + + processingParameter + + + BurstGeogridSnapX + + + Burst Geogrid Snap X value + + + int + + + + + 30.0 + + + + + + + processingParameter + + + BurstGeogridSnapY + + + Burst Geogrid Snap Y value + + + int + + + + + 30.0 + + + + + + + processingParameter + + + InputBackscatterNormalizationConvention + + + Normalization convention for input backscatter + + + string + + + + + beta0 + + + + + + + processingParameter + + + OutputBackscatterDecibelConversionEquation + + + Output Backscatter Decibel Conversion Equation + + + string + + + + + 10*log10(backscatter_linear) + + + + + + + processingParameter + + + OutputBackscatterExpressionConvention + + + Output Backscatter Expression Convention + + + string + + + + + linear backscatter intensity + + + + + + + processingParameter + + + OutputBackscatterNormalizationConvention + + + Output Backscatter Normalization Convention + + + string + + + + + gamma0 + + + + + + + processingParameter + + + PreprocessingMultilookingApplied + + + Flag to indicate if Pre Processing Multilooking was applied + + + boolean + + + + + False + + + + + + + processingParameter + + + WetTroposphericGeolocationCorrectionApplied + + + Flag to indicate if the Wet Tropospheric Geolocation Correction was applied + + + boolean + + + + + False + + + + + + + processingInformation + + + DemEgmModel + + + DEM Earth Gravitational Model + + + string + + + + + Earth Gravitational Model 2008 (EGM2008) + + + + + + + processingInformation + + + DemInterpolation + + + DEM interpolation method + + + string + + + + + biquintic + + + + + + + processingInformation + + + Geocoding + + + Geocoding algorithm + + + string + + + + + Area-Based SAR Geocoding with Adaptive Multilooking (GEO-AP) + + + + + + + processingInformation + + + GeocodingAlgorithmReference + + + Geocoding algorithm reference document + + + string + + + + + Gustavo H. X. Shiroma, Marco Lavalle, and Sean M. Buckley, "An Area-Based Projection Algorithm for SAR Radiometric Terrain Correction and Geocoding," in IEEE Transactions on Geoscience and Remote Sensing, vol. 60, pp. 1-23, 2022, Art no. 5222723, doi: 10.1109/TGRS.2022.3147472. + + + + + + + processingInformation + + + RadiometricTerrainCorrection + + + Radiometric terrain correction (RTC) algorithm + + + string + + + + + Area-Based SAR Radiometric Terrain Correction (RTC-AP) + + + + + + + processingInformation + + + RadiometricTerrainCorrectionAlgorithmReference + + + Radiometric terrain correction algorithm reference document + + + string + + + + + Gustavo H. X. Shiroma, Marco Lavalle, and Sean M. Buckley, "An Area-Based Projection Algorithm for SAR Radiometric Terrain Correction and Geocoding," in IEEE Transactions on Geoscience and Remote Sensing, vol. 60, pp. 1-23, 2022, Art no. 5222723, doi: 10.1109/TGRS.2022.3147472. + + + + + + + processingInformation + + + S1ReaderVersion + + + S1-Reader version used for processing + + + string + + + + + 0.2.2 + + + + + + + processingInformation + + + ISCEVersion + + + ISCE version used for processing + + + string + + + + + 0.15.0 + + + + + + + processingInformation + + + SoftwareVersion + + + Software version used for processing + + + string + + + + + 1.0.1 + + + + + + + processingInformation + + + L1SlcGranules + + + List of input L1 SLC products used + + + string + + + + + ["S1A_IW_SLC__1SDV_20170527T195629_20170527T195657_016772_01BDE2_30A5.zip"] + + + + + + + processingInformation + + + orbitFiles + + + List of input orbit files used + + + string + + + + + ["S1A_OPER_AUX_POEORB_OPOD_20210302T202525_V20170526T225942_20170528T005942.EOF"] + + + + + + + processingInformation + + + AnnotationFiles + + + List of input annotation files used + + + string + + + + + ["calibration-s1a-iw1-slc-vv-20170527t195629-20170527t195657-016772-01bde2-004.xml", "noise-s1a-iw1-slc-vv-20170527t195629-20170527t195657-016772-01bde2-004.xml"] + + + + + + + processingInformation + + + DemSource + + + Source description for the utilized DEM file + + + string + + + + + Digital Elevation Model (DEM) for the NASA OPERA project version 1.1 (v1.1) based on the Copernicus DEM 30-m and Copernicus 90-m referenced to the WGS84 ellipsoid + + + + + + + instrumentInformation + + + OrbitInterpolationMethod + + + Orbit Interpolation Method + + + string + + + + + Hermite + + + + + + + instrumentInformation + + + OrbitReferenceEpoch + + + Reference epoch in the format YYYY-MM-DDTHH:MM:SS.SSS + + + string + + + + + 2017-05-25T19:56:54.267407000 + + + + + + + instrumentInformation + + + OrbitType + + + PrOE (or) NOE (or) MOE (or) POE (or) Custom + + + string + + + + + POE precise orbit + + + + + + + + + + + + + + + + + + GeoTIFF + + + + + + + + + free + + + + + + + + + + + + + + + dataset + + + + + + + OPERA L2 RTC product generated by ASF using Sentinel-1 input data and SAS version 1.0.1 via HyP3 OPERA-RTC v1.0.0 + + + + + + PGEVersionClass + + + + + + + PGEName: RTC_S1_PGE PGEVersion: 2.1.0 + + + gov.nasa.esdis.umm.pgeversionclass + + + PGEVersionClass + + + + + + + + + Radiometric Terrain Corrected (RTC) Product - OPERA_L2_RTC-S1_20231204T090220Z_S1A_30_v1.0 + + + + + + + + + + ProductionDateTime + + + 2023-12-04T09:02:20.0710170000Z + + + + + + + + GranuleInput + + + + + + /home/rtc_user/input_dir/S1A_IW_SLC__1SDV_20170527T195629_20170527T195657_016772_01BDE2_30A5.zip + + + + + + + + + + + Reference DEM - /home/rtc_user/input_dir/dem.vrt + + + + + + + Orbit Ephemerides - /home/rtc_user/input_dir/S1A_OPER_AUX_POEORB_OPOD_20210302T202525_V20170526T225942_20170528T005942.EOF + + + + + + + Burst Database - /home/rtc_user/input_dir/opera_burst_database.sqlite3 + + + + + + + + + + + asNeeded + + + + \ No newline at end of file diff --git a/tests/test_prep_rtc.py b/tests/test_prep_rtc.py index 10a072c..a1fe826 100644 --- a/tests/test_prep_rtc.py +++ b/tests/test_prep_rtc.py @@ -9,7 +9,7 @@ def test_parse_response_for_params(): - test_response = json.loads(Path('tests/data/burst_response.json').read_text()) + test_response = json.loads((Path(__file__).parent / 'data' / 'burst_response.json').read_text()) slc_name, burst_id = prep_rtc.parse_response_for_burst_params(test_response) assert slc_name == 'S1A_IW_SLC__1SDV_20250413T020809_20250413T020836_058732_07464F_EF1E' assert burst_id == 't035_073251_iw2' diff --git a/tests/test_upload_rtc.py b/tests/test_upload_rtc.py index 8cddd23..56274d1 100644 --- a/tests/test_upload_rtc.py +++ b/tests/test_upload_rtc.py @@ -88,20 +88,14 @@ def test_update_xmls(update_mock, tmp_path): update_mock.assert_has_calls(calls, any_order=True) +@patch.object(hyp3_opera_rtc, '__version__', '1.0.0') def test_get_xml_with_asf_lineage(iso_xml_path): - version = hyp3_opera_rtc.__version__ - - with iso_xml_path.open() as f: - xml_text = f.read() - assert 'ASF' not in xml_text - assert f'via HyP3 OPERA-RTC {version}' not in xml_text - upload_rtc.update_xml_with_asf_lineage(iso_xml_path) - with iso_xml_path.open() as f: - xml_text = f.read() - assert 'ASF' in xml_text - assert f'via HyP3 OPERA-RTC v{version}' in xml_text + expected_updated_xml = Path(__file__).parent / 'data' / 'updated-opera_v1.0.iso.xml' + + expected, updated = expected_updated_xml.read_text(), iso_xml_path.read_text() + assert expected == updated def test_cant_find_lineage_in_xml(tmp_path):