Skip to content

Commit 63bf31a

Browse files
Virginia Brancatovbrancat
authored andcommitted
h5_prep fix to ASF/PGE comments (#801)
* Adding reference/secondary zeroDoppler time * Open sec_src_h5 only once * Remove closing of second dataset Co-authored-by: vbrancat <[email protected]>
1 parent 040aebc commit 63bf31a

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

python/packages/pybind_nisar/workflows/h5_prep.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,22 @@ def cp_geocode_meta(cfg, output_hdf5, dst):
122122
# Copy of identification
123123
identification_excludes = 'productType'
124124
if is_insar:
125-
identification_excludes = ['productType', 'listOfFrequencies']
125+
identification_excludes = ['productType', 'listOfFrequencies',
126+
'zeroDopplerStartTime', 'zeroDopplerEndTime']
126127
cp_h5_meta_data(src_h5, dst_h5, f'{common_parent_path}/identification',
127128
excludes=identification_excludes)
129+
# If insar, create reference/secondary zeroDopplerStartEndTime
130+
if is_insar:
131+
# Open secondary hdf5 to copy information
132+
with h5py.File(secondary_hdf5, 'r', libver='latest', swmr=True) as sec_src_h5:
133+
src_dataset = ['zeroDopplerStartTime', 'zeroDopplerEndTime']
134+
dst_dataset = ['referenceZeroDopplerStartTime', 'referenceZeroDopplerEndTime']
135+
for src_data, dst_data in zip(src_dataset, dst_dataset):
136+
cp_h5_meta_data(src_h5, dst_h5, f'{common_parent_path}/identification/{src_data}',
137+
f'{common_parent_path}/identification/{dst_data}')
138+
dst_data = dst_data.replace('reference', 'secondary')
139+
cp_h5_meta_data(sec_src_h5, dst_h5, f'{common_parent_path}/identification/{src_data}',
140+
f'{common_parent_path}/identification/{dst_data}')
128141

129142
# Flag isGeocoded
130143
ident = dst_h5[f'{common_parent_path}/identification']
@@ -144,10 +157,9 @@ def cp_geocode_meta(cfg, output_hdf5, dst):
144157
f'{dst_meta_path}/orbit')
145158

146159
# copy attitude information group
147-
if is_geocoded:
148-
cp_h5_meta_data(src_h5, dst_h5, f'{src_meta_path}/attitude',
149-
f'{dst_meta_path}/attitude')
150-
else:
160+
cp_h5_meta_data(src_h5, dst_h5, f'{src_meta_path}/attitude',
161+
f'{dst_meta_path}/attitude')
162+
if dst in ['RIFG', 'RUNW']:
151163
# RUNW and RIFG have no attitude group and have geolocation grid
152164
yds = dst_h5.create_dataset(f'{dst_meta_path}/geolocationGrid/zeroDopplerTime',
153165
data = src_h5[f'{src_meta_path}/geolocationGrid/zeroDopplerTime'])
@@ -176,15 +188,10 @@ def cp_geocode_meta(cfg, output_hdf5, dst):
176188
data=np.string_(dem_interp_method))
177189

178190
# copy processingInformation/inputs group
179-
exclude_args = ['l0bGranules', 'demFiles']
180-
if not is_geocoded:
181-
exclude_args = ['attitudeFiles', 'auxcalFiles',
182-
'l0bGranules', 'orbitFiles']
183-
184191
cp_h5_meta_data(src_h5, dst_h5,
185192
f'{src_meta_path}/processingInformation/inputs',
186193
f'{dst_meta_path}/processingInformation/inputs',
187-
excludes=exclude_args)
194+
excludes=['l0bGranules'])
188195

189196
# Create l1SlcGranules
190197
inputs = [input_hdf5]

0 commit comments

Comments
 (0)