@@ -461,6 +461,16 @@ def compute_differential_phase(phase_first,
461461 The differential phase data is written directly to the specified
462462 output datasets. This function does not return any data.
463463 """
464+ def _to_complex_if_needed (arr ):
465+ """
466+ Ensure an array is complex. If it's already complex, return as-is.
467+ Otherwise interpret values as phase (radians) and convert with exp(j*phi).
468+ """
469+ if np .iscomplexobj (arr ):
470+ return arr
471+ # Cast to float to avoid integer exponentiation issues
472+ return np .exp (1j * arr )
473+
464474 # Check if reading and writing will happen on the same file
465475 is_same_file_first_output = (phase_first == output_path )
466476 is_same_file_first_second = (phase_first == phase_second )
@@ -521,13 +531,19 @@ def compute_differential_phase(phase_first,
521531 second_data_block = get_raster_block (
522532 phase_second_raster ,
523533 block_param_side )
524- block_param = block_param_side
534+ chosen_block_param = block_param_side
525535 else :
526536 second_data_block = get_raster_block (
527537 phase_second_raster ,
528538 block_param_main )
529- block_param = block_param_main
539+ chosen_block_param = block_param_main
540+
541+ # Ensure complex (convert real-valued phase in radians to
542+ # complex phase)
543+ first_data_block = _to_complex_if_needed (first_data_block )
544+ second_data_block = _to_complex_if_needed (second_data_block )
530545
546+ # Optional resampling of FIRST to SECOND grid
531547 if resampling_flag :
532548 first_data_block = decimate_freq_a_array (
533549 main_slant ,
@@ -539,7 +555,7 @@ def compute_differential_phase(phase_first,
539555
540556 # Write result block to output
541557 write_raster_block (output_data_raster ,
542- diff_phase , block_param )
558+ diff_phase , chosen_block_param )
543559 finally :
544560 # Close the output file if it was opened separately
545561 if not is_same_file_first_second :
@@ -826,7 +842,7 @@ def insar_ionosphere_pair(original_cfg, runw_hdf5):
826842 if iono_method == 'main_diff_ms_band' :
827843 diff_dir = pathlib .Path (orig_scratch_path ,
828844 'ionosphere' , 'diff_ms' )
829- phase_first = original_out_paths ['RIFG ' ]
845+ phase_first = original_out_paths ['RUNW ' ]
830846 if rerun_insar_pairs > 0 :
831847 additional_runw = f'{ new_scratch } /RUNW.h5'
832848 phase_second = pathlib .Path (orig_scratch_path ,
@@ -860,14 +876,16 @@ def insar_ionosphere_pair(original_cfg, runw_hdf5):
860876 pol_list_a = iono_freq_pols ['A' ]
861877 pol_list_b = iono_freq_pols ['B' ]
862878 swath_path = RIFGGroupsPaths ().SwathsPath
879+ runw_swath_path = RUNWGroupsPaths ().SwathsPath
880+
863881 first_data_path = []
864882 for pol_a in pol_list_a :
865883
866- dest_freq_path = f"{ swath_path } /frequencyA"
884+ dest_freq_path = f"{ runw_swath_path } /frequencyA"
867885 dest_pol_path = f"{ dest_freq_path } /interferogram/{ pol_a } "
868- rifg_path_freq = f"{ dest_pol_path } /wrappedInterferogram "
886+ runw_path_freq = f"{ dest_pol_path } /unwrappedPhase "
869887
870- first_data_path .append (rifg_path_freq )
888+ first_data_path .append (runw_path_freq )
871889 first_slant_path = f"{ dest_freq_path } /interferogram/slantRange"
872890 second_data_path = []
873891 for pol_b in pol_list_b :
0 commit comments