OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
czcs_ctl_pt.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include "l1czcs.h"
3 #define N_ANCHOR 77
4 #define PI 3.14159265359
5 #define RADEG 180. / PI
6 
7 void czcs_ctl_pt(DATA_REC_TYPE data, gattr_struc *gattr, int line,
8  l1_data_struc *l1_data)
9 /*******************************************************************
10 
11  czcs_ctl_pt
12 
13  purpose: take the unevenly spaced anchor points from the CZCS CRTT file,
14  correct the navigation and make an evenly spaced set of
15  control points
16 
17  Returns type: void
18 
19  Parameters: (in calling order)
20  Type Name I/O Description
21  ---- ---- --- -----------
22  DATA_REC_TYPE data I CRTT data record
23  gattr_struc * gattr I structure with final
24  attributes
25  int line I line being processed
26  l1_data_struc * l1_data I/O data structure containing
27  the control point grid
28 
29  Modification history:
30  Programmer Date Description of change
31  ---------- ---- ---------------------
32  W. Robinson 19-Mar-2004 Original development
33 
34  *******************************************************************/ {
35  int j, cpix, start_year, start_day;
36  float tmplon, alon[N_ANCHOR], alat[N_ANCHOR], xlon[NCZCS_PIX],
38  float suna, sunz, gmt;
39  double pi, radeg;
40  /*
41  * First, convert the scaled values to floating point
42  * and convert lon from 0 - 360 system to -180 - +180 system
43  */
44  for (j = 0; j < N_ANCHOR; j++) {
45  alat[j] = fixed_pt_2_floating_pt(data.lat_anchr_pts[j], 22);
46  tmplon = fixed_pt_2_floating_pt(data.long_anchr_pts[j], 22);
47  if (tmplon > 180.) tmplon = tmplon - 360.;
48  alon[j] = tmplon;
49  }
50  /*
51  * expand anchor points to every pixel and initially correct the
52  * latitudes, longitudes
53  */
54  lonlat_(alon, alat, xlon, ylat);
55  /*
56  * get the sensor zenith angle (needed for final nav correction)
57  */
58  pi = PI;
59  radeg = RADEG;
60  satang_(&pi, &radeg, &(gattr->tilt), &(gattr->roll), &(gattr->pitch),
61  &(gattr->yaw), xlon, ylat, senz, sena);
62  /*
63  * do the final navigation correction
64  */
65  lladjust_(&(gattr->tilt), &(gattr->roll), &(gattr->pitch),
66  &(gattr->yaw), senz, xlon, ylat);
67  /*
68  * as test for Fred, code to call satang using updated lat, lon
69  */
70  /*
71  satang_( &pi, &radeg, &(gattr->tilt), &(gattr->roll), &(gattr->pitch),
72  &(gattr->yaw), xlon, ylat, senz, sena );
73  */
74  /*
75  * get the solar zenith for the center and for testing, get
76  * the solar data for the whole line
77  */
78  if (line == gattr->scan_lines / 2) {
79  cpix = gattr->pix_per_scan / 2;
80  gmt = (float) l1_data->msec[line] / (1000. * 3600.);
81  start_year = gattr->start_year; /* start year, day are shorts */
82  start_day = gattr->start_day; /* and sunangs need ints */
83  sunangs_(&start_year, &start_day, &gmt,
84  &xlon[ cpix ], &ylat[ cpix ], &sunz, &suna);
85  gattr->cntr_sol_zen = sunz;
86  }
87  /*
88  * for extra outputs of geometry and calibrated radiance data
89  */
90 #ifdef GEOM_CAL
91  {
92  int off;
93  /*
94  * derive the solar geometry for all points and fill struct with
95  * it and sensor info
96  */
97  gmt = (float) l1_data->msec[line] / (1000. * 3600.);
98  start_year = gattr->start_year;
99  start_day = gattr->start_day;
100  off = (line * gattr->pix_per_scan);
101  for (j = 0; j < gattr->pix_per_scan; j++) {
102  sunangs_(&start_year, &start_day, &gmt,
103  &xlon[ j ], &ylat[ j ], &sunz, &suna);
104  *(l1_data->sol_zen + off) = sunz;
105  *(l1_data->sol_az + off) = suna;
106  *(l1_data->sen_zen + off) = *(senz + j);
107  *(l1_data->sen_az + off) = *(sena + j);
108  *(l1_data->all_lat + off) = *(ylat + j);
109  *(l1_data->all_lon + off) = *(xlon + j);
110  off++;
111  }
112  }
113 #endif
114  /*
115  * set up the lat, lon control points
116  */
117  for (j = 0; j < gattr->n_ctl_pt; j++) {
118  *(l1_data->ctl_pt_lat + (line * gattr->n_ctl_pt) + j) =
119  ylat[ l1_data->ctl_pt_cols[j] - 1 ];
120  *(l1_data->ctl_pt_lon + (line * gattr->n_ctl_pt) + j) =
121  xlon[ l1_data->ctl_pt_cols[j] - 1 ];
122  }
123  /*
124  * and finish
125  */
126  return;
127 }
int j
Definition: decode_rs.h:73
float fixed_pt_2_floating_pt(int, int)
Definition: read_crtt.c:211
const double pi
float ylat[LAC_PIXEL_NUM]
Definition: l1a_seawifs.c:92
#define N_ANCHOR
Definition: czcs_ctl_pt.c:3
void sunangs_(int *, int *, float *, float *, float *, float *, float *)
void lladjust_(float *, float *, float *, float *, float[], float[], float[])
void satang_(double *, double *, float *, float *, float *, float *, float *, float *, float *, float *)
void czcs_ctl_pt(DATA_REC_TYPE data, gattr_struc *gattr, int line, l1_data_struc *l1_data)
Definition: czcs_ctl_pt.c:7
#define RADEG
Definition: czcs_ctl_pt.c:5
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude data
Definition: HISTORY.txt:356
float xlon[LAC_PIXEL_NUM]
Definition: l1a_seawifs.c:93
void lonlat_(float[], float[], float[], float[])
#define NCZCS_PIX
Definition: l1czcs.h:23
#define PI
Definition: czcs_ctl_pt.c:4