OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
epr_dump.c
Go to the documentation of this file.
1 /*
2  * $Id: epr_dump.c,v 1.2 2009-03-27 10:25:54 sabine Exp $
3  *
4  * Copyright (C) 2002 by Brockmann Consult (info@brockmann-consult.de)
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation. This program is distributed in the hope it will
9  * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
10  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16  */
17 
18 #include <assert.h>
19 #include <errno.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 
24 #include "epr_api.h"
25 #include "epr_core.h"
26 #include "epr_string.h"
27 #include "epr_ptrarray.h"
28 #include "epr_swap.h"
29 #include "epr_field.h"
30 #include "epr_record.h"
31 #include "epr_param.h"
32 #include "epr_dsd.h"
33 #include "epr_msph.h"
34 #include "epr_band.h"
35 #include "epr_bitmask.h"
36 
37 
38 /****************************** RESULTS OUTPUT ******************************/
39 
45 void epr_dump_record(const EPR_SRecord* record)
46 {
47  epr_print_record(record, stdout);
48 }
49 
56 void epr_print_record(const EPR_SRecord* record, FILE* ostream)
57 {
58  epr_uint field_index;
59  EPR_SField* field = NULL;
60 
61  epr_clear_err();
62 
63  for (field_index = 0; field_index < record->num_fields; field_index++)
64  {
65  field = record->fields[field_index];
66  epr_print_field(field, ostream);
67  }
68 }
69 
75 void epr_dump_field(const EPR_SField* field)
76 {
77  epr_print_field(field, stdout);
78 }
79 
86 void epr_print_field(const EPR_SField* field, FILE* ostream)
87 {
88  epr_uint i;
89 
90  epr_clear_err();
91 
92  fprintf(ostream, "%s = ", field->info->name);
93  if (field->info->data_type_id == e_tid_string)
94  {
95  fprintf(ostream, "\"%s\"", (const char*) field->elems);
96 /*
97  fprintf(ostream, "\"");
98  for (i = 0; i < field->info->num_elems; i++)
99  {
100  fprintf(ostream, "%c", ((char*) field->elems)[i]);
101  }
102  fprintf(ostream, "\"");
103 */
104  }
105  else if (field->info->data_type_id == e_tid_time)
106  {
107  EPR_STime* time = (EPR_STime*) field->elems;
108  fprintf(ostream, "{d=%d, j=%d, m=%d}", time->days, time->seconds, time->microseconds);
109  }
110  else {
111  if (field->info->num_elems > 1) {
112  fprintf(ostream, "{");
113  }
114  for (i = 0; i < field->info->num_elems; i++)
115  {
116  if (i > 0)
117  fprintf(ostream, ", ");
118  switch (field->info->data_type_id)
119  {
120  case e_tid_uchar:
121  fprintf(ostream, "%u", ((epr_uchar*) field->elems)[i]);
122  break;
123  case e_tid_char:
124  fprintf(ostream, "%d", ((char*) field->elems)[i]);
125  break;
126  case e_tid_ushort:
127  fprintf(ostream, "%u", ((epr_ushort*) field->elems)[i]);
128  break;
129  case e_tid_short:
130  fprintf(ostream, "%d", ((short*) field->elems)[i]);
131  break;
132  case e_tid_uint:
133  fprintf(ostream, "%u", ((epr_uint*) field->elems)[i]);
134  break;
135  case e_tid_int:
136  fprintf(ostream, "%d", ((int*) field->elems)[i]);
137  break;
138  case e_tid_float:
139  fprintf(ostream, "%f", ((float*) field->elems)[i]);
140  break;
141  case e_tid_double:
142  fprintf(ostream, "%f", ((double*) field->elems)[i]);
143  break;
144  default:
145  fprintf(ostream, "<<unknown data type>>");
146  }
147  }
148  if (field->info->num_elems > 1) {
149  fprintf(ostream, "}");
150  }
151  }
152  fprintf(ostream, "\n");
153 }
154 
155 
161 void epr_dump_element(const EPR_SRecord* record, epr_uint field_index, epr_uint element_index)
162 {
163  epr_print_element(record, field_index, element_index, stdout);
164 }
165 
166 
172 void epr_print_element(const EPR_SRecord* record, epr_uint field_index, epr_uint element_index, FILE* ostream)
173 {
174  EPR_SField* field = NULL;
175 
176  epr_clear_err();
177 
178  if (field_index >= record->num_fields)
179  {
181  "epr_print_element: element_index too large");
182  return;
183  }
184 
185  field = record->fields[field_index];
186 
187  if (element_index >= field->info->num_elems)
188  {
190  "epr_print_element: element_index too large");
191  return;
192  }
193 
194  fprintf(ostream, "%s [%d][%d] = ", field->info->name, field_index, element_index);
195  if (field->info->data_type_id == e_tid_string)
196  {
197  fprintf(ostream, "\"");
198  fprintf(ostream, "%c", ((char*) field->elems)[element_index]);
199  fprintf(ostream, "\"");
200  }
201  else if (field->info->data_type_id == e_tid_time)
202  {
203  EPR_STime* time = (EPR_STime*) field->elems;
204  fprintf(ostream, "{d=%d, j=%d, m=%d}", time->days, time->seconds, time->microseconds);
205  }
206  else {
207  fprintf(ostream, "{ ");
208  switch (field->info->data_type_id)
209  {
210  case e_tid_uchar:
211  fprintf(ostream, "%u", ((epr_uchar*) field->elems)[element_index]);
212  break;
213  case e_tid_char:
214  fprintf(ostream, "%d", ((char*) field->elems)[element_index]);
215  break;
216  case e_tid_ushort:
217  fprintf(ostream, "%u", ((epr_ushort*) field->elems)[element_index]);
218  break;
219  case e_tid_short:
220  fprintf(ostream, "%d", ((short*) field->elems)[element_index]);
221  break;
222  case e_tid_uint:
223  fprintf(ostream, "%u", ((epr_uint*) field->elems)[element_index]);
224  break;
225  case e_tid_int:
226  fprintf(ostream, "%d", ((int*) field->elems)[element_index]);
227  break;
228  case e_tid_float:
229  fprintf(ostream, "%f", ((float*) field->elems)[element_index]);
230  break;
231  case e_tid_double:
232  fprintf(ostream, "%f", ((double*) field->elems)[element_index]);
233  break;
234  default:
235  fprintf(ostream, "<<unknown data type>>");
236  }
237  fprintf(ostream, " }");
238  }
239  fprintf(ostream, " [%s]\n", field->info->unit);
240 }
@ e_err_illegal_arg
Definition: epr_api.h:81
unsigned int epr_uint
Definition: epr_api.h:188
unsigned short epr_ushort
Definition: epr_api.h:187
#define NULL
Definition: decode_rs.h:63
void epr_print_element(const EPR_SRecord *record, epr_uint field_index, epr_uint element_index, FILE *ostream)
Definition: epr_dump.c:172
@ e_tid_float
Definition: epr_api.h:60
void epr_dump_element(const EPR_SRecord *record, epr_uint field_index, epr_uint element_index)
Definition: epr_dump.c:161
@ e_tid_int
Definition: epr_api.h:58
@ e_tid_ushort
Definition: epr_api.h:52
@ e_tid_uint
Definition: epr_api.h:56
void epr_dump_field(const EPR_SField *field)
Definition: epr_dump.c:75
void epr_print_record(const EPR_SRecord *record, FILE *ostream)
Definition: epr_dump.c:56
@ e_tid_char
Definition: epr_api.h:50
void epr_clear_err()
Definition: epr_core.c:247
void epr_set_err(EPR_EErrCode err_code, const char *err_message)
Definition: epr_core.c:221
@ e_tid_double
Definition: epr_api.h:62
void epr_print_field(const EPR_SField *field, FILE *ostream)
Definition: epr_dump.c:86
@ e_tid_string
Definition: epr_api.h:64
this program makes no use of any feature of the SDP Toolkit that could generate such a then geolocation is calculated at that and then aggregated up to Resolved feature request Bug by adding three new int8 SDSs for each high resolution offsets between the high resolution geolocation and a bi linear interpolation extrapolation of the positions This can be used to reconstruct the high resolution geolocation Resolved Bug by delaying cumulation of gflags until after validation of derived products Resolved Bug by setting Latitude and Longitude to the correct fill resolving to support Near Real Time because they may be unnecessary if use of entrained ephemeris and attitude data is turned resolving bug report Corrected to filter out Aqua attitude records with missing status helping resolve bug MOD_PR03 will still correctly write scan and pixel data that does not depend upon the start time
Definition: HISTORY.txt:248
@ e_tid_short
Definition: epr_api.h:54
@ e_tid_time
Definition: epr_api.h:68
unsigned char epr_uchar
Definition: epr_api.h:186
@ e_tid_uchar
Definition: epr_api.h:48
int i
Definition: decode_rs.h:71
void epr_dump_record(const EPR_SRecord *record)
Definition: epr_dump.c:45