ECC-991: Added typicalDate and typicalTime

This commit is contained in:
Shahram Najm 2019-11-11 16:24:15 +00:00
parent 50c4744065
commit fa985d7c5c
3 changed files with 23 additions and 8 deletions

View File

@ -313,6 +313,8 @@ static int bufr_decode_edition3(const void* message, codes_bufr_header* hdr)
long nbits_localTablesVersionNumber = 1*8;
long pos_localTablesVersionNumber = 19*8;
const long typicalCentury = 21; /* This century */
long typicalYearOfCentury = 0;
long nbits_typicalYearOfCentury = 1*8;
long pos_typicalYearOfCentury = 20*8;
@ -353,11 +355,15 @@ static int bufr_decode_edition3(const void* message, codes_bufr_header* hdr)
hdr->masterTablesVersionNumber = (long)grib_decode_unsigned_long(
message, &pos_masterTablesVersionNumber, nbits_masterTablesVersionNumber);
hdr->localTablesVersionNumber = (long)grib_decode_unsigned_long(message, &pos_localTablesVersionNumber, nbits_localTablesVersionNumber);
hdr->typicalYearOfCentury = (long)grib_decode_unsigned_long(message, &pos_typicalYearOfCentury, nbits_typicalYearOfCentury);
typicalYearOfCentury = (long)grib_decode_unsigned_long(message, &pos_typicalYearOfCentury, nbits_typicalYearOfCentury);
hdr->typicalYear = (typicalCentury - 1) * 100 + typicalYearOfCentury;
hdr->typicalMonth = (long)grib_decode_unsigned_long(message, &pos_typicalMonth, nbits_typicalMonth);
hdr->typicalDay = (long)grib_decode_unsigned_long(message, &pos_typicalDay, nbits_typicalDay);
hdr->typicalHour = (long)grib_decode_unsigned_long(message, &pos_typicalHour, nbits_typicalHour);
hdr->typicalMinute = (long)grib_decode_unsigned_long(message, &pos_typicalMinute, nbits_typicalMinute);
hdr->typicalSecond = 0;
hdr->typicalDate = hdr->typicalYear * 10000 + hdr->typicalMonth * 100 + hdr->typicalDay;
hdr->typicalTime = hdr->typicalHour * 10000 + hdr->typicalMinute * 100 + hdr->typicalSecond;
offset_section2 = BUFR_SECTION0_LEN + section1Length; /*bytes*/
section2Length = 0;
@ -434,6 +440,7 @@ static int bufr_decode_edition4(const void* message, codes_bufr_header* hdr)
long nbits_localTablesVersionNumber = 1*8;
long pos_localTablesVersionNumber = 22*8;
long typicalYear2 = 0; // corrected
long nbits_typicalYear = 2*8;
long pos_typicalYear = 23*8;
@ -477,12 +484,16 @@ static int bufr_decode_edition4(const void* message, codes_bufr_header* hdr)
hdr->dataSubCategory = (long)grib_decode_unsigned_long(message, &pos_dataSubCategory, nbits_dataSubCategory);
hdr->masterTablesVersionNumber = (long)grib_decode_unsigned_long(message, &pos_masterTablesVersionNumber, nbits_masterTablesVersionNumber);
hdr->localTablesVersionNumber = (long)grib_decode_unsigned_long(message, &pos_localTablesVersionNumber, nbits_localTablesVersionNumber);
hdr->typicalYear = (long)grib_decode_unsigned_long(message, &pos_typicalYear, nbits_typicalYear);
typicalYear2 = hdr->typicalYear < 100 ? 2000 + hdr->typicalYear : hdr->typicalYear; // ECC-556
hdr->typicalMonth = (long)grib_decode_unsigned_long(message, &pos_typicalMonth, nbits_typicalMonth);
hdr->typicalDay = (long)grib_decode_unsigned_long(message, &pos_typicalDay, nbits_typicalDay);
hdr->typicalHour = (long)grib_decode_unsigned_long(message, &pos_typicalHour, nbits_typicalHour);
hdr->typicalMinute = (long)grib_decode_unsigned_long(message, &pos_typicalMinute, nbits_typicalMinute);
hdr->typicalSecond = (long)grib_decode_unsigned_long(message, &pos_typicalSecond, nbits_typicalSecond);
hdr->typicalDate = typicalYear2 * 10000 + hdr->typicalMonth * 100 + hdr->typicalDay;
hdr->typicalTime = hdr->typicalHour * 10000 + hdr->typicalMinute * 100 + hdr->typicalSecond;
offset_section2 = BUFR_SECTION0_LEN + section1Length; /*bytes*/
section2Length = 0;

View File

@ -1577,16 +1577,17 @@ typedef struct codes_bufr_header {
long dataSubCategory;
long masterTablesVersionNumber;
long localTablesVersionNumber;
long typicalYearOfCentury;
long typicalYear;
long typicalMonth;
long typicalDay;
long typicalHour;
long typicalMinute;
/* Section 1 keys: BUFR4-specific */
long internationalDataSubCategory;
long typicalYear;
long typicalSecond;
long typicalDate; // computed key
long typicalTime; // computed key
long internationalDataSubCategory; /*BUFR4-specific*/
long ecmwfLocalSectionPresent;

View File

@ -70,13 +70,16 @@ int main(int argc, char* argv[])
if (strstr(keys, "dataSubCategory")) printf("%ld ", bh.dataSubCategory);
if (strstr(keys, "masterTablesVersionNumber")) printf("%ld ", bh.masterTablesVersionNumber);
if (strstr(keys, "localTablesVersionNumber")) printf("%ld ", bh.localTablesVersionNumber);
if (strstr(keys, "typicalYearOfCentury")) printf("%ld ", bh.typicalYearOfCentury);
if (strstr(keys, "typicalYear")) printf("%ld ", bh.typicalYear);
if (strstr(keys, "typicalMonth")) printf("%ld ", bh.typicalMonth);
if (strstr(keys, "typicalDay")) printf("%ld ", bh.typicalDay);
if (strstr(keys, "typicalHour")) printf("%ld ", bh.typicalHour);
if (strstr(keys, "typicalMinute")) printf("%ld ", bh.typicalMinute);
if (strstr(keys, "typicalDate")) printf("%ld ", bh.typicalDate);
if (strstr(keys, "typicalTime")) printf("%ld ", bh.typicalTime);
if (strstr(keys, "internationalDataSubCategory")) printf("%ld ", bh.internationalDataSubCategory);
if (strstr(keys, "typicalYear")) printf("%ld ", bh.typicalYear);
if (strstr(keys, "typicalSecond")) printf("%ld ", bh.typicalSecond);
if (strstr(keys, "localSectionPresent")) printf("%ld ", bh.ecmwfLocalSectionPresent);