60 #define TIMECODEASIZE 28
61 #define MECS_CORE "CoreMetadata.0"
62 #define MECS_ARCH "ArchiveMetadata.0"
64 #define CALIBRATIONQUALITY_MACRO "marginal"
65 #define NADIRPOINTING_MACRO "Y"
66 #define ALGORITHMPACKAGENAME_MACRO "MODIS Level 1B Algorithm Package"
67 #define AUTOMATICQUALITYFLAG_MACRO "Suspect"
68 #define AUTOMATICQUALITYFLAGEXPLANATION_MACRO "not being investigated"
69 #define ANCILLARYINPUTTYPE_MACRO "Geolocation"
70 #define INSTRUMENTNAME_MACRO "Moderate Resolution Imaging SpectroRadiometer"
82 boolean skip_night_hi_res)
170 PGSt_PC_Logical in_fileID = 0;
171 intn hdf_return =
FAIL;
174 char OBC_fname[PGSd_PC_FILE_PATH_MAX];
177 char *location =
"Write_Gran_Metadata";
178 PGSt_MET_all_handles mdhandles;
181 struct tm *curtime =
NULL;
184 char beginDateTimeA[30];
185 char beginDateTimeB[30];
186 char procDateTimeA[30];
187 char procDateTimeB[30];
189 char sub_shortname[6];
194 const char delimiter[] =
"_";
207 } input_file_macros_t;
211 int32 input_file_luns[NUM_INPUT_FILES] =
242 char input_file_UR_name[NUM_INPUT_FILES][PGSd_PC_UREF_LENGTH_MAX];
243 char *input_filename_p[NUM_INPUT_FILES];
245 char L1B_modis_filenames[132];
257 float64 eastboundingcoordinate[4] ;
258 float64 westboundingcoordinate[4] ;
259 float64 northboundingcoordinate[4] ;
260 float64 southboundingcoordinate[4] ;
265 float64 equatorcrossinglongitude;
274 int32 gringpointsequenceno[4];
279 const char* product_version=
"NRT.061";
283 product_version += 4;
289 for (
i = 0;
i < 30;
i++)
291 beginDateTimeA[
i] =
'\0';
292 beginDateTimeB[
i] =
'\0';
293 procDateTimeA[
i] =
'\0';
294 procDateTimeB[
i] =
'\0';
309 if (returnStatus != PGS_S_SUCCESS)
313 "Could not retrieve file name from PCF.",
323 "Could not open file for SD read/write access.",
333 "time() failed in Write_Gran_Metadata(), Metadata.c");
335 if(!(curtime = (
struct tm *)gmtime(&
t)))
337 "localtime() failed in Write_Gran_Metadata(), Metadata.c");
341 "%Y-%m-%dT%H:%M:%S.000000Z", curtime)) == 0)
343 "strftime() failed in Write_Gran_Metadata(), Metadata.c");
353 beginDateTimeA[10] =
'T';
355 beginDateTimeA[26] =
'Z';
357 if (PGS_TD_ASCIItime_AtoB(beginDateTimeA, beginDateTimeB) != PGS_S_SUCCESS)
359 "PGS_TD_ASCIItime_AtoB() in Write_Gran_Metadata(), Metadata.c");
361 if(PGS_TD_ASCIItime_AtoB(procDateTimeA, procDateTimeB) != PGS_S_SUCCESS )
363 "PGS_TD_ASCIItime_AtoB() in Write_Gran_Metadata(), Metadata.c");
370 strcpy(sub_shortname,
"MOD02");
372 strcpy(sub_shortname,
"MYD02");
382 for (
R = 0 ;
R < NUM_INPUT_FILES ;
R++ )
384 if (
R == INDEX_LEADING_GRAN &&
387 else if (
R == INDEX_TRAILING_GRAN &&
393 returnStatus = PGS_PC_GetUniversalRef(input_file_luns[
R], &
version,
394 &input_file_UR_name[
R][0]);
395 if (returnStatus != PGS_S_SUCCESS)
399 "Could not get universal reference from PCF.",
400 "PGS_PC_GetUniversalRef", input_file_luns[
R],
NULL,
True);
414 for (
R = 0;
R < NUM_INPUT_FILES ;
R++ )
416 if (
R == INDEX_GEO_FILE)
418 if (
R == INDEX_LEADING_GRAN &&
421 else if (
R == INDEX_TRAILING_GRAN &&
425 input_filename_p[
i] = &input_file_UR_name[
R][0];
426 for (ptr = &input_file_UR_name[
R][0]; *ptr !=
'\0'; ptr++)
428 input_filename_p[
i] = ptr+1;
431 input_filename_p[
i] =
NULL;
442 if (skip_night_hi_res ==
True)
450 returnStatus = PGS_MET_Init(mcf_file_luns[
R], mdhandles);
451 if (returnStatus != PGS_S_SUCCESS)
455 "Could not initialize the PGS Metadata from MCF file.",
456 "PGS_MET_Init", mcf_file_luns[
R],
NULL,
True);
463 returnStatus = PGS_MET_GetSetAttr(mdhandles[1],
"ShortName", &ptr);
464 if (returnStatus != PGS_S_SUCCESS)
468 "Could not get the value of \"ShortName\" from MCF file.",
469 "PGS_MET_GetSetAttr", mcf_file_luns[
R],
NULL,
True);
473 strncmp(shortname,
"MOD", 3) == 0) ||
475 strncmp(shortname,
"MYD", 3) == 0)))
479 "ShortName in MCF file is not consistent with the"
480 " instrument name in L1A granule.",
481 NULL, mcf_file_luns[
R],
482 "The MCF file could be invalid.",
True);
488 sprintf(ptr,
"10.5067/MODIS/%s.%s", shortname, product_version);
494 returnStatus = PGS_MET_GetSetAttr(mdhandles[1],
"VersionID", &VersionID);
495 if (returnStatus != PGS_S_SUCCESS)
499 "Could not get the value of \"VersionID\" from MCF file.",
500 "PGS_MET_GetSetAttr", mcf_file_luns[
R],
NULL,
True);
503 if (VersionID < 1 || VersionID > 999)
507 "VersionID is not in range of [1-999].",
508 NULL, mcf_file_luns[
R],
509 "The MCF file could be invalid.",
True);
515 returnStatus = PGS_PC_GetReference (output_file_luns[
R], &
Version,
516 L1B_modis_filenames);
517 sprintf(L1B_modis_filenames,
"%s",
basename(L1B_modis_filenames));
519 sprintf(L1B_modis_filenames,
520 "%s%s.A%4.4s%3.3s.%2.2s%2.2s.%03d.%4.4s%3.3s%2.2s%2.2s%2.2s.%s",
521 sub_shortname, file_sub_name[
R],
522 &beginDateTimeB[0], &beginDateTimeB[5],
523 &beginDateTimeB[9],&beginDateTimeB[12],
524 VersionID, &procDateTimeB[0],
525 &procDateTimeB[5],&procDateTimeB[9],&procDateTimeB[12],
549 "AveragedBlackBodyTemperature" );
553 "AveragedMirrorTemperature" );
557 "AveragedFocalPlane1Temperature" );
561 "AveragedFocalPlane2Temperature" );
565 "AveragedFocalPlane3Temperature" );
569 "AveragedFocalPlane4Temperature" );
573 "CalibrationQuality" );
582 tables->QA.common_QA_tables.mission_phase );
599 set_attr (
"QAPERCENTMISSINGDATA.1" ,
601 set_attr (
"QAPERCENTINTERPOLATEDDATA.1" ,
603 set_attr (
"QAPERCENTOUTOFBOUNDSDATA.1" ,
612 set_attr (
"QAPERCENTMISSINGDATA.1" ,
614 set_attr (
"QAPERCENTINTERPOLATEDDATA.1" ,
616 set_attr (
"QAPERCENTOUTOFBOUNDSDATA.1" ,
625 set_attr (
"QAPERCENTMISSINGDATA.1" ,
627 set_attr (
"QAPERCENTMISSINGDATA.2" ,
629 set_attr (
"QAPERCENTINTERPOLATEDDATA.1" ,
631 set_attr (
"QAPERCENTINTERPOLATEDDATA.2" ,
633 set_attr (
"QAPERCENTOUTOFBOUNDSDATA.1" ,
635 set_attr (
"QAPERCENTOUTOFBOUNDSDATA.2" ,
649 set_attr (
"QAPERCENTMISSINGDATA.1" ,
651 set_attr (
"QAPERCENTMISSINGDATA.2" ,
653 set_attr (
"QAPERCENTINTERPOLATEDDATA.1" ,
655 set_attr (
"QAPERCENTINTERPOLATEDDATA.2" ,
657 set_attr (
"QAPERCENTOUTOFBOUNDSDATA.1" ,
659 set_attr (
"QAPERCENTOUTOFBOUNDSDATA.2" ,
684 &input_file_UR_name[INDEX_GEO_FILE][0]);
686 L1B_modis_filenames);
699 sprintf(ProductionHistory,
"PGE02:");
700 strcpy (MCSTversion,
tables->QA.common_QA_tables.MCST_Version);
702 strtok(MCSTversion, delimiter),
719 if ( strcmp (MOD03_ProductionHistory, MOD01_ProductionHistory) )
722 safe_strcat(ProductionHistory, MOD01_ProductionHistory,
726 safe_strcat(ProductionHistory, MOD03_ProductionHistory,
733 safe_strcat(ProductionHistory, MOD01_ProductionHistory,
737 copy_attr (
"ORBITNUMBER.1" , &orbitnumber );
738 copy_attr (
"EQUATORCROSSINGLONGITUDE.1", &equatorcrossinglongitude);
746 copy_attr (
"GRINGPOINTSEQUENCENO.1", gringpointsequenceno);
755 copy_attr (
"EASTBOUNDINGCOORDINATE" , eastboundingcoordinate);
756 copy_attr (
"WESTBOUNDINGCOORDINATE" , westboundingcoordinate);
757 copy_attr (
"NORTHBOUNDINGCOORDINATE" , northboundingcoordinate);
758 copy_attr (
"SOUTHBOUNDINGCOORDINATE" , southboundingcoordinate);
763 tables->QA.common_QA_tables.AlgorithmPackageAcceptanceDate);
765 tables->QA.common_QA_tables.AlgorithmPackageMaturityCode);
767 tables->QA.common_QA_tables.MCST_Version);
777 returnStatus = PGS_MET_Write(mdhandles[1],
MECS_CORE, out_sd_id[
R]);
778 if (returnStatus != PGS_S_SUCCESS)
782 "Could not write ECS Core metadata to output granule.",
783 "PGS_MET_Write", output_file_luns[
R],
NULL,
True);
787 returnStatus = PGS_MET_Write(mdhandles[2],
MECS_ARCH, out_sd_id[
R]);
788 if (returnStatus != PGS_S_SUCCESS)
792 "Could not write ECS Archive metadata to output granule.",
793 "PGS_MET_Write", output_file_luns[
R],
NULL,
True);
808 "Write_Global_Metadata", 0,
NULL,
True);
817 if (hdf_return ==
FAIL)
874 if (ret != PGS_S_SUCCESS)
876 char errorMessage[256];
877 sprintf(errorMessage,
"Could not get metadata \"%s\" from %s.",
930 if (ret != PGS_S_SUCCESS)
932 char errorMessage[256];
933 sprintf(errorMessage,
"Could not get metadata \"%s\" from %s.",
983 if (ret != PGS_S_SUCCESS)
985 char errorMessage[256];
986 sprintf(errorMessage,
"Toolkit error setting metadata \"%s\".", field);
1037 if (ret != PGS_S_SUCCESS)
1039 char errorMessage[256];
1040 sprintf(errorMessage,
"Toolkit error setting metadata \"%s\".", field);
1090 if (ret != PGS_S_SUCCESS)
1092 char errorMessage[256];
1093 sprintf(errorMessage,
"Toolkit error setting metadata \"%s\".", field);
1257 PGSt_SMF_status returnStatus;
1258 char *location =
"Gran_Meta_Cal";
1259 int32 B, B_38, D, S;
1260 int32 missing_pixels, outofbound_pixels,
1261 interpolated_pixels, total_pixels;
1267 int32 num_pixels_per_250m_det;
1268 int32 num_pixels_per_500m_det;
1269 int32 num_pixels_per_1km_det;
1277 }Door_Screen_Config;
1283 } temp[NUM_Config] = {
1284 {
"Telemetry Major Cycle 3A of 7",
"CR_DR_NAD_CLSD", 1},
1285 {
"Telemetry Major Cycle 3A of 7",
"CR_DR_SVD_OPEN", 0},
1286 {
"Telemetry Major Cycle 3A of 7",
"CR_DR_SDD_OPEN", 0},
1287 {
"Telemetry Major Cycle 3A of 7",
"CR_DR_SDS_OPEN", 0}
1289 int32 day_bands_at_night;
1290 uint32 day_bands_at_night_mask;
1308 num_pixels_per_250m_det;
1314 num_pixels_per_250m_det;
1317 num_pixels_per_250m_det;
1320 num_pixels_per_250m_det;
1323 num_pixels_per_250m_det;
1326 num_pixels_per_250m_det;
1329 num_pixels_per_250m_det;
1332 num_pixels_per_250m_det;
1335 num_pixels_per_250m_det;
1344 num_pixels_per_500m_det;
1350 num_pixels_per_500m_det;
1353 num_pixels_per_500m_det;
1356 num_pixels_per_500m_det;
1359 num_pixels_per_500m_det;
1362 num_pixels_per_500m_det;
1365 num_pixels_per_500m_det;
1368 num_pixels_per_500m_det;
1371 num_pixels_per_500m_det;
1379 num_pixels_per_1km_det;
1400 num_pixels_per_1km_det;
1403 num_pixels_per_1km_det;
1406 num_pixels_per_1km_det;
1409 num_pixels_per_1km_det;
1412 num_pixels_per_1km_det;
1415 num_pixels_per_1km_det;
1418 num_pixels_per_1km_det;
1421 num_pixels_per_1km_det;
1447 for (S = 0; S < L1A_Gran->
num_scans - 1; S++)
1464 day_bands_at_night = 0;
1465 day_bands_at_night_mask = 0x00000800;
1466 for (S = 0; S < L1A_Gran->
num_scans - 1; S++)
1468 if (L1B_Scan_Meta->
Bit_QA_Flags[S] & day_bands_at_night_mask)
1469 day_bands_at_night++;
1471 if (day_bands_at_night > 15)
1528 outofbound_pixels = 0;
1529 interpolated_pixels = 0;
1542 (int32)(100 * (float32)missing_pixels/total_pixels + 0.5);
1547 "QAPERCENTMISSINGDATA for 250m bands is out of range [0, 100]",
1552 (int32)(100 * (float32)outofbound_pixels/total_pixels + 0.5);
1557 "QAPERCENTOUTOFBOUNDSDATA for 250m bands is out of range [0, 100]",
1562 (int32)(100 * (float32) interpolated_pixels/total_pixels + 0.5);
1567 "QAPERCENTINTERPOLATEDDATA for 250m bands is out of range [0, 100]",
1572 outofbound_pixels = 0;
1573 interpolated_pixels = 0;
1586 (int32)(100 * (float32)missing_pixels/total_pixels + 0.5);
1591 "QAPERCENTMISSINGDATA for 500m bands is out of range [0, 100]",
1596 (int32)(100 * (float32)outofbound_pixels/total_pixels + 0.5);
1601 "QAPERCENTOUTOFBOUNDSDATA for 500m bands is out of range [0, 100]",
1606 (int32)(100 * (float32) interpolated_pixels/total_pixels + 0.5);
1611 "QAPERCENTINTERPOLATEDDATA for 500m bands is out of range [0, 100]",
1616 outofbound_pixels = 0;
1617 interpolated_pixels = 0;
1635 (int32)(100 * (float32)missing_pixels/total_pixels + 0.5);
1640 "QAPERCENTMISSINGDATA for 1km reflective bands is "
1641 "out of range [0, 100]",
1646 (int32)(100 * (float32)outofbound_pixels/total_pixels + 0.5);
1651 "QAPERCENTOUTOFBOUNDSDATA for 1km reflective bands is "
1652 "out of range [0, 100]",
1657 (int32)(100 * (float32) interpolated_pixels/total_pixels + 0.5);
1662 "QAPERCENTINTERPOLATEDDATA for 1km reflective bands is"
1663 " out of range [0, 100]",
1669 outofbound_pixels = 0;
1670 interpolated_pixels = 0;
1686 (int32)(100 * (float32)missing_pixels/total_pixels + 0.5);
1691 "QAPERCENTMISSINGDATA for emissive bands is "
1692 "out of range [0, 100]",
1697 (int32)(100 * (float32)outofbound_pixels/total_pixels + 0.5);
1702 "QAPERCENTOUTOFBOUNDSDATA for emissive bands is "
1703 "out of range [0, 100]",
1708 (int32)(100 * (float32)interpolated_pixels/total_pixels + 0.5);
1713 "QAPERCENTINTERPOLATEDDATA for emissive bands is"
1714 " out of range [0, 100]",
1719 for (S = 1; S < L1A_Gran->
num_scans; S++)
1728 for (Door_Screen_Config = NAD_Door;
1729 Door_Screen_Config < NUM_Config; Door_Screen_Config++)
1734 temp[Door_Screen_Config].vname,
1735 temp[Door_Screen_Config].fname,
1736 (VOIDP)&temp[Door_Screen_Config].buffer);
1741 return returnStatus;
1744 if (temp[Door_Screen_Config].buffer > 1)
1747 sprintf(msgbuf,
"Value[0] of \"%s\" is out of the range [0,1].",
1748 temp[Door_Screen_Config].fname);
1752 return returnStatus;
1756 if (temp[NAD_Door].buffer == 0)
1758 if (temp[SVD_Door].buffer == 1)
1760 if (temp[SDD_Door].buffer == 1)
1762 if (temp[SDD_Screen].buffer == 1)
1814 "Get_Elec_Config_Status", 0,
NULL,
True);
1815 return returnStatus;
1822 return(returnStatus);
1831 boolean skip_night_hi_res)
1890 PGSt_SMF_status returnStatus;
1891 char *location =
"Write_Global_Metadata";
1892 int32 out_sd_id[4] = {0, 0, 0, 0};
1894 int32 hdf_return =
FAIL;
1905 out_sd_id[3] = OBC_sd_id;
1916 if (skip_night_hi_res ==
True)
1938 hdf_return = SDsetattr (out_sd_id[
R],
1942 if (hdf_return ==
FAIL)
1944 "Could not write Number of Scans.",
1947 hdf_return = SDsetattr (out_sd_id[
R],
1948 "Number of Day mode scans",
1951 if (hdf_return ==
FAIL)
1953 "Could not write Number of Day mode scans.",
1956 hdf_return = SDsetattr (out_sd_id[
R],
1957 "Number of Night mode scans",
1960 if (hdf_return ==
FAIL)
1962 "Could not write Number of Night mode scans.",
1965 hdf_return = SDsetattr (out_sd_id[
R],
1969 if (hdf_return ==
FAIL)
1971 "Could not write Incomplete Scans.",
1974 hdf_return = SDsetattr (out_sd_id[
R],
1975 "Max Earth View Frames",
1978 if (hdf_return ==
FAIL)
1980 "Could not write Max Earth View Frames.",
1983 hdf_return = SDsetattr (out_sd_id[
R],
1984 "%Valid EV Observations",
1987 if (hdf_return ==
FAIL)
1989 "Could not write %Valid EV Observations.",
1992 hdf_return = SDsetattr (out_sd_id[
R],
1993 "%Saturated EV Observations",
1996 if (hdf_return ==
FAIL)
1998 "Could not write %Saturated EV Observations.",
2001 hdf_return = SDsetattr (out_sd_id[
R],
2002 "% L1A EV All Scan Data are Missing",
2005 if (hdf_return ==
FAIL)
2007 "Could not write % L1A EV All Scan Data are Missing.",
2010 hdf_return = SDsetattr (out_sd_id[
R],
2011 "% L1A EV RSB DN Not in Day Mode",
2014 if (hdf_return ==
FAIL)
2016 "Could not write % L1A EV RSB DN Not in Day Mode.",
2019 hdf_return = SDsetattr (out_sd_id[
R],
2020 "% L1A EV DN Missing Within Scan",
2023 if (hdf_return ==
FAIL)
2025 "Could not write % L1A EV DN Missing Within Scan.",
2028 hdf_return = SDsetattr (out_sd_id[
R],
2029 "% Dead Detector EV Data",
2032 if (hdf_return ==
FAIL)
2034 "Could not write % Dead Detector EV Data.",
2037 hdf_return = SDsetattr (out_sd_id[
R],
2038 "% Dead Subframe EV Data",
2041 if (hdf_return ==
FAIL)
2043 "Could not write % Dead Subframe EV Data.",
2046 hdf_return = SDsetattr (out_sd_id[
R],
2047 "% Sector Rotation EV Data",
2050 if (hdf_return ==
FAIL)
2052 "Could not write % Sector Rotation EV Data.",
2055 hdf_return = SDsetattr (out_sd_id[
R],
2056 "% Saturated EV Data",
2059 if (hdf_return ==
FAIL)
2061 "Could not write % Saturated EV Data.",
2064 hdf_return = SDsetattr (out_sd_id[
R],
2065 "% TEB EV Data With Moon in SVP",
2068 if (hdf_return ==
FAIL)
2070 "Could not write % TEB EV Data With Moon in SVP.",
2073 hdf_return = SDsetattr (out_sd_id[
R],
2074 "% EV Data Where Cannot Compute BG DN",
2077 if (hdf_return ==
FAIL)
2079 "Could not write % EV Data Where Cannot Compute BG DN.",
2082 hdf_return = SDsetattr (out_sd_id[
R],
2083 "% RSB EV Data With dn** Below Scale",
2086 if (hdf_return ==
FAIL)
2088 "Could not write % RSB EV Data With dn** Below Scale.",
2091 hdf_return = SDsetattr (out_sd_id[
R],
2092 "% EV Data Where Nadir Door Closed",
2095 if (hdf_return ==
FAIL)
2097 "Could not write % EV Data Where Nadir Door Closed.",
2100 hdf_return = SDsetattr (out_sd_id[
R],
2101 "% EV Data Not Calibrated",
2104 if (hdf_return ==
FAIL)
2106 "Could not write % EV Data Not Calibrated.",
2115 hdf_return = SDsetattr (out_sd_id[
R],
2116 "Bit QA Flags Last Value",
2119 if (hdf_return ==
FAIL)
2121 "Could not write Bit QA Flags Last Value.",
2124 hdf_return = SDsetattr (out_sd_id[
R],
2125 "Bit QA Flags Change",
2128 if (hdf_return ==
FAIL)
2130 "Could not write Bit QA Flags Change.",
2133 hdf_return = SDsetattr (out_sd_id[
R],
2134 "Granule Average QA Values",
2137 if (hdf_return ==
FAIL)
2139 "Could not write Granule Average QA Values.",
2142 hdf_return = SDsetattr (out_sd_id[
R],
2143 "Electronics Redundancy Vector",
2146 if (hdf_return ==
FAIL)
2148 "Could not write Electronics Redundancy Vector.",
2151 hdf_return = SDsetattr (out_sd_id[
R],
2152 "Electronics Configuration Change",
2155 if (hdf_return ==
FAIL)
2157 "Could not write Electronics Configuration Change.",
2160 hdf_return = SDsetattr (out_sd_id[
R],
2161 "Reflective LUT Serial Number and Date of Last Change",
2162 DFNT_CHAR8, (int32)strlen(
tables->refl.Serial_Number),
2163 (VOIDP)
tables->refl.Serial_Number);
2164 if (hdf_return ==
FAIL)
2166 "Could not write Reflective LUT Serial Number.",
2169 hdf_return = SDsetattr (out_sd_id[
R],
2170 "Emissive LUT Serial Number and Date of Last Change",
2171 DFNT_CHAR8, (int32)strlen(
tables->emiss.Serial_Number),
2172 (VOIDP)
tables->emiss.Serial_Number);
2173 if (hdf_return ==
FAIL)
2175 "Could not write Emissive LUT Serial Number.",
2178 hdf_return = SDsetattr (out_sd_id[
R],
2179 "QA LUT Serial Number and Date of Last Change",
2181 (int32)strlen(
tables->QA.common_QA_tables.Serial_Number),
2182 (VOIDP)
tables->QA.common_QA_tables.Serial_Number);
2183 if (hdf_return ==
FAIL)
2185 "Could not write QA LUT Serial Number.",
2188 hdf_return = SDsetattr (out_sd_id[
R],
2189 "Focal Plane Set Point State",
2192 if (hdf_return ==
FAIL)
2194 "Could not write Focal Plane Set Point State.",
2197 hdf_return = SDsetattr (out_sd_id[
R],
2198 "Doors and Screens Configuration", DFNT_INT8, 1,
2200 if (hdf_return ==
FAIL)
2202 "Could not write Doors and Screens Config.",
2205 hdf_return = SDsetattr (out_sd_id[
R],
2206 "Reflective Bands With Bad Data",
2210 if (hdf_return ==
FAIL)
2212 "Could not write Reflective Bands With Bad Data.",
2215 hdf_return = SDsetattr (out_sd_id[
R],
2216 "Emissive Bands With Bad Data",
2220 if (hdf_return ==
FAIL)
2222 "Could not write Emissive Bands With Bad Data.",
2225 hdf_return = SDsetattr (out_sd_id[
R],
2226 "Noise in Black Body Thermistors",
2229 if (hdf_return ==
FAIL)
2231 "Could not write Noise in Black Body Thermistors.",
2234 hdf_return = SDsetattr (out_sd_id[
R],
2235 "Noise in Average BB Temperature",
2238 if (hdf_return ==
FAIL)
2240 "Could not write Noise in Average BB Temperature.",
2243 hdf_return = SDsetattr (out_sd_id[
R],
2244 "Noise in LWIR FPA Temperature",
2247 if (hdf_return ==
FAIL)
2249 "Could not write Noise in LWIR FPA Temperature.",
2252 hdf_return = SDsetattr (out_sd_id[
R],
2253 "Noise in MWIR FPA Temperature",
2256 if (hdf_return ==
FAIL)
2258 "Could not write Noise in MWIR FPA Temperature.",
2261 hdf_return = SDsetattr (out_sd_id[
R],
2262 "Noise in Scan Mirror Thermistor #1",
2265 if (hdf_return ==
FAIL)
2267 "Could not write Noise in Scan Mirror Thermistor #1.",
2270 hdf_return = SDsetattr (out_sd_id[
R],
2271 "Noise in Scan Mirror Thermistor #2",
2274 if (hdf_return ==
FAIL)
2276 "Could not write Noise in Scan Mirror Thermistor #2.",
2279 hdf_return = SDsetattr (out_sd_id[
R],
2280 "Noise in Scan Mirror Thermistor Average",
2283 if (hdf_return ==
FAIL)
2285 "Could not write Noise in Scan Mirror Thermistor Avg.",
2288 hdf_return = SDsetattr (out_sd_id[
R],
2289 "Noise in Instrument Temperature",
2292 if (hdf_return ==
FAIL)
2294 "Could not write Noise in Instrument Temperature.",
2297 hdf_return = SDsetattr (out_sd_id[
R],
2298 "Noise in Cavity Temperature", DFNT_UINT8, 1,
2300 if (hdf_return ==
FAIL)
2302 "Could not write Noise in Cavity Temperature.",
2306 "Noise in Thermal Detectors",
2307 "number of emissive bands",
2308 "detectors per 1km band",
2315 "Could not write Noise in Thermal Detectors.",
2316 "write_sds_rank2", lun,
NULL,
True);
2320 "Change in relative responses of thermal detectors",
2321 "number of emissive bands",
2322 "detectors per 1km band",
2329 "Could not write Change in relative responses of "
2330 "thermal detectors.",
2331 "write_sds_rank2", lun,
NULL,
True);
2333 hdf_return = SDsetattr (out_sd_id[
R],
2334 "Noise in Temperature of NIR FPA",
2337 if (hdf_return ==
FAIL)
2339 "Could not write Noise in Temperature of NIR FPA.",
2342 hdf_return = SDsetattr (out_sd_id[
R],
2343 "Noise in Temperature of Vis FPA",
2346 if (hdf_return ==
FAIL)
2348 "Could not write Noise in Temperature of Vis FPA.",
2352 "DC Restore Change for Thermal Bands",
2354 "number of emissive bands",
2355 "detectors per 1km band",
2363 "Could not write DC Restore Change for Thermal Bands.",
2364 "write_sds_rank3", lun,
NULL,
True);
2368 "DC Restore Change for Reflective 250m Bands",
2370 "number of 250m bands",
2371 "detectors per 250m band",
2379 "Could not write DC Restore Change for Reflective 250m Bands.",
2380 "write_sds_rank3", lun,
NULL,
True);
2384 "DC Restore Change for Reflective 500m Bands",
2386 "number of 500m bands",
2387 "detectors per 500m band",
2395 "Could not write DC Restore Change for Reflective 500m Bands.",
2396 "write_sds_rank3", lun,
NULL,
True);
2400 "DC Restore Change for Reflective 1km Bands",
2402 "number of 1km reflective bands",
2403 "detectors per 1km band",
2411 "Could not write DC Restore Change for Reflective 1km Bands.",
2412 "write_sds_rank3", lun,
NULL,
True);
2414 hdf_return = SDsetattr (out_sd_id[
R],
2415 "Dead Detector List",
2418 (VOIDP)
tables->QA.common_QA_tables.dead_detector);
2419 if (hdf_return ==
FAIL)
2421 "Could not write Dead Detector List.",
2424 hdf_return = SDsetattr (out_sd_id[
R],
2425 "Noisy Detector List",
2428 (VOIDP)
tables->QA.common_QA_tables.noisy_detector);
2429 if (hdf_return ==
FAIL)
2431 "Could not write Noisy Detector List.",
2435 hdf_return = SDsetattr (out_sd_id[
R],
2436 "Dead Subframe List",
2439 (VOIDP)
tables->QA.common_QA_tables.dead_subframe);
2440 if (hdf_return ==
FAIL)
2442 "Could not write Dead Subframe List.",
2445 hdf_return = SDsetattr (out_sd_id[
R],
2446 "Noisy Subframe List",
2449 (VOIDP)
tables->QA.common_QA_tables.noisy_subframe);
2450 if (hdf_return ==
FAIL)
2452 "Could not write Noisy Subframe List.",
2457 hdf_return = SDsetattr (out_sd_id[
R],
2458 "Detector Quality Flag",
2461 (VOIDP)
tables->QA.common_QA_tables.Detector_Quality_Flag);
2462 if (hdf_return ==
FAIL)
2464 "Could not write Detector Quality Flag.",
2469 hdf_return = SDsetattr (out_sd_id[
R],
2470 "Detector Quality Flag2",
2473 (VOIDP)
tables->QA.common_QA_tables.Detector_Quality_Flag2);
2474 if (hdf_return ==
FAIL)
2476 "Could not write Detector Quality Flag2.",
2481 hdf_return = SDsetattr (out_sd_id[
R],
2482 "Earth-Sun Distance",
2485 if (hdf_return ==
FAIL)
2487 "Could not write Earth-Sun distance.",
2492 hdf_return = SDsetattr (out_sd_id[
R],
2493 "Solar Irradiance on RSB Detectors over pi",
2496 (VOIDP)
tables->refl.E_sun_over_pi);
2497 if (hdf_return ==
FAIL)
2499 "Could not write E_sun_over_pi.",
2503 hdf_return = SDsetattr (out_sd_id[
R],
2508 if (hdf_return ==
FAIL)
2510 "Could not write identifier_product_doi.",
2514 hdf_return = SDsetattr (out_sd_id[
R],
2519 if (hdf_return ==
FAIL)
2521 "Could not write identifier_product_doi_authority.",
2535 boolean *no_valid_value)
2585 PGSt_SMF_status returnStatus;
2586 char *location =
"Get_Electronics_Status";
2589 uint16 temp_final_value;
2593 boolean first_valid_value_found;
2600 if (vname ==
NULL || fname ==
NULL || final_value ==
NULL ||
2605 "One of vname, fname, final_value or is_changed is invalid.",
2607 return returnStatus;
2613 L1BErrorMsg(location, returnStatus,
"num_scans is invalid.",
2615 return returnStatus;
2621 first_valid_value_found =
False;
2622 temp_final_value = 0;
2630 return returnStatus;
2633 returnStatus =
read_vdata(v_id, 0, num_scans, vname,
2634 "LAST_VALID_SCAN", last_valid_scans);
2638 return returnStatus;
2641 for (S = 0; S < num_scans; S++)
2647 "Value[%d] of telemetry \"%s\" is out of the range [0,1].",
2652 return returnStatus;
2664 if (first_valid_value_found ==
True &&
values[S] != temp_final_value)
2667 temp_final_value =
values[S];
2668 first_valid_value_found =
True;
2672 *final_value = temp_final_value;
2673 *no_valid_value = !first_valid_value_found;
2675 return returnStatus;
2681 uint32 *Elec_config_status,
2682 uint32 *Elec_config_change,
2683 uint32 *Elec_config_invalid_flag)
2746 char *location =
"Get_Elec_Config_Status_Per_Gran";
2751 boolean no_valid_value;
2759 int32 num_elec_config_elements = 0;
2765 }Elec_config_fields[] = {
2766 {
"Telemetry Major Cycle 0 of 7",
"CR_BB_A_PWR_ON"},
2767 {
"Telemetry Major Cycle 0 of 7",
"CR_BB_B_PWR_ON"},
2768 {
"Telemetry Major Cycle 1 of 7",
"CR_CE_A_ON"},
2769 {
"Telemetry Major Cycle 1 of 7",
"CR_CE_B_ON"},
2770 {
"Telemetry Major Cycle 1 of 7",
"CR_CP_A_ON_M"},
2771 {
"Telemetry Major Cycle 1 of 7",
"CR_CP_B_ON_M"},
2772 {
"Telemetry Major Cycle 3B of 7",
"CR_FI_A_ON"},
2773 {
"Telemetry Major Cycle 3B of 7",
"CR_FI_B_ON"},
2774 {
"Telemetry Major Cycle 3B of 7",
"CR_FO_BLK1_ON"},
2775 {
"Telemetry Major Cycle 3B of 7",
"CR_FO_BLK2_ON"},
2776 {
"Telemetry Major Cycle 3B of 7",
"CR_FO_BLK3_ON"},
2777 {
"Telemetry Major Cycle 3B of 7",
"CR_FO_BLK4_ON"},
2778 {
"Telemetry Major Cycle 3C of 7",
"CR_FR_A_ON"},
2779 {
"Telemetry Major Cycle 3C of 7",
"CR_FR_B_ON"},
2780 {
"Telemetry Major Cycle 4B of 7",
"CS_FR_PC_DCR_ON"},
2781 {
"Telemetry Major Cycle 4B of 7",
"CS_FR_PV_DCR_ON"},
2782 {
"Telemetry Major Cycle 4A of 7",
"CR_PCLW_A_ON"},
2783 {
"Telemetry Major Cycle 4A of 7",
"CR_PCLW_B_ON"},
2784 {
"Telemetry Major Cycle 4A of 7",
"CR_PVLW_A_ON"},
2785 {
"Telemetry Major Cycle 4A of 7",
"CR_PVLW_B_ON"},
2786 {
"Telemetry Major Cycle 4B of 7",
"CR_PVSM_A_ON"},
2787 {
"Telemetry Major Cycle 4B of 7",
"CR_PVSM_B_ON"},
2788 {
"Telemetry Major Cycle 4B of 7",
"CR_PVNIR_A_ON"},
2789 {
"Telemetry Major Cycle 4B of 7",
"CR_PVNIR_B_ON"},
2790 {
"Telemetry Major Cycle 4B of 7",
"CR_PVVIS_A_ON"},
2791 {
"Telemetry Major Cycle 4B of 7",
"CR_PVVIS_B_ON"},
2792 {
"Telemetry Major Cycle 4A of 7",
"CR_PVLWA_ECAL_ON"},
2793 {
"Telemetry Major Cycle 4A of 7",
"CR_PVLWB_ECAL_ON"},
2794 {
"Telemetry Major Cycle 4B of 7",
"CR_PVNIRA_ECALON"},
2795 {
"Telemetry Major Cycle 4B of 7",
"CR_PVNIRB_ECALON"},
2796 {
"Telemetry Major Cycle 4B of 7",
"CR_PVSMA_ECAL_ON"},
2797 {
"Telemetry Major Cycle 4B of 7",
"CR_PVSMB_ECAL_ON"},
2798 {
"Telemetry Major Cycle 4B of 7",
"CR_PVVISA_ECALON"},
2799 {
"Telemetry Major Cycle 4B of 7",
"CR_PVVISB_ECALON"},
2800 {
"Telemetry Major Cycle 5A of 7",
"CR_RC_SMHTR_ON"},
2801 {
"Telemetry Major Cycle 5A of 7",
"CR_RC_LWHTR_ON"},
2802 {
"Telemetry Major Cycle 5B of 7",
"CR_SA_A_SCAN_ON"},
2803 {
"Telemetry Major Cycle 5B of 7",
"CR_SA_B_SCAN_ON"},
2804 {
"Telemetry Major Cycle 5B of 7",
"CR_SM_SDSM_A_ON"},
2805 {
"Telemetry Major Cycle 5B of 7",
"CR_SM_SDSM_B_ON"},
2806 {
"Telemetry Major Cycle 5B of 7",
"CR_SR_A_ON"},
2807 {
"Telemetry Major Cycle 5B of 7",
"CR_SR_B_ON"},
2808 {
"Telemetry Major Cycle 6 of 7",
"CR_TG_A_ON"},
2809 {
"Telemetry Major Cycle 6 of 7",
"CR_TG_B_ON"},
2818 L1BErrorMsg(location, returnStatus,
"number of scans is out of range",
2820 return returnStatus;
2829 while (Elec_config_fields[num_elec_config_elements].vname!=
NULL)
2830 num_elec_config_elements++;
2835 L1BErrorMsg(location, returnStatus,
"macro E_VECTOR_SIZE is too small",
2837 return returnStatus;
2844 Elec_config_status[ivar] = 0;
2845 Elec_config_change[ivar] = 0;
2846 Elec_config_invalid_flag[ivar] = 0;
2852 for (
i = 0;
i < 32 && total_fields < num_elec_config_elements;
2853 i++, total_fields++)
2863 Elec_config_fields[total_fields].vname,
2864 Elec_config_fields[total_fields].fname,
2871 "Get_Electronics_Status", 0,
NULL,
False);
2872 return returnStatus;
2881 if (final_value == 1)
2882 Elec_config_status[ivar] |=
mask;
2884 if (is_changed == 1)
2885 Elec_config_change[ivar] |=
mask;
2887 if (no_valid_value ==
True)
2888 Elec_config_invalid_flag[ivar] |=
mask;
2896 return returnStatus;
2904 uint32 *Elec_config_status,
2905 uint32 *Elec_config_change)
2973 PGSt_SMF_status returnStatus;
2974 char *location =
"Get_Elec_Config_Status";
2978 int32 Leading_sd_id;
2979 int32 num_scans_leading;
2995 char file_name[PGSd_PC_FILE_PATH_MAX];
3003 L1BErrorMsg(location, returnStatus,
"number of scans is out of range",
3005 return returnStatus;
3022 Elec_config_invalid_flag);
3026 "Get_Elec_Config_Status_Per_Gran",
3028 return returnStatus;
3039 if (returnStatus != PGS_S_SUCCESS)
3043 "Could not retrieve file name from PCF.",
3045 return returnStatus;
3048 Leading_sd_id = SDstart(file_name, DFACC_RDONLY);
3049 if (Leading_sd_id ==
FAIL)
3053 "Could not open file for SD read access.",
3056 "The file may be missing, corrupted or not an HDF-4 file.",
3058 return returnStatus;
3061 Leading_v_id = Hopen(file_name,DFACC_RDONLY,0);
3062 if (Leading_v_id ==
FAIL)
3066 "Could not open file for Vdata read access.",
3069 "The file may be corrupted or not an HDF-4 file.",
3071 return returnStatus;
3074 hdf_return = Vstart(Leading_v_id);
3075 if (hdf_return ==
FAIL)
3079 "Could not initialize Vdata interface.",
3082 "The file may be corrupted or not an HDF-4 file.",
3084 return returnStatus;
3092 "Could not read Number of Scans.",
3097 return returnStatus;
3109 Leading_Elec_config_status,
3110 Leading_Elec_config_change,
3111 Leading_Elec_config_invalid_flag);
3115 "Get_Elec_Config_Status_Per_Gran",
3117 return returnStatus;
3127 Elec_config_invalid_flag);
3131 "Get_Elec_Config_Status_Per_Gran",
3133 return returnStatus;
3146 Elec_config_change[
i] = Elec_config_change[
i] |
3147 ((~Leading_Elec_config_invalid_flag[
i])&
3148 (Leading_Elec_config_status[
i]^Elec_config_status[
i]));
3152 hdf_return = SDend(Leading_sd_id);
3153 if (hdf_return ==
FAIL)
3156 "Memory or the disk file must have become corrupted.",
3159 hdf_return = Vend(Leading_v_id);
3160 if (hdf_return ==
FAIL)
3163 "Memory or the disk file must have become corrupted.",
3166 hdf_return = Hclose(Leading_v_id);
3167 if (hdf_return ==
FAIL)
3170 "Memory or the disk file must have become corrupted.",
3183 if (Elec_config_invalid_flag[0] > 0 || Elec_config_invalid_flag[1] > 0)
3185 Elec_config_change[1] |= 0x80000000;
3186 Elec_config_status[1] |= 0x80000000;
3189 return returnStatus;