@@ -249,18 +249,20 @@ def get_burst_centers_and_boundaries(tree):
249
249
return center_pts , boundary_pts
250
250
251
251
def burst_from_xml (annotation_path : str , orbit_path : str , tiff_path : str ,
252
- open_method = open ):
253
- '''Parse bursts in Sentinel 1 annotation XML.
252
+ iw2_annotation_path : str , open_method = open ):
253
+ '''Parse bursts in Sentinel- 1 annotation XML.
254
254
255
255
Parameters:
256
256
-----------
257
257
annotation_path : str
258
- Path to Sentinel 1 annotation XML file of specific subswath and
258
+ Path to Sentinel- 1 annotation XML file of specific subswath and
259
259
polarization.
260
260
orbit_path : str
261
261
Path the orbit file.
262
262
tiff_path : str
263
- Path to tiff file holding Sentinel 1 SLCs.
263
+ Path to tiff file holding Sentinel-1 SLCs.
264
+ iw2_annotation_path : str
265
+ Path to Sentinel-1 annotation XML file of IW2 subswath.
264
266
open_method : function
265
267
Function used to open annotation file.
266
268
@@ -324,6 +326,14 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
324
326
starting_range = slant_range_time * isce3 .core .speed_of_light / 2
325
327
range_pxl_spacing = isce3 .core .speed_of_light / (2 * range_sampling_rate )
326
328
329
+ # calculate the range at mid swath (mid of SM swath, mid of IW2 or mid of EW3)
330
+ with open_method (iw2_annotation_path , 'r' ) as iw2_f :
331
+ iw2_tree = ET .parse (iw2_f )
332
+ iw2_slant_range_time = float (iw2_tree .find ('imageAnnotation/imageInformation/slantRangeTime' ).text )
333
+ iw2_n_samples = int (iw2_tree .find ('swathTiming/samplesPerBurst' ).text )
334
+ iw2_starting_range = iw2_slant_range_time * isce3 .core .speed_of_light / 2
335
+ iw2_mid_range = iw2_starting_range + 0.5 * iw2_n_samples * range_pxl_spacing
336
+
327
337
# find orbit state vectors in 'Data_Block/List_of_OSVs'
328
338
orbit_tree = ET .parse (orbit_path )
329
339
osv_list = orbit_tree .find ('Data_Block/List_of_OSVs' )
@@ -380,7 +390,7 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
380
390
381
391
bursts [i ] = Sentinel1BurstSlc (sensing_start , radar_freq , wavelength ,
382
392
azimuth_steer_rate , azimuth_time_interval ,
383
- slant_range_time , starting_range ,
393
+ slant_range_time , starting_range , iw2_mid_range ,
384
394
range_sampling_rate , range_pxl_spacing ,
385
395
(n_lines , n_samples ), az_fm_rate , doppler ,
386
396
rng_processing_bandwidth , pol , burst_id ,
@@ -416,12 +426,12 @@ def _is_zip_annotation_xml(path: str, id_str: str) -> bool:
416
426
return False
417
427
418
428
def load_bursts (path : str , orbit_path : str , swath_num : int , pol : str = 'vv' ):
419
- '''Find bursts in a Sentinel 1 zip file or a SAFE structured directory.
429
+ '''Find bursts in a Sentinel- 1 zip file or a SAFE structured directory.
420
430
421
431
Parameters:
422
432
-----------
423
433
path : str
424
- Path to Sentinel 1 zip file or SAFE directory
434
+ Path to Sentinel- 1 zip file or SAFE directory
425
435
orbit_path : str
426
436
Path the orbit file.
427
437
swath_num : int
@@ -456,7 +466,7 @@ def load_bursts(path: str, orbit_path: str, swath_num: int, pol: str = 'vv'):
456
466
raise ValueError (f'{ path } is unsupported' )
457
467
458
468
def _burst_from_zip (zip_path : str , id_str : str , orbit_path : str ):
459
- '''Find bursts in a Sentinel 1 zip file.
469
+ '''Find bursts in a Sentinel- 1 zip file.
460
470
461
471
Parameters:
462
472
-----------
@@ -475,22 +485,29 @@ def _burst_from_zip(zip_path: str, id_str: str, orbit_path: str):
475
485
with zipfile .ZipFile (zip_path , 'r' ) as z_file :
476
486
z_file_list = z_file .namelist ()
477
487
478
- # find annotation file
488
+ # find annotation file - subswath of interest
479
489
f_annotation = [f for f in z_file_list if _is_zip_annotation_xml (f , id_str )]
480
490
if not f_annotation :
481
491
raise ValueError (f"burst { id_str } not in SAFE: { zip_path } " )
482
492
f_annotation = f_annotation [0 ]
483
493
494
+ # find annotation file - IW2
495
+ iw2_id_str = f'iw2-{ id_str [4 :]} '
496
+ iw2_f_annotation = [f for f in z_file_list if _is_zip_annotation_xml (f , iw2_id_str )]
497
+ if not iw2_f_annotation :
498
+ raise ValueError (f"burst { iw2_id_str } not in SAFE: { zip_path } " )
499
+ iw2_f_annotation = iw2_f_annotation [0 ]
500
+
484
501
# find tiff file
485
502
f_tiff = [f for f in z_file_list
486
503
if 'measurement' in f and id_str in f and 'tiff' in f ]
487
504
f_tiff = f'/vsizip/{ zip_path } /{ f_tiff [0 ]} ' if f_tiff else ''
488
505
489
- bursts = burst_from_xml (f_annotation , orbit_path , f_tiff , z_file .open )
506
+ bursts = burst_from_xml (f_annotation , orbit_path , f_tiff , iw2_f_annotation , z_file .open )
490
507
return bursts
491
508
492
509
def _burst_from_safe_dir (safe_dir_path : str , id_str : str , orbit_path : str ):
493
- '''Find bursts in a Sentinel 1 SAFE structured directory.
510
+ '''Find bursts in a Sentinel- 1 SAFE structured directory.
494
511
495
512
Parameters:
496
513
-----------
@@ -507,13 +524,20 @@ def _burst_from_safe_dir(safe_dir_path: str, id_str: str, orbit_path: str):
507
524
List of Sentinel1BurstSlc objects found in annotation XML.
508
525
'''
509
526
510
- # find annotation file
527
+ # find annotation file - subswath of interest
511
528
annotation_list = os .listdir (f'{ safe_dir_path } /annotation' )
512
529
f_annotation = [f for f in annotation_list if id_str in f ]
513
530
if not f_annotation :
514
531
raise ValueError (f"burst { id_str } not in SAFE: { safe_dir_path } " )
515
532
f_annotation = f'{ safe_dir_path } /annotation/{ f_annotation [0 ]} '
516
533
534
+ # find annotation file - IW2
535
+ iw2_id_str = f'iw2-{ id_str [4 :]} '
536
+ iw2_f_annotation = [f for f in annotation_list if iw2_id_str in f ]
537
+ if not iw2_f_annotation :
538
+ raise ValueError (f"burst { iw2_id_str } not in SAFE: { safe_dir_path } " )
539
+ iw2_f_annotation = f'{ safe_dir_path } /annotation/{ iw2_f_annotation [0 ]} '
540
+
517
541
# find tiff file if measurement directory found
518
542
if os .path .isdir (f'{ safe_dir_path } /measurement' ):
519
543
measurement_list = os .listdir (f'{ safe_dir_path } /measurement' )
@@ -525,5 +549,5 @@ def _burst_from_safe_dir(safe_dir_path: str, id_str: str, orbit_path: str):
525
549
warnings .warn (warning_str )
526
550
f_tiff = ''
527
551
528
- bursts = burst_from_xml (f_annotation , orbit_path , f_tiff )
552
+ bursts = burst_from_xml (f_annotation , orbit_path , f_tiff , iw2_f_annotation )
529
553
return bursts
0 commit comments