16
16
from nisar .workflows .yaml_argparse import YamlArgparse
17
17
18
18
19
+ def prep_subband_h5 (full_hdf5 : str ,
20
+ sub_band_hdf5 : str ,
21
+ freq_pols ):
22
+
23
+ common_parent_path = 'science/LSAR'
24
+ swath_path = f'{ common_parent_path } /SLC/swaths/'
25
+ freq_a_path = f'{ swath_path } /frequencyA/'
26
+ freq_b_path = f'{ swath_path } /frequencyB/'
27
+ metadata_path = f'{ common_parent_path } /SLC/metadata/'
28
+ ident_path = f'{ common_parent_path } /identification/'
29
+ pol_a_path = f'{ freq_a_path } /listOfPolarizations'
30
+ pol_b_path = f'{ freq_b_path } /listOfPolarizations'
31
+
32
+ with h5py .File (full_hdf5 , 'r' , libver = 'latest' , swmr = True ) as src_h5 , \
33
+ h5py .File (sub_band_hdf5 , 'w' ) as dst_h5 :
34
+
35
+ pols_freqA = list (
36
+ np .array (src_h5 [pol_a_path ][()], dtype = str ))
37
+ pols_freqB = list (
38
+ np .array (src_h5 [pol_b_path ][()], dtype = str ))
39
+
40
+ if freq_pols ['A' ]:
41
+ pols_a_excludes = [pol for pol in pols_freqA
42
+ if pol not in freq_pols ['A' ]]
43
+ else :
44
+ pols_a_excludes = pols_freqA
45
+
46
+ if freq_pols ['B' ]:
47
+ pols_b_excludes = [pol for pol in pols_freqB
48
+ if pol not in freq_pols ['B' ]]
49
+ else :
50
+ pols_b_excludes = pols_freqB
51
+
52
+ if pols_a_excludes :
53
+ cp_h5_meta_data (src_h5 , dst_h5 , freq_a_path ,
54
+ excludes = pols_a_excludes )
55
+ else :
56
+ cp_h5_meta_data (src_h5 , dst_h5 , freq_a_path ,
57
+ excludes = ['' ])
58
+
59
+ if pols_b_excludes :
60
+ cp_h5_meta_data (src_h5 , dst_h5 , freq_b_path ,
61
+ excludes = pols_b_excludes )
62
+ else :
63
+ cp_h5_meta_data (src_h5 , dst_h5 , freq_b_path ,
64
+ excludes = ['' ])
65
+
66
+ cp_h5_meta_data (src_h5 , dst_h5 , metadata_path ,
67
+ excludes = ['' ])
68
+ cp_h5_meta_data (src_h5 , dst_h5 , ident_path ,
69
+ excludes = ['' ])
70
+ cp_h5_meta_data (src_h5 , dst_h5 , swath_path ,
71
+ excludes = ['frequencyA' , 'frequencyB' ])
72
+
19
73
def run (cfg : dict ):
20
74
'''
21
75
run bandpass
22
76
'''
23
77
# pull parameters from cfg
24
78
ref_hdf5 = cfg ['input_file_group' ]['input_file_path' ]
25
79
sec_hdf5 = cfg ['input_file_group' ]['secondary_file_path' ]
26
- freq_pols = cfg ['processing' ]['input_subset' ]['list_of_frequencies' ]
27
80
28
81
# Extract range split spectrum dictionary and corresponding parameters
29
82
ionosphere_option = cfg ['processing' ]['ionosphere_phase_correction' ]
83
+ method = ionosphere_option ['spectral_diversity' ]
30
84
split_cfg = ionosphere_option ['split_range_spectrum' ]
31
85
iono_freq_pol = ionosphere_option ['list_of_frequencies' ]
32
86
blocksize = split_cfg ['lines_per_block' ]
33
- method = split_cfg ['spectral_diversity' ]
34
87
window_function = split_cfg ['window_function' ]
35
88
window_shape = split_cfg ['window_shape' ]
36
89
low_band_bandwidth = split_cfg ['low_band_bandwidth' ]
@@ -51,7 +104,7 @@ def run(cfg: dict):
51
104
52
105
common_parent_path = 'science/LSAR'
53
106
freq = 'A'
54
-
107
+ print ( 'test' , iono_freq_pol )
55
108
pol_list = iono_freq_pol [freq ]
56
109
info_channel .log (f'Split the main band { pol_list } of the signal' )
57
110
@@ -93,12 +146,17 @@ def run(cfg: dict):
93
146
94
147
dest_freq_path = os .path .join (slc_product .SwathPath ,
95
148
f'frequency{ freq } ' )
149
+
150
+ # prepare HDF5 for subband SLC HDF5
151
+ prep_subband_h5 (hdf5_str , low_band_output , iono_freq_pol )
152
+ prep_subband_h5 (hdf5_str , high_band_output , iono_freq_pol )
153
+
96
154
with h5py .File (hdf5_str , 'r' , libver = 'latest' , swmr = True ) as src_h5 , \
97
- h5py .File (low_band_output , 'w ' ) as dst_h5_low , \
98
- h5py .File (high_band_output , 'w ' ) as dst_h5_high :
155
+ h5py .File (low_band_output , 'r+ ' ) as dst_h5_low , \
156
+ h5py .File (high_band_output , 'r+ ' ) as dst_h5_high :
99
157
# Copy HDF5 metadata for low high band
100
- cp_h5_meta_data (src_h5 , dst_h5_low , f'{ common_parent_path } ' )
101
- cp_h5_meta_data (src_h5 , dst_h5_high , f'{ common_parent_path } ' )
158
+ # cp_h5_meta_data(src_h5, dst_h5_low, f'{common_parent_path}')
159
+ # cp_h5_meta_data(src_h5, dst_h5_high, f'{common_parent_path}')
102
160
for pol in pol_list :
103
161
raster_str = f'HDF5:{ hdf5_str } :/{ slc_product .slcPath (freq , pol )} '
104
162
slc_raster = isce3 .io .Raster (raster_str )
0 commit comments