|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <tuple> |
| 4 | +#include <vector> |
| 5 | + |
| 6 | +#include <Eigen/Dense> |
| 7 | + |
| 8 | +#include <isce3/core/EMatrix.h> |
| 9 | +#include <isce3/core/Ellipsoid.h> |
| 10 | +#include <isce3/core/Linspace.h> |
| 11 | +#include <isce3/core/Orbit.h> |
| 12 | +#include <isce3/core/Poly1d.h> |
| 13 | +#include <isce3/geometry/DEMInterpolator.h> |
| 14 | + |
| 15 | +namespace isce3 { namespace antenna { |
| 16 | + |
| 17 | +/** |
| 18 | + * A class for estimating one-way or two-way elevation (EL) power |
| 19 | + * pattern from 2-D raw echo data over quasi-homogenous scene |
| 20 | + * and provide approximate look (off-nadir or EL) angle and |
| 21 | + * ellipsoidal incidence angle (no local slope). |
| 22 | + * The final power in dB scale is fit into N-order polynomials |
| 23 | + * as a function of look angle in radians. |
| 24 | + * Required relative radiometric calibration from \f$\beta^{0}\f$ to |
| 25 | + * \f$\gamma^{0}\f$ is done approximately by using slant ranges and |
| 26 | + * ellipsoidal incidence angle. |
| 27 | + */ |
| 28 | +class ElPatternEst { |
| 29 | + // aliases |
| 30 | +public: |
| 31 | + using RowMatrixXcf = isce3::core::EMatrix2D<std::complex<float>>; |
| 32 | + |
| 33 | +protected: |
| 34 | + using Linspace_t = isce3::core::Linspace<double>; |
| 35 | + using tuple4_t = std::tuple<Eigen::ArrayXd, isce3::core::Linspace<double>, |
| 36 | + Eigen::ArrayXd, Eigen::ArrayXd>; |
| 37 | + using tuple5_t = std::tuple<Eigen::ArrayXd, isce3::core::Linspace<double>, |
| 38 | + Eigen::ArrayXd, Eigen::ArrayXd, isce3::core::Poly1d>; |
| 39 | + |
| 40 | +public: |
| 41 | + // constructors |
| 42 | + /** |
| 43 | + * A constructor with full input arguments. |
| 44 | + * @param[in] sr_start start slant range in (m) |
| 45 | + * @param[in] orbit isce3 Orbit object |
| 46 | + * @param[in] polyfit_deg (optional) polyfit degree of polynomial |
| 47 | + * for polyfitting estimated power patterns. The value must be > 1. |
| 48 | + * Default is 6. |
| 49 | + * @pram[in] dem_interp (optional) isce3 DEMInterpolator object. |
| 50 | + * Default is global 0.0 (m) height (reference ellipsoid). |
| 51 | + * Note that simply averaged DEM will be used. No local slope is taken into |
| 52 | + * account! |
| 53 | + * @param[in] win_ped (optional) Raised-cosine window pedestal. A value |
| 54 | + * within [0, 1]. Default is Hann |
| 55 | + * window.https://en.wikipedia.org/wiki/Hann_function <a |
| 56 | + * href="https://en.wikipedia.org/wiki/Hann_function" target="_blank">See |
| 57 | + * raised cosine window</a>. |
| 58 | + * @param[in] ellips (optional) isce3 Ellipsoid object. Default is WGS84. |
| 59 | + * @param[in] center_scale_pf (optional) whether or not use center and |
| 60 | + * scaling in polyfit. Default is false. |
| 61 | + * @exception InvalidArgument |
| 62 | + */ |
| 63 | + ElPatternEst(double sr_start, const isce3::core::Orbit& orbit, |
| 64 | + int polyfit_deg = 6, |
| 65 | + const isce3::geometry::DEMInterpolator& dem_interp = {}, |
| 66 | + double win_ped = 0.0, const isce3::core::Ellipsoid& ellips = {}, |
| 67 | + bool center_scale_pf = false); |
| 68 | + |
| 69 | + /** |
| 70 | + * A more concise constructor of key inputs. |
| 71 | + * @param[in] sr_start start slant range in (m) |
| 72 | + * @param[in] orbit isce3 Orbit object |
| 73 | + * @param[in] dem_interp isce3 DEMInterpolator object. |
| 74 | + * @exception InvalidArgument |
| 75 | + */ |
| 76 | + ElPatternEst(double sr_start, const isce3::core::Orbit& orbit, |
| 77 | + const isce3::geometry::DEMInterpolator& dem_interp) |
| 78 | + : ElPatternEst(sr_start, orbit, 6, dem_interp, 0.0, |
| 79 | + isce3::core::Ellipsoid(), false) |
| 80 | + {} |
| 81 | + |
| 82 | + // methods |
| 83 | + /** |
| 84 | + * Estimated averaged two-way time-series power pattern in Elevation from |
| 85 | + * 2-D raw echo data uniformly sampled in slant range direction. Uniform |
| 86 | + * sampling in azimuth direction is not required! Note that it is assumed |
| 87 | + * the data either has no TX gap (bad values) or its TX gap (bad values) |
| 88 | + * have been already replaced by meaningful data. |
| 89 | + * @param[in] echo_mat raw echo matrix, a row-major Eigen matrix of type |
| 90 | + * complex float. The rows represent range lines. The matrix shape is pulses |
| 91 | + * (azimuth bins) by range bins. |
| 92 | + * @param[in] sr_spacing slant range spacing in (m). |
| 93 | + * @param[in] chirp_rate transmit chirp rate in (Hz/sec). |
| 94 | + * @param[in] chirp_dur transmit chirp duration in (sec). |
| 95 | + * @param[in] az_time (optional) relative azimuth time in seconds w.r.t |
| 96 | + * reference epoch time of orbit object. Default is the mid orbit time if |
| 97 | + * not specified or if set to {} or std::nullopt. |
| 98 | + * @param[in] size_avg (optional) the block size for averaging in slant |
| 99 | + * range direction. Default is 8. |
| 100 | + * @param[in] inc_corr (optional) whether or not apply correction for |
| 101 | + * incidence angles calculated at a certain mean DEM height wrt reference |
| 102 | + * ellipsoid w/o taking into account any local slope! Default is true. |
| 103 | + * @return eigen vector of times-series range-averaged peak-normalized |
| 104 | + * 2-way power pattern in (dB) which is uniformly sampled in slant range |
| 105 | + * with new range spacing defined by "sr_spacing * size_avg". |
| 106 | + * @return slant ranges in meters in the form of isce3 Linspace object |
| 107 | + * @return look angles vector in radians. |
| 108 | + * @return ellipsoidal incidence angles vector in radians. |
| 109 | + * @return isce3 Poly1d object mapping power in dB as a function |
| 110 | + * look angle in radians |
| 111 | + * @exception InvalidArgument, RuntimeError |
| 112 | + * @see powerPattern1way() |
| 113 | + */ |
| 114 | + tuple5_t powerPattern2way(const Eigen::Ref<const RowMatrixXcf>& echo_mat, |
| 115 | + double sr_spacing, double chirp_rate, double chirp_dur, |
| 116 | + std::optional<double> az_time = {}, int size_avg = 8, |
| 117 | + bool inc_corr = true); |
| 118 | + |
| 119 | + /** |
| 120 | + * Estimated averaged one-way time-series power pattern in Elevation from |
| 121 | + * 2-D raw echo data uniformly sampled in slant range direction. Uniform |
| 122 | + * sampling in azimuth direction is not required! Note that it is assumed |
| 123 | + * the data either has no TX gap (bad values) or its TX gap (bad values) |
| 124 | + * have been already replaced by meaningful data. |
| 125 | + * @param[in] echo_mat raw echo matrix, a row-major Eigen matrix of type |
| 126 | + * complex float. The rows represent range lines. The matrix shape is pulses |
| 127 | + * (azimuth bins) by range bins. |
| 128 | + * @param[in] sr_spacing slant range spacing in (m). |
| 129 | + * @param[in] chirp_rate transmit chirp rate in (Hz/sec). |
| 130 | + * @param[in] chirp_dur transmit chirp duration in (sec). |
| 131 | + * @param[in] az_time (optional) relative azimuth time in seconds w.r.t |
| 132 | + * reference epoch time of orbit object. Default is the mid orbit time if |
| 133 | + * not specified or if set to {} or std::nullopt. |
| 134 | + * @param[in] size_avg (optional) the block size for averaging in slant |
| 135 | + * range direction. Default is 8. |
| 136 | + * @param[in] inc_corr (optional) whether or not apply correction for |
| 137 | + * incidence angles calculated at a certain mean DEM height wrt reference |
| 138 | + * ellipsoid w/o taking into account any local slope! Default is true. |
| 139 | + * @return eigen vector of times-series range-averaged peak-normalized |
| 140 | + * 1-way power pattern in (dB) which is uniformly sampled in slant range |
| 141 | + * with new range spacing defined by "sr_spacing * size_avg". |
| 142 | + * @return slant ranges in meters in the form of isce3 Linspace object |
| 143 | + * @return look angles vector in radians. |
| 144 | + * @return ellipsoidal incidence angles vector in radians. |
| 145 | + * @return isce3 Poly1d object mapping power in dB as a function |
| 146 | + * look angle in radians |
| 147 | + * @exception InvalidArgument, RuntimeError |
| 148 | + * @see powerPattern2way() |
| 149 | + */ |
| 150 | + tuple5_t powerPattern1way(const Eigen::Ref<const RowMatrixXcf>& echo_mat, |
| 151 | + double sr_spacing, double chirp_rate, double chirp_dur, |
| 152 | + std::optional<double> az_time = {}, int size_avg = 8, |
| 153 | + bool inc_corr = true); |
| 154 | + |
| 155 | + /** |
| 156 | + * Get raised-cosine window pedestal set at the constructor. |
| 157 | + * @return window pedestal used for weighting ref chirp in |
| 158 | + * range compression. |
| 159 | + */ |
| 160 | + double winPed() const { return _win_ped; } |
| 161 | + |
| 162 | + /** |
| 163 | + * Get degree of polyfit set at the constructor. |
| 164 | + * @return degree of polyfit used for 1-way or 2-way power pattern (dB) |
| 165 | + * as a function of look angles (rad). |
| 166 | + */ |
| 167 | + int polyfitDeg() const { return _polyfit_deg; } |
| 168 | + |
| 169 | + /** |
| 170 | + * Check whether the polyfit process is centeralized and scaled. |
| 171 | + * @return bool |
| 172 | + */ |
| 173 | + bool isCenterScalePolyfit() const { return _center_scale_pf; } |
| 174 | + |
| 175 | +private: |
| 176 | + /** |
| 177 | + * Helper method for public methods "powPat1w" and "powPat2w" |
| 178 | + * @return peak-normalized calibrated averaged 2-way power pattern vector |
| 179 | + * in linear scale |
| 180 | + * @return slant ranges in meters in the form of isce3 Linspace object |
| 181 | + * @return look angles vector in radians. |
| 182 | + * @return ellipsoidal incidence angles vector in radians. |
| 183 | + * look angle in radians |
| 184 | + * @see powerPattern2way(), powerPattern1way() |
| 185 | + */ |
| 186 | + tuple4_t _getCalibPowLinear(const Eigen::Ref<const RowMatrixXcf>& echo_mat, |
| 187 | + double sr_spacing, double chirp_rate, double chirp_dur, |
| 188 | + std::optional<double> az_time, int size_avg, bool inc_corr); |
| 189 | + |
| 190 | + // members |
| 191 | +protected: |
| 192 | + // input common parameters |
| 193 | + double _sr_start; |
| 194 | + isce3::core::Orbit _orbit; |
| 195 | + double _polyfit_deg; |
| 196 | + isce3::geometry::DEMInterpolator _dem_interp; |
| 197 | + double _win_ped; |
| 198 | + isce3::core::Ellipsoid _ellips; |
| 199 | + bool _center_scale_pf; |
| 200 | +}; |
| 201 | + |
| 202 | +}} // namespace isce3::antenna |
0 commit comments