8#include <isce3/core/Matrix.h>
9#include <isce3/except/Error.h>
61 inline int numSubSwaths()
const {
return _validSamplesArraysVect.size(); }
65 std::string error_msg =
66 "ERROR the number of sub-swaths must be greater than zero";
67 throw isce3::except::OutOfRange(ISCE_SRCINFO(), error_msg);
104 return _validSamplesArraysVect;
117 _validSamplesArraysVect = v;
169 int operator()(
const int azimuth_index,
const int range_index)
const {
174 inline int length()
const {
return _rlength; }
183 inline int width()
const {
return _rwidth; }
201 std::vector<isce3::core::Matrix<int>> _validSamplesArraysVect;
204 inline void validate();
209isce3::product::SubSwaths::validate() {
211 std::string error_str =
"";
215 error_str +=
"Number of azimuth lines must be positive. \n";
220 error_str +=
"Number of range samples must be positive. \n";
223 for (
int s = 0; s < _validSamplesArraysVect.size(); ++s) {
224 if (_validSamplesArraysVect[s].size() == 0) {
227 if (_validSamplesArraysVect[s].width() != 2) {
228 error_str +=
"The valid samples array of sub-swath ";
229 error_str += std::to_string(s + 1);
230 error_str +=
" does not have two columns. The";
231 error_str +=
" columns should represent the indices";
232 error_str +=
" of the first valid range sample and next";
233 error_str +=
" sample after the last valid sample";
234 error_str +=
" for each azimuth line, respectively.\n";
237 if (_validSamplesArraysVect[s].length() != length()) {
238 error_str +=
"The valid samples array of sub-swath ";
239 error_str += std::to_string(s + 1);
240 error_str +=
" has ";
241 error_str += std::to_string(_validSamplesArraysVect[s].length());
242 error_str +=
" lines whereas the number of azimuth lines is ";
243 error_str += std::to_string(length());
246 bool flag_informed_error_negative =
false;
247 bool flag_informed_error_width =
false;
248 for (
int i = 0; i < length(); ++i) {
250 for (
int j = 0; j < 2; ++j) {
254 if (_validSamplesArraysVect[s](i, j) < 0 and
255 !flag_informed_error_negative) {
256 error_str +=
"The valid samples array of sub-swath ";
257 error_str += std::to_string(s + 1);
258 error_str +=
" has negative indices. For example,";
259 error_str +=
" the array element at azimuth line ";
260 error_str += std::to_string(i);
261 error_str +=
" and column ";
262 error_str += std::to_string(j);
263 error_str +=
" has value ";
264 error_str += std::to_string(_validSamplesArraysVect[s](i, j));
267 if (_validSamplesArraysVect[s](i, j) > width() and
268 !flag_informed_error_width) {
269 error_str +=
"The valid samples array of sub-swath ";
270 error_str += std::to_string(s + 1);
271 error_str +=
" has invalid range indices.";
272 error_str +=
" The array element at azimuth line ";
273 error_str += std::to_string(i);
274 error_str +=
" and column ";
275 error_str += std::to_string(j);
276 error_str +=
" has value ";
277 error_str += std::to_string(_validSamplesArraysVect[s](i, j));
278 error_str +=
" which is invalid for the sub-swath with ";
279 error_str += std::to_string(width());
280 error_str +=
" range samples.\n";
281 flag_informed_error_width =
true;
287 if (flag_informed_error_negative and flag_informed_error_width) {
293 if (! error_str.empty())
295 throw isce3::except::InvalidArgument(ISCE_SRCINFO(), error_str);
Data structure for a 2D row-major matrix.
Definition Matrix.h:23
SubSwaths(const int length, const int width, const std::vector< isce3::core::Matrix< int > > &v)
Construct a new SubSwaths object.
Definition SubSwaths.h:53
void numSubSwaths(const int n)
Set number of sub-swaths.
Definition SubSwaths.h:63
void length(const int &t)
Set the radar grid length.
Definition SubSwaths.h:177
int operator()(const int azimuth_index, const int range_index) const
Test if a radar sample belongs to a sub-swath or if it is invalid.
Definition SubSwaths.h:169
void width(const int &t)
Set the radar grid width.
Definition SubSwaths.h:186
const isce3::core::Matrix< int > & getValidSamplesArray(const int n) const
Get valid samples for a sub-swath's array indexed from 1 (1st sub-swath)
Definition SubSwaths.cpp:11
int width() const
Get the radar grid width.
Definition SubSwaths.h:183
int length() const
Get the radar grid length.
Definition SubSwaths.h:174
SubSwaths(const int length, const int width, const int n=1)
Construct a new SubSwaths object.
Definition SubSwaths.h:38
void setValidSamplesArraysVect(const std::vector< isce3::core::Matrix< int > > &v)
Set valid samples sub-swaths vector of arrays.
Definition SubSwaths.h:116
void setValidSamplesArray(const int n, const isce3::core::Matrix< int > &v)
Set valid samples for a sub-swath's array indexed from 1 (1st sub-swath)
Definition SubSwaths.cpp:30
const std::vector< isce3::core::Matrix< int > > & getValidSamplesArraysVect() const
Get valid samples sub-swaths vector of arrays.
Definition SubSwaths.h:103
int getSampleSubSwath(const int azimuth_index, const int range_index) const
Test if a radar sample belongs to a sub-swath or if it is invalid.
Definition SubSwaths.cpp:58
int numSubSwaths() const
Get number of sub-swaths.
Definition SubSwaths.h:61
The isce3::product namespace.
Definition forward.h:3
base interpolator is an abstract base class
Definition BinarySearchFunc.cpp:5