Skip to content

Commit 106db10

Browse files
committed
excluded polarzation not used for subband SLC HDF5
1 parent 7b54599 commit 106db10

File tree

4 files changed

+75
-17
lines changed

4 files changed

+75
-17
lines changed

python/packages/nisar/workflows/split_spectrum.py

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,74 @@
1616
from nisar.workflows.yaml_argparse import YamlArgparse
1717

1818

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+
1973
def run(cfg: dict):
2074
'''
2175
run bandpass
2276
'''
2377
# pull parameters from cfg
2478
ref_hdf5 = cfg['input_file_group']['input_file_path']
2579
sec_hdf5 = cfg['input_file_group']['secondary_file_path']
26-
freq_pols = cfg['processing']['input_subset']['list_of_frequencies']
2780

2881
# Extract range split spectrum dictionary and corresponding parameters
2982
ionosphere_option = cfg['processing']['ionosphere_phase_correction']
83+
method = ionosphere_option['spectral_diversity']
3084
split_cfg = ionosphere_option['split_range_spectrum']
3185
iono_freq_pol = ionosphere_option['list_of_frequencies']
3286
blocksize = split_cfg['lines_per_block']
33-
method = split_cfg['spectral_diversity']
3487
window_function = split_cfg['window_function']
3588
window_shape = split_cfg['window_shape']
3689
low_band_bandwidth = split_cfg['low_band_bandwidth']
@@ -51,7 +104,7 @@ def run(cfg: dict):
51104

52105
common_parent_path = 'science/LSAR'
53106
freq = 'A'
54-
107+
print('test', iono_freq_pol)
55108
pol_list = iono_freq_pol[freq]
56109
info_channel.log(f'Split the main band {pol_list} of the signal')
57110

@@ -93,12 +146,17 @@ def run(cfg: dict):
93146

94147
dest_freq_path = os.path.join(slc_product.SwathPath,
95148
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+
96154
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:
99157
# 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}')
102160
for pol in pol_list:
103161
raster_str = f'HDF5:{hdf5_str}:/{slc_product.slcPath(freq, pol)}'
104162
slc_raster = isce3.io.Raster(raster_str)

python/packages/nisar/workflows/split_spectrum_runconfig.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def yaml_check(self):
3232
iono_freq_pol = iono_cfg['list_of_frequencies']
3333
ref_slc_path = self.cfg['input_file_group']['input_file_path']
3434
sec_slc_path = self.cfg['input_file_group']['secondary_file_path']
35-
iono_method = split_cfg['spectral_diversity']
35+
iono_method = iono_cfg['spectral_diversity']
3636

3737
# Extract main range bandwidth from reference RSLC
3838
ref_slc = SLC(hdf5file=ref_slc_path)
@@ -66,7 +66,7 @@ def yaml_check(self):
6666

6767
# Depending on how the user has selected "spectral_diversity" check if
6868
# "low_bandwidth" and "high_bandwidth" are assigned. Otherwise, use default
69-
if split_cfg['spectral_diversity'] == 'split_main_band':
69+
if iono_method == 'split_main_band':
7070
# If "low_bandwidth" or 'high_bandwidth" is not allocated,
7171
# split the main range bandwidth into two 1/3 sub-bands.
7272
if split_cfg['low_band_bandwidth'] is None or split_cfg[
@@ -103,11 +103,11 @@ def yaml_check(self):
103103
# Co-polarizations are found, split_main_band will be used for co-pols
104104
common_copol_ref_sec = [pol for pol in common_pol_refsec_freqA
105105
if pol in ['VV', 'HH']]
106-
iono_freq_pol = {'A': common_copol_ref_sec}
106+
iono_freq_pol['A'] = common_copol_ref_sec
107107

108108
# If common co-pols not found, cross-pol will be alternatively used.
109109
if not common_copol_ref_sec:
110-
iono_freq_pol = {'A': common_pol_refsec_freqA}
110+
iono_freq_pol['A'] = common_pol_refsec_freqA
111111
info_str = f"{iono_freq_pol} will be used for split_main_band"
112112
info_channel.log(info_str)
113113
self.cfg['processing'][

share/nisar/defaults/insar.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ runconfig:
151151

152152
ionosphere_phase_correction:
153153
enabled: False
154+
spectral_diversity: split_main_band
154155
list_of_frequencies:
155156
A:
156157
B:
157158
split_range_spectrum:
158159
lines_per_block: 1000
159-
spectral_diversity: split_main_band
160160
low_band_bandwidth:
161161
high_band_bandwidth:
162162
window_function: tukey

share/nisar/schemas/insar.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,6 @@ bandpass_options:
496496
split_range_spectrum_options:
497497
# Number of lines per block for block processing)
498498
lines_per_block: int(min=1, required=False)
499-
# 'split_main_band' splits the main range bandwidth into a low and high subband
500-
# being 1/3 (fixed for now) of the total main range spectrum.
501-
# 'main_side_band' uses the additional NISAR 5 MHz side-band to estimate the
502-
# ionosphere phase screen. Main and side-bands are intended to be at the same polarization
503-
spectral_diversity: enum('split_main_band', 'main_side_band', 'main_diff_main_side_band', required=False)
504499
# Low bandwidth. If unspecified is automatically set by the workflow according to
505500
# the selected spectral diversity
506501
low_band_bandwidth: num(min=0, required=False)
@@ -515,6 +510,11 @@ split_range_spectrum_options:
515510
ionosphere_phase_correction_options:
516511
# Boolean flag to enable/disable ionosphere phase correction
517512
enabled: bool(required=False)
513+
# 'split_main_band' splits the main range bandwidth into a low and high subband
514+
# being 1/3 (fixed for now) of the total main range spectrum.
515+
# 'main_side_band' uses the additional NISAR 5 MHz side-band to estimate the
516+
# ionosphere phase screen. Main and side-bands are intended to be at the same polarization
517+
spectral_diversity: enum('split_main_band', 'main_side_band', 'main_diff_main_side_band', required=False)
518518
split_range_spectrum: include('split_range_spectrum_options', required=False)
519519
list_of_frequencies: include('ionosphere_freq_pol_options', required=False)
520520

0 commit comments

Comments
 (0)