Skip to content

Commit 1b25c05

Browse files
seongsujeongSeongsu JeongLiangJYu
authored
Patch for "no polynomial" case for azimuth FM rate mitigation & handling the burst without burst polygon (#134)
* Take care of the case when the az. time of the polynomial list does not cover sensing start / stop * Let `InterpolatedUnivariateSpline` to return boundary values when the input parameter is out of the interpolator's range * extrapolate the burst center point the border polygon when the burst polygon data is missing in the metadata * Interface to turn on / off the correction * ditch out burst border polygon extrapolation, and fill that with `None` * Place empty geometry instead of `None` * whitespace removal * Apply suggestions from code review Co-authored-by: Liang Yu <liangjyu@gmail.com> * add description about "no polynomials for burst" case * get rid of unnecessary module in `s1-reader.py` * bump the version * more clarification about the missing polynomial case --------- Co-authored-by: Seongsu Jeong <seongsu.jeong@jpl.nasa.gov> Co-authored-by: Liang Yu <liangjyu@gmail.com>
1 parent b5e20e0 commit 1b25c05

File tree

4 files changed

+59
-12
lines changed

4 files changed

+59
-12
lines changed

src/s1reader/s1_annotation.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,13 +1180,15 @@ def from_polynomial_lists(cls,
11801180
fm_rate_coeff_burst_arr,
11811181
fm_rate_tau0_burst_vec) = cls.extract_polynomial_sequence(az_fm_rate_list,
11821182
sensing_start,
1183-
sensing_end)
1183+
sensing_end,
1184+
handle_out_of_range=True)
11841185

11851186
(dc_aztime_burst_vec,
11861187
dc_coeff_burst_arr,
11871188
dc_tau0_burst_vec) = cls.extract_polynomial_sequence(doppler_centroid_list,
11881189
sensing_start,
1189-
sensing_end)
1190+
sensing_end,
1191+
handle_out_of_range=True)
11901192

11911193
return cls(fm_rate_aztime_burst_vec, fm_rate_coeff_burst_arr, fm_rate_tau0_burst_vec,
11921194
dc_aztime_burst_vec, dc_coeff_burst_arr, dc_tau0_burst_vec)
@@ -1195,7 +1197,8 @@ def from_polynomial_lists(cls,
11951197
@classmethod
11961198
def extract_polynomial_sequence(cls, polynomial_list: list,
11971199
datetime_start: datetime.datetime,
1198-
datetime_end: datetime.datetime):
1200+
datetime_end: datetime.datetime,
1201+
handle_out_of_range=True):
11991202
'''
12001203
Scan `vec_azimuth_time` end find indices of the vector
12011204
that covers the period defined with
@@ -1246,6 +1249,20 @@ def extract_polynomial_sequence(cls, polynomial_list: list,
12461249

12471250
# Scale factor to convert range (in meters) to seconds (tau)
12481251
range_to_tau = 2.0 / speed_of_light
1252+
1253+
# Take care of the case when the az. time of the polynomial list does not cover
1254+
# the sensing start/stop
1255+
if (index_end == index_start) and handle_out_of_range:
1256+
# 0--1--2--3--4--5 <- az. time of polynomial list (index shown on the left)
1257+
#|--| <- sensing start / stop
1258+
if index_start == 0:
1259+
index_end += 1
1260+
1261+
# 0--1--2--3--4--5 <- az. time of polynomial list (index shown on the left)
1262+
# |--| <- sensing start / stop
1263+
else:
1264+
index_start -= 1
1265+
12491266
for poly in polynomial_list[index_start:index_end+1]:
12501267
vec_aztime_sequence.append(poly[0])
12511268
arr_coeff_sequence.append(poly[1].coeffs)

src/s1reader/s1_burst_slc.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,15 +911,29 @@ def az_fm_rate_mismatch_from_llh(self,
911911
for datetime_vec in self.extended_coeffs.dc_aztime_vec]
912912

913913
# calculate splined interpolation of the coeffs. and tau_0s
914+
if len(fm_rate_aztime_sec_vec) <= 1:
915+
# Interpolator object cannot be created with only one set of polynomials.
916+
# Such case happens when there is no polygon that falls between a burst's start / stop
917+
# which was found from very few Sentinel-1 IW SLCs processed by IPF 002.36
918+
# Return an empty LUT2d in that case
919+
return isce3.core.LUT2d()
914920
interpolator_tau0_ka = InterpolatedUnivariateSpline(
915921
fm_rate_aztime_sec_vec,
916922
self.extended_coeffs.fm_rate_tau0_vec,
923+
ext=3,
917924
k=1)
918925
tau0_ka_interp = interpolator_tau0_ka(vec_t)[..., np.newaxis]
919926

927+
if len(dc_aztime_sec_vec) <=1:
928+
# Interpolator object cannot be created with only one set of polynomials.
929+
# Such case happens when there is no polygon that falls between a burst's start / stop
930+
# which was found from very few Sentinel-1 IW SLCs processed by IPF 002.36
931+
# Return an empty LUT2d in that case
932+
return isce3.core.LUT2d()
920933
interpolator_tau0_fdc_interp = InterpolatedUnivariateSpline(
921934
dc_aztime_sec_vec,
922935
self.extended_coeffs.dc_tau0_vec,
936+
ext=3,
923937
k=1)
924938
tau0_fdc_interp = interpolator_tau0_fdc_interp(vec_t)[..., np.newaxis]
925939

src/s1reader/s1_reader.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from nisar.workflows.stage_dem import check_dateline
2020

2121
from s1reader import s1_annotation # to access __file__
22-
from s1reader.s1_annotation import (RFI_INFO_AVAILABLE_FROM,
22+
from s1reader.s1_annotation import (RFI_INFO_AVAILABLE_FROM,
2323
CalibrationAnnotation,
2424
AuxCal, BurstCalibration,
2525
BurstEAP, BurstNoise, BurstExtendedCoeffs,
@@ -221,16 +221,20 @@ def calculate_centroid(lons, lats):
221221

222222
return shapely.geometry.Point(llh_centroid[:2])
223223

224-
def get_burst_centers_and_boundaries(tree):
224+
def get_burst_centers_and_boundaries(tree, num_bursts=None):
225225
'''Parse grid points list and calculate burst center lat and lon
226226
227-
Parameters:
228-
-----------
227+
Parameters
228+
----------
229229
tree : Element
230230
Element containing geolocation grid points.
231-
232-
Returns:
233-
--------
231+
num_bursts: int or None
232+
Expected number of bursts in the subswath.
233+
To check if the # of polygon is the same as the parsed polygons.
234+
When it's None, the number of burst is the same as # polygons found in this function.
235+
236+
Returns
237+
-------
234238
center_pts : list
235239
List of burst centroids ass shapely Points
236240
boundary_pts : list
@@ -252,6 +256,9 @@ def get_burst_centers_and_boundaries(tree):
252256
lons[i] = float(grid_pt[5].text)
253257

254258
unique_line_indices = np.unique(lines)
259+
260+
if num_bursts is None:
261+
num_bursts = len(unique_line_indices) - 1
255262
n_bursts = len(unique_line_indices) - 1
256263
center_pts = [[]] * n_bursts
257264
boundary_pts = [[]] * n_bursts
@@ -273,6 +280,14 @@ def get_burst_centers_and_boundaries(tree):
273280
poly = shapely.geometry.Polygon(zip(burst_lons, burst_lats))
274281
boundary_pts[i] = check_dateline(poly)
275282

283+
num_border_polygon = len(unique_line_indices) - 1
284+
if num_bursts > num_border_polygon:
285+
warnings.warn('Inconsistency between # bursts in subswath, and the # polygons. ')
286+
num_missing_polygons = num_bursts - num_border_polygon
287+
288+
center_pts += [shapely.Point()] * num_missing_polygons
289+
boundary_pts += [[shapely.Polygon()]] * num_missing_polygons
290+
276291
return center_pts, boundary_pts
277292

278293

@@ -853,8 +868,6 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
853868

854869
orbit_number = int(tree.find('adsHeader/absoluteOrbitNumber').text)
855870

856-
center_pts, boundary_pts = get_burst_centers_and_boundaries(tree)
857-
858871
wavelength = isce3.core.speed_of_light / radar_freq
859872
starting_range = slant_range_time * isce3.core.speed_of_light / 2
860873
range_pxl_spacing = isce3.core.speed_of_light / (2 * range_sampling_rate)
@@ -912,6 +925,8 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
912925
n_bursts = int(burst_list_elements.attrib['count'])
913926
bursts = [[]] * n_bursts
914927

928+
center_pts, boundary_pts = get_burst_centers_and_boundaries(tree, num_bursts=n_bursts)
929+
915930
for i, burst_list_element in enumerate(burst_list_elements):
916931
# Zero Doppler azimuth time of the first line of this burst
917932
sensing_start = as_datetime(burst_list_element.find('azimuthTime').text)

src/s1reader/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# release history
55
Tag = collections.namedtuple('Tag', 'version date')
66
release_history = (
7+
Tag('0.2.3', '2023-09-21'),
78
Tag('0.2.2', '2023-09-08'),
89
Tag('0.2.1', '2023-08-23'),
910
Tag('0.2.0', '2023-07-25'),

0 commit comments

Comments
 (0)