OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
fill_mstr.c
Go to the documentation of this file.
1 #include "l1czcs.h"
2 
3 void fill_mstr(int *mstr_last, mstr_struc *mstr, timqual_struc *init_info,
4  int ds_num, int st_scan, int en_scan)
5 /*******************************************************************
6 
7  fill_mstr
8 
9  purpose: fill the master list of czcs sczn info
10 
11  Returns type: void
12 
13  Parameters: (in calling order)
14  Type Name I/O Description
15  ---- ---- --- -----------
16  int * mstr_last I/O last filled line of the master
17  list
18  mstr_struc * mstr I/O structure of the master list
19  timqual_struc * init_info I structure with time, quality
20  summary to add to master list
21  int ds_num I current dataset in use
22  int st_scan I start scan of new data to add
23  to master list
24  int en_scan I and end scan (see above)
25 
26  Modification history:
27  Programmer Date Description of change
28  ---------- ---- ---------------------
29  W. Robinson, SAIC 6 Aug 2004 Original development
30 
31  *******************************************************************/
32  {
33  int in_st_scan, nscan, i, j;
34  int32_t step;
35  /*
36  * this will preserve a 124 msec scan line step in the master list -
37  * any gaps will be marked as having non-existant data (exist = 0)
38  *
39  * (if we start with scan 0 as input, don't worry about 124 msec spacing
40  */
41  printf("fill_mstr: filling master struct after index %d with input scans %d to %d\n",
42  *mstr_last, st_scan, en_scan);
43  if (st_scan == 0) {
44  in_st_scan = 1;
45  (*mstr_last)++;
46  mstr->msec[*mstr_last] = init_info->msec[0];
47  mstr->exist[*mstr_last] = 1;
48  mstr->qual[*mstr_last] = init_info->qual[0];
49  mstr->ds_num[*mstr_last] = ds_num;
50  mstr->scan[*mstr_last] = (int32_t) st_scan;
51  } else
52  in_st_scan = st_scan;
53 
54  nscan = en_scan - in_st_scan;
55  if (nscan > 0) {
56  /*
57  * transfer the msec and quality over to the master list, expanding
58  * any time gaps
59  */
60  for (i = 0; i < nscan; i++) {
61  step = (init_info->msec[in_st_scan] - mstr->msec[*mstr_last] + 60) /
62  124;
63  /*
64  * note that the msec step can be off by as much as +-30 msec, so the
65  * 60 msec will generously account for it
66  * very large or < 1 time steps will cause skipping of the line
67  * during fill
68  */
69  if ((step > 900) || (step <= 0)) {
70  printf("fill_mstr: Unrealistic time gap found at scan %d\n",
71  i);
72  printf(" Gap of %d lines. Skipping this line\n",
73  step);
74  } else {
75  if (step > 1) {
76  printf(
77  "fill_mstr: gap of %d lines found in filling master at scan # %d\n",
78  step, i);
79  for (j = 0; j < step - 1; j++) {
80  mstr->exist[ *mstr_last + 1 ] = 0;
81  mstr->msec[ *mstr_last + 1 ] = mstr->msec[ *mstr_last ] + 124;
82  (*mstr_last)++;
83  }
84  }
85  /*
86  * fill new entry
87  */
88  (*mstr_last)++;
89  mstr->msec[*mstr_last] = init_info->msec[in_st_scan];
90  mstr->exist[*mstr_last] = 1;
91  mstr->qual[*mstr_last] = init_info->qual[in_st_scan];
92  mstr->ds_num[*mstr_last] = ds_num;
93  mstr->scan[*mstr_last] = (int32_t) in_st_scan;
94  }
95  in_st_scan++;
96  }
97  }
98  return;
99 }
int j
Definition: decode_rs.h:73
int32 nscan
Definition: l1_czcs_hdf.c:19
void fill_mstr(int *mstr_last, mstr_struc *mstr, timqual_struc *init_info, int ds_num, int st_scan, int en_scan)
Definition: fill_mstr.c:3
int i
Definition: decode_rs.h:71