OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
rd_nav_t.c
Go to the documentation of this file.
1 #include "l1stat.h"
2 #include "l1stat_proto.h"
3 
4 extern int32 stat_status;
5 
6 int rd_nav_t(int32 sdfid, int32 nscans, nav_t_str *nav_t)
7 /*******************************************************************
8 
9  rd_nav_t
10 
11  purpose: read a set of navigation and time values from the
12  L1 dataset
13 
14  Returns type: none
15 
16  Parameters: (in calling order)
17  Type Name I/O Description
18  ---- ---- --- -----------
19  int32 sdfid I SD interface ID
20  int32 nscans I # of scan lines
21  nav_t_str * nav_t O structure containing the
22  pointers to the nav sds data
23 
24  Modification history:
25  Programmer Date Description of change
26  ---------- ---- ---------------------
27  W. Robinson, GSC 29-Dec-1999 Original development
28 
29  *******************************************************************/ {
30  int32 start[3], edge[3];
31  /*
32  * Allocate space for the navigation buffers
33  */
34 
35  if ((nav_t->orb_vec = (float32 *) calloc(nscans * 3, sizeof (float32))) == NULL) {
36  sprintf(err_msg, "chk_nav: cannot allocate memory for reading orb_vec");
37  return FAIL;
38  }
39 
40  if ((nav_t->sun_ref = (float32 *) calloc(nscans * 3, sizeof (float32))) == NULL) {
41  sprintf(err_msg, "chk_nav: cannot allocate memory for reading sun_ref");
42  return FAIL;
43  }
44 
45  if ((nav_t->sen_mat = (float32 *) calloc(nscans * 3 * 3, sizeof (float32))) == NULL) {
46  sprintf(err_msg, "chk_nav: cannot allocate memory for reading sen_mat");
47  return FAIL;
48  }
49 
50  if ((nav_t->scan_ell = (float32 *) calloc(nscans * 6, sizeof (float32))) == NULL) {
51  sprintf(err_msg, "chk_nav: cannot allocate memory for reading scan_ell");
52  return FAIL;
53  }
54 
55  if ((nav_t->msec = (int32_t *) calloc(nscans, sizeof (int32_t))) == NULL) {
56  sprintf(err_msg, "chk_nav: cannot allocate memory for reading msec");
57  return FAIL;
58  }
59  if ((nav_t->nflag = (int32 *) calloc(nscans * 8, sizeof (int32))) == NULL) {
60  sprintf(err_msg, "chk_nav: cannot allocate memory for reading nflag");
61  return FAIL;
62  }
63 
64  /*
65  * Set start and end dims for reading orb_vec sds
66  */
67  start[0] = start[1] = start[2] = 0;
68  edge[0] = nscans;
69  edge[1] = 3;
70  edge[2] = 0;
71  if ((rdslice(sdfid, ORBVEC, start, edge, (VOIDP) nav_t->orb_vec)) < 0) {
73  return FAIL;
74  }
75 
76  /*
77  * Set start and end dims and read sun_ref sds
78  */
79  start[0] = start[1] = start[2] = 0;
80  edge[0] = nscans;
81  edge[1] = 3;
82  edge[2] = 0;
83  if ((rdslice(sdfid, SUNREF, start, edge, (VOIDP) nav_t->sun_ref)) < 0) {
85  return FAIL;
86  }
87 
88  /*
89  * Set start and end dims and read sen_mat sds
90  */
91  start[0] = start[1] = start[2] = 0;
92  edge[0] = nscans;
93  edge[1] = 3;
94  edge[2] = 3;
95  if ((rdslice(sdfid, SENMAT, start, edge, (VOIDP) nav_t->sen_mat)) < 0) {
97  return FAIL;
98  }
99 
100  /*
101  * Set start and end dims and read scan_ell sds
102  */
103  start[0] = start[1] = start[2] = 0;
104  edge[0] = nscans;
105  edge[1] = 6;
106  edge[2] = 0;
107  if ((rdslice(sdfid, SCANELL, start, edge, (VOIDP) nav_t->scan_ell)) < 0) {
108  stat_status = stat_status | 1;
109  return FAIL;
110  }
111 
112  /*
113  * Set start and end dims and read msec sds
114  */
115  start[0] = start[1] = start[2] = 0;
116  edge[0] = nscans;
117  edge[1] = 0;
118  edge[2] = 0;
119  if ((rdslice(sdfid, "msec", start, edge, (VOIDP) nav_t->msec)) < 0) {
120  stat_status = stat_status | 1;
121  return FAIL;
122  }
123 
124  /*
125  * Set start and end dims and read nflag sds
126  */
127  start[0] = start[1] = start[2] = 0;
128  edge[0] = nscans;
129  edge[1] = 8;
130  edge[2] = 0;
131  if ((rdslice(sdfid, NFLAG, start, edge, (VOIDP) nav_t->nflag)) < 0) {
132  stat_status = stat_status | 1;
133  return FAIL;
134  }
135  return SUCCEED;
136 }
int32 rdslice(int32 sdfid, char *name, int32 *start, int32 *edge, void *buf)
Definition: stat_chk_utl.c:94
#define ORBVEC
Definition: l1stat.h:50
#define FAIL
Definition: ObpgReadGrid.h:18
#define NULL
Definition: decode_rs.h:63
#define SENMAT
Definition: l1stat.h:51
#define SUNREF
Definition: l1stat.h:53
#define SCANELL
Definition: l1stat.h:52
int rd_nav_t(int32 sdfid, int32 nscans, nav_t_str *nav_t)
Definition: rd_nav_t.c:6
int32 stat_status
Definition: l1stat_chk.c:8
#define NFLAG
Definition: l1stat.h:54
char err_msg[1024]
Definition: l1stat_chk.c:7