From 4357ebcbbc9a608b1edae55f1f24d702b15f08ae Mon Sep 17 00:00:00 2001 From: Seongsu Jeong Date: Tue, 5 Sep 2023 15:49:40 -0700 Subject: [PATCH 1/2] orbit type when `orbit_file_path` is list --- src/rtc/h5_prep.py | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/rtc/h5_prep.py b/src/rtc/h5_prep.py index cb755c1..add543b 100644 --- a/src/rtc/h5_prep.py +++ b/src/rtc/h5_prep.py @@ -278,7 +278,7 @@ def create_hdf5_file(product_id, output_hdf5_file, orbit, burst, cfg, # save orbit orbit_group = hdf5_obj.require_group('/metadata/orbit') - save_orbit(orbit, orbit_group, os.path.basename(cfg.orbit_file_path)) + save_orbit(orbit, orbit_group, cfg.orbit_file_path) return hdf5_obj @@ -301,15 +301,29 @@ def save_orbit(orbit, orbit_group, orbit_file_path): 'referenceEpoch', data=np.string_(orbit.reference_epoch.isoformat())) - # Orbit source/type - if 'RESORB' in orbit_file_path: - orbit_type = 'RES restituted orbit' - elif 'POEORB' in orbit_file_path: - orbit_type = 'POE precise orbit' - else: - orbit_type = 'Undefined' - - d = orbit_group.require_dataset("orbitType", (), "S25", + # Orbit source/type + if isinstance(orbit_file_path, str): + orbit_file_basename = os.path.basename(orbit_file_path) + if 'RESORB' in orbit_file_basename: + orbit_type = 'RES restituted orbit' + elif 'POEORB' in orbit_file_basename: + orbit_type = 'POE precise orbit' + else: + orbit_type = 'Undefined' + + elif isinstance(orbit_file_path, list): + orbit_type_list = [] + for individual_orbit_file in orbit_file_path: + if 'RESORB' in individual_orbit_file: + orbit_type_individual = 'RES restituted orbit' + elif 'POEORB' in individual_orbit_file: + orbit_type_individual = 'POE precise orbit' + else: + orbit_type_individual = 'Undefined' + orbit_type_list.append(orbit_type_individual) + orbit_type = '; '.join(orbit_type_list) + + d = orbit_group.require_dataset("orbitType", (), "S64", data=np.string_(orbit_type)) d.attrs["description"] = np.string_( "Type of orbit file used in processing") From f5173c941eb6b2b0130cf789be3a72ab9b634913 Mon Sep 17 00:00:00 2001 From: Seongsu Jeong Date: Tue, 5 Sep 2023 23:08:57 -0700 Subject: [PATCH 2/2] Update src/rtc/h5_prep.py Co-authored-by: Gustavo H. X. Shiroma <52007211+gshiroma@users.noreply.github.com> --- src/rtc/h5_prep.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rtc/h5_prep.py b/src/rtc/h5_prep.py index add543b..0085b7c 100644 --- a/src/rtc/h5_prep.py +++ b/src/rtc/h5_prep.py @@ -302,14 +302,13 @@ def save_orbit(orbit, orbit_group, orbit_file_path): data=np.string_(orbit.reference_epoch.isoformat())) # Orbit source/type + orbit_type = 'Undefined' if isinstance(orbit_file_path, str): orbit_file_basename = os.path.basename(orbit_file_path) if 'RESORB' in orbit_file_basename: orbit_type = 'RES restituted orbit' elif 'POEORB' in orbit_file_basename: orbit_type = 'POE precise orbit' - else: - orbit_type = 'Undefined' elif isinstance(orbit_file_path, list): orbit_type_list = []