pdstemplates.c(3)

πŸ“¦
version 2.3.0 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– pdstemplates.c πŸ’–

bestie. gather round. today we're reading pdstemplates.c(3) from the Library Functions Manual, and it's literally the blueprint for GRIB2 Product Definition Templates. no cap, this is the lore. 🌸


✨ NAME ✨

pdstemplates.c β€” Functions for GRIB2 Product Definition Templates used in Section 4 - the Product Definition Section (PDS).


πŸ¦‹ SYNOPSIS πŸ¦‹

#include 'grib2_int.h'

πŸ‘‘ Functions

  • gtemplate * extpdstemplate (g2int number, g2int *list) β€” This subroutine generates the remaining octet map for a given Product Definition Template, if required.
  • int g2c_get_pds_template (int pds_template_num, int *maplen, int *map, int *needext) β€” Get PDS template information.
  • int g2c_get_pds_template_extension (int pds_template_num, int *template, int *extlen, int *ext) β€” Get pds template extension information.
  • int g2c_get_pdt_len (int pds_template_num, int *maplen) β€” Get initial length (number of entries) in static part of PDS template.
  • static g2int getpdsindex (g2int number) β€” This function returns the index of specified Product Definition Template in array templates.
  • gtemplate * getpdstemplate (g2int number) β€” This subroutine returns PDS template information for a specified Product Definition Template.

πŸŽ€ Variables

  • static const struct pdstemplate templatespds [G2C_MAX_PDS_TEMPLATE] β€” Data for struct for PDS template.

🌈 Detailed Description 🌈

Functions for GRIB2 Product Definition Templates used in Section 4 - the Product Definition Section (PDS).

Every single Template has three parts, and honestly? iconic structure:

  1. The number of entries in the template (mappdslen).
  2. A map of the template (mappds), which contains the number of octets in which to pack each of the template values.
  3. A logical value (needext) that indicates whether the Template needs to be extended. In some cases the number of entries in a template can vary depending upon values specified in the "static" part of the template. (See Template 4.3 as an example).

πŸ’… Note

Array mappds contains the number of octets in which the corresponding template values will be stored. A negative value in mappds is used to indicate that the corresponding template entry can contain negative values. This information is used later when packing (or unpacking) the template data values. Negative data values in GRIB are stored with the left most bit set to one, and a negative number of octets value in mappds[] indicates that this possibility should be considered. The number of octets used to store the data value in this case would be the absolute value of the negative value in mappds.

so basically: negative number in the map = "this entry is allowed to be negative, and the real size is the absolute value." noted. 🫢

πŸ“œ Program History Log πŸ“œ

  • 2001-06-28 β€” Gilbert β€” Initial
  • 2009-01-14 β€” Vuong β€” Changed structure name template to gtemplate
  • 2009-12-15 β€” Vuong β€” Added Product Definition Templates 4.31, 4.15
  • 2010-08-03 β€” Vuong β€” Added Product Definition Template 4.42 and 4.43
  • 2010-12-08 β€” Vuong β€” Corrected Product Definition Template 4.42 and 4.43
  • 2012-03-29 β€” Vuong β€” Added Templates 4.44,4.45,4.46,4.47,4.48,4.50, 4.51,4.91,4.32 and 4.52
  • 2013-08-05 β€” Vuong β€” Corrected 4.91 and added Templates 4.33,4.34,4.53,4.54
  • 2015-10-07 β€” Vuong β€” Added Templates 4.57, 4.60, 4.61 and allow a forecast time to be negative
  • 2022-10-18 β€” Hartnett β€” Added g2c_get_pds_template() and g2c_get_pds_template_extension().
  • 2024-09-09 β€” Stahl β€” Added extension for Template 4.35
  • 2024-12-04 β€” Stahl β€” Added 55 missing templates, including those from July 2024 WMO updates.

🌟 Author

Stephen Gilbert

🌟 Date

2001-06-28

Definition in file pdstemplates.c.


🧚 Function Documentation 🧚

🌸 gtemplate * extpdstemplate (g2int number, g2int * list)

This subroutine generates the remaining octet map for a given Product Definition Template, if required. Some Templates can vary depending on data values given in an earlier part of the Template, and it is necessary to know some of the earlier entry values to generate the full octet map of the Template.

This function allocates memory in the ext field of the gtemplate struct. This memory must be freed by the caller.

bestie pls. free it. don't leak. πŸ’€

Parameters

  • number β€” number of the Product Definition Template 4.NN that is being requested.
  • list β€” The list of values for each entry in the the Product Definition Template.

Returns

Pointer to the returned template struct. Returns NULL pointer if template not found.

Author

Stephen Gilbert

Date

2000-05-11

Definition at line 553 of file pdstemplates.c.

References getpdsindex(), and getpdstemplate().

Referenced by g2_addfield(), g2_unpack4(), and g2c_get_pds_template_extension().


🌸 int g2c_get_pds_template (int pds_template_num, int * maplen, int * map, int * needext)

Get PDS template information. The PDS template consists of a template map, its length, and, for some templates, an extra extension map, and its length. If an extension is needed, use g2c_get_pds_template_extension() to get it.

Parameters

  • pds_template_num β€” The PDS template number.
  • maplen β€” Pointer that gets the length of the map. Ignored if NULL.
  • map β€” Pointer that gets the map as an array of int. Memory must be allocated by caller. Ignored if NULL.
  • needext β€” Pointer that a non-zero value if an extension to this template is needed. Ignored if NULL.

Returns

  • G2C_NOERROR β€” No error.
  • G2C_ENOTEMPLATE β€” Template not found.

Author

Ed Hartnett

Date

10/18/22

Definition at line 1806 of file pdstemplates.c.

References G2C_ENOTEMPLATE, G2C_MAX_PDS_TEMPLATE, G2C_NOERROR, and templatespds.

Referenced by g2c_rw_section4_metadata().


🌸 int g2c_get_pds_template_extension (int pds_template_num, int * template, int * extlen, int * ext)

Get pds template extension information.

Parameters

  • pds_template_num β€” The pds template number.
  • template β€” Pointer to array that contains the template values.
  • extlen β€” Pointer that gets the length of the extension. Ignored if NULL.
  • ext β€” Pointer that gets template extension array, if there is one. Memory must be allocated by the caller. Ignored if NULL.

Returns

  • G2C_NOERROR β€” No error.
  • G2C_EINVAL β€” Invalid input.
  • G2C_ENOTEMPLATE β€” Template not found.
  • G2C_ENOMEM β€” Out of memory.

Author

Ed Hartnett

Date

10/16/22

Definition at line 1731 of file pdstemplates.c.

References gtemplate::ext, gtemplate::extlen, extpdstemplate(), G2C_EINVAL, G2C_ENOMEM, G2C_ENOTEMPLATE, G2C_MAX_PDS_TEMPLATE, G2C_NOERROR, and templatespds.


🌸 int g2c_get_pdt_len (int pds_template_num, int * maplen)

Get initial length (number of entries) in static part of PDS template.

Parameters

  • pds_template_num β€” The PDS template number.
  • maplen β€” Pointer that gets the length of the map. Ignored if NULL.

Returns

  • G2C_NOERROR β€” No error.
  • G2C_ENOTEMPLATE β€” Template not found.

Author

Alyson Stahl

Date

01/21/25

Definition at line 1848 of file pdstemplates.c.

References G2C_ENOTEMPLATE, G2C_MAX_PDS_TEMPLATE, G2C_NOERROR, and templatespds.


🌸 g2int getpdsindex (g2int number) [static]

This function returns the index of specified Product Definition Template in array templates.

Parameters

  • number β€” The number of the Product Definition Template that is being requested.

Returns

Index of PDT in array templates, if template exists. -1, otherwise.

Author

Stephen Gilbert

Date

2001-06-28

Definition at line 469 of file pdstemplates.c.

References G2C_MAX_PDS_TEMPLATE, getpdsindex(), and templatespds.

Referenced by extpdstemplate(), getpdsindex(), and getpdstemplate().


🌸 gtemplate * getpdstemplate (g2int number)

This subroutine returns PDS template information for a specified Product Definition Template. The number of entries in the template is returned along with a map of the number of octets occupied by each entry. Also, a flag is returned to indicate whether the template would need to be extended.

This function allocates memory for the gtemplate struct, which must be freed by the caller.

Parameters

  • number β€” the number of the Product Definition Template that is being requested.

Returns

Pointer to the returned template struct. Returns NULL pointer if template not found.

Author

Stephen Gilbert

Date

2000-05-11

Definition at line 504 of file pdstemplates.c.

References getpdsindex(), and templatespds.

Referenced by extpdstemplate(), g2_addfield(), and g2_unpack4().


πŸ’œ Variable Documentation πŸ’œ

🌸 const struct pdstemplate templatespds[G2C_MAX_PDS_TEMPLATE] [static]

Data for struct for PDS template.

Definition at line 59 of file pdstemplates.c.

Referenced by g2c_get_pds_template(), g2c_get_pds_template_extension(), g2c_get_pdt_len(), getpdsindex(), and getpdstemplate().


🫢 Author 🫢

Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.


okay that's the whole page bestie, you ate that. πŸ’…βœ¨ this was auto-generated by Doxygen for NCEPLIBS-g2c, Version 2.3.0 β€” go off, Doxygen, you did that fr fr. πŸŽ€πŸ¦‹ no cap, read the docs, free your memory, slay. πŸ’–

πŸ“¦ where this page comes from