OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
get_valid_L0_file.c
Go to the documentation of this file.
1 #include "L1A_prototype.h"
2 #include "PGS_TYPES.h"
3 #include "PGS_MODIS_35005.h"
4 #include "PGS_IO_L0.h"
5 #include "PGS_SMF.h"
6 #include "PC_pcf_info.h"
7 
8 
9 PGSt_SMF_status get_valid_L0_file (PGSt_tag spacecraft_tag,
10  PGSt_IO_L0_VirtualDataSet *L0_file,
11  PGSt_double *start_time,
12  PGSt_double *stop_time)
13 /*
14 !C*****************************************************************************
15 
16 !Description: Function get_valid_L0_file opens the L0 file and validates the
17  L0 header.
18 
19 !Input Parameters:
20  PGSt_tag spacecraft_tag ** Spacecraft tag **
21 
22 !Output Parameters:
23  PGSt_double start_time ** Start time of
24  L0 file **
25  PGSt_double stop_time ** Stop time of
26  L0 file **
27  PGEt_IO_L0_virtualDataSet L0_file opened L0 file structure
28 
29 Return Values:
30  MODIS_S_SUCCESS (PGS_MODIS_35005.h)
31  MODIS_E_GET_VALID_L0_FILE (PGS_MODIS_35005.h)
32 
33 Externally Defined:
34  PGSt_PC_Logical (PGS_TYPES.h)
35  PGSt_tag (PGS_TYPES.h)
36  PGSt_IO_L0_VirtualDataSet (PGS_IO_L0.h)
37  PGSt_double (PGS_TYPES.h)
38  PC_CURRENT_L0_PCF_ID (PC_pcf_info.h)
39  global_last_gran_stop_time (level1a)
40  global_first_gran_start_time (level1a)
41  PC_L1A_SCAN_RATE (PC_pcf_info.h)
42 
43 Called By:
44  initialize_level1a
45  read_a_packet
46  set_start_position
47 
48 Routines Called:
49  PGS_IO_L0_Open
50  PGS_SMF_TestSuccessLevel
51  validate_L0_header
52  log_fmt_msg
53  PGS_PC_GetConfigData
54  PGS_PC_GetUniversalRef
55 
56 !Revision History:
57  $Log: get_valid_L0_file.c,v $
58  Revision 6.1 2010/08/24 13:54:43 kuyper
59  Corrected inappropriate use of NULL in an arithmetic context.
60 
61  Revision 4.2 2003/11/12 21:05:37 kuyper
62  Removed declarations that duplicate L1A_prototype.h entries.
63 
64  Revision 4.1 2002/10/21 19:01:59 vlin
65  Updated buffer format for variable "global_L0_logical".
66 
67  revision 1.1 1999/11/18 10:32:00
68  John Seaton/GSC (seaton@ltpmail.gsfc.nasa.gov)
69  Added scan rate on to last_gran_stop_time to pick
70  up data that crosses L) file boundaries from processing
71  599001 to 599002.
72 
73  revision 1.0 1997/09/18 17:30:00
74  Qi Huang/RDC (qhuang@ltpmail.gsfc.nasa.gov)
75  Original development
76 
77 !Team-unique Header:
78  This software is developed by the MODIS Science
79  Data Support Team (SDST) for the National Aeronautics
80  and Space Administration (NASA), Goddard Space Flight
81  Center (GSFC), under contract NAS5-32373.
82 
83 References and Credits:
84  None
85 
86 Design Notes:
87  None
88 
89 !END
90 **************************************************************************/
91 
92 {
93  char *routine = "get_valid_L0_file";
94  PGSt_SMF_status returnStatus;
95  PGSt_SMF_status PGS_status;
96  char msg[300];
97  PGSt_integer version_num;
98  char file_name[PGSd_PC_VALUE_LENGTH_MAX];
99  PGSt_double scan_rate;
100  char scan_rate_string[PGSd_PC_VALUE_LENGTH_MAX];
101 
102 
103  returnStatus = MODIS_S_SUCCESS;
104 
105  version_num = 2;
106  PGS_status = PGS_PC_GetUniversalRef(global_L0_logical,
107  &version_num,
108  file_name);
109 
110  if (PGS_SMF_TestSuccessLevel(PGS_status) != PGS_TRUE) {
111  sprintf(msg, "Unable to retrieve L0 file name. LUN: %u Version: %d",
112  (unsigned)global_L0_logical, version_num);
114  }
115 
116  else {
117  if (global_input_pointer[1][0] == '\0')
118  strcpy(global_input_pointer[1], file_name);
119  else
120  strcpy(global_input_pointer[2], file_name);
121  }
122 
123  PGS_status = PGS_IO_L0_Open(global_L0_logical, spacecraft_tag, L0_file,
124  start_time, stop_time);
125 
126  if (PGS_SMF_TestSuccessLevel(PGS_status) != PGS_TRUE) {
127  returnStatus = MODIS_E_GET_VALID_L0_FILE;
128  sprintf(msg, "PGS_IO_L0_Open could not open the L0 file successfully LUN: %u",
129  (unsigned)global_L0_logical);
131  }
132 
133  else {
134  PGS_status = PGS_PC_GetConfigData(PC_L1A_SCAN_RATE, scan_rate_string);
135  if (PGS_SMF_TestSuccessLevel(PGS_status) == PGS_TRUE)
136  scan_rate = (PGSt_double) atof(scan_rate_string);
137  else {
138  scan_rate = 0.0;
140  "The scan rate could not be retrieved from pcf file");
141  }
142 
143  if ((*start_time > global_last_gran_stop_time + scan_rate) ||
144  ((*stop_time < global_first_gran_start_time) &&
146  returnStatus = MODIS_E_GET_VALID_L0_FILE;
147  sprintf(msg, "L0 data set does not correspond with granule times\n"
148  "L0 Start/Stop: %f %f\nPCF Start/Stop: %f %f", *start_time, *stop_time,
151  }
152  /* Comment out for now; use "inhouse" tools another time.
153  else
154  if ((PGS_status = validate_L0_header(*L0_file)) != MODIS_S_SUCCESS) {
155  returnStatus = MODIS_E_GET_VALID_L0_FILE;
156  sprintf(msg, "L0 LUN: %u", (unsigned)global_L0_logical);
157  log_fmt_msg(MODIS_F_L0_HEADER_VAL_FAILED, routine, msg);
158  }
159  */
160  }
161 
162  return (returnStatus);
163 
164 }
#define MODIS_E_GET_VALID_L0_FILE
#define PC_L1A_SCAN_RATE
Definition: PC_pcf_info.h:64
PGSt_PC_Logical global_L0_logical
Definition: level1a.c:35
char global_input_pointer[MAX_INPUTS][PGSd_PC_VALUE_LENGTH_MAX]
Definition: level1a.c:23
#define PC_CURRENT_L0_PCF_ID
Definition: PC_pcf_info.h:52
PGSt_SMF_status get_valid_L0_file(PGSt_tag spacecraft_tag, PGSt_IO_L0_VirtualDataSet *L0_file, PGSt_double *start_time, PGSt_double *stop_time)
#define MODIS_E_GETCONFIG_FAILED
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
PGSt_double global_last_gran_stop_time
Definition: level1a.c:31
PGSt_double global_first_gran_start_time
Definition: level1a.c:30
#define MODIS_S_SUCCESS
string msg
Definition: mapgen.py:227
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")