Skip to content

Commit

Permalink
Updating gds templates to current WMO values (#581)
Browse files Browse the repository at this point in the history
* template 3.13

* comma

* 3.23

* typos and format

* typo

* 3.33

* 3.61

* 3.62

* 3.63

* 3.150
  • Loading branch information
AlysonStahl-NOAA authored Jan 8, 2025
1 parent 80806b4 commit 32cdb31
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/grib2.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ g2int g2_gribend(unsigned char *cgrib);
#define G2C_SECTION1_LEN 13 /**< Length of section 1 array. */

/* Constants to help with templates. */
#define G2C_MAX_GDS_TEMPLATE 31 /**< Maximum number of grid templates. */
#define G2C_MAX_GDS_TEMPLATE 38 /**< Maximum number of grid templates. */
#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. */
Expand Down
18 changes: 17 additions & 1 deletion src/gridtemplates.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* 2010-05-11 | Vuong | Added GDT 3.32769 Rotate Lat/Lon Non-E Staggered grid (Arakawa)
* 2013-08-06 | Vuong | Added GDT 3.4, 3.5, 3.12, 3.101, 3.140
* 2022-10-16 | Hartnett | Added g2c_get_grid_template().
* 2025-01-06 | Stahl| Added GDT 3.13, 3.23, 3.33, 3.61, 3.62, 3.63, 3.150
*
* @author Stephen Gilbert @date 2001-06-28
*/
Expand Down Expand Up @@ -119,7 +120,22 @@ static const struct gridtemplate templatesgrid[G2C_MAX_GDS_TEMPLATE] =
/* 3.1100: Hovmoller Diagram Grid */
{1100, 28, 0, {1, 1, 4, 1, 4, 1, 4, 4, 4, 4, -4, 4, 1, -4, 4, 1, 4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1}},
/* 3.1200: Time Section Grid */
{1200, 16, 1, {4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2}}};
{1200, 16, 1, {4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2}},

/* 3.13: Mercator with modelling subdomains definition */
{13, 23, 0, {1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, -4, 4, 1, 4, 4, 4, 4, 4, 4, 4}},
/* 3.23: Polar stereographic projection with modelling subdomains definition */
{23, 22, 0, {1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, 1, 4, 4, 4, 4}},
/* 3.30: Lambert conformal with modelling subdomains definition */
{33, 26, 0, {1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, 1, -4, -4, -4, 4, 4, 4, 4, 4}},
/* 3.61: Spectral Mercator with modelling subdomains definition */
{61, 23, 0, {1, 4, 4, 1, 8, 8, 8, 8, 8, 8, 1, 1, 4, 1, 4, 1, 4, -4, 4, -4, -4, 4, 4}},
/* 3.62: Spectral Polar Stereographic with modelling subdomains definition */
{62, 23, 0, {1, 4, 4, 1, 8, 8, 8, 8, 8, 8, 1, 1, 4, 1, 4, 1, 4, -4, 4, 1, -4, 4, 1}},
/* 3.63: Spectral Lambert Conformal with modelling subdomains definition */
{63, 26, 0, {1, 4, 4, 1, 8, 8, 8, 8, 8, 8, 1, 1, 4, 1, 4, 1, 4, -4, 4, -4, 4, 1, -4, -4, -4, 4}},
/* 3.150: Hierarchical Equal Area isoLatitude Pixelization grid (HEALPix) */
{150, 13, 0, {1, 1, 4, 1, 4, 1, 4, 1, 4, 4, 1, 1, 1}}};

/**
* This function returns the index of specified Grid Definition
Expand Down
27 changes: 21 additions & 6 deletions tests/tst_get_grid_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "grib2_int.h"

/* Number of grid templates to test. */
#define NUM_TESTS 31
#define NUM_TESTS 38

/* Number of grid templates with extensions. */
#define NUM_EXT_TESTS 5
Expand All @@ -18,10 +18,18 @@ main()
printf("Testing g2c_get_grid_template()\n");
printf("Testing simple g2c_get_grid_template() calls...\n");
{
int template_number[NUM_TESTS] = {0, 1, 2, 3, 4, 5, 12, 101, 140, 10, 20, 30, 31, 40, 41, 42, 43, 50, 51, 52, 53, 90, 100, 110, 120, 204, 32768, 32769, 1000, 1100, 1200};
int expected_maplen[NUM_TESTS] = {19, 22, 22, 25, 13, 16, 22, 4, 17, 19, 18, 22, 22, 19, 22, 22, 25, 5, 8, 8, 11, 21, 11, 16, 7, 19, 19, 21, 20, 28, 16};
int expected_needsext[NUM_TESTS] = {0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1};
int expected_extlen[NUM_TESTS] = {0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 2, 0, 2};
int template_number[NUM_TESTS] = {
0, 1, 2, 3, 4, 5, 12, 101, 140, 10, 20, 30, 31, 40, 41, 42, 43, 50, 51, 52, 53, 90, 100, 110, 120,
204, 32768, 32769, 1000, 1100, 1200, 13, 23, 33, 61, 62, 63, 150};
int expected_maplen[NUM_TESTS] = {
19, 22, 22, 25, 13, 16, 22, 4, 17, 19, 18, 22, 22, 19, 22, 22, 25, 5, 8, 8, 11, 21, 11, 16, 7, 19,
19, 21, 20, 28, 16, 23, 22, 26, 23, 23, 26, 13};
int expected_needsext[NUM_TESTS] = {
0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0,
0, 0, 0, 0, 0};
int expected_extlen[NUM_TESTS] = {
0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 2, 0, 2, 0, 0,
0, 0, 0, 0, 0};
int expected_map[NUM_TESTS][28] = {
{1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, 0, 0, 0}, /* 0 */
{1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, -4, 4, 4, 0, 0, 0}, /* 1 */
Expand Down Expand Up @@ -53,7 +61,14 @@ main()
{1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, 4, 4}, /* 32769 */
{1, 1, 4, 1, 4, 1, 4, 4, 4, 4, -4, 4, 1, 4, 4, 1, 2, 1, 1, 2}, /* 1000 */
{1, 1, 4, 1, 4, 1, 4, 4, 4, 4, -4, 4, 1, -4, 4, 1, 4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1}, /* 1100 */
{4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2} /* 1200 */
{4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2}, /* 1200 */
{1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, -4, 4, 1, 4, 4, 4, 4, 4, 4, 4}, /* 13 */
{1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, 1, 4, 4, 4, 4}, /* 23 */
{1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, 1, -4, -4, -4, 4, 4, 4, 4, 4}, /* 33 */
{1, 4, 4, 1, 8, 8, 8, 8, 8, 8, 1, 1, 4, 1, 4, 1, 4, -4, 4, -4, -4, 4, 4}, /* 61 */
{1, 4, 4, 1, 8, 8, 8, 8, 8, 8, 1, 1, 4, 1, 4, 1, 4, -4, 4, 1, -4, 4, 1}, /* 62 */
{1, 4, 4, 1, 8, 8, 8, 8, 8, 8, 1, 1, 4, 1, 4, 1, 4, -4, 4, -4, 4, 1, -4, -4, -4, 4}, /* 63 */
{1, 1, 4, 1, 4, 1, 4, 1, 4, 4, 1, 1, 1}, /* 150 */
};
int expected_ext[NUM_EXT_TESTS][8] = {
{4, 4, -4, -4},
Expand Down

0 comments on commit 32cdb31

Please sign in to comment.