Skip to content

Commit 49b5b77

Browse files
Bo HuangBo Huanggmgunterbhawkinsrad-eng-59
authored andcommitted
Created Tx beamforming code to generate Tx beamformed gain that is in… (#815)
* Created Tx beamforming code to generate Tx beamformed gain that is interpolated based on slant range. * Update python/extensions/pybind_isce3/antenna/beamform_tx.py replace import pybind_isce3 as isce to import isce3 Co-Authored-By: Geoffrey M Gunter <[email protected]> * Update python/extensions/pybind_isce3/antenna/beamform_tx.py Capital camel case for class names for pep-8 guidelines. Co-Authored-By: Geoffrey M Gunter <[email protected]> * moved beamform_tx.py from pybind_isce3/antenna to /pybind_nisar/antenna * class attributes are explicit, updated docstrings, added property decorators * Updated tx_cal_beamform wrapper and removed unneccesary main() * Updated all Docstrings and constant temperature phase correction mechanism * Added a missing parameter in the docstring for parse_ant function * Correcte typo in temp_phase_offset variable. Formatted script with Black for pep-8 compliance. * Removed /pybind_isce3/antenna/beamform_tx.py * Minor docstring udpates * Added unit tx bf unit test and unit test data. * Update tests/python/packages/pybind_nisar/workflows/beamform_tx.py Co-authored-by: Brian P Hawkins <[email protected]> * Update python/packages/pybind_nisar/antenna/beamform_tx.py Removed unnecessary indentation. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/pybind_nisar/antenna/beamform_tx.py Removed class methods description Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/pybind_nisar/antenna/beamform_tx.py Added unit to slant range description. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update tests/python/packages/pybind_nisar/workflows/beamform_tx.py Removed hardcoded link and replaced it with iscetest data directory. Co-authored-by: Geoffrey M Gunter <[email protected]> * Removed slant range as an output of Tx beamformer. Updated docstring, added units to description, etc. * DEM interpolator object is now the input to slant_range_interp function. * Takes UTC(scalar or array) as input and returns Tx BMF gain, removed quanternion conversion * Updated slant_range_interp to interpolate UTC. Quaternions now uses first position. * Updated slant_range_interp to interpolate UTC. Quaternions now uses first position. * Added UTC as input to Tx beamforming test. * Updated class constructor and pre-computation;updated quaternion * Corrected typo in class attribute bcal_offset * Updated unit test based on new code structure. * beamform_tx.py is replaced by new code that performs both Tx and Rx beamforming. * beamformer class now generates combo gain pattern by multiplying Tx and Rx gain. * Update python/packages/nisar/antenna/beamform_data.py updated ISCE3 attitude description Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamform_data.py Updated DEM description Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamform_data.py Update UTC naming. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamform_data.py Updated ISCE3 orbit description. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamform_data.py Update import statements. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update tests/python/packages/nisar/workflows/beamform_tx.py Updated import statement from pybind_nisar to nisar Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamformer.py Updated txAntPat description Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamformer.py Updated rxAntPat description. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamform_data.py Updated UTC description Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamform_data.py Updated slant range description Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamform_data.py Corrected mb_angle data type. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamform_data.py Updated temp_phase_offset from List to Sequence. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamform_data.py Updated Tx Beamformer class description. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamform_data.py Updated Rx Antenna Pattern class description. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamform_data.py Updated WD to wd along with its description. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/ant_pat_gen.py Removed extra blank line Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/ant_pat_gen.py Removed camel case for txAntPat Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/ant_pat_gen.py Removed camel case for rxAntPat. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamformer.py Updated Beamformer class description. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamformer.py Added blank line after Attributes header. Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/beamformer.py Updated constructor of beamformer class with camel case removed for txAntPat and rxAntPat. Co-authored-by: Geoffrey M Gunter <[email protected]> * Deleted beamform_tx.py * Renamed beamformer_data.py to antenna_pattern.py. * Added __init__.py and cleaned up code. * Updated python/packages/nisar/__init__.py to include antenna module. * Update Raw.py to read txCal and other parameters. * Forgot to add this file last time. * Removed camel case for object instantiation. * Cleaned up typo and camel case. * removed obsolete beamform_tx.py * Updated CMakeLists.txt to add beamformer test. * Added REE antenna file, REE raw data file, and instrument table. * This is the Unit test of beamformer * Uploaded new REE data with sc to ECEF quaternion. * Updated beamformer test based on new REE data set. * Updated pass/fail criteria * Updated class method names to be more descriptive. * Combined object instantiation from ant_pat_gen.py into antenna_pattern.py. * Removed ant_pat_gen.py since it has been combined with antenna_pattern.py. * Updated init file after combining two files together. * Created Instrument Table Parser. * Updated unit test to use instrument parser; removed mb_angle. * Added CAL Mask and removed hcal, bcal, and lcal indices. * Hardcoded some attributes; generate unity-gain weights if BCAL_INTERVAL is not availble in L0B. * WD is now a vector, udpated AC table indexing accordingly; tx_cal becomes correlator_3taps. * Added comments and minor bug fixes. * Update python/packages/nisar/antenna/antenna_pattern.py Co-authored-by: Hirad Ghaemi <[email protected]> * Clean up and added Rx correction offset place holder. * Removed num_chan from Rx and Tx data classes. * Updated beamformer attributes based on Hirad's recommendations. * added list_rx_TRM with update to Raw.py;changed parameter 'pol' to 'pols', 'HH','HV', etc. * minor comment update and chagned tx_weight_norm to complex. * variable typo update; removed debugging print statment from Raw.py * Added additional comment about HCAL/BCAL computation. * Corrected unit test function name. * Simplified data_fs computation. * corrected ElevationBeamformer class typo * Added rx_correction_offset computation to beamformer.py * Update Rx beam weight derivation based on approach by Brian and Chandini. RD,WD, and WL are applied in the new Rx algorithm. * removed unnecessary import statments. * Update python/packages/nisar/antenna/antenna_pattern.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/antenna_pattern.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/antenna_pattern.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/antenna/antenna_pattern.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Update tests/python/packages/nisar/antenna/beamformer.py Co-authored-by: Geoffrey M Gunter <[email protected]> * changed utc_time to transmit_time, minor bug fixin unit test. * minor updates of comments based on Geoff's suggestions. * accidentally removed antenna_pattern.py, adding it back. * doc string udpate; removed ac_angles attribute. * Remove rng_lines_idx as a member of ElevationBeamformer class. * Changed Cal Path Mask to enum. * removed angle_low_idx and angle_high_idx. * Update Unit test max gain value;updated temp_phase_offset variable name. * Removed 'pol' and 'freq_group' attributes from TxTrmInfo and RxTrmInfo. * Initialized Tx and Rx correction factors to array of ones. * Docstring and coding style update. * Update python/packages/nisar/products/readers/Raw/Raw.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/products/readers/Raw/Raw.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Docstring update for Raw.py and others. * Update python/packages/nisar/products/readers/instrument/instrument_parser.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/products/readers/instrument/instrument_parser.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/products/readers/instrument/instrument_parser.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/products/readers/instrument/instrument_parser.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/products/readers/instrument/instrument_parser.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/products/readers/instrument/instrument_parser.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Update python/packages/nisar/products/readers/instrument/instrument_parser.py Co-authored-by: Geoffrey M Gunter <[email protected]> * Changed all instances of ACPath and TAPath to ac_path and ta_path. * Updated docstring; allow users to access data from each qFSP. * Updated getListOfRxTRMs in Raw.py and unit test accordingly. * comprehensiv update, including unit test, docstring, and coding. * antenna_pattern_old.py was deleted * Removed duplicate import * Updated Sequence declaration. * Removed extra hyphens. * Added function description for getRangeLineIndex. * Updated test datasets. * Updated docstring for orbit, attitude, and dem isce3 objects. * Updated docstring for tx_trm_info and rx_trm_info. * Updated docstring for _compute_receive_pattern_weights. * slant_range is passed in as a isce3.core.Linspace obj. * Removed everything related to bcal/lcal interval in Raw.py and beamformer. * changed sequenceOfTxTRMs to listOfTxTRMs. * Updated docstring for correlator_tap2. * Updated remaining sequenceOfTxTRMs to listOfTxTRMs. * Moved instrument parser to unit test directory. * Updated unit test to import instrument_parser. * Uploaded New L0B data generated by ReeUtilPy2.7.1. * Update docstring: cal_path_mask and cal_type_enum. * naming convention update, changed radar_time to transmit_time. * cal_interval no longer dictates Tx CAL; np.isscalar is applied. * updated rd/rd/wd naming;updated num_range_bins_dbf_fs rounding. * Added dbf_swtich_fs, default is 48MHz. * Added intermediate variable to store Tx weights after being corrected. * Added intermediate variable to store Rx corrected weights. * Updated slant_range_interp_dbf_fs. * removed commented code. * Removed cal_mask_enum * Replaced incorrect use of assertion with ValueError. * Addressed Fs naming and rest of Hirad's comments. * Updated doctring to reflect correct output dimension. * Added -3dB mask and include negative deviation in unit test power verification. * Added check to verify dbf_fs and data_fs in downsampling operation. * Updated README.md * Updated variable names and tolerance values. * Corrected typo in README file. * Corrected cal_path_mask definition. * Updated docstring for freq_group. Co-authored-by: Bo Huang <[email protected]> Co-authored-by: Geoffrey M Gunter <[email protected]> Co-authored-by: Brian P Hawkins <[email protected]> Co-authored-by: Hirad Ghaemi <[email protected]>
1 parent be423af commit 49b5b77

File tree

13 files changed

+1419
-1
lines changed

13 files changed

+1419
-1
lines changed

python/packages/nisar/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
from . import products
33
from . import workflows
44
from . import types
5+
from . import antenna
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .antenna_pattern import CalPath, TxTrmInfo, RxTrmInfo, get_tx_and_rx_trm_info
2+
from .beamformer import ElevationBeamformer
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
import numpy as np
2+
from typing import Sequence
3+
from dataclasses import dataclass
4+
from enum import IntEnum, EnumMeta, unique
5+
6+
7+
@unique
8+
class CalPath(IntEnum):
9+
"""Tx calibration range line types (HCAL = HPA, LCAL = LNA, BCAL = BYPASS)"""
10+
11+
HPA = 0
12+
LNA = 1
13+
BYPASS = 2
14+
15+
16+
@dataclass
17+
class TxTrmInfo:
18+
19+
"""TX Antenna Pattern class used to compute the Tx normalized beamformed gain pattern.
20+
21+
Attributes:
22+
-----------------
23+
transmit_time: sequence of float
24+
transmit pulse time of range line in seconds w.r.t radar product reference
25+
fc: float
26+
Radar center frequency, in Hertz
27+
channels: sequence of int
28+
Tx channels defined by L0B raw data 'listOfTxTRMs'
29+
correlator_tap2: 2D sequence of complex
30+
second tap of 3-tap correlator for all range lines and channels
31+
cal_path_mask: sequence of CalPath
32+
Enum Mask from L0B data which indicates range line types: 0 = HCAL, 1 = LCAL, 2 = BCAL
33+
tx_correction_factor: sequence of complex
34+
Tx Cal correction factor that captures both magnitude and phase variation due to
35+
temperature. A place holder initialied to one is designated in case if
36+
temperature calibration is applied, len = num of channels
37+
"""
38+
39+
transmit_time: Sequence[float]
40+
fc: float
41+
channels: Sequence[int]
42+
correlator_tap2: Sequence[Sequence[complex]]
43+
cal_path_mask: Sequence[CalPath]
44+
tx_correction_factor: Sequence[complex] = np.ones(12, dtype=complex)
45+
46+
47+
@dataclass
48+
class RxTrmInfo:
49+
50+
"""Rx Antenna Pattern class used to compute the Rx normalized beamformed gain pattern.
51+
52+
Attributes:
53+
-----------------
54+
transmit_time: sequence of float
55+
transmit time of range line in seconds w.r.t radar product reference
56+
fc: float
57+
Radar center frequency, in Hertz
58+
channels: sequence of int
59+
Rx channels defined by L0B raw data 'listOfRxTRMs'
60+
rd: sequence of int
61+
Round trip time at starting elevation angle in Time-To-Angle LUT calculated with respect to a
62+
transmit pulse. Value is provided as 'adc_fs' clock sample counts, len = 12
63+
wd: sequence of int
64+
Receive window delay to first valid data sample relative to RD.
65+
Value is provided as 'adc_fs' clock sample counts, len = 12
66+
wl: sequence of int
67+
Length of receive data window provided as 'adc_fs' clock sample counts, len = 12
68+
ac_chan_coef: 2D sequence of complex
69+
Rx CAL path channel coeff., size = [num of chan x num of coeffs]
70+
ta_dbf_switch: sequence of int
71+
'N' time-index values @ 'ta_lut_fs' clock rate to map fast-time indices to 'N' Elevation
72+
angle indices for each channel
73+
num_lut_items: int
74+
number of entries in CAL Angle-To-Coefficient and Time-To-Angle tables
75+
num_chan_qfsp: int
76+
There are 4 channels/beams being processed during beamforming per qFSP FPGA.
77+
dbf_fs: float
78+
Sampling frequency of DBF fast-time indexing in time-to-angle and angle-to-coefficient
79+
transformation, in Hertz. This value can be different from sampling frequency of Raw data
80+
and clock rate for fast-time range gating of Raw data.
81+
adc_fs: float
82+
ADC sampling frequency at which fast-time range gating paramters RD/WD/WL are generated.
83+
ta_lut_fs: float
84+
sampling frequency of Time to Angle Table dbf_switch values.
85+
NISAR: number of 96-MHz clock rate divided by 2, which is 48 MHz.
86+
rx_correction_factor: sequence of complex
87+
A place holder is designated for applying possbile secondary Rx phase and magnitude corrections,
88+
currently initialized to one, 1 per each channel, size = num_chan
89+
"""
90+
91+
transmit_time: Sequence[float]
92+
fc: float
93+
channels: Sequence[int]
94+
rd: Sequence[int]
95+
wd: Sequence[int]
96+
wl: Sequence[int]
97+
ac_chan_coef: Sequence[Sequence[complex]]
98+
ta_dbf_switch: Sequence[int]
99+
num_lut_items: int = 256
100+
num_chan_qfsp: int = 4
101+
dbf_fs: float = 96e6
102+
adc_fs: float = 240e6
103+
ta_lut_fs: float = 48e6
104+
rx_correction_factor: Sequence[complex] = np.ones(12, dtype=complex)
105+
106+
107+
def get_tx_and_rx_trm_info(
108+
transmit_time,
109+
fc,
110+
channels_tx,
111+
channels_rx,
112+
correlator_tap2,
113+
cal_path_mask,
114+
dbf_fs,
115+
adc_fs,
116+
ta_lut_fs,
117+
rd,
118+
wd,
119+
wl,
120+
ac_chan_coef,
121+
ta_dbf_switch,
122+
num_lut_items=256,
123+
num_chan_qfsp=4,
124+
rx_correction_factor=np.ones(12, dtype=complex),
125+
tx_correction_factor=np.ones(12, dtype=complex),
126+
):
127+
128+
"""This function instantiates TxTrmInfo and RxTrmInfo objects.
129+
130+
Attributes:
131+
-----------
132+
transmit_time: sequence of float
133+
transmit time of range line in seconds w.r.t radar product reference
134+
fc: float
135+
Radar center frequency, in Hertz
136+
channels_tx: sequence of int
137+
Tx channels defined by L0B raw data 'listOfTxTRMs'
138+
channels_rx: sequence of int
139+
Rx channels defined by L0B raw data 'listOfRxTRMs'
140+
correlator_tap2: 2D sequence of complex
141+
second tap of 3-tap correlator for all range lines
142+
cal_path_mask: sequence of CalPath
143+
Enum Mask from L0B data which indicates range line types: 0 = HCAL, 1 = LCAL, 2 = BCAL
144+
dbf_fs: float
145+
Time to Angle Table Sampling frequency,in hertz, may be different from Raw data frequency
146+
adc_fs: float
147+
ADC sampling frequency. It is also the frequency which RD/WD/WL are generated.
148+
ta_lut_fs: float
149+
sampling frequency of Time to Angle Table dbf_switch values.
150+
NISAR: number of 96-MHz clock rate divided by 2, which is 48 MHz.
151+
rd: sequence of int
152+
Round trip time at starting elevation angle in Time-To-Angle LUT calculated with respect to a
153+
transmit pulse. Value is provided as 240 MHz clock sample counts, len = 12
154+
wd: sequence of int
155+
Receive window delay to first valid data sample relative to RD.
156+
Value is provided as 240 MHz clock sample counts, len = 12
157+
wl: sequence of int
158+
Length of receive data window provided as 240 MHz clock sample counts, len = 12
159+
ac_chan_coef: 2D sequence of complex
160+
Rx CAL path channel coeff., size = [num of chan x num of Angle-To-Coefficient table coeff.]
161+
ta_dbf_switch: sequence of int
162+
'N' time-index values @ 'ta_lut_fs' clock rate to map fast-time indices to 'N' Elevation
163+
angle indices for each channel
164+
num_lut_items: int
165+
number of entries in CAL Angle-To-Coefficient and Time-To-Angle tables
166+
num_chan_qfsp: int
167+
number of channels/beams being processed during beamforming per qFSP FPGA, default=4
168+
rx_correction_factor: sequence of complex
169+
A place holder is designated for applying possbile secondary Rx phase and magnitude correction,
170+
currently initialized to one, 1 per each channel, size = num_chan
171+
tx_correction_factor: sequence of complex
172+
Tx Cal correction factor that captures both magnitude and phase variation due to
173+
temperature. A place holder initialied to one is designated in case if
174+
temperature calibration is applied, len = num of channels
175+
"""
176+
177+
# Instantiate Tx Beamformer object
178+
tx_trm_info = TxTrmInfo(
179+
transmit_time,
180+
fc,
181+
channels_tx,
182+
correlator_tap2,
183+
cal_path_mask,
184+
tx_correction_factor,
185+
)
186+
187+
# Instantiate Rx Beamformer object
188+
rx_trm_info = RxTrmInfo(
189+
transmit_time,
190+
fc,
191+
channels_rx,
192+
rd,
193+
wd,
194+
wl,
195+
ac_chan_coef,
196+
ta_dbf_switch,
197+
num_lut_items,
198+
num_chan_qfsp,
199+
dbf_fs,
200+
adc_fs,
201+
ta_lut_fs,
202+
rx_correction_factor,
203+
)
204+
205+
return tx_trm_info, rx_trm_info

0 commit comments

Comments
 (0)