Skip to content

Commit

Permalink
allow for the product version to be a string
Browse files Browse the repository at this point in the history
  • Loading branch information
gshiroma committed Sep 6, 2023
1 parent 34f351b commit 55e0e25
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 18 deletions.
34 changes: 29 additions & 5 deletions src/rtc/h5_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,32 @@ def save_hdf5_file(hdf5_obj, output_hdf5_file, clip_max,
logger.info(f'file saved: {output_hdf5_file}')


def get_product_version(product_version_runconfig):
'''
Returns the product version from the product
version defined by the user in the runconfig.
Parameters
---------
product_version_runconfig: scalar
RunConfig product version
Returns
-------
product_version: scalar
Product version
'''
if product_version_runconfig is None:
product_version = SOFTWARE_VERSION
return product_version
try:
product_version_float = float(product_version_runconfig)
product_version = f'{product_version_float:.1f}'
except ValueError:
product_version = product_version_runconfig
return product_version


def create_hdf5_file(product_id, output_hdf5_file, orbit, burst, cfg,
processing_datetime, is_mosaic):
'''Create HDF5 file
Expand Down Expand Up @@ -362,11 +388,9 @@ def get_metadata_dict(product_id: str,
product_type = cfg_in.groups.primary_executable.product_type

# product version
product_version_float = cfg_in.groups.product_group.product_version
if product_version_float is None:
product_version = SOFTWARE_VERSION
else:
product_version = f'{product_version_float:.1f}'
product_version_runconfig = cfg_in.groups.product_group.product_version
product_version_runconfig = cfg.groups.product_group.product_version
product_version = get_product_version(product_version_runconfig)

# DEM description
dem_file_description = cfg_in.dem_file_description
Expand Down
9 changes: 4 additions & 5 deletions src/rtc/rtc_s1.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from rtc.version import VERSION as SOFTWARE_VERSION
from rtc.h5_prep import (save_hdf5_file, create_hdf5_file,
get_metadata_dict,
get_product_version,
all_metadata_dict_to_geotiff_metadata_dict,
layer_hdf5_dict,
DATA_BASE_GROUP,
Expand Down Expand Up @@ -266,13 +267,11 @@ def run_parallel(cfg: RunConfig, logfile_path, flag_logger_full_format):

# primary executable
product_type = cfg.groups.primary_executable.product_type
product_version_float = cfg.groups.product_group.product_version
product_version_runconfig = cfg.groups.product_group.product_version
rtc_s1_static_validity_start_date = \
cfg.groups.product_group.rtc_s1_static_validity_start_date
if product_version_float is None:
product_version = SOFTWARE_VERSION
else:
product_version = f'{product_version_float:.1f}'
product_version_runconfig = cfg.groups.product_group.product_version
product_version = get_product_version(product_version_runconfig)

# unpack processing parameters
processing_namespace = cfg.groups.processing
Expand Down
9 changes: 4 additions & 5 deletions src/rtc/rtc_s1_single_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from rtc.core import (save_as_cog, check_ancillary_inputs,
build_empty_vrt)
from rtc.h5_prep import (save_hdf5_file, create_hdf5_file,
get_product_version,
get_metadata_dict,
all_metadata_dict_to_geotiff_metadata_dict,
layer_names_dict,
Expand Down Expand Up @@ -1096,13 +1097,11 @@ def run_single_job(cfg: RunConfig):

# primary executable
product_type = cfg.groups.primary_executable.product_type
product_version_float = cfg.groups.product_group.product_version
rtc_s1_static_validity_start_date = \
cfg.groups.product_group.rtc_s1_static_validity_start_date
if product_version_float is None:
product_version = SOFTWARE_VERSION
else:
product_version = f'{product_version_float:.1f}'

product_version_runconfig = cfg.groups.product_group.product_version
product_version = get_product_version(product_version_runconfig)

# unpack processing parameters
processing_namespace = cfg.groups.processing
Expand Down
2 changes: 1 addition & 1 deletion src/rtc/schemas/rtc_s1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ runconfig:

processing_type: enum('NOMINAL', 'URGENT', 'CUSTOM', 'UNDEFINED', required=False)

product_version: num(required=False)
product_version: str(required=False)

# Directory where PGE will place results
product_path: str()
Expand Down
2 changes: 0 additions & 2 deletions tests/runconfigs/s1b_los_angeles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ runconfig:
product_group:
processing_type: 'CUSTOM'

# product_version: 3.1

# Directory where PGE will place results
product_path: .

Expand Down

0 comments on commit 55e0e25

Please sign in to comment.