Skip to content

Commit d400197

Browse files
gshiromaLiang Yu
authored andcommitted
Fix copy of the HDF5 group geolocationGrid (#775)
* add option to update scales list when copying HDF5 datasets * update h5_prep geolocationGrid copy using cp_h5_meta_data() with new attach_scales_list parameter * update copy of the group geolocationGrid for L1 and L2 products * rename output dataset zeroDopplerTime to zeroDopplerAzimuthTime * substitute coordiantes with coordinates * Update python/packages/pybind_nisar/workflows/h5_prep.py Co-Authored-By: Liang Yu <[email protected]> * simplify test for re-attaching HDF5 coordinates Co-authored-by: Liang Yu <[email protected]>
1 parent 5b1a350 commit d400197

File tree

5 files changed

+35
-11
lines changed

5 files changed

+35
-11
lines changed

cxx/isce3/geocode/GeocodePolygon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ GeocodePolygon<T>::GeocodePolygon(
2727
pyre::journal::info_t _info("isce.geometry.GeocodePolygon");
2828

2929
if (x_vect.size() != y_vect.size()) {
30-
std::string error_msg = "ERROR number of X- and Y-coordiantes"
30+
std::string error_msg = "ERROR number of X- and Y-coordinates"
3131
" do not match: " + std::to_string(x_vect.size()) +
3232
" != " + std::to_string(y_vect.size());
3333
throw isce3::except::InvalidArgument(ISCE_SRCINFO(), error_msg);

cxx/isce3/geometry/boundingbox.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace isce3{
3131
* @param[in] numiter Max number of iterations for convergence
3232
*
3333
* The outputs of this method is an OGRLinearRing.
34-
* Transformer from radar geometry coordinates to map coordiantes with a DEM
34+
* Transformer from radar geometry coordinates to map coordinates with a DEM
3535
* The sequence of walking the perimeter is always in the following order :
3636
* <ul>
3737
* <li> Start at Early Time, Near Range edge. Always the first point of the polygon.

doc/sphinx/geometry/getGeoPerimeter.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
getGeoPerimeter
66
==================
77

8-
This is an extension of Rdr2Geo but only performs the transformation of radar coordiantes to
8+
This is an extension of Rdr2Geo but only performs the transformation of radar coordinates to
99
map cordinates at the edges of the swath and returns a GeoJson string representing the Perimeter
1010
of the radar grid. The Geojson form allows one to use the result directly with other GIS software
1111
and REST interfaces.

python/packages/pybind_nisar/h5/bulk.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env python3 #
22

33
def cp_h5_meta_data(src_h5, dst_h5, src_path, dst_path=None,
4-
excludes=None, renames=None, flag_overwrite=False):
4+
excludes=None, renames=None, flag_overwrite=False,
5+
attach_scales_list = None):
56
'''
67
Copy HDF5 node contents
78
@@ -21,6 +22,12 @@ def cp_h5_meta_data(src_h5, dst_h5, src_path, dst_path=None,
2122
renames : dict of (str, str), optional
2223
Dict where keys are source node names and vales
2324
are destination node names
25+
flag_overwrite : bool, optional
26+
If flag_overwrite, delete existing dataset
27+
attach_scales_list : list, optional
28+
List of new dimensions (scales) to overwrite
29+
existing dimensions attributes in destination
30+
datasets
2431
'''
2532

2633
import h5py
@@ -42,7 +49,8 @@ def cp_h5_meta_data(src_h5, dst_h5, src_path, dst_path=None,
4249
if dst_parent_path not in dst_h5:
4350
dst_h5.create_group(dst_parent_path)
4451

45-
if excludes or renames:
52+
if excludes or renames or attach_scales_list is not None:
53+
4654
# copy dataset piecemeal from src_h5:src_path to dst_h5:dst_path
4755
# create dst_path if needed
4856
if dst_path not in dst_h5:
@@ -60,12 +68,17 @@ def cp_h5_meta_data(src_h5, dst_h5, src_path, dst_path=None,
6068
src_sub_path = os.path.join(src_path, subnode_src)
6169
node_obj = src_h5[src_sub_path]
6270

63-
# if flag_overwrite, delete exising dataset
71+
# if flag_overwrite, delete existing dataset
6472
if flag_overwrite and subnode_dst in dst_group:
6573
del dst_group[subnode_dst]
6674

6775
# copy group/dataset
6876
dst_group.copy(node_obj, subnode_dst)
77+
if (attach_scales_list is not None and
78+
'DIMENSION_LIST' in node_obj.attrs.keys()):
79+
dst_group[subnode_dst].attrs.__delitem__('DIMENSION_LIST')
80+
for i, dim in enumerate(attach_scales_list):
81+
dst_group[subnode_dst].dims[i].attach_scale(dim)
6982
else:
7083
dst_group = dst_h5[dst_parent_path]
7184

python/packages/pybind_nisar/workflows/h5_prep.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,31 @@ def cp_geocode_meta(cfg, output_hdf5, dst):
147147
if is_geocoded:
148148
cp_h5_meta_data(src_h5, dst_h5, f'{src_meta_path}/attitude',
149149
f'{dst_meta_path}/attitude')
150-
if dst not in ['GCOV', 'GSLC']:
150+
if dst != 'GCOV':
151151
# the lines below should be deleted after radar-grid
152152
# cubes are added to all L2 workflows
153+
yds = dst_h5.create_dataset(f'{dst_meta_path}/radarGrid/yCoordinates',
154+
data = src_h5[f'{src_meta_path}/geolocationGrid/zeroDopplerTime'])
155+
xds = dst_h5.create_dataset(f'{dst_meta_path}/radarGrid/xCoodinates',
156+
data = src_h5[f'{src_meta_path}/geolocationGrid/slantRange'])
153157
cp_h5_meta_data(src_h5, dst_h5,
154158
f'{src_meta_path}/geolocationGrid',
155159
f'{dst_meta_path}/radarGrid',
156-
renames={'coordinateX': 'xCoordinates',
157-
'coordinateY': 'yCoordinates',
158-
'zeroDopplerTime': 'zeroDopplerAzimuthTime'})
160+
renames={'coordinateX': 'slantRange',
161+
'coordinateY': 'zeroDopplerAzimuthTime'},
162+
excludes=['slantRange', 'zeroDopplerTime'],
163+
attach_scales_list = [yds, xds])
159164
else:
160165
# RUNW and RIFG have no attitude group and have geolocation grid
166+
yds = dst_h5.create_dataset(f'{dst_meta_path}/geolocationGrid/zeroDopplerTime',
167+
data = src_h5[f'{src_meta_path}/geolocationGrid/zeroDopplerTime'])
168+
xds = dst_h5.create_dataset(f'{dst_meta_path}/geolocationGrid/slantRange',
169+
data = src_h5[f'{src_meta_path}/geolocationGrid/slantRange'])
161170
cp_h5_meta_data(src_h5, dst_h5,
162171
f'{src_meta_path}/geolocationGrid',
163-
f'{dst_meta_path}/geolocationGrid')
172+
f'{dst_meta_path}/geolocationGrid',
173+
excludes=['zeroDopplerTime', 'slantRange'],
174+
attach_scales_list = [yds, xds])
164175

165176
# copy processingInformation/algorithms group (common across products)
166177
cp_h5_meta_data(src_h5, dst_h5,

0 commit comments

Comments
 (0)