59 #define TIMECODEASIZE 28
60 #define MECS_CORE "CoreMetadata.0"
61 #define MECS_ARCH "ArchiveMetadata.0"
63 #define CALIBRATIONQUALITY_MACRO "marginal"
64 #define NADIRPOINTING_MACRO "Y"
65 #define ALGORITHMPACKAGENAME_MACRO "MODIS Level 1B Algorithm Package"
66 #define AUTOMATICQUALITYFLAG_MACRO "Suspect"
67 #define AUTOMATICQUALITYFLAGEXPLANATION_MACRO "not being investigated"
68 #define ANCILLARYINPUTTYPE_MACRO "Geolocation"
69 #define INSTRUMENTNAME_MACRO "Moderate Resolution Imaging SpectroRadiometer"
81 boolean skip_night_hi_res)
191 PGSt_PC_Logical in_fileID = 0;
192 intn hdf_return =
FAIL;
195 char OBC_fname[PGSd_PC_FILE_PATH_MAX];
198 char *location =
"Write_Gran_Metadata";
199 PGSt_MET_all_handles mdhandles;
202 struct tm *curtime =
NULL;
205 char beginDateTimeA[30];
206 char beginDateTimeB[30];
207 char procDateTimeA[30];
208 char procDateTimeB[30];
210 char sub_shortname[6];
215 const char delimiter[] =
"_";
228 } input_file_macros_t;
232 int32 input_file_luns[NUM_INPUT_FILES] =
263 char input_file_UR_name[NUM_INPUT_FILES][PGSd_PC_UREF_LENGTH_MAX];
264 char *input_filename_p[NUM_INPUT_FILES];
266 char L1B_modis_filenames[132];
278 float64 eastboundingcoordinate[4] ;
279 float64 westboundingcoordinate[4] ;
280 float64 northboundingcoordinate[4] ;
281 float64 southboundingcoordinate[4] ;
286 float64 equatorcrossinglongitude;
295 int32 gringpointsequenceno[4];
300 const char* product_version =
"NRT.061";
304 product_version += 4;
311 for (
i = 0;
i < 30;
i++)
313 beginDateTimeA[
i] =
'\0';
314 beginDateTimeB[
i] =
'\0';
315 procDateTimeA[
i] =
'\0';
316 procDateTimeB[
i] =
'\0';
331 if (returnStatus != PGS_S_SUCCESS)
335 "Could not retrieve file name from PCF.",
345 "Could not open file for SD read/write access.",
355 "time() failed in Write_Gran_Metadata(), Metadata.c");
357 if(!(curtime = (
struct tm *)gmtime(&
t)))
359 "localtime() failed in Write_Gran_Metadata(), Metadata.c");
363 "%Y-%m-%dT%H:%M:%S.000000Z", curtime)) == 0)
365 "strftime() failed in Write_Gran_Metadata(), Metadata.c");
375 beginDateTimeA[10] =
'T';
377 beginDateTimeA[26] =
'Z';
379 if (PGS_TD_ASCIItime_AtoB(beginDateTimeA, beginDateTimeB) != PGS_S_SUCCESS)
381 "PGS_TD_ASCIItime_AtoB() in Write_Gran_Metadata(), Metadata.c");
383 if(PGS_TD_ASCIItime_AtoB(procDateTimeA, procDateTimeB) != PGS_S_SUCCESS )
385 "PGS_TD_ASCIItime_AtoB() in Write_Gran_Metadata(), Metadata.c");
392 strcpy(sub_shortname,
"MOD02");
394 strcpy(sub_shortname,
"MYD02");
404 for (
R = 0 ;
R < NUM_INPUT_FILES ;
R++ )
406 if (
R == INDEX_LEADING_GRAN &&
409 else if (
R == INDEX_TRAILING_GRAN &&
415 returnStatus = PGS_PC_GetUniversalRef(input_file_luns[
R], &
version,
416 &input_file_UR_name[
R][0]);
417 if (returnStatus != PGS_S_SUCCESS)
421 "Could not get universal reference from PCF.",
422 "PGS_PC_GetUniversalRef", input_file_luns[
R],
NULL,
True);
436 for (
R = 0;
R < NUM_INPUT_FILES ;
R++ )
438 if (
R == INDEX_GEO_FILE)
440 if (
R == INDEX_LEADING_GRAN &&
443 else if (
R == INDEX_TRAILING_GRAN &&
447 input_filename_p[
i] = &input_file_UR_name[
R][0];
448 for (ptr = &input_file_UR_name[
R][0]; *ptr !=
'\0'; ptr++)
450 input_filename_p[
i] = ptr+1;
453 input_filename_p[
i] =
NULL;
464 if (skip_night_hi_res ==
True)
472 returnStatus = PGS_MET_Init(mcf_file_luns[
R], mdhandles);
473 if (returnStatus != PGS_S_SUCCESS)
477 "Could not initialize the PGS Metadata from MCF file.",
478 "PGS_MET_Init", mcf_file_luns[
R],
NULL,
True);
485 returnStatus = PGS_MET_GetSetAttr(mdhandles[1],
"ShortName", &ptr);
486 if (returnStatus != PGS_S_SUCCESS)
490 "Could not get the value of \"ShortName\" from MCF file.",
491 "PGS_MET_GetSetAttr", mcf_file_luns[
R],
NULL,
True);
495 strncmp(shortname,
"MOD", 3) == 0) ||
497 strncmp(shortname,
"MYD", 3) == 0)))
501 "ShortName in MCF file is not consistent with the"
502 " instrument name in L1A granule.",
503 NULL, mcf_file_luns[
R],
504 "The MCF file could be invalid.",
True);
510 sprintf(ptr,
"10.5067/MODIS/%s.%s", shortname, product_version);
516 returnStatus = PGS_MET_GetSetAttr(mdhandles[1],
"VersionID", &VersionID);
517 if (returnStatus != PGS_S_SUCCESS)
521 "Could not get the value of \"VersionID\" from MCF file.",
522 "PGS_MET_GetSetAttr", mcf_file_luns[
R],
NULL,
True);
525 if (VersionID < 1 || VersionID > 999)
529 "VersionID is not in range of [1-999].",
530 NULL, mcf_file_luns[
R],
531 "The MCF file could be invalid.",
True);
537 returnStatus = PGS_PC_GetReference (output_file_luns[
R], &
Version,
538 L1B_modis_filenames);
539 sprintf(L1B_modis_filenames,
"%s",
basename(L1B_modis_filenames));
541 sprintf(L1B_modis_filenames,
542 "%s%s.A%4.4s%3.3s.%2.2s%2.2s.%03d.%4.4s%3.3s%2.2s%2.2s%2.2s.%s",
543 sub_shortname, file_sub_name[
R],
544 &beginDateTimeB[0], &beginDateTimeB[5],
545 &beginDateTimeB[9],&beginDateTimeB[12],
546 VersionID, &procDateTimeB[0],
547 &procDateTimeB[5],&procDateTimeB[9],&procDateTimeB[12],
571 "AveragedBlackBodyTemperature" );
575 "AveragedMirrorTemperature" );
579 "AveragedFocalPlane1Temperature" );
583 "AveragedFocalPlane2Temperature" );
587 "AveragedFocalPlane3Temperature" );
591 "AveragedFocalPlane4Temperature" );
595 "CalibrationQuality" );
604 tables->QA.common_QA_tables.mission_phase );
621 set_attr (
"QAPERCENTMISSINGDATA.1" ,
623 set_attr (
"QAPERCENTINTERPOLATEDDATA.1" ,
625 set_attr (
"QAPERCENTOUTOFBOUNDSDATA.1" ,
634 set_attr (
"QAPERCENTMISSINGDATA.1" ,
636 set_attr (
"QAPERCENTINTERPOLATEDDATA.1" ,
638 set_attr (
"QAPERCENTOUTOFBOUNDSDATA.1" ,
647 set_attr (
"QAPERCENTMISSINGDATA.1" ,
649 set_attr (
"QAPERCENTMISSINGDATA.2" ,
651 set_attr (
"QAPERCENTINTERPOLATEDDATA.1" ,
653 set_attr (
"QAPERCENTINTERPOLATEDDATA.2" ,
655 set_attr (
"QAPERCENTOUTOFBOUNDSDATA.1" ,
657 set_attr (
"QAPERCENTOUTOFBOUNDSDATA.2" ,
671 set_attr (
"QAPERCENTMISSINGDATA.1" ,
673 set_attr (
"QAPERCENTMISSINGDATA.2" ,
675 set_attr (
"QAPERCENTINTERPOLATEDDATA.1" ,
677 set_attr (
"QAPERCENTINTERPOLATEDDATA.2" ,
679 set_attr (
"QAPERCENTOUTOFBOUNDSDATA.1" ,
681 set_attr (
"QAPERCENTOUTOFBOUNDSDATA.2" ,
706 &input_file_UR_name[INDEX_GEO_FILE][0]);
708 L1B_modis_filenames);
721 sprintf(ProductionHistory,
"PGE02:");
722 strcpy (MCSTversion,
tables->QA.common_QA_tables.MCST_Version);
724 strtok(MCSTversion, delimiter),
741 if ( strcmp (MOD03_ProductionHistory, MOD01_ProductionHistory) )
744 safe_strcat(ProductionHistory, MOD01_ProductionHistory,
748 safe_strcat(ProductionHistory, MOD03_ProductionHistory,
755 safe_strcat(ProductionHistory, MOD01_ProductionHistory,
759 copy_attr (
"ORBITNUMBER.1" , &orbitnumber );
760 copy_attr (
"EQUATORCROSSINGLONGITUDE.1", &equatorcrossinglongitude);
768 copy_attr (
"GRINGPOINTSEQUENCENO.1", gringpointsequenceno);
777 copy_attr (
"EASTBOUNDINGCOORDINATE" , eastboundingcoordinate);
778 copy_attr (
"WESTBOUNDINGCOORDINATE" , westboundingcoordinate);
779 copy_attr (
"NORTHBOUNDINGCOORDINATE" , northboundingcoordinate);
780 copy_attr (
"SOUTHBOUNDINGCOORDINATE" , southboundingcoordinate);
785 tables->QA.common_QA_tables.AlgorithmPackageAcceptanceDate);
787 tables->QA.common_QA_tables.AlgorithmPackageMaturityCode);
789 tables->QA.common_QA_tables.MCST_Version);
799 returnStatus = PGS_MET_Write(mdhandles[1],
MECS_CORE, out_sd_id[
R]);
800 if (returnStatus != PGS_S_SUCCESS)
804 "Could not write ECS Core metadata to output granule.",
805 "PGS_MET_Write", output_file_luns[
R],
NULL,
True);
809 returnStatus = PGS_MET_Write(mdhandles[2],
MECS_ARCH, out_sd_id[
R]);
810 if (returnStatus != PGS_S_SUCCESS)
814 "Could not write ECS Archive metadata to output granule.",
815 "PGS_MET_Write", output_file_luns[
R],
NULL,
True);
830 "Write_Global_Metadata", 0,
NULL,
True);
839 if (hdf_return ==
FAIL)
896 if (ret != PGS_S_SUCCESS)
898 char errorMessage[256];
899 sprintf(errorMessage,
"Could not get metadata \"%s\" from %s.",
952 if (ret != PGS_S_SUCCESS)
954 char errorMessage[256];
955 sprintf(errorMessage,
"Could not get metadata \"%s\" from %s.",
1005 if (ret != PGS_S_SUCCESS)
1007 char errorMessage[256];
1008 sprintf(errorMessage,
"Toolkit error setting metadata \"%s\".", field);
1059 if (ret != PGS_S_SUCCESS)
1061 char errorMessage[256];
1062 sprintf(errorMessage,
"Toolkit error setting metadata \"%s\".", field);
1112 if (ret != PGS_S_SUCCESS)
1114 char errorMessage[256];
1115 sprintf(errorMessage,
"Toolkit error setting metadata \"%s\".", field);
1279 PGSt_SMF_status returnStatus;
1280 char *location =
"Gran_Meta_Cal";
1281 int32 B, B_38, D, S;
1282 int32 missing_pixels, outofbound_pixels,
1283 interpolated_pixels, total_pixels;
1289 int32 num_pixels_per_250m_det;
1290 int32 num_pixels_per_500m_det;
1291 int32 num_pixels_per_1km_det;
1299 }Door_Screen_Config;
1305 } temp[NUM_Config] = {
1306 {
"Telemetry Major Cycle 3A of 7",
"CR_DR_NAD_CLSD", 1},
1307 {
"Telemetry Major Cycle 3A of 7",
"CR_DR_SVD_OPEN", 0},
1308 {
"Telemetry Major Cycle 3A of 7",
"CR_DR_SDD_OPEN", 0},
1309 {
"Telemetry Major Cycle 3A of 7",
"CR_DR_SDS_OPEN", 0}
1311 int32 day_bands_at_night;
1312 uint32 day_bands_at_night_mask;
1330 num_pixels_per_250m_det;
1336 num_pixels_per_250m_det;
1339 num_pixels_per_250m_det;
1342 num_pixels_per_250m_det;
1345 num_pixels_per_250m_det;
1348 num_pixels_per_250m_det;
1351 num_pixels_per_250m_det;
1354 num_pixels_per_250m_det;
1357 num_pixels_per_250m_det;
1366 num_pixels_per_500m_det;
1372 num_pixels_per_500m_det;
1375 num_pixels_per_500m_det;
1378 num_pixels_per_500m_det;
1381 num_pixels_per_500m_det;
1384 num_pixels_per_500m_det;
1387 num_pixels_per_500m_det;
1390 num_pixels_per_500m_det;
1393 num_pixels_per_500m_det;
1401 num_pixels_per_1km_det;
1422 num_pixels_per_1km_det;
1425 num_pixels_per_1km_det;
1428 num_pixels_per_1km_det;
1431 num_pixels_per_1km_det;
1434 num_pixels_per_1km_det;
1437 num_pixels_per_1km_det;
1440 num_pixels_per_1km_det;
1443 num_pixels_per_1km_det;
1469 for (S = 0; S < L1A_Gran->
num_scans - 1; S++)
1486 day_bands_at_night = 0;
1487 day_bands_at_night_mask = 0x00000800;
1488 for (S = 0; S < L1A_Gran->
num_scans - 1; S++)
1490 if (L1B_Scan_Meta->
Bit_QA_Flags[S] & day_bands_at_night_mask)
1491 day_bands_at_night++;
1493 if (day_bands_at_night > 15)
1550 outofbound_pixels = 0;
1551 interpolated_pixels = 0;
1564 (int32)(100 * (float32)missing_pixels/total_pixels + 0.5);
1569 "QAPERCENTMISSINGDATA for 250m bands is out of range [0, 100]",
1574 (int32)(100 * (float32)outofbound_pixels/total_pixels + 0.5);
1579 "QAPERCENTOUTOFBOUNDSDATA for 250m bands is out of range [0, 100]",
1584 (int32)(100 * (float32) interpolated_pixels/total_pixels + 0.5);
1589 "QAPERCENTINTERPOLATEDDATA for 250m bands is out of range [0, 100]",
1594 outofbound_pixels = 0;
1595 interpolated_pixels = 0;
1608 (int32)(100 * (float32)missing_pixels/total_pixels + 0.5);
1613 "QAPERCENTMISSINGDATA for 500m bands is out of range [0, 100]",
1618 (int32)(100 * (float32)outofbound_pixels/total_pixels + 0.5);
1623 "QAPERCENTOUTOFBOUNDSDATA for 500m bands is out of range [0, 100]",
1628 (int32)(100 * (float32) interpolated_pixels/total_pixels + 0.5);
1633 "QAPERCENTINTERPOLATEDDATA for 500m bands is out of range [0, 100]",
1638 outofbound_pixels = 0;
1639 interpolated_pixels = 0;
1657 (int32)(100 * (float32)missing_pixels/total_pixels + 0.5);
1662 "QAPERCENTMISSINGDATA for 1km reflective bands is "
1663 "out of range [0, 100]",
1668 (int32)(100 * (float32)outofbound_pixels/total_pixels + 0.5);
1673 "QAPERCENTOUTOFBOUNDSDATA for 1km reflective bands is "
1674 "out of range [0, 100]",
1679 (int32)(100 * (float32) interpolated_pixels/total_pixels + 0.5);
1684 "QAPERCENTINTERPOLATEDDATA for 1km reflective bands is"
1685 " out of range [0, 100]",
1691 outofbound_pixels = 0;
1692 interpolated_pixels = 0;
1708 (int32)(100 * (float32)missing_pixels/total_pixels + 0.5);
1713 "QAPERCENTMISSINGDATA for emissive bands is "
1714 "out of range [0, 100]",
1719 (int32)(100 * (float32)outofbound_pixels/total_pixels + 0.5);
1724 "QAPERCENTOUTOFBOUNDSDATA for emissive bands is "
1725 "out of range [0, 100]",
1730 (int32)(100 * (float32)interpolated_pixels/total_pixels + 0.5);
1735 "QAPERCENTINTERPOLATEDDATA for emissive bands is"
1736 " out of range [0, 100]",
1741 for (S = 1; S < L1A_Gran->
num_scans; S++)
1750 for (Door_Screen_Config = NAD_Door;
1751 Door_Screen_Config < NUM_Config; Door_Screen_Config++)
1756 temp[Door_Screen_Config].vname,
1757 temp[Door_Screen_Config].fname,
1758 (VOIDP)&temp[Door_Screen_Config].buffer);
1763 return returnStatus;
1766 if (temp[Door_Screen_Config].buffer > 1)
1769 sprintf(msgbuf,
"Value[0] of \"%s\" is out of the range [0,1].",
1770 temp[Door_Screen_Config].fname);
1774 return returnStatus;
1778 if (temp[NAD_Door].buffer == 0)
1780 if (temp[SVD_Door].buffer == 1)
1782 if (temp[SDD_Door].buffer == 1)
1784 if (temp[SDD_Screen].buffer == 1)
1836 "Get_Elec_Config_Status", 0,
NULL,
True);
1837 return returnStatus;
1844 return(returnStatus);
1853 boolean skip_night_hi_res)
1912 PGSt_SMF_status returnStatus;
1913 char *location =
"Write_Global_Metadata";
1914 int32 out_sd_id[4] = {0, 0, 0, 0};
1916 int32 hdf_return =
FAIL;
1927 out_sd_id[3] = OBC_sd_id;
1938 if (skip_night_hi_res ==
True)
1960 hdf_return = SDsetattr (out_sd_id[
R],
1964 if (hdf_return ==
FAIL)
1966 "Could not write Number of Scans.",
1969 hdf_return = SDsetattr (out_sd_id[
R],
1970 "Number of Day mode scans",
1973 if (hdf_return ==
FAIL)
1975 "Could not write Number of Day mode scans.",
1978 hdf_return = SDsetattr (out_sd_id[
R],
1979 "Number of Night mode scans",
1982 if (hdf_return ==
FAIL)
1984 "Could not write Number of Night mode scans.",
1987 hdf_return = SDsetattr (out_sd_id[
R],
1991 if (hdf_return ==
FAIL)
1993 "Could not write Incomplete Scans.",
1996 hdf_return = SDsetattr (out_sd_id[
R],
1997 "Max Earth View Frames",
2000 if (hdf_return ==
FAIL)
2002 "Could not write Max Earth View Frames.",
2005 hdf_return = SDsetattr (out_sd_id[
R],
2006 "%Valid EV Observations",
2009 if (hdf_return ==
FAIL)
2011 "Could not write %Valid EV Observations.",
2014 hdf_return = SDsetattr (out_sd_id[
R],
2015 "%Saturated EV Observations",
2018 if (hdf_return ==
FAIL)
2020 "Could not write %Saturated EV Observations.",
2023 hdf_return = SDsetattr (out_sd_id[
R],
2024 "% L1A EV All Scan Data are Missing",
2027 if (hdf_return ==
FAIL)
2029 "Could not write % L1A EV All Scan Data are Missing.",
2032 hdf_return = SDsetattr (out_sd_id[
R],
2033 "% L1A EV RSB DN Not in Day Mode",
2036 if (hdf_return ==
FAIL)
2038 "Could not write % L1A EV RSB DN Not in Day Mode.",
2041 hdf_return = SDsetattr (out_sd_id[
R],
2042 "% L1A EV DN Missing Within Scan",
2045 if (hdf_return ==
FAIL)
2047 "Could not write % L1A EV DN Missing Within Scan.",
2050 hdf_return = SDsetattr (out_sd_id[
R],
2051 "% Dead Detector EV Data",
2054 if (hdf_return ==
FAIL)
2056 "Could not write % Dead Detector EV Data.",
2059 hdf_return = SDsetattr (out_sd_id[
R],
2060 "% Dead Subframe EV Data",
2064 if (hdf_return ==
FAIL)
2066 "Could not write % Dead Subframe EV Data.",
2069 hdf_return = SDsetattr (out_sd_id[
R],
2070 "% Sector Rotation EV Data",
2074 if (hdf_return ==
FAIL)
2076 "Could not write % Sector Rotation EV Data.",
2079 hdf_return = SDsetattr (out_sd_id[
R],
2080 "% Saturated EV Data",
2083 if (hdf_return ==
FAIL)
2085 "Could not write % Saturated EV Data.",
2088 hdf_return = SDsetattr (out_sd_id[
R],
2089 "% TEB EV Data With Moon in SVP",
2092 if (hdf_return ==
FAIL)
2094 "Could not write % TEB EV Data With Moon in SVP.",
2097 hdf_return = SDsetattr (out_sd_id[
R],
2098 "% EV Data Where Cannot Compute BG DN",
2101 if (hdf_return ==
FAIL)
2103 "Could not write % EV Data Where Cannot Compute BG DN.",
2106 hdf_return = SDsetattr (out_sd_id[
R],
2107 "% RSB EV Data With dn** Below Scale",
2110 if (hdf_return ==
FAIL)
2112 "Could not write % RSB EV Data With dn** Below Scale.",
2115 hdf_return = SDsetattr (out_sd_id[
R],
2116 "% EV Data Where Nadir Door Closed",
2119 if (hdf_return ==
FAIL)
2121 "Could not write % EV Data Where Nadir Door Closed.",
2124 hdf_return = SDsetattr (out_sd_id[
R],
2125 "% EV Data Not Calibrated",
2128 if (hdf_return ==
FAIL)
2130 "Could not write % EV Data Not Calibrated.",
2139 hdf_return = SDsetattr (out_sd_id[
R],
2140 "Bit QA Flags Last Value",
2143 if (hdf_return ==
FAIL)
2145 "Could not write Bit QA Flags Last Value.",
2148 hdf_return = SDsetattr (out_sd_id[
R],
2149 "Bit QA Flags Change",
2152 if (hdf_return ==
FAIL)
2154 "Could not write Bit QA Flags Change.",
2157 hdf_return = SDsetattr (out_sd_id[
R],
2158 "Granule Average QA Values",
2161 if (hdf_return ==
FAIL)
2163 "Could not write Granule Average QA Values.",
2166 hdf_return = SDsetattr (out_sd_id[
R],
2167 "Electronics Redundancy Vector",
2170 if (hdf_return ==
FAIL)
2172 "Could not write Electronics Redundancy Vector.",
2175 hdf_return = SDsetattr (out_sd_id[
R],
2176 "Electronics Configuration Change",
2179 if (hdf_return ==
FAIL)
2181 "Could not write Electronics Configuration Change.",
2184 hdf_return = SDsetattr (out_sd_id[
R],
2185 "Reflective LUT Serial Number and Date of Last Change",
2186 DFNT_CHAR8, (int32)strlen(
tables->refl.Serial_Number),
2187 (VOIDP)
tables->refl.Serial_Number);
2188 if (hdf_return ==
FAIL)
2190 "Could not write Reflective LUT Serial Number.",
2193 hdf_return = SDsetattr (out_sd_id[
R],
2194 "Emissive LUT Serial Number and Date of Last Change",
2195 DFNT_CHAR8, (int32)strlen(
tables->emiss.Serial_Number),
2196 (VOIDP)
tables->emiss.Serial_Number);
2197 if (hdf_return ==
FAIL)
2199 "Could not write Emissive LUT Serial Number.",
2202 hdf_return = SDsetattr (out_sd_id[
R],
2203 "QA LUT Serial Number and Date of Last Change",
2205 (int32)strlen(
tables->QA.common_QA_tables.Serial_Number),
2206 (VOIDP)
tables->QA.common_QA_tables.Serial_Number);
2207 if (hdf_return ==
FAIL)
2209 "Could not write QA LUT Serial Number.",
2212 hdf_return = SDsetattr (out_sd_id[
R],
2213 "Focal Plane Set Point State",
2216 if (hdf_return ==
FAIL)
2218 "Could not write Focal Plane Set Point State.",
2221 hdf_return = SDsetattr (out_sd_id[
R],
2222 "Doors and Screens Configuration", DFNT_INT8, 1,
2224 if (hdf_return ==
FAIL)
2226 "Could not write Doors and Screens Config.",
2229 hdf_return = SDsetattr (out_sd_id[
R],
2230 "Reflective Bands With Bad Data",
2234 if (hdf_return ==
FAIL)
2236 "Could not write Reflective Bands With Bad Data.",
2239 hdf_return = SDsetattr (out_sd_id[
R],
2240 "Emissive Bands With Bad Data",
2244 if (hdf_return ==
FAIL)
2246 "Could not write Emissive Bands With Bad Data.",
2249 hdf_return = SDsetattr (out_sd_id[
R],
2250 "Noise in Black Body Thermistors",
2253 if (hdf_return ==
FAIL)
2255 "Could not write Noise in Black Body Thermistors.",
2258 hdf_return = SDsetattr (out_sd_id[
R],
2259 "Noise in Average BB Temperature",
2262 if (hdf_return ==
FAIL)
2264 "Could not write Noise in Average BB Temperature.",
2267 hdf_return = SDsetattr (out_sd_id[
R],
2268 "Noise in LWIR FPA Temperature",
2271 if (hdf_return ==
FAIL)
2273 "Could not write Noise in LWIR FPA Temperature.",
2276 hdf_return = SDsetattr (out_sd_id[
R],
2277 "Noise in MWIR FPA Temperature",
2280 if (hdf_return ==
FAIL)
2282 "Could not write Noise in MWIR FPA Temperature.",
2285 hdf_return = SDsetattr (out_sd_id[
R],
2286 "Noise in Scan Mirror Thermistor #1",
2289 if (hdf_return ==
FAIL)
2291 "Could not write Noise in Scan Mirror Thermistor #1.",
2294 hdf_return = SDsetattr (out_sd_id[
R],
2295 "Noise in Scan Mirror Thermistor #2",
2298 if (hdf_return ==
FAIL)
2300 "Could not write Noise in Scan Mirror Thermistor #2.",
2303 hdf_return = SDsetattr (out_sd_id[
R],
2304 "Noise in Scan Mirror Thermistor Average",
2307 if (hdf_return ==
FAIL)
2309 "Could not write Noise in Scan Mirror Thermistor Avg.",
2312 hdf_return = SDsetattr (out_sd_id[
R],
2313 "Noise in Instrument Temperature",
2316 if (hdf_return ==
FAIL)
2318 "Could not write Noise in Instrument Temperature.",
2321 hdf_return = SDsetattr (out_sd_id[
R],
2322 "Noise in Cavity Temperature", DFNT_UINT8, 1,
2324 if (hdf_return ==
FAIL)
2326 "Could not write Noise in Cavity Temperature.",
2330 "Noise in Thermal Detectors",
2331 "number of emissive bands",
2332 "detectors per 1km band",
2339 "Could not write Noise in Thermal Detectors.",
2340 "write_sds_rank2", lun,
NULL,
True);
2344 "Change in relative responses of thermal detectors",
2345 "number of emissive bands",
2346 "detectors per 1km band",
2353 "Could not write Change in relative responses of "
2354 "thermal detectors.",
2355 "write_sds_rank2", lun,
NULL,
True);
2357 hdf_return = SDsetattr (out_sd_id[
R],
2358 "Noise in Temperature of NIR FPA",
2361 if (hdf_return ==
FAIL)
2363 "Could not write Noise in Temperature of NIR FPA.",
2366 hdf_return = SDsetattr (out_sd_id[
R],
2367 "Noise in Temperature of Vis FPA",
2370 if (hdf_return ==
FAIL)
2372 "Could not write Noise in Temperature of Vis FPA.",
2376 "DC Restore Change for Thermal Bands",
2378 "number of emissive bands",
2379 "detectors per 1km band",
2387 "Could not write DC Restore Change for Thermal Bands.",
2388 "write_sds_rank3", lun,
NULL,
True);
2392 "DC Restore Change for Reflective 250m Bands",
2394 "number of 250m bands",
2395 "detectors per 250m band",
2403 "Could not write DC Restore Change for Reflective 250m Bands.",
2404 "write_sds_rank3", lun,
NULL,
True);
2408 "DC Restore Change for Reflective 500m Bands",
2410 "number of 500m bands",
2411 "detectors per 500m band",
2419 "Could not write DC Restore Change for Reflective 500m Bands.",
2420 "write_sds_rank3", lun,
NULL,
True);
2424 "DC Restore Change for Reflective 1km Bands",
2426 "number of 1km reflective bands",
2427 "detectors per 1km band",
2435 "Could not write DC Restore Change for Reflective 1km Bands.",
2436 "write_sds_rank3", lun,
NULL,
True);
2438 hdf_return = SDsetattr (out_sd_id[
R],
2439 "Dead Detector List",
2442 (VOIDP)
tables->QA.common_QA_tables.dead_detector);
2443 if (hdf_return ==
FAIL)
2445 "Could not write Dead Detector List.",
2448 hdf_return = SDsetattr (out_sd_id[
R],
2449 "Noisy Detector List",
2452 (VOIDP)
tables->QA.common_QA_tables.noisy_detector);
2453 if (hdf_return ==
FAIL)
2455 "Could not write Noisy Detector List.",
2459 hdf_return = SDsetattr (out_sd_id[
R],
2460 "Dead Subframe List",
2463 (VOIDP)
tables->QA.common_QA_tables.dead_subframe);
2464 if (hdf_return ==
FAIL)
2466 "Could not write Dead Subframe List.",
2469 hdf_return = SDsetattr (out_sd_id[
R],
2470 "Noisy Subframe List",
2473 (VOIDP)
tables->QA.common_QA_tables.noisy_subframe);
2474 if (hdf_return ==
FAIL)
2476 "Could not write Noisy Subframe List.",
2481 hdf_return = SDsetattr (out_sd_id[
R],
2482 "Detector Quality Flag",
2485 (VOIDP)
tables->QA.common_QA_tables.Detector_Quality_Flag);
2486 if (hdf_return ==
FAIL)
2488 "Could not write Detector Quality Flag.",
2493 hdf_return = SDsetattr (out_sd_id[
R],
2494 "Detector Quality Flag2",
2497 (VOIDP)
tables->QA.common_QA_tables.Detector_Quality_Flag2);
2498 if (hdf_return ==
FAIL)
2500 "Could not write Detector Quality Flag2.",
2505 hdf_return = SDsetattr (out_sd_id[
R],
2506 "Earth-Sun Distance",
2509 if (hdf_return ==
FAIL)
2511 "Could not write Earth-Sun distance.",
2516 hdf_return = SDsetattr (out_sd_id[
R],
2517 "Solar Irradiance on RSB Detectors over pi",
2520 (VOIDP)
tables->refl.E_sun_over_pi);
2522 if (hdf_return ==
FAIL)
2524 "Could not write E_sun_over_pi.",
2528 hdf_return = SDsetattr (out_sd_id[
R],
2533 if (hdf_return ==
FAIL)
2535 "Could not write identifier_product_doi.",
2539 hdf_return = SDsetattr (out_sd_id[
R],
2544 if (hdf_return ==
FAIL)
2546 "Could not write identifier_product_doi_authority.",
2561 boolean *no_valid_value)
2612 PGSt_SMF_status returnStatus;
2613 char *location =
"Get_Electronics_Status";
2616 uint16 temp_final_value;
2620 boolean first_valid_value_found;
2627 if (vname ==
NULL || fname ==
NULL || final_value ==
NULL ||
2632 "One of vname, fname, final_value or is_changed is invalid.",
2634 return returnStatus;
2640 L1BErrorMsg(location, returnStatus,
"num_scans is invalid.",
2642 return returnStatus;
2648 first_valid_value_found =
False;
2649 temp_final_value = 0;
2657 return returnStatus;
2660 returnStatus =
read_vdata(v_id, 0, num_scans, vname,
2661 "LAST_VALID_SCAN", last_valid_scans);
2665 return returnStatus;
2668 for (S = 0; S < num_scans; S++)
2674 "Value[%d] of telemetry \"%s\" is out of the range [0,1].",
2679 return returnStatus;
2691 if (first_valid_value_found ==
True &&
values[S] != temp_final_value)
2694 temp_final_value =
values[S];
2695 first_valid_value_found =
True;
2699 *final_value = temp_final_value;
2700 *no_valid_value = !first_valid_value_found;
2702 return returnStatus;
2708 uint32 *Elec_config_status,
2709 uint32 *Elec_config_change,
2710 uint32 *Elec_config_invalid_flag)
2774 char *location =
"Get_Elec_Config_Status_Per_Gran";
2779 boolean no_valid_value;
2787 int32 num_elec_config_elements = 0;
2793 }Elec_config_fields[] = {
2794 {
"Telemetry Major Cycle 0 of 7",
"CR_BB_A_PWR_ON"},
2795 {
"Telemetry Major Cycle 0 of 7",
"CR_BB_B_PWR_ON"},
2796 {
"Telemetry Major Cycle 1 of 7",
"CR_CE_A_ON"},
2797 {
"Telemetry Major Cycle 1 of 7",
"CR_CE_B_ON"},
2798 {
"Telemetry Major Cycle 1 of 7",
"CR_CP_A_ON_M"},
2799 {
"Telemetry Major Cycle 1 of 7",
"CR_CP_B_ON_M"},
2800 {
"Telemetry Major Cycle 3B of 7",
"CR_FI_A_ON"},
2801 {
"Telemetry Major Cycle 3B of 7",
"CR_FI_B_ON"},
2802 {
"Telemetry Major Cycle 3B of 7",
"CR_FO_BLK1_ON"},
2803 {
"Telemetry Major Cycle 3B of 7",
"CR_FO_BLK2_ON"},
2804 {
"Telemetry Major Cycle 3B of 7",
"CR_FO_BLK3_ON"},
2805 {
"Telemetry Major Cycle 3B of 7",
"CR_FO_BLK4_ON"},
2806 {
"Telemetry Major Cycle 3C of 7",
"CR_FR_A_ON"},
2807 {
"Telemetry Major Cycle 3C of 7",
"CR_FR_B_ON"},
2808 {
"Telemetry Major Cycle 4B of 7",
"CS_FR_PC_DCR_ON"},
2809 {
"Telemetry Major Cycle 4B of 7",
"CS_FR_PV_DCR_ON"},
2810 {
"Telemetry Major Cycle 4A of 7",
"CR_PCLW_A_ON"},
2811 {
"Telemetry Major Cycle 4A of 7",
"CR_PCLW_B_ON"},
2812 {
"Telemetry Major Cycle 4A of 7",
"CR_PVLW_A_ON"},
2813 {
"Telemetry Major Cycle 4A of 7",
"CR_PVLW_B_ON"},
2814 {
"Telemetry Major Cycle 4B of 7",
"CR_PVSM_A_ON"},
2815 {
"Telemetry Major Cycle 4B of 7",
"CR_PVSM_B_ON"},
2816 {
"Telemetry Major Cycle 4B of 7",
"CR_PVNIR_A_ON"},
2817 {
"Telemetry Major Cycle 4B of 7",
"CR_PVNIR_B_ON"},
2818 {
"Telemetry Major Cycle 4B of 7",
"CR_PVVIS_A_ON"},
2819 {
"Telemetry Major Cycle 4B of 7",
"CR_PVVIS_B_ON"},
2820 {
"Telemetry Major Cycle 4A of 7",
"CR_PVLWA_ECAL_ON"},
2821 {
"Telemetry Major Cycle 4A of 7",
"CR_PVLWB_ECAL_ON"},
2822 {
"Telemetry Major Cycle 4B of 7",
"CR_PVNIRA_ECALON"},
2823 {
"Telemetry Major Cycle 4B of 7",
"CR_PVNIRB_ECALON"},
2824 {
"Telemetry Major Cycle 4B of 7",
"CR_PVSMA_ECAL_ON"},
2825 {
"Telemetry Major Cycle 4B of 7",
"CR_PVSMB_ECAL_ON"},
2826 {
"Telemetry Major Cycle 4B of 7",
"CR_PVVISA_ECALON"},
2827 {
"Telemetry Major Cycle 4B of 7",
"CR_PVVISB_ECALON"},
2828 {
"Telemetry Major Cycle 5A of 7",
"CR_RC_SMHTR_ON"},
2829 {
"Telemetry Major Cycle 5A of 7",
"CR_RC_LWHTR_ON"},
2830 {
"Telemetry Major Cycle 5B of 7",
"CR_SA_A_SCAN_ON"},
2831 {
"Telemetry Major Cycle 5B of 7",
"CR_SA_B_SCAN_ON"},
2832 {
"Telemetry Major Cycle 5B of 7",
"CR_SM_SDSM_A_ON"},
2833 {
"Telemetry Major Cycle 5B of 7",
"CR_SM_SDSM_B_ON"},
2834 {
"Telemetry Major Cycle 5B of 7",
"CR_SR_A_ON"},
2835 {
"Telemetry Major Cycle 5B of 7",
"CR_SR_B_ON"},
2836 {
"Telemetry Major Cycle 6 of 7",
"CR_TG_A_ON"},
2837 {
"Telemetry Major Cycle 6 of 7",
"CR_TG_B_ON"},
2846 L1BErrorMsg(location, returnStatus,
"number of scans is out of range",
2848 return returnStatus;
2857 while (Elec_config_fields[num_elec_config_elements].vname!=
NULL)
2858 num_elec_config_elements++;
2863 L1BErrorMsg(location, returnStatus,
"macro E_VECTOR_SIZE is too small",
2865 return returnStatus;
2872 Elec_config_status[ivar] = 0;
2873 Elec_config_change[ivar] = 0;
2874 Elec_config_invalid_flag[ivar] = 0;
2880 for (
i = 0;
i < 32 && total_fields < num_elec_config_elements;
2881 i++, total_fields++)
2891 Elec_config_fields[total_fields].vname,
2892 Elec_config_fields[total_fields].fname,
2899 "Get_Electronics_Status", 0,
NULL,
False);
2900 return returnStatus;
2909 if (final_value == 1)
2910 Elec_config_status[ivar] |=
mask;
2912 if (is_changed == 1)
2913 Elec_config_change[ivar] |=
mask;
2915 if (no_valid_value ==
True)
2916 Elec_config_invalid_flag[ivar] |=
mask;
2924 return returnStatus;
2932 uint32 *Elec_config_status,
2933 uint32 *Elec_config_change)
3002 PGSt_SMF_status returnStatus;
3003 char *location =
"Get_Elec_Config_Status";
3007 int32 Leading_sd_id;
3008 int32 num_scans_leading;
3024 char file_name[PGSd_PC_FILE_PATH_MAX];
3032 L1BErrorMsg(location, returnStatus,
"number of scans is out of range",
3034 return returnStatus;
3051 Elec_config_invalid_flag);
3055 "Get_Elec_Config_Status_Per_Gran",
3057 return returnStatus;
3068 if (returnStatus != PGS_S_SUCCESS)
3072 "Could not retrieve file name from PCF.",
3074 return returnStatus;
3077 Leading_sd_id = SDstart(file_name, DFACC_RDONLY);
3078 if (Leading_sd_id ==
FAIL)
3082 "Could not open file for SD read access.",
3085 "The file may be missing, corrupted or not an HDF-4 file.",
3087 return returnStatus;
3090 Leading_v_id = Hopen(file_name,DFACC_RDONLY,0);
3091 if (Leading_v_id ==
FAIL)
3095 "Could not open file for Vdata read access.",
3098 "The file may be corrupted or not an HDF-4 file.",
3100 return returnStatus;
3103 hdf_return = Vstart(Leading_v_id);
3104 if (hdf_return ==
FAIL)
3108 "Could not initialize Vdata interface.",
3111 "The file may be corrupted or not an HDF-4 file.",
3113 return returnStatus;
3121 "Could not read Number of Scans.",
3126 return returnStatus;
3138 Leading_Elec_config_status,
3139 Leading_Elec_config_change,
3140 Leading_Elec_config_invalid_flag);
3144 "Get_Elec_Config_Status_Per_Gran",
3146 return returnStatus;
3156 Elec_config_invalid_flag);
3160 "Get_Elec_Config_Status_Per_Gran",
3162 return returnStatus;
3175 Elec_config_change[
i] = Elec_config_change[
i] |
3176 ((~Leading_Elec_config_invalid_flag[
i])&
3177 (Leading_Elec_config_status[
i]^Elec_config_status[
i]));
3181 hdf_return = SDend(Leading_sd_id);
3182 if (hdf_return ==
FAIL)
3185 "Memory or the disk file must have become corrupted.",
3188 hdf_return = Vend(Leading_v_id);
3189 if (hdf_return ==
FAIL)
3192 "Memory or the disk file must have become corrupted.",
3195 hdf_return = Hclose(Leading_v_id);
3196 if (hdf_return ==
FAIL)
3199 "Memory or the disk file must have become corrupted.",
3212 if (Elec_config_invalid_flag[0] > 0 || Elec_config_invalid_flag[1] > 0)
3214 Elec_config_change[1] |= 0x80000000;
3215 Elec_config_status[1] |= 0x80000000;
3218 return returnStatus;