@@ -485,27 +485,33 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
485
485
product_annotation = ProductAnnotation .from_et (tree_lads )
486
486
487
487
# load the Calibraton annotation
488
- calibration_annotation_path = \
489
- annotation_path .replace ('annotation/' , 'annotation/calibration/calibration-' )
490
- with open_method (calibration_annotation_path , 'r' ) as f_cads :
491
- tree_cads = ET .parse (f_cads )
492
- calibration_annotation = \
493
- CalibrationAnnotation .from_et (tree_cads ,
494
- calibration_annotation_path )
488
+ try :
489
+ calibration_annotation_path = \
490
+ annotation_path .replace ('annotation/' , 'annotation/calibration/calibration-' )
491
+ with open_method (calibration_annotation_path , 'r' ) as f_cads :
492
+ tree_cads = ET .parse (f_cads )
493
+ calibration_annotation = \
494
+ CalibrationAnnotation .from_et (tree_cads ,
495
+ calibration_annotation_path )
496
+ except (FileNotFoundError , KeyError ):
497
+ calibration_annotation = None
495
498
496
499
# load the Noise annotation
497
- noise_annotation_path = annotation_path .replace ('annotation/' , 'annotation/calibration/noise-' )
498
- with open_method (noise_annotation_path , 'r' ) as f_nads :
499
- tree_nads = ET .parse (f_nads )
500
- noise_annotation = NoiseAnnotation .from_et (tree_nads , ipf_version ,
501
- noise_annotation_path )
500
+ try :
501
+ noise_annotation_path = annotation_path .replace ('annotation/' , 'annotation/calibration/noise-' )
502
+ with open_method (noise_annotation_path , 'r' ) as f_nads :
503
+ tree_nads = ET .parse (f_nads )
504
+ noise_annotation = NoiseAnnotation .from_et (tree_nads , ipf_version ,
505
+ noise_annotation_path )
506
+ except (FileNotFoundError , KeyError ):
507
+ noise_annotation = None
502
508
503
509
# load AUX_CAL annotation
504
510
eap_necessity = is_eap_correction_necessary (ipf_version )
505
511
if eap_necessity .phase_correction and flag_apply_eap :
506
512
path_aux_cals = os .path .join (f'{ os .path .dirname (s1_annotation .__file__ )} ' ,
507
- 'data' ,
508
- 'aux_cal' )
513
+ 'data' ,
514
+ 'aux_cal' )
509
515
path_aux_cal = get_path_aux_cal (path_aux_cals , annotation_path )
510
516
511
517
# Raise error flag when AUX_CAL file cannot be found
@@ -577,8 +583,11 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
577
583
iw2_mid_range = iw2_starting_range + 0.5 * iw2_n_samples * range_pxl_spacing
578
584
579
585
# find orbit state vectors in 'Data_Block/List_of_OSVs'
580
- orbit_tree = ET .parse (orbit_path )
581
- osv_list = orbit_tree .find ('Data_Block/List_of_OSVs' )
586
+ if orbit_path :
587
+ orbit_tree = ET .parse (orbit_path )
588
+ osv_list = orbit_tree .find ('Data_Block/List_of_OSVs' )
589
+ else :
590
+ osv_list = []
582
591
583
592
# load individual burst
584
593
burst_list_elements = tree .find ('swathTiming/burstList' )
@@ -611,11 +620,14 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
611
620
azimuth_time_interval )
612
621
doppler = Doppler (poly1d , lut2d )
613
622
614
- # get orbit from state vector list/element tree
615
- sensing_duration = datetime .timedelta (
616
- seconds = n_lines * azimuth_time_interval )
617
- orbit = get_burst_orbit (sensing_start , sensing_start + sensing_duration ,
618
- osv_list )
623
+ if len (osv_list ) > 0 :
624
+ # get orbit from state vector list/element tree
625
+ sensing_duration = datetime .timedelta (
626
+ seconds = n_lines * azimuth_time_interval )
627
+ orbit = get_burst_orbit (sensing_start , sensing_start + sensing_duration ,
628
+ osv_list )
629
+ else :
630
+ orbit = None
619
631
620
632
# determine burst offset and dimensions
621
633
# TODO move to own method
@@ -634,12 +646,17 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
634
646
635
647
burst_id = f't{ track_number :03d} _{ burst_num } _{ swath_name .lower ()} '
636
648
637
-
638
649
# Extract burst-wise information for Calibration, Noise, and EAP correction
639
- burst_calibration = BurstCalibration .from_calibration_annotation (calibration_annotation ,
640
- sensing_start )
641
- burst_noise = BurstNoise .from_noise_annotation (noise_annotation , sensing_start ,
642
- i * n_lines , (i + 1 )* n_lines - 1 , ipf_version )
650
+ if calibration_annotation is None :
651
+ burst_calibration = None
652
+ else :
653
+ burst_calibration = BurstCalibration .from_calibration_annotation (calibration_annotation ,
654
+ sensing_start )
655
+ if noise_annotation is None :
656
+ burst_noise = None
657
+ else :
658
+ burst_noise = BurstNoise .from_noise_annotation (noise_annotation , sensing_start ,
659
+ i * n_lines , (i + 1 )* n_lines - 1 , ipf_version )
643
660
if aux_cal_subswath is None :
644
661
# Not applying EAP correction; (IPF high enough or user turned that off)
645
662
# No need to fill in `burst_aux_cal`
0 commit comments