Skip to content

Commit d827d3d

Browse files
committed
use radargrid step parameters to simplify _steps_to_vecs
Now that the function `self.as_isce3_radargrid` has parameters for step sizes, we dont need to redo the logic to compute the coordinates. This should fix #105 where the differing logic causes different coordinates. It also allows us to remove redundant error checking that happens in the `as_isce3_radaragrid` function
1 parent 0e0c781 commit d827d3d

File tree

1 file changed

+7
-63
lines changed

1 file changed

+7
-63
lines changed

src/s1reader/s1_burst_slc.py

Lines changed: 7 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -527,45 +527,15 @@ def as_dict(self):
527527
self_as_dict[key] = val
528528
return self_as_dict
529529

530+
def _steps_to_vecs(self, range_step: float, az_step: float):
531+
"""Convert range_step (meters) and az_step (sec) into aranges to generate LUT2ds."""
532+
radargrid = self.as_isce3_radargrid(az_step=az_step, rg_step=range_step)
533+
n_az, n_range = radargrid.shape
530534

531-
def _steps_to_vecs(self, range_step, az_step):
532-
''' convert range_step (meters) and az_step (seconds) into aranges to
533-
generate LUT2ds
534-
'''
535-
step_errs = []
536-
if range_step <= 0:
537-
step_errs.append('range')
538-
if az_step <= 0:
539-
step_errs.append('azimuth')
540-
if step_errs:
541-
step_errs = ', '.join(step_errs)
542-
err_str = f'Following step size(s) <=0: {step_errs}'
543-
raise ValueError(err_str)
544-
545-
# container to store names of axis vectors that are invalid: i.e. size 0
546-
vec_errs = []
547-
548-
# compute range vector
549-
n_range = np.ceil(self.width * self.range_pixel_spacing / range_step).astype(int)
550535
range_vec = self.starting_range + np.arange(0, n_range) * range_step
551-
if range_vec.size == 0:
552-
vec_errs.append('range')
553-
554-
# compute azimuth vector
555-
n_az = np.ceil(self.length * self.azimuth_time_interval / az_step).astype(int)
556-
rdrgrid = self.as_isce3_radargrid()
557-
az_vec = rdrgrid.sensing_start + np.arange(0, n_az) * az_step
558-
if az_vec.size == 0:
559-
vec_errs.append('azimuth')
560-
561-
if vec_errs:
562-
vec_errs = ', '.join(vec_errs)
563-
err_str = f'Cannot build aranges from following step(s): {vec_errs}'
564-
raise ValueError(err_str)
565-
536+
az_vec = radargrid.sensing_start + np.arange(0, n_az) * az_step
566537
return range_vec, az_vec
567538

568-
569539
def bistatic_delay(self, range_step=1, az_step=1):
570540
'''Computes the bistatic delay correction in azimuth direction
571541
due to the movement of the platform between pulse transmission and echo reception
@@ -752,8 +722,7 @@ def az_fm_rate_mismatch_mitigation(self,
752722
range_step=None,
753723
az_step=None,
754724
threshold_rdr2geo=1e-8,
755-
numiter_rdr2geo=25,
756-
custom_radargrid=None):
725+
numiter_rdr2geo=25):
757726
'''
758727
- Calculate Lon / Lat / Hgt in radar grid, to be used for the
759728
actual computation of az fm mismatch rate
@@ -776,9 +745,6 @@ def az_fm_rate_mismatch_mitigation(self,
776745
Threshold of the iteration for rdr2geo
777746
numiter_rdr2geo: int
778747
Maximum number of iteration for rdr2geo
779-
custom_radargrid: isce3.product.RadarGridParameters
780-
ISCE3 radar grid to define the correction grid.
781-
If None, the full resolution radargrid of the burst will be used.
782748
783749
Return:
784750
-------
@@ -801,29 +767,7 @@ def az_fm_rate_mismatch_mitigation(self,
801767
os.makedirs(path_scratch, exist_ok=True)
802768

803769
# define the radar grid to calculate az fm mismatch rate
804-
correction_radargrid = self.as_isce3_radargrid()
805-
if custom_radargrid is not None:
806-
correction_radargrid = custom_radargrid
807-
808-
# Override the radargrid definition if `rg_step` and `az_step` is defined
809-
if range_step and az_step:
810-
if custom_radargrid is not None:
811-
warnings.warn('range_step and az_step assigned. '
812-
'Overriding the custom radargrid definition.')
813-
814-
width_radargrid, length_radargrid = \
815-
[vec.size for vec in self._steps_to_vecs(range_step, az_step)]
816-
sensing_start_radargrid = self.as_isce3_radargrid().sensing_start
817-
correction_radargrid = isce3.product.RadarGridParameters(
818-
sensing_start_radargrid,
819-
self.wavelength,
820-
1/az_step,
821-
self.starting_range,
822-
range_step,
823-
isce3.core.LookSide.Right,
824-
length_radargrid,
825-
width_radargrid,
826-
self.as_isce3_radargrid().ref_epoch)
770+
correction_radargrid = self.as_isce3_radargrid(az_step=az_step, range_step=range_step)
827771

828772
# Run topo on scratch directory
829773
if not os.path.isfile(path_dem):

0 commit comments

Comments
 (0)