isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
RadarGridParameters.h
1 //-*- C++ -*-
2 //-*- coding: utf-8 -*-
3 
4 #pragma once
5 
6 #include "forward.h"
7 
8 // isce3::core
9 #include <isce3/core/Metadata.h>
10 #include <isce3/core/DateTime.h>
11 #include <isce3/core/LookSide.h>
12 #include <isce3/core/TimeDelta.h>
13 #include <isce3/except/Error.h>
14 
16 
17  public:
19  inline RadarGridParameters();
20 
27  char frequency = 'A');
28 
36 
38  inline RadarGridParameters(const isce3::core::Metadata & meta,
40 
42  inline RadarGridParameters(double sensingStart,
43  double wavelength,
44  double prf,
45  double startingRange,
46  double rangePixelSpacing,
47  isce3::core::LookSide lookSide,
48  size_t length,
49  size_t width,
50  isce3::core::DateTime refEpoch);
51 
53  inline RadarGridParameters(const RadarGridParameters & rgparam);
54 
56  inline RadarGridParameters&
57  operator=(const RadarGridParameters& rgparam);
58 
60  inline isce3::core::LookSide lookSide() const { return _lookSide; }
61 
63  inline void lookSide(isce3::core::LookSide side) { _lookSide = side; }
64 
66  inline void lookSide(const std::string &);
67 
69  inline const isce3::core::DateTime & refEpoch() const { return _refEpoch; }
70 
74  inline void refEpoch(const isce3::core::DateTime &epoch) { _refEpoch = epoch; }
75 
77  inline double sensingStart() const { return _sensingStart; }
78 
80  inline void sensingStart(const double & t){ _sensingStart = t; }
81 
83  inline double wavelength() const { return _wavelength; }
84 
86  inline void wavelength(const double & t) { _wavelength = t; }
87 
89  inline double prf() const { return _prf; }
90 
92  inline void prf(const double & t){ _prf = t; }
93 
95  inline double azimuthTimeInterval() const { return 1.0/_prf; };
96 
98  inline double startingRange() const { return _startingRange; }
99 
101  inline void startingRange(const double & r){ _startingRange = r; }
102 
104  inline double rangePixelSpacing() const { return _rangePixelSpacing; }
105 
107  inline void rangePixelSpacing(const double & t) { _rangePixelSpacing = t; }
108 
110  inline size_t length() const { return _rlength; }
111 
113  inline void length(const size_t & t) { _rlength = t; }
114 
116  inline size_t width() const { return _rwidth; }
117 
119  inline void width(const size_t & t) { _rwidth = t; }
120 
122  inline size_t size() const { return _rlength * _rwidth; }
123 
125  inline double sensingStop() const { return sensingTime(_rlength - 1.0); }
126 
128  inline double sensingMid() const {
129  return 0.5 * (sensingStart() + sensingStop());
130  }
131 
133  inline double sensingTime(double line) const {
134  return _sensingStart + line / _prf;
135  }
136 
138  inline isce3::core::DateTime sensingDateTime(double line) const {
139  return _refEpoch + sensingTime(line);
140  }
141 
143  inline double endingRange() const {
144  return slantRange(_rwidth - 1.0);
145  }
146 
148  inline double midRange() const {
149  return 0.5 * (startingRange() + endingRange());
150  }
151 
153  inline double slantRange(double sample) const {
154  return _startingRange + sample * _rangePixelSpacing;
155  }
156 
158  inline RadarGridParameters offsetAndResize(double yoff, double xoff, size_t ysize, size_t xsize) const
159  {
160  return RadarGridParameters( sensingTime(yoff),
161  wavelength(),
162  prf(),
163  slantRange(xoff),
165  lookSide(),
166  ysize,
167  xsize,
168  refEpoch());
169  }
170 
171 
173  inline RadarGridParameters multilook(size_t azlooks, size_t rglooks) const
174  {
175  //Check for number of points on edge
176  if ((azlooks == 0) || (rglooks == 0))
177  {
178  std::string errstr = "Number of looks must be positive. " +
179  std::to_string(azlooks) + "Az x" +
180  std::to_string(rglooks) + "Rg looks requested.";
181  throw isce3::except::OutOfRange(ISCE_SRCINFO(), errstr);
182  }
183 
184  //Currently implements the multilooking operation used in ISCE2
185  return RadarGridParameters( sensingTime(0.5 * (azlooks-1)),
186  wavelength(),
187  prf() / (1.0 * azlooks),
188  slantRange(0.5 * (rglooks-1)),
189  rangePixelSpacing() * rglooks,
190  lookSide(),
191  length()/azlooks,
192  width()/rglooks,
193  refEpoch());
194  }
195 
196  // Protected data members can be accessed by derived classes
197  protected:
200 
203 
205  double _wavelength;
206 
208  double _prf;
209 
212 
215 
217  size_t _rlength;
218 
220  size_t _rwidth;
221 
224 
226  inline void validate() const;
227 };
228 
230  : _lookSide(isce3::core::LookSide::Left), _sensingStart {0},
231  _wavelength {0}, _prf {0}, _startingRange {0},
232  _rangePixelSpacing {0}, _rlength {0}, _rwidth {0}, _refEpoch {1} {}
233 
234 // Constructor from an isce3::core::Metadata object.
239  const isce3::core::DateTime & refEpoch) :
240  _lookSide(meta.lookSide),
241  _sensingStart((meta.sensingStart - refEpoch).getTotalSeconds()),
242  _wavelength(meta.radarWavelength),
243  _prf(meta.prf),
244  _startingRange(meta.rangeFirstSample),
245  _rangePixelSpacing(meta.slantRangePixelSpacing),
246  _rlength(meta.length),
247  _rwidth(meta.width),
248  _refEpoch(refEpoch) { validate(); }
249 
250 // Copy constructors
254  _lookSide(rgparams.lookSide()),
255  _sensingStart(rgparams.sensingStart()),
256  _wavelength(rgparams.wavelength()),
257  _prf(rgparams.prf()),
258  _startingRange(rgparams.startingRange()),
259  _rangePixelSpacing(rgparams.rangePixelSpacing()),
260  _rlength(rgparams.length()),
261  _rwidth(rgparams.width()),
262  _refEpoch(rgparams.refEpoch()) { validate(); }
263 
264 // Assignment operator
268 operator=(const RadarGridParameters & rgparams) {
269  _sensingStart = rgparams.sensingStart();
270  _wavelength = rgparams.wavelength();
271  _prf = rgparams.prf();
272  _startingRange = rgparams.startingRange();
273  _rangePixelSpacing = rgparams.rangePixelSpacing();
274  _lookSide = rgparams.lookSide(),
275  _rlength = rgparams.length();
276  _rwidth = rgparams.width();
277  _refEpoch = rgparams.refEpoch();
278  validate();
279  return *this;
280 }
281 
282 // Constructor from individual components and values
284 RadarGridParameters(double sensingStart,
285  double wavelength,
286  double prf,
287  double startingRange,
288  double rangePixelSpacing,
289  isce3::core::LookSide lookSide,
290  size_t length,
291  size_t width,
292  isce3::core::DateTime refEpoch) :
293  _lookSide(lookSide),
294  _sensingStart(sensingStart),
295  _wavelength(wavelength),
296  _prf(prf),
297  _startingRange(startingRange),
298  _rangePixelSpacing(rangePixelSpacing),
299  _rlength(length),
300  _rwidth(width),
301  _refEpoch(refEpoch) { validate(); }
302 
303 // Validation of radar grid parameters
304 void
306 validate() const
307 {
308 
309  std::string errstr = "";
310 
311  if (wavelength() <= 0.)
312  {
313  errstr += "Radar wavelength must be positive. \n";
314  }
315 
316  if (prf() <= 0.)
317  {
318  errstr += "Pulse Repetition Frequency must be positive. \n";
319  }
320 
321  if (startingRange() <= 0.)
322  {
323  errstr += "Starting Range must be positive. \n";
324  }
325 
326  if (rangePixelSpacing() <= 0. )
327  {
328  errstr += "Slant range pixel spacing must be positive. \n";
329  }
330 
331  if (length() == 0)
332  {
333  errstr += "Radar Grid should have length of at least 1. \n";
334  }
335 
336  if (width() == 0)
337  {
338  errstr += "Radar Grid should have width of at least 1. \n";
339  }
340 
341  if (! errstr.empty())
342  {
343  throw isce3::except::InvalidArgument(ISCE_SRCINFO(), errstr);
344  }
345 }
346 
347 
349 void
351 lookSide(const std::string & inputLook) {
352  _lookSide = isce3::core::parseLookSide(inputLook);
353 }
double _startingRange
Slant range to center of first pixel.
Definition: RadarGridParameters.h:211
double _wavelength
Imaging wavelength.
Definition: RadarGridParameters.h:205
Definition: Swath.h:25
void lookSide(isce3::core::LookSide side)
Set look direction.
Definition: RadarGridParameters.h:63
double sensingStart() const
Get sensing start time in seconds since reference epoch.
Definition: RadarGridParameters.h:77
RadarGridParameters & operator=(const RadarGridParameters &rgparam)
Assignment operator.
Definition: RadarGridParameters.h:268
void width(const size_t &t)
Set radar grid width.
Definition: RadarGridParameters.h:119
double endingRange() const
Get ending slant range.
Definition: RadarGridParameters.h:143
Data structure to store date time to nano-sec precision.
Definition: DateTime.h:18
double sensingMid() const
Get sensing mid time in seconds.
Definition: RadarGridParameters.h:128
LookSide
Side that radar looks at, Left or Right.
Definition: LookSide.h:13
Definition: RadarGridParameters.h:15
void length(const size_t &t)
Set radar grid length.
Definition: RadarGridParameters.h:113
size_t width() const
Get radar grid width.
Definition: RadarGridParameters.h:116
size_t _rlength
Number of lines in the image.
Definition: RadarGridParameters.h:217
void sensingStart(const double &t)
Set sensing start time in seconds since reference epoch.
Definition: RadarGridParameters.h:80
void validate() const
Validate parameters of data structure.
Definition: RadarGridParameters.h:306
double prf() const
Get pulse repetition frequency in Hz - inverse of azimuth time interval.
Definition: RadarGridParameters.h:89
size_t length() const
Get radar grid length.
Definition: RadarGridParameters.h:110
isce3::core::LookSide lookSide() const
Get the look direction.
Definition: RadarGridParameters.h:60
isce3::core::DateTime sensingDateTime(double line) const
Get a sensing DateTime for a given line (zero-index row)
Definition: RadarGridParameters.h:138
RadarGridParameters offsetAndResize(double yoff, double xoff, size_t ysize, size_t xsize) const
Crop/ Expand while keeping the spacing the same with top left offset and size.
Definition: RadarGridParameters.h:158
double sensingStop() const
Get sensing stop time in seconds since reference epoch.
Definition: RadarGridParameters.h:125
double azimuthTimeInterval() const
Get azimuth time interval in seconds.
Definition: RadarGridParameters.h:95
const isce3::core::DateTime & refEpoch() const
Get reference epoch DateTime.
Definition: RadarGridParameters.h:69
Data structure for storing basic radar geometry image metadata.
Definition: Metadata.h:17
double midRange() const
Get middle slant range.
Definition: RadarGridParameters.h:148
double rangePixelSpacing() const
Get slant range pixel spacing in meters.
Definition: RadarGridParameters.h:104
LookSide parseLookSide(const std::string &str)
Parse string (e.g., &quot;left&quot; or &quot;right&quot;) to enum LookSide.
Definition: LookSide.cpp:13
RadarGridParameters multilook(size_t azlooks, size_t rglooks) const
Multilook.
Definition: RadarGridParameters.h:173
double startingRange() const
Get starting slant range in meters.
Definition: RadarGridParameters.h:98
double _rangePixelSpacing
Slant range pixel spacing.
Definition: RadarGridParameters.h:214
void startingRange(const double &r)
Set starting slant range in meters.
Definition: RadarGridParameters.h:101
void prf(const double &t)
Set pulse repetition frequency in Hz - inverse of azimuth time interval.
Definition: RadarGridParameters.h:92
isce3::core::LookSide _lookSide
Left or right looking geometry indicator.
Definition: RadarGridParameters.h:199
RadarGridParameters()
Default constructor.
Definition: RadarGridParameters.h:229
double _sensingStart
Sensing start time.
Definition: RadarGridParameters.h:202
Definition: Product.h:29
double _prf
PRF.
Definition: RadarGridParameters.h:208
double sensingTime(double line) const
Get sensing time for a given line (zero-index row)
Definition: RadarGridParameters.h:133
size_t _rwidth
Number of samples in the image.
Definition: RadarGridParameters.h:220
double wavelength() const
Get radar wavelength in meters.
Definition: RadarGridParameters.h:83
Definition: Error.h:21
void rangePixelSpacing(const double &t)
Set slant range pixel spacing in meters.
Definition: RadarGridParameters.h:107
isce3::core::DateTime _refEpoch
Reference epoch for time tags.
Definition: RadarGridParameters.h:223
void refEpoch(const isce3::core::DateTime &epoch)
Set reference epoch DateTime.
Definition: RadarGridParameters.h:74
size_t size() const
Get total number of radar grid elements.
Definition: RadarGridParameters.h:122
void wavelength(const double &t)
Set radar wavelength in meters.
Definition: RadarGridParameters.h:86
double slantRange(double sample) const
Get slant range for a given sample (zero-index column)
Definition: RadarGridParameters.h:153

Generated for ISCE3.0 by doxygen 1.8.5.