OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
cz_clean.c
Go to the documentation of this file.
1 #include "l1czcs.h"
2 
3 int cz_clean(gattr_struc *gattr, l1_data_struc *l1_data)
4 /*******************************************************************
5 
6  cz_clean
7 
8  purpose: clean up the czcs data for the following
9  - bad time in the lines (solution - remove lines)
10 
11  Returns type: int - 0 no problems, else no good lines left in file
12 
13  Parameters: (in calling order)
14  Type Name I/O Description
15  ---- ---- --- -----------
16  gattr_struc * gattr I/O structure with final
17  attributes
18  l1_data_struc * l1_data I/O arrays data counts, lat, lons
19 
20  Modification history:
21  Programmer Date Description of change
22  ---------- ---- ---------------------
23  W. Robinson 23-Sep-2004 Original development,
24  W. Robinson, SAIC 19 Dec 2005 add the pos_err array to this
25 
26  *******************************************************************/ {
27  int i, linout = 0, nlin, npix, nctl_pix, msec, icompr, j, ncompr;
28 
29  /*
30  * loop through the scan lines, any bad lines are compressed out
31  * and the # scan lines is adjusted accordingly
32  */
33  nlin = gattr->scan_lines;
34  npix = gattr->pix_per_scan;
35  nctl_pix = gattr->n_ctl_pt;
36  icompr = 0;
37 
38  for (i = 0; i < nlin; i++) {
39  /*
40  * currently, the only check is on the msec in each line
41  */
42  msec = *(l1_data->msec + i);
43  /*
44  * if a bad msec found, don't incriment the output line and note that
45  * compression must be done
46  */
47  if ((msec < 0) || (msec > 86399999)) {
48  icompr = 1;
49  } else {
50  /*
51  * once the compress switch is on, copy lines to proper place
52  */
53  if (icompr == 1) {
54  for (j = 0; j < 6; j++)
55  memcpy(l1_data->counts[j] + npix * linout,
56  l1_data->counts[j] + npix * i, npix);
57  *(l1_data->msec + linout) = *(l1_data->msec + i);
58  memcpy(l1_data->ctl_pt_lat + nctl_pix * linout,
59  l1_data->ctl_pt_lat + nctl_pix * i,
60  nctl_pix * sizeof ( float));
61  memcpy(l1_data->ctl_pt_lon + nctl_pix * linout,
62  l1_data->ctl_pt_lon + nctl_pix * i,
63  nctl_pix * sizeof ( float));
64  /* note that ctl_pt_cols, ctl_pt_rows don't need change */
65  *(l1_data->tilt + linout) = *(l1_data->tilt + i);
66  *(l1_data->slat + linout) = *(l1_data->slat + i);
67  *(l1_data->slon + linout) = *(l1_data->slon + i);
68  *(l1_data->clat + linout) = *(l1_data->clat + i);
69  *(l1_data->clon + linout) = *(l1_data->clon + i);
70  *(l1_data->elat + linout) = *(l1_data->elat + i);
71  *(l1_data->elon + linout) = *(l1_data->elon + i);
72  memcpy(l1_data->cal_sum + 5 * linout,
73  l1_data->cal_sum + 5 * i, 5 * sizeof ( unsigned char));
74  memcpy(l1_data->cal_scan + 6 * linout,
75  l1_data->cal_scan + 6 * i, 6 * sizeof ( unsigned char));
76  memcpy(l1_data->orb_vec + 3 * linout,
77  l1_data->orb_vec + 3 * i, 3 * sizeof ( float));
78  memcpy(l1_data->att_ang + 3 * linout,
79  l1_data->att_ang + 3 * i, 3 * sizeof ( float));
80  *(l1_data->pos_err + linout) = *(l1_data->pos_err + i);
81  memcpy(l1_data->slope + 6 * linout,
82  l1_data->slope + 6 * i, 6 * sizeof ( float));
83  memcpy(l1_data->intercept + 6 * linout,
84  l1_data->intercept + 6 * i, 6 * sizeof ( float));
85  *(l1_data->gain + linout) = *(l1_data->gain + i);
86 #ifdef GEOM_CAL
87  memcpy(l1_data->sen_zen + npix * linout,
88  l1_data->sen_zen + npix * i, npix * sizeof ( float));
89  memcpy(l1_data->sen_az + npix * linout,
90  l1_data->sen_az + npix * i, npix * sizeof ( float));
91  memcpy(l1_data->sol_zen + npix * linout,
92  l1_data->sol_zen + npix * i, npix * sizeof ( float));
93  memcpy(l1_data->sol_az + npix * linout,
94  l1_data->sol_az + npix * i, npix * sizeof ( float));
95  memcpy(l1_data->all_lat + npix * linout,
96  l1_data->all_lat + npix * i, npix * sizeof ( float));
97  memcpy(l1_data->all_lon + npix * linout,
98  l1_data->all_lon + npix * i, npix * sizeof ( float));
99  memcpy(l1_data->Lt_443 + npix * linout,
100  l1_data->Lt_443 + npix * i, npix * sizeof ( float));
101  memcpy(l1_data->Lt_520 + npix * linout,
102  l1_data->Lt_520 + npix * i, npix * sizeof ( float));
103  memcpy(l1_data->Lt_550 + npix * linout,
104  l1_data->Lt_550 + npix * i, npix * sizeof ( float));
105  memcpy(l1_data->Lt_670 + npix * linout,
106  l1_data->Lt_670 + npix * i, npix * sizeof ( float));
107  memcpy(l1_data->Lt_750 + npix * linout,
108  l1_data->Lt_750 + npix * i, npix * sizeof ( float));
109  memcpy(l1_data->Lt_11500 + npix * linout,
110  l1_data->Lt_11500 + npix * i, npix * sizeof ( float));
111 #endif
112  }
113  linout++;
114  }
115  }
116  /*
117  * re-set the # lines and # control lines
118  */
119  gattr->scan_lines = linout;
120  gattr->n_ctl_lin = linout;
121  /*
122  * and end
123  */
124  if (icompr != 0) {
125  ncompr = nlin - linout;
126  printf("cz_clean: %d bad lines (of %d) were compressed out of the L1 file\n",
127  ncompr, nlin);
128  }
129  if (linout == 0) {
130  printf("cz_clean: No good lines were found in the file\n");
131  return -1;
132  } else
133  return 0;
134 }
int j
Definition: decode_rs.h:73
int32 * msec
Definition: l1_czcs_hdf.c:31
int nlin
Definition: get_cmp.c:28
int cz_clean(gattr_struc *gattr, l1_data_struc *l1_data)
Definition: cz_clean.c:3
int i
Definition: decode_rs.h:71
int npix
Definition: get_cmp.c:27