OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
GEO_validate_earth_location.c
Go to the documentation of this file.
1 #include "PGS_MODIS_35251.h"
2 #include "GEO_global_arrays.h" /* Just for LAT_IDX, LON_IDX, HT_IDX */
3 #include "GEO_validation.h"
4 #include "mapi.h"
5 #include "smfio.h"
6 
7 PGSt_SMF_status GEO_validate_earth_location (
8  int const mirr_impulse_flag,
9  double terrain_sample_position[][MAX_PADDED][3],
10  int const sample_number,
11  int const num_detectors,
12  unsigned char sample_flags[][MAX_PADDED])
13 
14 /*
15 !C******************************************************************************
16 !Description:
17  subprogram in validation group of the Level-1A geolocation
18  software to validate the pixel earth locations. The
19  pixel_flags are set for any earth location where validity
20  checks fail.
21 
22 !Input Parameters:
23  mirr_impulse_flag - mirror impulse encoder flag for this scan
24  terrain_sample_position
25  - computed geodetic coordinates for pixels
26  sample_number - the sample number within the scan
27  num_detectors - number of detectors in the sample
28 
29 !Output Parameters:
30  sample_flags - geolocation flags for pixels
31 
32 Return Values:
33  MODIS_E_BAD_INPUT_ARG If any input argument fails validity tests.
34  PGS_S_SUCCESS Otherwise
35 
36 Externally Defined:
37  BAD_TERRAIN "GEO_geo.h"
38  DETECTORS_QKM "GEO_geo.h"
39  HT_IDX "GEO_global_arrays.h"
40  INVALID_INPUT_DATA "GEO_geo.h"
41  LAT_IDX "GEO_global_arrays.h"
42  LON_IDX "GEO_global_arrays.h"
43  MAX_TERRAIN_HEIGHT "GEO_geo.h"
44  MIN_TERRAIN_HEIGHT "GEO_geo.h"
45  MODIS_E_BAD_INPUT_ARG "PGS_MODIS_35251.h"
46  NO_ELLIPSE_INTERSECT "GEO_geo.h"
47  MAX_PADDED "GEO_geo.h"
48  PGS_S_SUCCESS "PGS_SMF.h"
49 
50 Called by:
51  GEO_locate_one_scan "GEO_output.h"
52 
53 Routines Called:
54  modsmf "smfio.h"
55 
56 !Revision History:
57  * $Log: GEO_validate_earth_location.c,v $
58  * Revision 6.3 2010/12/15 23:26:52 kuyper
59  * Removed setting of terrain_sample_position fill values which was redundant
60  * in C5, and pointless in C6.
61  *
62  * Revision 6.2 2009/05/29 14:22:05 xgeng
63  * Removed 3 locally defined constants and use global constants instead.
64  *
65  * Revision 6.1 2009/05/19 22:09:22 xgeng
66  * Replaced MAX_SCAN_SAMPLE with PADDED_SAMPLES
67  * Replaced MAX_DETECTORS with DETECTORS_QKM.
68  * Renamed frame_number to sample_number, and pixel_flags to sample_flags.
69  * Changed to return a status code.
70  * Changed MAX_SCAN_SAMPLE to MAX_PADDED.
71  * The above changes match with PDL revision 6.1 and 6.2.
72  *
73  *
74  * Xu Geng (xu.geng@saic.com)
75  *
76  * Revision 4.2 2003/10/24 21:16:25 vlin
77  * expanded the size of message buffer.
78  *
79  * Revision 4.1 2003/02/21 22:51:30 kuyper
80  * Corrected to use void* pointers with %p format code.
81 
82  5/22/95
83  Frederick S. Patt (patt@modis-xl.gsfc.nasa.gov)
84  Finished coding (stub version).
85 
86 Requirements:
87  PR03-F-3.2.3-2
88  PR03-F-4.1-1
89 
90 !Team-unique Header:
91  This software is developed by the MODIS Science Data Support
92  Team for the National Aeronautics and Space Administration,
93  Goddard Space Flight Center, under contract NAS5-32373.
94 
95 Design Notes:
96  The design specifies the same fill values as
97  GEO_initialize_product for terrain_sample_position latitude,
98  longitude, and height. The structures that are used for that
99  initialization are not availible to this routine. If
100  GEO_initialize_product is changed then LAT_FILL, LON_FILL, and
101  HT_FILL will have to be changed to correspond.
102 
103 !END*************************************************************************
104 */
105 
106 {
107  /* Local variable declarations */
108  int det; /* loop index */
109  char msgbuf[128];
110  char filefunc[] = __FILE__ ", GEO_validate_earth_location";
111 
112  /* Begin program logic */
113 
114  if((sample_flags == NULL) || (terrain_sample_position == NULL) ||
115  (num_detectors < 0) || (num_detectors > DETECTORS_QKM) ||
116  (sample_number < 0) || (sample_number >= MAX_PADDED))
117  {
118  sprintf(msgbuf, "sample_flags: %p,terrain_sample_position: %p, "
119  "num_detectors: %d, sample_number = %d", (void*)sample_flags,
120  (void*)terrain_sample_position, num_detectors, sample_number);
121  modsmf(MODIS_E_BAD_INPUT_ARG, msgbuf, filefunc);
122  return MODIS_E_BAD_INPUT_ARG;
123  }
124 
125  /* Check for invalid mirror data */
126  if (mirr_impulse_flag == BAD_DATA) {
127  for (det = 0; det < num_detectors; det++) {
128  sample_flags[det][sample_number] |= INVALID_INPUT_DATA;
129  }
130  }
131 
132  for (det = 0; det < num_detectors; det++) {
133  if( (sample_flags[det][sample_number] &
135  ( (terrain_sample_position[det][sample_number][HT_IDX] <
137  (terrain_sample_position[det][sample_number][HT_IDX] >
138  MAX_TERRAIN_HEIGHT) ) )
139  {
140  sample_flags[det][sample_number] |= BAD_TERRAIN;
141  }
142  }
143 
144  return PGS_S_SUCCESS;
145 
146 } /* END GEO_validate_earth_location */
const double MAX_TERRAIN_HEIGHT
PGSt_SMF_status GEO_validate_earth_location(int const mirr_impulse_flag, double terrain_sample_position[][MAX_PADDED][3], int const sample_number, int const num_detectors, unsigned char sample_flags[][MAX_PADDED])
#define NULL
Definition: decode_rs.h:63
#define MODIS_E_BAD_INPUT_ARG
const unsigned char NO_ELLIPSE_INTERSECT
#define MAX_PADDED
Definition: GEO_geo.h:84
const int BAD_DATA
@ HT_IDX
const unsigned char BAD_TERRAIN
const double MIN_TERRAIN_HEIGHT
const unsigned char INVALID_INPUT_DATA
#define DETECTORS_QKM
Definition: GEO_geo.h:87
int mirr_impulse_flag[MAX_SCAN_NUMBER]