OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
cz_ll_upd.c
Go to the documentation of this file.
1 #include "l1czcs.h"
2 
3 void cz_ll_upd(l1_data_struc *l1_data, gattr_struc *gattr)
4 /*******************************************************************
5 
6  cz_ll_upd
7 
8  purpose: Update the latitude, longitude information using the
9  improved navigation.
10 
11  Returns type: void
12 
13  Parameters: (in calling order)
14  Type Name I/O Description
15  ---- ---- --- -----------
16  l1_data_struc * l1_data I arrays data counts, lat, lons
17  gattr_struc * gattr I/O structure with final
18  attributes
19 
20  Modification history:
21  Programmer Date Description of change
22  ---------- ---- ---------------------
23  W. Robinson 5-Apr-2004 Original development
24 
25  *******************************************************************/ {
26  int i, j, nctlpix, nlin, ctr_ctl_pt;
27  int32_t loc;
28  float maxlat, minlat, low_neg, low_pos, hi_neg, hi_pos;
29  /*
30  * the western longitude is the longitude of the first pixel of the last line
31  * and the eastern is the last pixel of the first line
32  */
33  nctlpix = gattr->n_ctl_pt;
34  nlin = gattr->scan_lines;
35  /*
36  * We need to use the most general method to get the dataset bounds.
37  * get the min, max lat and for longitude, get min, max in (+) and
38  * (-) long ranges. The W and E get determined from these
39  */
40  low_neg = 999.;
41  low_pos = 999.;
42  hi_neg = -999.;
43  hi_pos = -999.;
44  maxlat = -999.;
45  minlat = 999.;
46  loc = 0;
47  for (i = 0; i < nlin; i++) {
48  /*
49  * Avoid getting information from lines where the data is missing in
50  * the vis and NIR bands and where scan quality(4, 5) are bad
51  */
52  if ((l1_data->cal_sum[ i * 5 + 3 ] == 0) &&
53  (l1_data->cal_sum[ i * 5 + 4 ] == 0) &&
54  (l1_data->cal_scan[ i * 6 ] == 0) &&
55  (l1_data->cal_scan[ i * 6 + 1 ] == 0) &&
56  (l1_data->cal_scan[ i * 6 + 2 ] == 0) &&
57  (l1_data->cal_scan[ i * 6 + 3 ] == 0) &&
58  (l1_data->cal_scan[ i * 6 + 4 ] == 0)) {
59  loc = i * nctlpix;
60  for (j = 0; j < nctlpix; j++) {
61  if (l1_data->ctl_pt_lat[ loc ] > maxlat)
62  maxlat = l1_data->ctl_pt_lat[ loc ];
63  if (l1_data->ctl_pt_lat[ loc ] < minlat)
64  minlat = l1_data->ctl_pt_lat[ loc ];
65  if (l1_data->ctl_pt_lon[ loc ] >= 0.) {
66  if (l1_data->ctl_pt_lon[ loc ] > hi_pos)
67  hi_pos = l1_data->ctl_pt_lon[ loc ];
68  if (l1_data->ctl_pt_lon[ loc ] < low_pos)
69  low_pos = l1_data->ctl_pt_lon[ loc ];
70  } else {
71  if (l1_data->ctl_pt_lon[ loc ] > hi_neg)
72  hi_neg = l1_data->ctl_pt_lon[ loc ];
73  if (l1_data->ctl_pt_lon[ loc ] < low_neg)
74  low_neg = l1_data->ctl_pt_lon[ loc ];
75  }
76  loc++;
77  }
78  }
79  }
80  /*
81  * latitude is done, so set it. for longitude, there are 5 conditions
82  * limits are 0 - N, 1 - S, 2 - W, 3 - E
83  */
84  gattr->limits[0] = maxlat;
85  gattr->limits[1] = minlat;
86  if ((low_neg == 999.) && (low_pos != 999.)) {
87  gattr->limits[2] = low_pos; /* all + long */
88  gattr->limits[3] = hi_pos;
89  } else if ((low_neg != 999.) && (low_pos == 999.)) {
90  gattr->limits[2] = low_neg; /* all - long */
91  gattr->limits[3] = hi_neg;
92  } else if ((hi_neg > -90.) && (low_pos < 90)) {
93  gattr->limits[2] = low_neg; /* long straddles 0 degrees */
94  gattr->limits[3] = hi_pos;
95  } else if ((low_neg <= -90.) && (hi_pos >= 90)) {
96  gattr->limits[2] = low_pos; /* long straddles date line */
97  gattr->limits[3] = hi_neg;
98  } else {
99  gattr->limits[2] = -180.; /* indeterminent */
100  gattr->limits[3] = 180.;
101  }
102  /*
103  * corner and center start, end line lat and lon info
104  * note that using aqua convention, this is dataset array relative,
105  * ie, top left is first line, pixel in array
106  */
107  gattr->up_lft_lat = l1_data->ctl_pt_lat[ 0 ];
108  gattr->up_lft_lon = l1_data->ctl_pt_lon[ 0 ];
109  gattr->lo_lft_lat = l1_data->ctl_pt_lat[ (nlin - 1) * nctlpix ];
110  gattr->lo_lft_lon = l1_data->ctl_pt_lon[ (nlin - 1) * nctlpix ];
111  gattr->up_rgt_lat = l1_data->ctl_pt_lat[ nctlpix - 1 ];
112  gattr->up_rgt_lon = l1_data->ctl_pt_lon[ nctlpix - 1 ];
113  gattr->lo_rgt_lat =
114  l1_data->ctl_pt_lat[ (nlin - 1) * nctlpix + (nctlpix - 1) ];
115  gattr->lo_rgt_lon =
116  l1_data->ctl_pt_lon[ (nlin - 1) * nctlpix + (nctlpix - 1) ];
117 
118  ctr_ctl_pt = (nctlpix - 1) / 2;
119  gattr->start_cntr_lat = l1_data->ctl_pt_lat[ ctr_ctl_pt ];
120  gattr->start_cntr_lon = l1_data->ctl_pt_lon[ ctr_ctl_pt ];
121  gattr->end_cntr_lat =
122  l1_data->ctl_pt_lat[ (nlin - 1) * nctlpix + ctr_ctl_pt ];
123  gattr->end_cntr_lon =
124  l1_data->ctl_pt_lon[ (nlin - 1) * nctlpix + ctr_ctl_pt ];
125  gattr->center_lat =
126  l1_data->ctl_pt_lat[ (nlin - 1) / 2 * nctlpix + ctr_ctl_pt ];
127  gattr->center_lon =
128  l1_data->ctl_pt_lon[ (nlin - 1) / 2 * nctlpix + ctr_ctl_pt ];
129 
130  return;
131 }
int j
Definition: decode_rs.h:73
void cz_ll_upd(l1_data_struc *l1_data, gattr_struc *gattr)
Definition: cz_ll_upd.c:3
int nlin
Definition: get_cmp.c:28
data_t loc[NROOTS]
Definition: decode_rs.h:78
int i
Definition: decode_rs.h:71