OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
getl0scene.c
Go to the documentation of this file.
1 /* ============================================================== */
2 /* Module: getl0scene.c */
3 /* Purpose: Generate index of contiguous scenes with the L0 file */
4 /* Author: B.A. Franz, General Scences Corp., 9/97 */
5 /* ============================================================== */
6 
7 #include <string.h>
8 #include "swl0_proto.h"
9 
10 INT16 goodFrame(swl0indx *indx, INT16 irec);
11 INT16 goodTLM(swl0indx *indx, INT16 irec);
12 INT16 newScene(INT16 thisRec, INT16 lastRec, swl0indx *indx);
13 
14 INT16 getl0scene(swl0indx *indx, swl0scene scene[]) {
15  INT16 nscenes = 0;
16  INT16 irec;
17  INT16 wantFrame;
18  INT16 lastRec;
19  INT16 is;
20  INT16 firstInstFound;
21 
22  /* */
23  /* HRPT files will be held to one scene */
24  /* */
25 
26  if (indx->type == HRPT) {
27 
28  nscenes = 1;
29  scene[0].nrec = 0;
30  scene[0].type = 1;
31  firstInstFound = 0;
32 
33  for (irec = 0; irec < indx->nrecs; irec++) {
34 
35  wantFrame = (indx->rec[irec].mnftype == LACTYPE) &&
36  goodFrame(indx, irec);
37 
38  if (wantFrame && (indx->rec[irec].mnfnum != 2))
39  firstInstFound = 1;
40 
41  /* Delay start rec for first valid inst telemetry */
42  if (!firstInstFound)
43  wantFrame = 0;
44 
45  if (wantFrame) {
46  scene[0].indx[scene[0].nrec] = irec;
47  if (goodTLM(indx, irec))
48  scene[0].qual[scene[0].nrec] = 0;
49  else
50  scene[0].qual[scene[0].nrec] = 1;
51  scene[0].nrec++;
52  }
53  }
54 
55  if (scene[0].nrec < MINFRAMES)
56  nscenes = 0;
57 
58  } else {
59 
60 
61  nscenes = -1;
62  lastRec = -1;
63 
64  for (irec = 0; irec < indx->nrecs; irec++) {
65 
66  if (goodFrame(indx, irec)) {
67 
68  if (newScene(irec, lastRec, indx)) {
69  nscenes++;
70  if (nscenes > 0 && scene[nscenes - 1].nrec < MINFRAMES) {
71  nscenes--;
72  printf("getl0scene: scene %d of size %d is too small.\n",
73  nscenes, scene[nscenes].nrec);
74  }
75  if (nscenes >= MAXSCENES) {
76  printf("getl0scene: Warning: Max Scene Limit Exceeded\n");
77  break;
78  }
79  scene[nscenes].nrec = 0;
80  firstInstFound = 0;
81  lastRec = irec;
82  }
83 
84  /* If LAC, delay start of scene for first inst telemetry */
85  if ((indx->rec[irec].mnfnum != 2) ||
86  (indx->rec[irec].mnftype == GACTYPE))
87  firstInstFound = 1;
88 
89  if (firstInstFound) {
90  scene[nscenes].indx[scene[nscenes].nrec] = irec;
91  if (goodTLM(indx, irec))
92  scene[nscenes].qual[scene[nscenes].nrec] = 0;
93  else
94  scene[nscenes].qual[scene[nscenes].nrec] = 1;
95  scene[nscenes].nrec++;
96  lastRec = irec;
97  }
98  }
99  }
100 
101  nscenes++;
102  if (nscenes > 0 && scene[nscenes - 1].nrec < MINFRAMES) {
103  nscenes--;
104  fprintf(stderr,
105  "-W- %s line %d: scene %d of size %d is too small.\n",
106  __FILE__, __LINE__, nscenes, scene[nscenes].nrec);
107  }
108 
109  }
110 
111 
112  for (is = 0; is < nscenes; is++) {
113  strncpy(scene[is].l0file, indx->l0file, FILENAME_MAX);
114  scene[is].srec = scene[is].indx[ 0 ];
115  scene[is].erec = scene[is].indx[ scene[is].nrec - 1 ];
116  scene[is].crec = scene[is].indx[ scene[is].nrec / 2 ];
117  scene[is].stime = indx->rec[ scene[is].srec ].time;
118  scene[is].etime = indx->rec[ scene[is].erec ].time;
119  scene[is].ctime = indx->rec[ scene[is].crec ].time;
120  scene[is].mnftype = indx->rec[ scene[is].srec ].mnftype;
121  scene[is].type = indx->type;
122  scene[is].nscan = scene[is].nrec;
123  if (scene[is].mnftype == GACTYPE) { /* 5 GAC scans/frame */
124  scene[is].nscan *= 5;
125  scene[is].etime += (DTGAC / 5 * 4);
126  }
127  scene[is].orbnum = getorbnum(scene[is].ctime);
128  }
129 
130  return nscenes;
131 }
132 
133 
134 /* ----------------------------------------------------------------- */
135 /* goodFrame() - returns 1 if critical frame info is good. */
136 
137 /* ----------------------------------------------------------------- */
138 INT16 goodFrame(swl0indx *indx, INT16 irec) {
139  INT16 status = 0;
140 
141  /* Don't want any timing or scid errors */
142  status = !(indx->rec[irec].tRanError ||
143  indx->rec[irec].tSeqError ||
144  indx->rec[irec].tDifError ||
145  indx->rec[irec].scidError ||
146  indx->rec[irec].maxErrBits);
147 
148  return (status);
149 }
150 
151 
152 /* ----------------------------------------------------------------- */
153 /* goodTLM() - returns 1 if SOH telemetry looks OK. */
154 
155 /* ----------------------------------------------------------------- */
156 INT16 goodTLM(swl0indx *indx, INT16 irec) {
157  INT16 status = 1;
158 
159  /*
160  * Only care about mnf #1, since that is where we find the
161  * critical navigation telemetry.
162  */
163  if (indx->rec[irec].mnfnum == 1)
164  status = !(indx->rec[irec].bitError ||
165  indx->rec[irec].sgaError ||
166  indx->rec[irec].saaError ||
167  indx->rec[irec].sacError);
168 
169  return (status);
170 }
171 
172 
173 /* ----------------------------------------------------------------- */
174 /* newScene() - returns 1 if the current record should start a new */
175 /* scene. */
176 
177 /* ----------------------------------------------------------------- */
178 INT16 newScene(INT16 thisRec, INT16 lastRec, swl0indx *indx) {
179  FLOAT64 delTime;
180 
181  if (lastRec < 0) {
182  printf("First scene located.\n");
183  return (1);
184  }
185 
186  if (indx->rec[thisRec].mnftype != indx->rec[lastRec].mnftype) {
187  printf("Scene break for frame type change: %3d %3d\n",
188  indx->rec[thisRec].mnftype, indx->rec[lastRec].mnftype);
189  return (1);
190  }
191 
192  delTime = indx->rec[thisRec].time - indx->rec[lastRec].time;
193 
194  if ((indx->rec[thisRec].mnftype == GACTYPE) &&
195  (delTime < 0 || delTime > DELSCENEGAC)) {
196  printf("Scene break for GAC time difference: %lf\n", delTime);
197  return (1);
198  }
199 
200 
201  if ((indx->rec[thisRec].mnftype != GACTYPE) &&
202  (delTime < 0 || delTime > DELSCENELAC)) {
203  printf("Scene break for LAC time difference: %lf\n", delTime);
204  return (1);
205  }
206 
207  return (0);
208 }
209 
210 
double FLOAT64
Definition: elements.h:8
int status
Definition: l1_czcs_hdf.c:32
INT32 getorbnum(FLOAT64 usec)
Definition: getorbnum.c:44
int16_t * qual
Definition: l2bin.cpp:86
#define DELSCENEGAC
Definition: swl0_parms.h:51
#define LACTYPE
Definition: swl0_parms.h:20
this program makes no use of any feature of the SDP Toolkit that could generate such a then geolocation is calculated at that and then aggregated up to Resolved feature request Bug by adding three new int8 SDSs for each high resolution offsets between the high resolution geolocation and a bi linear interpolation extrapolation of the positions This can be used to reconstruct the high resolution geolocation Resolved Bug by delaying cumulation of gflags until after validation of derived products Resolved Bug by setting Latitude and Longitude to the correct fill resolving to support Near Real Time because they may be unnecessary if use of entrained ephemeris and attitude data is turned resolving bug report Corrected to filter out Aqua attitude records with missing status helping resolve bug MOD_PR03 will still correctly write scan and pixel data that does not depend upon the start thereby resolving MODur00108 Changed header guard macro names to avoid reserved name resolving MODur00104 Maneuver list file for Terra satellite was updated to include data from Jecue DuChateu Maneuver list files for both Terra and Aqua were updated to include two maneuvers from recent IOT weekly reports The limits for Z component of angular momentum was and to set the fourth GEO scan quality flag for a scan depending upon whether or not it occurred during one of them Added _FillValue attributes to many and changed the fill value for the sector start times from resolving MODur00072 Writes boundingcoordinate metadata to L1A archived metadata For PERCENT *ECS change to treat rather resolving GSFcd01518 Added a LogReport Changed to create the Average Temperatures vdata even if the number of scans is
Definition: HISTORY.txt:301
#define DELSCENELAC
Definition: swl0_parms.h:50
short int INT16
Definition: elements.h:5
#define DTGAC
Definition: swl0_parms.h:46
#define HRPT
Definition: l1stat.h:35
INT16 newScene(INT16 thisRec, INT16 lastRec, swl0indx *indx)
Definition: getl0scene.c:178
#define GACTYPE
Definition: swl0_parms.h:19
INT16 goodFrame(swl0indx *indx, INT16 irec)
Definition: getl0scene.c:138
INT16 goodTLM(swl0indx *indx, INT16 irec)
Definition: getl0scene.c:156
#define MINFRAMES
Definition: swl0_parms.h:13
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second and prod_ix set to PARAM_TYPE_INT name_prefix is compared with the beginning of the product name If name_suffix is not empty the it must match the end of the product name The characters right after the prefix are read as an integer and prod_ix is set to that number strncpy(l2prod->name_prefix, "myprod", UNITLEN)
int16_t * nscenes
Definition: l2bin.cpp:86
#define MAXSCENES
Definition: swl0_parms.h:10
INT16 getl0scene(swl0indx *indx, swl0scene scene[])
Definition: getl0scene.c:14
def ctime(the_file)
Definition: ProcUtils.py:332