OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
VcstCalculateGridCenter.h
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * NAME: VcstCalculateGridCenter.h
4  *
5  * DESCRIPTION: contains function declarations for functions used in the
6  * ProSdrViirs geolocation routines.
7  *
8  **************************************************************************/
9 
10 #include <VcstGeoRctnglStruct.h>
12 
13 template <typename T>
14 
16 (
17  int scanIdx,
18  // const int inActScans,
19  const int inDet,
20  const int inMidRow,
21  const ViirsGeoRctnglType& inRect,
23  T* gridPtr
24  ) {
25  // Fill the map data set in the grid
26  inPsds->fillMds(&gridPtr->gmds);
27 
28  int row;
29  int col;
30  int width;
31 
32  // for(int scanIdx=0; scanIdx < inActScans; scanIdx++)
33  // {
34  // Compute the row number of the middle row of a scan
35  // row = (scanIdx * inDet) + inMidRow;
36  row = inMidRow;
37 
38  // Calculate the cntr grid row/col for each rectangle in the scan
39  for (int rectIdx = 0; rectIdx < inRect.numRctngl; rectIdx++) {
40  // Determine the width of the rectangle
41  width = inRect.rcol[rectIdx] - inRect.lcol[rectIdx] + 1;
42 
43  // Capture the middle column of this rectangle
44  col = inRect.mcol[rectIdx];
45 
46  // No matter what the width of the rectangle is, computing
47  // the cntr grid row/col will require at least 2 pixels in
48  // the middle column of the rectangle.
49  // Ensure that these two pixels are not fill.
50  if ((gridPtr->grow[row][col] < FLOAT32_FILL_TEST) ||
51  (gridPtr->grow[row + 1][col] < FLOAT32_FILL_TEST)) {
52  gridPtr->ctr_grow[scanIdx][rectIdx] = ERR_FLOAT64_FILL;
53  gridPtr->ctr_gcol[scanIdx][rectIdx] = ERR_FLOAT64_FILL;
54  } else {
55  // If the width of the rectangle is an odd number, then
56  // there is an exact middle column. Use the 2 grid
57  // row/col values to calculate the cntr grid row/col
58  if ((width % 2) != 0) {
59  gridPtr->ctr_grow[scanIdx][rectIdx] =
60  (gridPtr->grow[row][col] +
61  gridPtr->grow[row + 1][col]) / 2.e0;
62 
63  gridPtr->ctr_gcol[scanIdx][rectIdx] =
64  (gridPtr->gcol[row][col] +
65  gridPtr->gcol[row + 1][col]) / 2.e0;
66  } else {
67  // The rectangle width is an even number, therefore there
68  // is no exact middle column. Use the 4 surrounding grid
69  // row/col values to calculate the cntr grid row/col
70  if ((gridPtr->grow[row][col + 1] < FLOAT32_FILL_TEST) ||
71  (gridPtr->grow[row + 1][col + 1] < FLOAT32_FILL_TEST)) {
72  gridPtr->ctr_grow[scanIdx][rectIdx] = ERR_FLOAT64_FILL;
73  gridPtr->ctr_gcol[scanIdx][rectIdx] = ERR_FLOAT64_FILL;
74  } else {
75  gridPtr->ctr_grow[scanIdx][rectIdx] =
76  (gridPtr->grow[row][col] +
77  gridPtr->grow[row][col + 1] +
78  gridPtr->grow[row + 1][col] +
79  gridPtr->grow[row + 1][col + 1]) / 4.e0;
80 
81  gridPtr->ctr_gcol[scanIdx][rectIdx] =
82  (gridPtr->gcol[row][col] +
83  gridPtr->gcol[row][col + 1] +
84  gridPtr->gcol[row + 1][col] +
85  gridPtr->gcol[row + 1][col + 1]) / 4.e0;
86  }
87  }
88  }
89  }
90  // }
91 }
92 
93 
const double ERR_FLOAT64_FILL
Definition: VcstCmnConsts.h:80
void calculateGridCenter(int scanIdx, const int inDet, const int inMidRow, const ViirsGeoRctnglType &inRect, VcstPolarStereographicDataSet *inPsds, T *gridPtr)
int mcol[VIIRSI_MAX_NRCTNGL]
const float FLOAT32_FILL_TEST
void fillMds(mds_type *const anMds) const
int lcol[VIIRSI_MAX_NRCTNGL]
int rcol[VIIRSI_MAX_NRCTNGL]