8
8
9
9
import h5py
10
10
import journal
11
-
12
11
import pybind_isce3 as isce3
13
12
from pybind_nisar .products .readers import SLC
14
- from pybind_nisar .workflows import h5_prep , gpu_check
15
- from pybind_nisar .workflows .crossmul_argparse import CrossmulArgparse
13
+ from pybind_nisar .workflows import gpu_check , h5_prep
16
14
from pybind_nisar .workflows .crossmul_runconfig import CrossmulRunConfig
15
+ from pybind_nisar .workflows .yaml_argparse import YamlArgparse
16
+
17
17
18
18
def run (cfg : dict , output_hdf5 : str = None ):
19
19
'''
@@ -53,10 +53,11 @@ def run(cfg: dict, output_hdf5: str = None):
53
53
crossmul .range_looks = cfg ['processing' ]['crossmul' ]['range_looks' ]
54
54
crossmul .az_looks = cfg ['processing' ]['crossmul' ]['azimuth_looks' ]
55
55
crossmul .oversample = cfg ['processing' ]['crossmul' ]['oversample' ]
56
- crossmul .rows_per_block = cfg ['processing' ]['crossmul' ]['rows_per_block' ]
56
+ crossmul .rows_per_block = cfg ['processing' ]['crossmul' ]['rows_per_block' ]
57
57
58
58
# check if user provided path to raster(s) is a file or directory
59
- coregistered_slc_path = pathlib .Path (cfg ['processing' ]['crossmul' ]['coregistered_slc_path' ])
59
+ coregistered_slc_path = pathlib .Path (
60
+ cfg ['processing' ]['crossmul' ]['coregistered_slc_path' ])
60
61
coregistered_is_file = coregistered_slc_path .is_file ()
61
62
if not coregistered_is_file and not coregistered_slc_path .is_dir ():
62
63
err_str = f"{ coregistered_slc_path } is invalid; needs to be a file or directory."
@@ -67,25 +68,30 @@ def run(cfg: dict, output_hdf5: str = None):
67
68
with h5py .File (output_hdf5 , 'a' , libver = 'latest' , swmr = True ) as dst_h5 :
68
69
for freq , pol_list in freq_pols .items ():
69
70
# get 2d doppler, discard azimuth dependency, and set crossmul dopplers
70
- ref_dopp = isce3 .core .avg_lut2d_to_lut1d (ref_slc .getDopplerCentroid (frequency = freq ))
71
- sec_dopp = isce3 .core .avg_lut2d_to_lut1d (sec_slc .getDopplerCentroid (frequency = freq ))
71
+ ref_dopp = isce3 .core .avg_lut2d_to_lut1d (
72
+ ref_slc .getDopplerCentroid (frequency = freq ))
73
+ sec_dopp = isce3 .core .avg_lut2d_to_lut1d (
74
+ sec_slc .getDopplerCentroid (frequency = freq ))
72
75
crossmul .set_dopplers (ref_dopp , sec_dopp )
73
76
74
77
freq_group_path = f'/science/LSAR/RIFG/swaths/frequency{ freq } '
75
78
76
79
if flatten is not None :
77
80
# set frequency dependent range offset raster
78
- flatten_raster = isce3 .io .Raster (f'{ flatten_path } /geo2rdr/freq{ freq } /range.off' )
81
+ flatten_raster = isce3 .io .Raster (
82
+ f'{ flatten_path } /geo2rdr/freq{ freq } /range.off' )
79
83
80
84
# prepare range filter parameters
81
85
rdr_grid = ref_slc .getRadarGrid (freq )
82
86
rg_pxl_spacing = rdr_grid .range_pixel_spacing
83
87
wavelength = rdr_grid .wavelength
84
88
rg_sample_freq = isce3 .core .speed_of_light / 2.0 / rg_pxl_spacing
85
- rg_bandwidth = ref_slc .getSwathMetadata (freq ).processed_range_bandwidth
89
+ rg_bandwidth = ref_slc .getSwathMetadata (
90
+ freq ).processed_range_bandwidth
86
91
87
92
# set crossmul range filter
88
- crossmul .set_rg_filter (rg_sample_freq , rg_bandwidth , rg_pxl_spacing , wavelength )
93
+ crossmul .set_rg_filter (rg_sample_freq , rg_bandwidth ,
94
+ rg_pxl_spacing , wavelength )
89
95
90
96
for pol in pol_list :
91
97
pol_group_path = f'{ freq_group_path } /interferogram/{ pol } '
@@ -98,7 +104,7 @@ def run(cfg: dict, output_hdf5: str = None):
98
104
if coregistered_is_file :
99
105
raster_str = f'HDF5:{ sec_hdf5 } :/{ sec_slc .slcPath (freq , pol )} '
100
106
else :
101
- raster_str = str (coregistered_slc_path / \
107
+ raster_str = str (coregistered_slc_path / \
102
108
f'resample_slc/freq{ freq } /{ pol } /coregistered_secondary.slc' )
103
109
104
110
sec_slc_raster = isce3 .io .Raster (raster_str )
@@ -108,8 +114,9 @@ def run(cfg: dict, output_hdf5: str = None):
108
114
igram_dataset = dst_h5 [dataset_path ]
109
115
110
116
# Construct the output ratster directly from HDF5 dataset
111
- igram_raster = isce3 .io .Raster (f"IH5:::ID={ igram_dataset .id .id } " .encode ("utf-8" ),
112
- update = True )
117
+ igram_raster = isce3 .io .Raster (
118
+ f"IH5:::ID={ igram_dataset .id .id } " .encode ("utf-8" ),
119
+ update = True )
113
120
114
121
# call crossmul with coherence if multilooked
115
122
if crossmul .range_looks > 1 or crossmul .az_looks > 1 :
@@ -119,10 +126,12 @@ def run(cfg: dict, output_hdf5: str = None):
119
126
120
127
# Construct the output ratster directly from HDF5 dataset
121
128
coherence_raster = isce3 .io .Raster (
122
- f"IH5:::ID={ coherence_dataset .id .id } " .encode ("utf-8" ), update = True )
129
+ f"IH5:::ID={ coherence_dataset .id .id } " .encode ("utf-8" ),
130
+ update = True )
123
131
124
132
if flatten is not None :
125
- crossmul .crossmul (ref_slc_raster , sec_slc_raster , flatten_raster ,
133
+ crossmul .crossmul (ref_slc_raster , sec_slc_raster ,
134
+ flatten_raster ,
126
135
igram_raster , coherence_raster )
127
136
else :
128
137
crossmul .crossmul (ref_slc_raster , sec_slc_raster ,
@@ -131,20 +140,22 @@ def run(cfg: dict, output_hdf5: str = None):
131
140
del coherence_raster
132
141
else :
133
142
# no coherence without multilook
134
- crossmul .crossmul (ref_slc_raster , sec_slc_raster , igram_raster )
143
+ crossmul .crossmul (ref_slc_raster , sec_slc_raster ,
144
+ igram_raster )
135
145
136
146
del igram_raster
137
147
138
148
t_all_elapsed = time .time () - t_all
139
- info_channel .log (f"successfully ran crossmul in { t_all_elapsed :.3f} seconds" )
149
+ info_channel .log (
150
+ f"successfully ran crossmul in { t_all_elapsed :.3f} seconds" )
140
151
141
152
142
153
if __name__ == "__main__" :
143
154
'''
144
155
run crossmul from command line
145
156
'''
146
157
# load command line args
147
- crossmul_parser = CrossmulArgparse ()
158
+ crossmul_parser = YamlArgparse ()
148
159
args = crossmul_parser .parse ()
149
160
# get a runconfig dict from command line args
150
161
crossmul_runconfig = CrossmulRunConfig (args )
0 commit comments