OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
wrt_czcs_qual.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include "l1czcs.h"
3 #include "hdf.h"
4 #include "mfhdf.h"
5 
6 int wrt_czcs_qual(int32 sdfid, int32 vid, int nlin, l1_data_struc l1_data)
7 /*******************************************************************
8 
9  wrt_czcs_qual
10 
11  purpose: write the CZCS file quality data to the raw data vgroup
12  including: cal_sum - errors for the line
13  cal_scan - band specific errors
14 
15  Returns type: int - FAIL if failed, else SUCCEED
16 
17  Parameters: (in calling order)
18  Type Name I/O Description
19  ---- ---- --- -----------
20  int32 sdfid I sd file id from hdf
21  int32 vid I v-group id
22  int nlin I number of lines of data
23  l1_data_struc l1_data I structure of data arrays
24 
25  Modification history:
26  Programmer Date Description of change
27  ---------- ---- ---------------------
28  W. Robinson 20-Apr-2004 Original development
29 
30  *******************************************************************/ {
31 #define CAL_SUM_LNAM "Calibration Qcality Summary"
32 #define CAL_SCAN_LNAM "Calibration Quality per Scan"
33 
34  int32 create_sds(int32, char *, int32, int32, int32 *, int32, VOIDP *);
35  int32 set_dim_names(int32, char *, char *, char *);
36  int dims[3] = {0, 0, 0}, sdsid, iret;
37  char *tot_line = "Number of Scan Lines";
38 
39  /*
40  * cal_sum
41  */
42  dims[0] = nlin;
43  dims[1] = 5;
44  if ((sdsid = create_sds(sdfid, "cal_sum", DFNT_UINT8, 2,
45  (int32 *) dims, vid, (VOIDP) l1_data.cal_sum)) < 0) {
46  fprintf(stderr, "wrt_czcs_qual: create_sds failed on cal_sum\n");
47  return FAIL;
48  }
49  if ((iret = set_dim_names(sdsid, tot_line, "num_qual", NULL)) < 0) {
50  fprintf(stderr, "wrt_czcs_qual: set_dim_names failed on cal_sum\n");
51  return FAIL;
52  }
53  if ((iret = SDsetattr(sdsid, "long_name", DFNT_CHAR,
54  strlen(CAL_SUM_LNAM) + 1, (VOIDP) CAL_SUM_LNAM)), 0) {
55  fprintf(stderr, "wrt_czcs_qual: SDsetattr failed on cal_sum, long_name\n");
56  return FAIL;
57  }
58  /*
59  * cal_scan
60  */
61  dims[1] = 6;
62  if ((sdsid = create_sds(sdfid, "cal_scan", DFNT_UINT8, 2,
63  (int32 *) dims, vid, (VOIDP) l1_data.cal_scan)) < 0) {
64  fprintf(stderr, "wrt_czcs_qual: create_sds failed on cal_scan\n");
65  return FAIL;
66  }
67  if ((iret = set_dim_names(sdsid, tot_line, "Number of Bands", NULL)) < 0) {
68  fprintf(stderr, "wrt_czcs_qual: set_dim_names failed on cal_scan\n");
69  return FAIL;
70  }
71  if ((iret = SDsetattr(sdsid, "long_name", DFNT_CHAR,
72  strlen(CAL_SCAN_LNAM) + 1, (VOIDP) CAL_SCAN_LNAM)), 0) {
73  fprintf(stderr,
74  "wrt_czcs_qual: SDsetattr failed on cal_scan, long_name\n");
75  return FAIL;
76  }
77  return SUCCEED;
78 }
int wrt_czcs_qual(int32 sdfid, int32 vid, int nlin, l1_data_struc l1_data)
Definition: wrt_czcs_qual.c:6
#define FAIL
Definition: ObpgReadGrid.h:18
#define NULL
Definition: decode_rs.h:63
#define CAL_SCAN_LNAM
int32 set_dim_names(int32 sds_id, char *d0, char *d1, char *d2)
Definition: set_dim_names.c:29
int nlin
Definition: get_cmp.c:28
#define CAL_SUM_LNAM
int32 create_sds(int32 sdfid, char *sdsname, int32 nt, int32 rank, int32 *dims, int32 vid, VOIDP *data)
Definition: create_sds.c:10