OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
GEO_read_L1AECS_metadata.c
Go to the documentation of this file.
1 #include "PGS_MODIS_35251.h"
2 #include "GEO_input.h"
3 #include "GEO_product.h"
4 #include "L1a_data.h"
5 #include "smfio.h"
6 
8  MODFILE * const l1a_file,
9  ECS_metadata_struct * const ECS_metadata
10  )
11 
12 /*
13 !C**************************************************************************
14 !Description:
15  Routine in the input group of the Level-1A geolocation
16  software to read ECS Inventory metadata from the
17  L1A product file.
18 
19  Reads ECS Inventory Metadata:
20  RANGEBEGINNINGDATE
21  RANGEBEGINNINGTIME
22  RANGEENDINGDATE
23  RANGEENDINGTIME
24  DAYNIGHTFLAG
25  LOCALGRANULEID
26  PARAMETERVALUE.1 ("GRANULENUMBER")
27  ASSOCIATEDPLATFORMSHORTNAME.1
28  PRODUCTIONHISTORY
29 
30 !Input Parameters:
31  MODFILE *l1a_file - MAPI structure for Level 1A file
32 
33 !Output Parameters:
34  ECS_metadata - structure for ECS metadata inputs
35 
36 Returns:
37  SUCCEED if all metadatea are retrieved
38  FAIL otherwise.
39 
40 Global variables:
41  None.
42 
43 Called by:
44  GEO_prepare_l1a_data()
45 
46 Routines Called:
47  getMODISECSinfo - Reads an ECS metadata attribute from an
48  HDF global attribute.
49  modsmf - writes error status messages to log
50 
51 !Revision History:
52  * $Log: GEO_read_L1AECS_metadata.c,v $
53  * Revision 4.1 2003/02/21 22:49:42 kuyper
54  * Corrected to use void* pointers with %p format code.
55  *
56  * Revision 3.1 2002/06/13 22:51:29 kuyper
57  * Removed unnecessary NCSA acknowledgement.
58  *
59  * Revision 2.4 2001/01/17 16:06:37 vlin
60  * PRODUCTIONHISTORY is added per CCR 507
61  *
62  * Revision 2.3 2000/08/12 23:02:24 fhliang
63  * Added AssociatedPlatformShortName to the metadata list.
64  * Changed return type to 'int'.
65  * Cleaned up messages.
66  * Changed 'rtval' to 'retval'.
67  * Added static char filefunc and used it in calls to modsmf().
68  * Removed an extra PDL paragraph.
69  *
70  * Revision 2.2 1998/03/04 00:48:51 jjb
71  * Bug Fix MODxl00638: Initialized ECS_metadata ingest strings
72  * to prevent writing uninitialized metadata strings
73  * into the MOD03 product's metadata.
74  *
75  * Revision 2.1 1997/10/21 18:16:22 kuyper
76  * Returned from ClearCase
77  *
78  * Revision /main/GEO_V2_DEV/3 1997/10/06 kuyper
79  * Changed MECS_CORE to L1A_COREMETADATA.
80  *
81  * Revision /main/GEO_V2_DEV/2 1997/09/3 Ding
82  * Modified the code to read V2 input data.
83  * ding@ltpmail.gsfc.nasa.gov
84  *
85  * Revision 1.6.1.1 1997/07/21 22:20:17 kuyper
86  * Merged in out-of-sequence changes.
87  *
88  * Revision 1.6 1997/07/21 16:24:34 kuyper
89  * Baselined Version 1
90  *
91  *Parallel development:
92  * Revision 1.5 1997/06/02 17:51:51 kuyper
93  * Merged seed files.
94  *
95  * Revision 1.5 1997/03/26 18:12:56 fhliang
96  * Initial revision of SDST delivery of GEO_read_L1AECS_metadata.c.
97  *
98  Revision 1.4 1997/03/11 22:05:34 fshaw
99  *** empty log message ***
100 
101  Revision 1.3 1997/02/13 23:25:11 kuyper
102  Fixed typo in error message.
103 
104  Revision 1.2 1997/01/13 19:41:15 kuyper
105  Adjusted #include file list.
106  James Kuyper Jr. <kuyper@ltpmail.gsfc.nasa.gov>
107 
108  Revision 1.1 1997/01/08 16:06:27 mikej
109  Initial revision
110 
111 
112 Requirements:
113  PR03-F-2.1-1
114  PR03-F-2.1-2
115  PR03-F-2.1-3
116 
117 
118 !Team-unique Header:
119  This software is developed by the MODIS Science Data Support
120  Team for the National Aeronautics and Space Administration,
121  Goddard Space Flight Center, under contract NAS5-32373.
122 
123 !END***************************************************************************
124 */
125 
126 {
127 
128 #define N_ELEMENTS(foo) ((int) (sizeof(foo) / sizeof(foo[0])))
129 #define STRMAX 120
130 #define ARGMAX 80
131  const char ECSINITSTRING[] = "NOT SET"; /* metadata output initialization*/
132 
133  /*
134  Warning: The order and sequence of the initilizations can not
135  be changed. We finish the initilization later and count on this order
136  */
137  struct ECSmeta{
138  char *attrNameStr; /* name of metadata */
139  char *hdfAttrname; /* name of HDF global attribute */
140  char datatype[DATATYPELENMAX]; /* metadata data type */
141  long int n_elements; /* Number of metadata elements to retrieve */
142  void * data; /* pointer to the data */
143  } ECS_input_metadata[] = {
145  (long int) sizeof(ECS_metadata->rangebeginningdate), NULL},
147  (long int) sizeof(ECS_metadata->rangebeginningtime), NULL},
149  (long int) sizeof(ECS_metadata->rangeendingdate), NULL},
151  (long int) sizeof(ECS_metadata->rangeendingtime), NULL},
153  (long int) sizeof(ECS_metadata->operationmode), NULL},
155  (long int) sizeof(ECS_metadata->localinputgranuleid), NULL},
157  (long int) sizeof(ECS_metadata->granulenumber), NULL},
159  (long int) sizeof(ECS_metadata->platformshortname), NULL},
160  {MECS_PRODHISTORY, ARCHIVEMETADATA, TXT, (long int) sizeof( \
161  (ECS_metadata->version_metadata).productionhistory), NULL}
162  };
163 
164  int i, retval=SUCCEED; /* loop index */
165  int sameattr;
166  char msgbuf[STRMAX]; /* scratch string buffer */
167 
168  static char filefunc[] = __FILE__", GEO_read_L1AECS_metadata";
169 
170 
171  if((l1a_file == NULL) || (ECS_metadata == NULL) )
172  {
173  sprintf(msgbuf, " l1a_file = %p, ECS_metadata = %p",
174  (void*)l1a_file, (void*)ECS_metadata);
175  modsmf(MODIS_E_BAD_INPUT_ARG, msgbuf, filefunc);
176 
177  return FAIL;
178  }
179 
180 /* Initialize ECS_metadata output */
181  (void)memset(ECS_metadata,0,sizeof(ECS_metadata_struct));
182  (void)strncpy(ECS_metadata->rangebeginningdate,ECSINITSTRING,
183  sizeof(ECS_metadata->rangebeginningdate)-1);
184  (void)strncpy(ECS_metadata->rangebeginningtime,ECSINITSTRING,
185  sizeof(ECS_metadata->rangebeginningtime)-1);
186  (void)strncpy(ECS_metadata->rangeendingdate,ECSINITSTRING,
187  sizeof(ECS_metadata->rangeendingdate)-1);
188  (void)strncpy(ECS_metadata->rangeendingtime,ECSINITSTRING,
189  sizeof(ECS_metadata->rangeendingtime)-1);
190  (void)strncpy(ECS_metadata->operationmode,ECSINITSTRING,
191  sizeof(ECS_metadata->operationmode)-1);
192  (void)strncpy(ECS_metadata->localinputgranuleid,ECSINITSTRING,
193  sizeof(ECS_metadata->localinputgranuleid)-1);
194  (void)strncpy(ECS_metadata->granulenumber,ECSINITSTRING,
195  sizeof(ECS_metadata->granulenumber)-1);
196  (void)strncpy(ECS_metadata->platformshortname,ECSINITSTRING,
197  sizeof(ECS_metadata->platformshortname)-1);
198  (void)strncpy((ECS_metadata->version_metadata).productionhistory,ECSINITSTRING,\
199  sizeof((ECS_metadata->version_metadata).productionhistory)-1);
200 
201 /* Finish initializing the ECS_input_metadata array with the contents
202  defined above.
203 
204  See warning about sequence in declaration section
205 */
206  ECS_input_metadata[0].data = &ECS_metadata->rangebeginningdate;
207  ECS_input_metadata[1].data = &ECS_metadata->rangebeginningtime;
208  ECS_input_metadata[2].data = &ECS_metadata->rangeendingdate;
209  ECS_input_metadata[3].data = &ECS_metadata->rangeendingtime;
210  ECS_input_metadata[4].data = &ECS_metadata->operationmode;
211  ECS_input_metadata[5].data = &ECS_metadata->localinputgranuleid;
212  ECS_input_metadata[6].data = &ECS_metadata->granulenumber;
213  ECS_input_metadata[7].data = &ECS_metadata->platformshortname;
214  ECS_input_metadata[8].data = &ECS_metadata->version_metadata.productionhistory;
215 
216  for (i = 0; i < N_ELEMENTS(ECS_input_metadata); i++)
217  {
218  sameattr = (i > 0 && !(strncmp(ECS_input_metadata[i].hdfAttrname,
219  ECS_input_metadata[i-1].hdfAttrname,
220  sizeof(ECS_input_metadata[i].hdfAttrname))));
221  if (getMODISECSinfo(l1a_file, (sameattr ? NULL :
222  ECS_input_metadata[i].hdfAttrname),
223  ECS_input_metadata[i].attrNameStr, ECS_input_metadata[i].datatype,
224  &ECS_input_metadata[i].n_elements, ECS_input_metadata[i].data) != MAPIOK &&
225  strcmp(ECS_input_metadata[i].attrNameStr, MECS_PRODHISTORY) != 0) {
226  sprintf(msgbuf, "getMODISECSinfo(%.*s)", ARGMAX,
227  ECS_input_metadata[i].attrNameStr);
228  modsmf(MODIS_E_GEO, msgbuf, filefunc);
229 
230  retval = FAIL;
231  }
232  }
233 
234  return retval;
235 }
#define CORE_PARAMETERVALUE
Definition: L1a_data.h:136
#define FAIL
Definition: ObpgReadGrid.h:18
#define CORE_RANGE_BEG_DATE
Definition: L1a_data.h:130
#define NULL
Definition: decode_rs.h:63
#define MODIS_E_BAD_INPUT_ARG
#define CORE_RANGE_ENDING_TIME
Definition: L1a_data.h:133
#define MECS_PRODHISTORY
Definition: L1a_data.h:138
#define MODIS_E_GEO
#define N_ELEMENTS(foo)
#define CORE_LOCALGRANULEID
Definition: L1a_data.h:135
#define ARCHIVEMETADATA
Definition: GEO_product.h:102
#define CORE_RANGE_BEG_TIME
Definition: L1a_data.h:131
#define STRMAX
int GEO_read_L1AECS_metadata(MODFILE *const l1a_file, ECS_metadata_struct *const ECS_metadata)
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude data
Definition: HISTORY.txt:356
#define CORE_DAYNIGHTFLAG
Definition: L1a_data.h:134
#define CORE_RANGE_ENDING_DATE
Definition: L1a_data.h:132
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second and prod_ix set to PARAM_TYPE_INT name_prefix is compared with the beginning of the product name If name_suffix is not empty the it must match the end of the product name The characters right after the prefix are read as an integer and prod_ix is set to that number strncpy(l2prod->name_prefix, "myprod", UNITLEN)
char localinputgranuleid[PGSd_PC_FILE_PATH_MAX]
int i
Definition: decode_rs.h:71
#define CORE_ASSOCIATEDPLATFORMSHORTNAME
Definition: L1a_data.h:137
version_metadata_struct version_metadata
#define L1A_COREMETADATA
Definition: GEO_product.h:118
#define ARGMAX