Go to the documentation of this file.
7 int main(
int argc,
char *argv[]) {
13 char ncdump[500000] =
"";
14 char tmpstr[1000] =
"";
15 char cmd_string[250] =
"";
17 char range_date[11] =
"";
18 char range_time[9] =
"";
30 char julian_str[4] =
"";
35 char date_stamp[15] =
"";
39 printf(
"\nUSAGE: %s MODIS_L1A_L1B_or_GEO_file [start|stop]\n", argv[0]);
42 if (!(fptr = fopen(argv[1],
"r"))) {
48 len = strlen(argv[1]);
49 ifile = malloc(1 + (len *
sizeof (
char)));
52 seadas = getenv(
"OCSSWROOT");
54 strcat(cmd_string,
"ncdump");
56 strcpy(cmd_string, seadas);
57 strcat(cmd_string,
"/run/bin3/ncdump");
58 if (!(testptr = fopen(cmd_string,
"r"))) {
59 strcpy(cmd_string, seadas);
60 strcat(cmd_string,
"/bin/ncdump");
61 if (!(testptr = fopen(cmd_string,
"r"))) {
62 printf(
"modis_timestamp: Error - ncdump must exist in $SEADAS/run/bin3/ or $SEADAS/bin/ to run this program.\n");
68 strcat(cmd_string,
" -h ");
69 strcat(cmd_string,
ifile);
71 fp =
popen(cmd_string,
"r");
72 while (fgets(tmpstr,
sizeof tmpstr, fp)) {
73 strcat(ncdump, tmpstr);
78 if (argc == 2) argv[2] = argv[1];
79 if (strcmp(argv[2],
"stop") == 0) ptr = strstr(ncdump,
"RANGEENDINGDATE");
80 else ptr = strstr(ncdump,
"RANGEBEGINNINGDATE");
82 printf(
"modis_timestamp: Error - File doesn't appear to have a valid MODIS HDF header.\n");
85 ptr = strstr(ptr,
"VALUE");
87 printf(
"modis_timestamp: Error - File doesn't appear to have a valid MODIS HDF header.\n");
90 strncpy(range_date, ptr + 25, 10);
91 range_date[10] =
'\0';
94 if (strcmp(argv[2],
"stop") == 0) ptr = strstr(ncdump,
"RANGEENDINGTIME");
95 else ptr = strstr(ncdump,
"RANGEBEGINNINGTIME");
97 printf(
"modis_timestamp: Error - File doesn't appear to have a valid MODIS HDF header.\n");
100 ptr = strstr(ptr,
"VALUE");
102 printf(
"modis_timestamp: Error - File doesn't appear to have a valid MODIS HDF header.\n");
105 strncpy(range_time, ptr + 25, 8);
106 range_time[8] =
'\0';
109 ptr = strstr(ncdump,
" SHORTNAME");
111 printf(
"modis_timestamp: Error - File doesn't appear to have a valid MODIS HDF header.\n");
114 ptr = strstr(ptr,
"VALUE");
116 printf(
"modis_timestamp: Error - File doesn't appear to have a valid MODIS HDF header.\n");
125 }
else if (strcmp(
platform,
"MOD") == 0) {
128 printf(
"modis_timestamp: Error - Could not determine platform.\n");
134 strncpy(month, &range_date[5], 2);
140 sscanf(
year,
"%d", &year_int);
148 sscanf(
day,
"%d", &day_int);
150 if (strcmp(month,
"01") == 0)
152 else if (strcmp(month,
"02") == 0)
154 else if (strcmp(month,
"03") == 0)
155 basedays = 59 + add_leap_day;
156 else if (strcmp(month,
"04") == 0)
157 basedays = 90 + add_leap_day;
158 else if (strcmp(month,
"05") == 0)
159 basedays = 120 + add_leap_day;
160 else if (strcmp(month,
"06") == 0)
161 basedays = 151 + add_leap_day;
162 else if (strcmp(month,
"07") == 0)
163 basedays = 181 + add_leap_day;
164 else if (strcmp(month,
"08") == 0)
165 basedays = 212 + add_leap_day;
166 else if (strcmp(month,
"09") == 0)
167 basedays = 243 + add_leap_day;
168 else if (strcmp(month,
"10") == 0)
169 basedays = 273 + add_leap_day;
170 else if (strcmp(month,
"11") == 0)
171 basedays = 304 + add_leap_day;
172 else if (strcmp(month,
"12") == 0)
173 basedays = 334 + add_leap_day;
175 julian_days = basedays + day_int;
177 if (julian_days < 10) {
178 strcpy(julian_str,
"00\0");
179 }
else if (julian_days < 100) {
180 strcpy(julian_str,
"0\0");
185 sprintf(jul_str,
"%d", julian_days);
186 strcat(julian_str, jul_str);
190 ptr = &range_time[3];
193 ptr = &range_time[6];
198 date_stamp[0] = first_letter;
199 date_stamp[1] =
'\0';
200 strcat(date_stamp,
year);
201 strcat(date_stamp, julian_str);
202 strcat(date_stamp, hour);
203 strcat(date_stamp,
min);
204 strcat(date_stamp, sec);
205 date_stamp[14] =
'\0';
207 printf(
"%s", date_stamp);
These are used to scale the SD before writing it to the HDF4 file The default is and which means the product is not scaled at all Since the product is usually stored as a float inside of this is a way to write the float out as a integer l2prod min
int main(int argc, char *argv[])
FILE * popen(const char *, const char *)
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)
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")