Skip to content

Commit

Permalink
Updated unit tests for RTC-S1 to account for gamma integration changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Collins committed Apr 5, 2023
1 parent 7b35f71 commit 12ed47a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/opera/test/data/test_rtc_s1_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ RunConfig:
- 'python3 -c "from opera.util.metadata_utils import create_test_rtc_metadata_product; create_test_rtc_metadata_product(\"rtc_s1_test/output_dir/t069_147170_iw1/rtc_product_v1.0.h5\")";'
- 'touch rtc_s1_test/output_dir/t069_147170_iw1/rtc_product_v1.0_VH.tif;'
- 'touch rtc_s1_test/output_dir/t069_147170_iw1/rtc_product_v1.0_VV.tif;'
- 'touch rtc_s1_test/output_dir/t069_147170_iw1/rtc_product_v1.0.png;'
- 'touch rtc_s1_test/output_dir/t069_147170_iw1/rtc_product_v1.0_nlooks.tif;'
- 'touch rtc_s1_test/output_dir/t069_147170_iw1/rtc_product_v1.0_layover_shadow_mask.tif;'
- 'dd if=/dev/urandom of=rtc_s1_test/output_dir/t069_147170_iw1/rtc_product_v1.0_VH.tif bs=1M count=1;'
- 'dd if=/dev/urandom of=rtc_s1_test/output_dir/t069_147170_iw1/rtc_product_v1.0_VV.tif bs=1M count=1;'
- 'dd if=/dev/urandom of=rtc_s1_test/output_dir/t069_147170_iw1/rtc_product_v1.0.png bs=1M count=1;'
- 'dd if=/dev/urandom of=rtc_s1_test/output_dir/t069_147170_iw1/rtc_product_v1.0_nlooks.tif bs=1M count=1;'
- 'dd if=/dev/urandom of=rtc_s1_test/output_dir/t069_147170_iw1/rtc_product_v1.0_layover_shadow_mask.tif bs=1M count=1;'
- '/bin/echo RTC-S1 invoked with RunConfig'
ErrorCodeBase: 300000
SchemaPath: pge/rtc_s1/schema/rtc_s1_sas_schema.yaml
Expand Down Expand Up @@ -78,6 +84,7 @@ RunConfig:
product_id: rtc_product
save_bursts: True
save_mosaics: False
save_browse: True
output_imagery_format: COG

processing:
Expand Down
19 changes: 17 additions & 2 deletions src/opera/test/pge/rtc_s1/test_rtc_s1_pge.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from opera.util import PgeLogger
from opera.util.metadata_utils import create_test_rtc_metadata_product
from opera.util.metadata_utils import get_rtc_s1_product_metadata
from opera.util.metadata_utils import get_sensor_from_spacecraft_name


class RtcS1PgeTestCase(unittest.TestCase):
Expand Down Expand Up @@ -166,11 +167,12 @@ def test_filename_application(self):
output_file = output_files[0]

rtc_metadata = get_rtc_s1_product_metadata(output_file)
sensor = get_sensor_from_spacecraft_name(rtc_metadata['identification']['platform'])

file_name_regex = rf"{pge.PROJECT}_{pge.LEVEL}_{pge.NAME}-{pge.SOURCE}_" \
rf"\w{{4}}-\w{{6}}-\w{{3}}_" \
rf"\d{{8}}T\d{{6}}Z_\d{{8}}T\d{{6}}Z_" \
rf"{rtc_metadata['identification']['missionId']}_" \
rf"{sensor}_" \
rf"{int(rtc_metadata['frequencyA']['xCoordinateSpacing'])}_" \
rf"v{pge.runconfig.product_version}.h5"

Expand All @@ -184,12 +186,23 @@ def test_filename_application(self):

output_files = glob.glob(join(pge.runconfig.output_product_path, f"{core_filename}*.tif"))

self.assertEqual(len(output_files), 2)
self.assertEqual(len(output_files), 4)

output_files = list(map(os.path.basename, output_files))

self.assertIn(f"{core_filename}_VV.tif", output_files)
self.assertIn(f"{core_filename}_VH.tif", output_files)
self.assertIn(f"{core_filename}_nlooks.tif", output_files)
self.assertIn(f"{core_filename}_layover_shadow_mask.tif", output_files)

# Finally, ensure file name was applied to the png browse image
output_files = glob.glob(join(pge.runconfig.output_product_path, f"{core_filename}*.png"))

self.assertEqual(len(output_files), 1)

output_files = list(map(os.path.basename, output_files))

self.assertIn(f"{core_filename}_BROWSE.png", output_files)

def test_iso_metadata_creation(self):
"""
Expand Down Expand Up @@ -428,6 +441,7 @@ def test_expected_extension(self):

product_group = runconfig_dict['RunConfig']['Groups']['SAS']['runconfig']['groups']['product_group']
product_group['output_imagery_format'] = "NETCDF"
product_group['save_browse'] = False # Don't check for the .png browse image

with open(test_runconfig_path, 'w', encoding='utf-8') as outfile:
yaml.safe_dump(runconfig_dict, outfile, sort_keys=False)
Expand All @@ -453,6 +467,7 @@ def test_expected_extension(self):

product_group = runconfig_dict['RunConfig']['Groups']['SAS']['runconfig']['groups']['product_group']
product_group['output_imagery_format'] = "HDF5"
product_group['save_browse'] = False # Don't check for the .png browse image

with open(test_runconfig_path, 'w', encoding='utf-8') as outfile:
yaml.safe_dump(runconfig_dict, outfile, sort_keys=False)
Expand Down
2 changes: 1 addition & 1 deletion src/opera/test/util/test_metadata_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_get_rtc_s1_product_metadata(self):
self.assertAlmostEqual(product_output['frequencyA']['centerFrequency'], 5405000454.33435)
self.assertEqual(product_output['orbit']['orbitType'], "POE")
self.assertEqual(product_output['processingInformation']['inputs']['demSource'], 'dem.tif')
for po, eo in zip(product_output['processingInformation']['inputs']['auxcalFiles'],
for po, eo in zip(product_output['processingInformation']['inputs']['annotationFiles'],
['calibration-s1b-iw1-slc-vv-20180504t104508-20180504t104533-010770-013aee-004.xml',
'noise-s1b-iw1-slc-vv-20180504t104508-20180504t104533-010770-013aee-004.xml']):
self.assertEqual(po, eo)
Expand Down

0 comments on commit 12ed47a

Please sign in to comment.