|
| 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