Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating drs templates to current WMO values #580

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/drstemplates.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* 2009-01-14 | Vuong | Changed structure name template to gtemplate
* 2022-10-18 | Hartnett | Added g2c_get_drs_template().
* 2023-09-08 | Engle | Added template 5.42.
* 2025-01-06 | Stahl | Added template 5.53
*
* @author Stephen Gilbert @date 2001-06-28
*/
Expand Down Expand Up @@ -106,6 +107,10 @@ static const struct drstemplate templatesdrs[G2C_MAX_DRS_TEMPLATE] =
* encoding](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-42.shtml) */
{42, 8, 0, {4, -2, -2, 1, 1, 1, 1, 2}},

/** [5.53: Spectral data for limited area models - Complex packing
* encoding](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-53.shtml) */
{53, 11, 0, {4, -2, -2, 1, 1, 1, -4, 2, 2, 4, 1}},

/** 5.40000: Grid point data - JPEG2000 encoding
*
* This is a local template number, from a time before WMO standardized use of JPEG2000
Expand Down
2 changes: 1 addition & 1 deletion src/grib2.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ g2int g2_gribend(unsigned char *cgrib);
#define G2C_MAX_GDS_TEMPLATE_MAPLEN 28 /**< Maximum grid template map length. */
#define G2C_MAX_PDS_TEMPLATE 102 /**< Maximum number of PDS templates. */
#define G2C_MAX_PDS_TEMPLATE_MAPLEN 50 /**< Maximum template map length. */
#define G2C_MAX_DRS_TEMPLATE 10 /**< Maximum number of DRS templates. */
#define G2C_MAX_DRS_TEMPLATE 11 /**< Maximum number of DRS templates. */
#define G2C_MAX_DRS_TEMPLATE_MAPLEN 18 /**< Maximum DRS template map length. */

/* File handling functions. */
Expand Down
9 changes: 5 additions & 4 deletions tests/tst_drstemplates.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ main()
printf("ok!\n");
printf("Testing all getdrstemplate() calls...\n");
{
#define NUM_TEST 9
int number[NUM_TEST] = {0, 2, 3, 50, 51, 40, 41, 40000, 40010};
int expected_maplen[NUM_TEST] = {5, 16, 18, 5, 10, 7, 5, 7, 5};
#define NUM_TEST 10
int number[NUM_TEST] = {0, 2, 3, 50, 51, 40, 41, 40000, 40010, 53};
int expected_maplen[NUM_TEST] = {5, 16, 18, 5, 10, 7, 5, 7, 5, 11};
int expected_map[NUM_TEST][18] = {
{4, -2, -2, 1, 1}, /* 0 */
{4, -2, -2, 1, 1, 1, 1, 4, 4, 4, 1, 1, 4, 1, 4, 1}, /* 2 */
Expand All @@ -94,7 +94,8 @@ main()
{4, -2, -2, 1, 1, 1, 1}, /* 40 */
{4, -2, -2, 1, 1}, /* 41 */
{4, -2, -2, 1, 1, 1, 1}, /* 40000 */
{4, -2, -2, 1, 1} /* 40010 */
{4, -2, -2, 1, 1}, /* 40010 */
{4, -2, -2, 1, 1, 1, -4, 2, 2, 4, 1}, /* 53*/
};

int t;
Expand Down
Loading