Skip to content

Commit

Permalink
Added initial logic for staging of compressed CSLC products from DISP-S1
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Collins committed Jan 23, 2024
1 parent 5372117 commit 3105ea7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
27 changes: 26 additions & 1 deletion src/opera/pge/disp_s1/disp_s1_pge.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,30 @@ def _netcdf_filename(self, inter_filename):

return netcdf_filename

def _compressed_cslc_filename(self, inter_filename):
"""
Returns the file name to use for compressed CSLC files produced by the
DISP-S1 PGE.
The current convention is to maintain the filename assigned by the DISP-S1
SAS, but this function is still required to ensure the compressed CSLC products
are moved to the output directory defined by the RunConfig.
Parameters
----------
inter_filename : str
The intermediate filename of the compressed CSLC product to generate
a filename for. This parameter may be used to inspect the file
in order to derive any necessary components of the returned filename.
Returns
-------
compressed_cslc_filename : str
The file name to assign to compressed CSLC product(s) created by this PGE.
"""
return os.path.basename(inter_filename)

def _ancillary_filename(self):
"""
Helper method to derive the core component of the file names for the
Expand Down Expand Up @@ -747,6 +771,7 @@ def __init__(self, pge_name, runconfig_path, **kwargs):
{
# Note: ordering matters here!
'*.nc': self._netcdf_filename,
'*.png': self._browse_filename
'*.png': self._browse_filename,
'compressed*.h5': self._compressed_cslc_filename
}
)
4 changes: 2 additions & 2 deletions src/opera/test/data/test_disp_s1_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ RunConfig:
- '-p disp_s1_pge_test/output_dir/compressed_slcs;'
- 'python3 -c "from opera.util.h5_utils import create_test_disp_metadata_product; create_test_disp_metadata_product(\"disp_s1_pge_test/output_dir/20180101_20180330.unw.nc\")";'
- 'dd if=/dev/urandom of=disp_s1_pge_test/output_dir/20180101_20180330.unw.png bs=1M count=1;'
- 'dd if=/dev/urandom of=disp_s1_pge_test/output_dir/compressed_slcs/compressed_slc_t087_185683_iw2_20180222_20180330.h5 bs=1M count=1;'
- 'dd if=/dev/urandom of=disp_s1_pge_test/output_dir/compressed_slcs/compressed_slc_t087_185684_iw2_20180222_20180330.h5 bs=1M count=1;'
- 'dd if=/dev/urandom of=disp_s1_pge_test/output_dir/compressed_slcs/compressed_t087_185683_iw2_20180222_20180330.h5 bs=1M count=1;'
- 'dd if=/dev/urandom of=disp_s1_pge_test/output_dir/compressed_slcs/compressed_t087_185684_iw2_20180222_20180330.h5 bs=1M count=1;'
- '/bin/echo DISP-S1 invoked with RunConfig'
ErrorCodeBase: 500000
SchemaPath: pge/disp_s1/schema/disp_s1_sas_schema.yaml
Expand Down
8 changes: 7 additions & 1 deletion src/opera/test/pge/disp_s1/test_disp_s1_pge.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_disp_s1_pge_execution(self):
expected_log_file = pge.logger.get_file_name()
self.assertTrue(os.path.exists(expected_log_file))

# Lastly, check that the dummy output product was created and renamed
# Lastly, check that the dummy output products were created and renamed
expected_disp_product = join(
pge.runconfig.output_product_path,
pge._netcdf_filename(
Expand All @@ -222,6 +222,12 @@ def test_disp_s1_pge_execution(self):
)
self.assertTrue(os.path.exists(expected_disp_product))

expected_compressed_cslc_product = join(
pge.runconfig.output_product_path,
pge._compressed_cslc_filename('compressed_t087_185683_iw2_20180222_20180330.h5')
)
self.assertTrue(os.path.exists(expected_compressed_cslc_product))

# Open and read the log
with open(expected_log_file, 'r', encoding='utf-8') as infile:
log_contents = infile.read()
Expand Down

0 comments on commit 3105ea7

Please sign in to comment.