grib2io.templates

GRIB2 section templates classes and metadata descriptor classes

   1"""
   2GRIB2 section templates classes and metadata descriptor classes
   3"""
   4from dataclasses import dataclass, field
   5from collections import defaultdict
   6import datetime
   7
   8from . import tables
   9from . import utils
  10
  11_section_attrs = {0:['discipline'],
  12                  1:['originatingCenter', 'originatingSubCenter', 'masterTableInfo', 'localTableInfo',
  13                     'significanceOfReferenceTime', 'year', 'month', 'day', 'hour', 'minute', 'second',
  14                     'refDate', 'productionStatus', 'typeOfData'],
  15                  2:[],
  16                  3:['sourceOfGridDefinition', 'numberOfDataPoints', 'interpretationOfListOfNumbers',
  17                     'gridDefinitionTemplateNumber', 'shapeOfEarth', 'earthRadius', 'earthMajorAxis',
  18                     'earthMinorAxis', 'resolutionAndComponentFlags', 'ny', 'nx', 'scanModeFlags'],
  19                  4:['productDefinitionTemplateNumber','fullName', 'units', 'shortName','leadTime',
  20                     'unitOfFirstFixedSurface','valueOfFirstFixedSurface',
  21                     'unitOfSecondFixedSurface','valueOfSecondFixedSurface',
  22                     'validDate','duration','level'],
  23                  5:['dataRepresentationTemplateNumber','numberOfPackedValues','typeOfValues'],
  24                  6:['bitMapFlag'],
  25                  7:[],
  26                  8:[],}
  27
  28
  29class Grib2Metadata():
  30    """
  31    Class to hold GRIB2 metadata both as numeric code value as stored in
  32    GRIB2 and its plain langauge definition.
  33
  34    Attributes
  35    ----------
  36    **`value : int`**
  37        GRIB2 metadata integer code value.
  38
  39    **`table : str, optional`**
  40        GRIB2 table to lookup the `value`. Default is None.
  41
  42    **`definition : str`**
  43        Plain language description of numeric metadata.
  44    """
  45    __slots__ = ('value','table')
  46    def __init__(self, value, table=None):
  47        self.value = value
  48        self.table = table
  49    def __call__(self):
  50        return self.value
  51    def __hash__(self):
  52        return hash(self.value)   # AS- added hash() to self.value as pandas was raising error about some non integer returns from hash method
  53    def __repr__(self):
  54        return f"{self.__class__.__name__}({self.value}, table = '{self.table}')"
  55    def __str__(self):
  56        return f'{self.value} - {self.definition}'
  57    def __eq__(self,other):
  58        return self.value == other or self.definition[0] == other
  59    def __gt__(self,other):
  60        return self.value > other
  61    def __ge__(self,other):
  62        return self.value >= other
  63    def __lt__(self,other):
  64        return self.value < other
  65    def __le__(self,other):
  66        return self.value <= other
  67    def __contains__(self,other):
  68        return other in self.definition
  69    def __hash__(self):
  70        return hash(self.value)
  71    def __index__(self):
  72        return int(self.value)
  73    @property
  74    def definition(self):
  75        return tables.get_value_from_table(self.value,self.table)
  76    def show_table(self):
  77        """
  78        Provide the table related to this metadata.
  79        """
  80        return tables.get_table(self.table)
  81
  82# ----------------------------------------------------------------------------------------
  83# Descriptor Classes for Section 0 metadata.
  84# ----------------------------------------------------------------------------------------
  85class IndicatorSection:
  86    """
  87    [GRIB2 Indicator Section (0)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect0.shtml)
  88    """
  89    def __get__(self, obj, objtype=None):
  90        return obj.section0
  91    def __set__(self, obj, value):
  92        obj.section0 = value
  93
  94class Discipline:
  95    """[Discipline](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table0-0.shtml)"""
  96    def __get__(self, obj, objtype=None):
  97        return Grib2Metadata(obj.indicatorSection[2],table='0.0')
  98    def __set__(self, obj, value):
  99        obj.section0[2] = value
 100
 101
 102# ----------------------------------------------------------------------------------------
 103# Descriptor Classes for Section 1 metadata.
 104# ----------------------------------------------------------------------------------------
 105class IdentificationSection:
 106    """
 107    GRIB2 Section 1, [Identification Section](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect1.shtml)
 108    """
 109    def __get__(self, obj, objtype=None):
 110        return obj.section1
 111    def __set__(self, obj, value):
 112        obj.section1 = value
 113
 114class OriginatingCenter:
 115    """[Originating Center](https://www.nco.ncep.noaa.gov/pmb/docs/on388/table0.html)"""
 116    def __get__(self, obj, objtype=None):
 117        return Grib2Metadata(obj.section1[0],table='originating_centers')
 118    def __set__(self, obj, value):
 119        obj.section1[0] = value
 120
 121class OriginatingSubCenter:
 122    """[Originating SubCenter](https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablec.html)"""
 123    def __get__(self, obj, objtype=None):
 124        return Grib2Metadata(obj.section1[1],table='originating_subcenters')
 125    def __set__(self, obj, value):
 126        obj.section1[1] = value
 127
 128class MasterTableInfo:
 129    """[GRIB2 Master Table Version](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-0.shtml)"""
 130    def __get__(self, obj, objtype=None):
 131        return Grib2Metadata(obj.section1[2],table='1.0')
 132    def __set__(self, obj, value):
 133        obj.section1[2] = value
 134
 135class LocalTableInfo:
 136    """[GRIB2 Local Tables Version Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-1.shtml)"""
 137    def __get__(self, obj, objtype=None):
 138        return Grib2Metadata(obj.section1[3],table='1.1')
 139    def __set__(self, obj, value):
 140        obj.section1[3] = value
 141
 142class SignificanceOfReferenceTime:
 143    """[Significance of Reference Time](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-2.shtml)"""
 144    def __get__(self, obj, objtype=None):
 145        return Grib2Metadata(obj.section1[4],table='1.2')
 146    def __set__(self, obj, value):
 147        obj.section1[4] = value
 148
 149class Year:
 150    """Year of reference time"""
 151    def __get__(self, obj, objtype=None):
 152        return obj.section1[5]
 153    def __set__(self, obj, value):
 154        obj.section1[5] = value
 155
 156class Month:
 157    """Month of reference time"""
 158    def __get__(self, obj, objtype=None):
 159        return obj.section1[6]
 160    def __set__(self, obj, value):
 161        obj.section1[6] = value
 162
 163class Day:
 164    """Day of reference time"""
 165    def __get__(self, obj, objtype=None):
 166        return obj.section1[7]
 167    def __set__(self, obj, value):
 168        obj.section1[7] = value
 169
 170class Hour:
 171    """Hour of reference time"""
 172    def __get__(self, obj, objtype=None):
 173        return obj.section1[8]
 174    def __set__(self, obj, value):
 175        obj.section1[8] = value
 176
 177class Minute:
 178    """Minute of reference time"""
 179    def __get__(self, obj, objtype=None):
 180        return obj.section1[9]
 181    def __set__(self, obj, value):
 182        obj.section1[9] = value
 183
 184class Second:
 185    """Second of reference time"""
 186    def __get__(self, obj, objtype=None):
 187        return obj.section1[10]
 188    def __set__(self, obj, value):
 189        obj.section1[10] = value
 190
 191class RefDate:
 192    """Reference Date. NOTE: This is a `datetime.datetime` object."""
 193    def __get__(self, obj, objtype=None):
 194        return datetime.datetime(*obj.section1[5:11])
 195    def __set__(self, obj, value):
 196        if isinstance(value,datetime.datetime):
 197            obj.section1[5] = value.year
 198            obj.section1[6] = value.month
 199            obj.section1[7] = value.day
 200            obj.section1[8] = value.hour
 201            obj.section1[9] = value.minute
 202            obj.section1[10] = value.second
 203        else:
 204            msg = 'Reference date must be a datetime.datetime object.'
 205            raise TypeError(msg)
 206
 207class ProductionStatus:
 208    """[Production Status of Processed Data](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-3.shtml)"""
 209    def __get__(self, obj, objtype=None):
 210        return Grib2Metadata(obj.section1[11],table='1.3')
 211    def __set__(self, obj, value):
 212        obj.section1[11] = value
 213
 214class TypeOfData:
 215    """[Type of Processed Data in this GRIB message](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-4.shtml)"""
 216    def __get__(self, obj, objtype=None):
 217        return Grib2Metadata(obj.section1[12],table='1.4')
 218    def __set__(self, obj, value):
 219        obj.section1[12] = value
 220
 221# ----------------------------------------------------------------------------------------
 222# Descriptor Classes for Section 2 metadata.
 223# ----------------------------------------------------------------------------------------
 224
 225# ----------------------------------------------------------------------------------------
 226# Descriptor Classes for Section 3 metadata.
 227# ----------------------------------------------------------------------------------------
 228class GridDefinitionSection:
 229    """
 230    GRIB2 Section 3, [Grid Definition Section](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml)
 231    """
 232    def __get__(self, obj, objtype=None):
 233        return obj.section3[0:5]
 234    def __set__(self, obj, value):
 235        raise RuntimeError
 236
 237class SourceOfGridDefinition:
 238    """[Source of Grid Definition](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-0.shtml)"""
 239    def __get__(self, obj, objtype=None):
 240        return Grib2Metadata(obj.section3[0],table='3.0')
 241    def __set__(self, obj, value):
 242        raise RuntimeError
 243
 244class NumberOfDataPoints:
 245    """Number of Data Points"""
 246    def __get__(self, obj, objtype=None):
 247        return obj.section3[1]
 248    def __set__(self, obj, value):
 249        raise RuntimeError
 250
 251class InterpretationOfListOfNumbers:
 252    """Interpretation of List of Numbers"""
 253    def __get__(self, obj, objtype=None):
 254        return Grib2Metadata(obj.section3[3],table='3.11')
 255    def __set__(self, obj, value):
 256        raise RuntimeError
 257
 258class GridDefinitionTemplateNumber:
 259    """[Grid Definition Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-1.shtml)"""
 260    def __get__(self, obj, objtype=None):
 261        return Grib2Metadata(obj.section3[4],table='3.1')
 262    def __set__(self, obj, value):
 263        raise RuntimeError
 264
 265class GridDefinitionTemplate:
 266    """Grid definition template"""
 267    def __get__(self, obj, objtype=None):
 268        return obj.section3[5:]
 269    def __set__(self, obj, value):
 270        raise RuntimeError
 271
 272class EarthParams:
 273    """Metadata about the shape of the Earth"""
 274    def __get__(self, obj, objtype=None):
 275        if obj.section3[5] in {50,51,52,1200}:
 276            return None
 277        return tables.get_table('earth_params')[str(obj.section3[5])]
 278    def __set__(self, obj, value):
 279        raise RuntimeError
 280
 281class DxSign:
 282    """Sign of Grid Length in X-Direction"""
 283    def __get__(self, obj, objtype=None):
 284        if obj.section3[4] in {0,1,203,205,32768,32769} and \
 285        obj.section3[17] > obj.section3[20]:
 286            return -1.0
 287        return 1.0
 288    def __set__(self, obj, value):
 289        raise RuntimeError
 290
 291class DySign:
 292    """Sign of Grid Length in Y-Direction"""
 293    def __get__(self, obj, objtype=None):
 294        if obj.section3[4] in {0,1,203,205,32768,32769} and \
 295        obj.section3[16] > obj.section3[19]:
 296            return -1.0
 297        return 1.0
 298    def __set__(self, obj, value):
 299        raise RuntimeError
 300
 301class LLScaleFactor:
 302    """Scale Factor for Lats/Lons"""
 303    def __get__(self, obj, objtype=None):
 304        if obj.section3[4] in {0,1,203,205,32768,32769}:
 305            llscalefactor = float(obj.section3[14])
 306            if llscalefactor == 0:
 307                return 1
 308            return llscalefactor
 309        return 1
 310    def __set__(self, obj, value):
 311        raise RuntimeError
 312
 313class LLDivisor:
 314    """Divisor Value for scaling Lats/Lons"""
 315    def __get__(self, obj, objtype=None):
 316        if obj.section3[4] in {0,1,203,205,32768,32769}:
 317            lldivisor = float(obj.section3[15])
 318            if lldivisor <= 0:
 319                return 1.e6
 320            return lldivisor
 321        return 1.e6
 322    def __set__(self, obj, value):
 323        raise RuntimeError
 324
 325class XYDivisor:
 326    """Divisor Value for scaling grid lengths"""
 327    def __get__(self, obj, objtype=None):
 328        if obj.section3[4] in {0,1,203,205,32768,32769}:
 329            return obj._lldivisor
 330        return 1.e3
 331    def __set__(self, obj, value):
 332        raise RuntimeError
 333
 334class ShapeOfEarth:
 335    """[Shape of the Reference System](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-2.shtml)"""
 336    def __get__(self, obj, objtype=None):
 337        return Grib2Metadata(obj.section3[5],table='3.2')
 338    def __set__(self, obj, value):
 339        obj.section3[5] = value
 340
 341class EarthShape:
 342    """Description of the shape of the Earth"""
 343    def __get__(self, obj, objtype=None):
 344        return obj._earthparams['shape']
 345    def __set__(self, obj, value):
 346        raise RuntimeError
 347
 348class EarthRadius:
 349    """Radius of the Earth (Assumes "spherical")"""
 350    def __get__(self, obj, objtype=None):
 351        ep = obj._earthparams
 352        if ep['shape'] == 'spherical':
 353            if ep['radius'] is None:
 354                return obj.section3[7]/(10.**obj.section3[6])
 355            else:
 356                return ep['radius']
 357        elif ep['shape'] in {'ellipsoid','oblateSpheriod'}:
 358            return None
 359    def __set__(self, obj, value):
 360        raise RuntimeError
 361
 362class EarthMajorAxis:
 363    """Major Axis of the Earth (Assumes "oblate spheroid" or "ellipsoid")"""
 364    def __get__(self, obj, objtype=None):
 365        ep = obj._earthparams
 366        if ep['shape'] == 'spherical':
 367            return None
 368        elif ep['shape'] in {'ellipsoid','oblateSpheriod'}:
 369            if ep['major_axis'] is None and ep['minor_axis'] is None:
 370                return obj.section3[9]/(10.**obj.section3[8])
 371            else:
 372                return ep['major_axis']
 373    def __set__(self, obj, value):
 374        raise RuntimeError
 375
 376class EarthMinorAxis:
 377    """Minor Axis of the Earth (Assumes "oblate spheroid" or "ellipsoid")"""
 378    def __get__(self, obj, objtype=None):
 379        ep = obj._earthparams
 380        if ep['shape'] == 'spherical':
 381            return None
 382        if ep['shape'] in {'ellipsoid','oblateSpheriod'}:
 383            if ep['major_axis'] is None and ep['minor_axis'] is None:
 384                return obj.section3[11]/(10.**section3[10])
 385            else:
 386                return ep['minor_axis']
 387    def __set__(self, obj, value):
 388        raise RuntimeError
 389
 390class Nx:
 391    """Number of grid points in the X-direction (generally East-West)"""
 392    def __get__(self, obj, objtype=None):
 393        return obj.section3[12]
 394    def __set__(self, obj, value):
 395        obj.section3[12] = value
 396        obj.section3[1] = value * obj.section3[13]
 397
 398class Ny:
 399    """Number of grid points in the Y-direction (generally North-South)"""
 400    def __get__(self, obj, objtype=None):
 401        return obj.section3[13]
 402    def __set__(self, obj, value):
 403        obj.section3[13] = value
 404        obj.section3[1] = value * obj.section3[12]
 405
 406class ScanModeFlags:
 407    """[Scanning Mode](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-4.shtml)"""
 408    _key = {0:18, 1:18, 10:15, 20:17, 30:17, 31:17, 40:18, 41:18, 90:16, 110:15, 203:18, 204:18, 205:18, 32768:18, 32769:18}
 409    def __get__(self, obj, objtype=None):
 410        if obj.gdtn == 50:
 411            return [None, None, None, None]
 412        else:
 413            return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list)[0:8]
 414    def __set__(self, obj, value):
 415        obj.section3[self._key[obj.gdtn]+5] = value
 416
 417class ResolutionAndComponentFlags:
 418    """[Resolution and Component Flags](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-3.shtml)"""
 419    _key = {0:13, 1:13, 10:11, 20:11, 30:11, 31:11, 40:13, 41:13, 90:11, 110:11, 203:13, 204:13, 205:13, 32768:13, 32769:13}
 420    def __get__(self, obj, objtype=None):
 421        if obj.gdtn == 50:
 422            return [None for i in range(8)]
 423        else:
 424            return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list)
 425    def __set__(self, obj, value):
 426        obj.section3[self._key[obj.gdtn]+5] = value
 427
 428class LatitudeFirstGridpoint:
 429    """Latitude of first gridpoint"""
 430    _key = {0:11, 1:11, 10:9, 20:9, 30:9, 31:9, 40:11, 41:11, 110:9, 203:11, 204:11, 205:11, 32768:11, 32769:11}
 431    def __get__(self, obj, objtype=None):
 432        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
 433    def __set__(self, obj, value):
 434        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
 435
 436class LongitudeFirstGridpoint:
 437    """Longitude of first gridpoint"""
 438    _key = {0:12, 1:12, 10:10, 20:10, 30:10, 31:10, 40:12, 41:12, 110:10, 203:12, 204:12, 205:12, 32768:12, 32769:12}
 439    def __get__(self, obj, objtype=None):
 440        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
 441    def __set__(self, obj, value):
 442        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
 443
 444class LatitudeLastGridpoint:
 445    """Latitude of last gridpoint"""
 446    _key = {0:14, 1:14, 10:13, 40:14, 41:14, 203:14, 204:14, 205:14, 32768:14, 32769:19}
 447    def __get__(self, obj, objtype=None):
 448        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
 449    def __set__(self, obj, value):
 450        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
 451
 452class LongitudeLastGridpoint:
 453    """Longitude of last gridpoint"""
 454    _key = {0:15, 1:15, 10:14, 40:15, 41:15, 203:15, 204:15, 205:15, 32768:15, 32769:20}
 455    def __get__(self, obj, objtype=None):
 456        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
 457    def __set__(self, obj, value):
 458        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
 459
 460class LatitudeCenterGridpoint:
 461    """Latitude of center gridpoint"""
 462    _key = {32768:14, 32769:14}
 463    def __get__(self, obj, objtype=None):
 464        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
 465    def __set__(self, obj, value):
 466        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
 467
 468class LongitudeCenterGridpoint:
 469    """Longitude of center gridpoint"""
 470    _key = {32768:15, 32769:15}
 471    def __get__(self, obj, objtype=None):
 472        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
 473    def __set__(self, obj, value):
 474        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
 475
 476class GridlengthXDirection:
 477    """Grid lenth in the X-Direction"""
 478    _key = {0:16, 1:16, 10:17, 20:14, 30:14, 31:14, 40:16, 41:16, 203:16, 204:16, 205:16, 32768:16, 32769:16}
 479    def __get__(self, obj, objtype=None):
 480        return (obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._xydivisor)*obj._dxsign
 481    def __set__(self, obj, value):
 482        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._xydivisor/obj._llscalefactor)
 483
 484class GridlengthYDirection:
 485    """Grid lenth in the Y-Direction"""
 486    _key = {0:17, 1:17, 10:18, 20:15, 30:15, 31:15, 40:17, 41:17, 203:17, 204:17, 205:17, 32768:17, 32769:17}
 487    def __get__(self, obj, objtype=None):
 488        return (obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._xydivisor)*obj._dysign
 489    def __set__(self, obj, value):
 490        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._xydivisor/obj._llscalefactor)
 491
 492class LatitudeSouthernPole:
 493    """Latitude of the Southern Pole for a Rotated Lat/Lon Grid"""
 494    _key = {1:19, 30:20, 31:20, 41:19}
 495    def __get__(self, obj, objtype=None):
 496        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
 497    def __set__(self, obj, value):
 498        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
 499
 500class LongitudeSouthernPole:
 501    """Longitude of the Southern Pole for a Rotated Lat/Lon Grid"""
 502    _key = {1:20, 30:21, 31:21, 41:20}
 503    def __get__(self, obj, objtype=None):
 504        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
 505    def __set__(self, obj, value):
 506        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
 507
 508class AnglePoleRotation:
 509    """Angle of Pole Rotation for a Rotated Lat/Lon Grid"""
 510    _key = {1:21, 41:21}
 511    def __get__(self, obj, objtype=None):
 512        return obj.section3[self._key[obj.gdtn]+5]
 513    def __set__(self, obj, value):
 514        obj.section3[self._key[obj.gdtn]+5] = int(value)
 515
 516class LatitudeTrueScale:
 517    """Latitude at which grid lengths are specified"""
 518    _key = {10:12, 20:12, 30:12, 31:12}
 519    def __get__(self, obj, objtype=None):
 520        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
 521    def __set__(self, obj, value):
 522        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
 523
 524class GridOrientation:
 525    """Longitude at which the grid is oriented"""
 526    _key = {10:16, 20:13, 30:13, 31:13}
 527    def __get__(self, obj, objtype=None):
 528        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
 529    def __set__(self, obj, value):
 530        if obj.gdtn == 10 and (value < 0 or value > 90):
 531            raise ValueError("Grid orientation is limited to range of 0 to 90 degrees.")
 532        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
 533
 534class ProjectionCenterFlag:
 535    """[Projection Center](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-5.shtml)"""
 536    _key = {20:16, 30:16, 31:16}
 537    def __get__(self, obj, objtype=None):
 538        return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list)[0]
 539    def __set__(self, obj, value):
 540        obj.section3[self._key[obj.gdtn]+5] = value
 541
 542class StandardLatitude1:
 543    """First Standard Latitude (from the pole at which the secant cone cuts the sphere)"""
 544    _key = {30:18, 31:18}
 545    def __get__(self, obj, objtype=None):
 546        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
 547    def __set__(self, obj, value):
 548        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
 549
 550class StandardLatitude2:
 551    """Second Standard Latitude (from the pole at which the secant cone cuts the sphere)"""
 552    _key = {30:19, 31:19}
 553    def __get__(self, obj, objtype=None):
 554        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
 555    def __set__(self, obj, value):
 556        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
 557
 558class SpectralFunctionParameters:
 559    """Spectral Function Parameters"""
 560    def __get__(self, obj, objtype=None):
 561        return obj.section3[0:3]
 562    def __set__(self, obj, value):
 563        obj.section3[0:3] = value[0:3]
 564
 565class ProjParameters:
 566    """PROJ Parameters to define the reference system"""
 567    def __get__(self, obj, objtype=None):
 568        projparams = {}
 569        projparams['a'] = 1.0
 570        projparams['b'] = 1.0
 571        if obj.earthRadius is not None:
 572            projparams['a'] = obj.earthRadius
 573            projparams['b'] = obj.earthRadius
 574        else:
 575            if obj.earthMajorAxis is not None: projparams['a'] = obj.earthMajorAxis
 576            if obj.earthMajorAxis is not None: projparams['b'] = obj.earthMinorAxis
 577        if obj.gdtn == 0:
 578            projparams['proj'] = 'longlat'
 579        elif obj.gdtn == 1:
 580            projparams['o_proj'] = 'longlat'
 581            projparams['proj'] = 'ob_tran'
 582            projparams['o_lat_p'] = -1.0*obj.latitudeSouthernPole
 583            projparams['o_lon_p'] = obj.anglePoleRotation
 584            projparams['lon_0'] = obj.longitudeSouthernPole
 585        elif obj.gdtn == 10:
 586            projparams['proj'] = 'merc'
 587            projparams['lat_ts'] = obj.latitudeTrueScale
 588            projparams['lon_0'] = 0.5*(obj.longitudeFirstGridpoint+obj.longitudeLastGridpoint)
 589        elif obj.gdtn == 20:
 590            if obj.projectionCenterFlag == 0:
 591                lat0 = 90.0
 592            elif obj.projectionCenterFlag == 1:
 593                lat0 = -90.0
 594            projparams['proj'] = 'stere'
 595            projparams['lat_ts'] = obj.latitudeTrueScale
 596            projparams['lat_0'] = lat0
 597            projparams['lon_0'] = obj.gridOrientation
 598        elif obj.gdtn == 30:
 599            projparams['proj'] = 'lcc'
 600            projparams['lat_1'] = obj.standardLatitude1
 601            projparams['lat_2'] = obj.standardLatitude2
 602            projparams['lat_0'] = obj.latitudeTrueScale
 603            projparams['lon_0'] = obj.gridOrientation
 604        elif obj.gdtn == 31:
 605            projparams['proj'] = 'aea'
 606            projparams['lat_1'] = obj.standardLatitude1
 607            projparams['lat_2'] = obj.standardLatitude2
 608            projparams['lat_0'] = obj.latitudeTrueScale
 609            projparams['lon_0'] = obj.gridOrientation
 610        elif obj.gdtn == 40:
 611            projparams['proj'] = 'eqc'
 612        elif obj.gdtn == 32769:
 613            projparams['proj'] = 'aeqd'
 614            projparams['lon_0'] = obj.longitudeCenterGridpoint
 615            projparams['lat_0'] = obj.latitudeCenterGridpoint
 616        return projparams
 617    def __set__(self, obj, value):
 618        raise RuntimeError
 619
 620@dataclass(init=False)
 621class GridDefinitionTemplate0():
 622    """[Grid Definition Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-0.shtml)"""
 623    _len = 19
 624    _num = 0
 625    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
 626    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
 627    latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint())
 628    longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint())
 629    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
 630    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
 631    @classmethod
 632    @property
 633    def _attrs(cls):
 634        return list(cls.__dataclass_fields__.keys())
 635
 636@dataclass(init=False)
 637class GridDefinitionTemplate1():
 638    """[Grid Definition Template 1](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-1.shtml)"""
 639    _len = 22
 640    _num = 1
 641    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
 642    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
 643    latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint())
 644    longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint())
 645    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
 646    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
 647    latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole())
 648    longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole())
 649    anglePoleRotation: float = field(init=False, repr=False, default=AnglePoleRotation())
 650    @classmethod
 651    @property
 652    def _attrs(cls):
 653        return list(cls.__dataclass_fields__.keys())
 654
 655@dataclass(init=False)
 656class GridDefinitionTemplate10():
 657    """[Grid Definition Template 10](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-10.shtml)"""
 658    _len = 19
 659    _num = 10
 660    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
 661    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
 662    latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale())
 663    latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint())
 664    longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint())
 665    gridOrientation: float = field(init=False, repr=False, default=GridOrientation())
 666    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
 667    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
 668    projParameters: dict = field(init=False, repr=False, default=ProjParameters())
 669    @classmethod
 670    @property
 671    def _attrs(cls):
 672        return list(cls.__dataclass_fields__.keys())
 673
 674@dataclass(init=False)
 675class GridDefinitionTemplate20():
 676    """[Grid Definition Template 20](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-20.shtml)"""
 677    _len = 18
 678    _num = 20
 679    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
 680    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
 681    latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale())
 682    gridOrientation: float = field(init=False, repr=False, default=GridOrientation())
 683    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
 684    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
 685    projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag())
 686    projParameters: dict = field(init=False, repr=False, default=ProjParameters())
 687    @classmethod
 688    @property
 689    def _attrs(cls):
 690        return list(cls.__dataclass_fields__.keys())
 691
 692@dataclass(init=False)
 693class GridDefinitionTemplate30():
 694    """[Grid Definition Template 30](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-30.shtml)"""
 695    _len = 22
 696    _num = 30
 697    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
 698    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
 699    latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale())
 700    gridOrientation: float = field(init=False, repr=False, default=GridOrientation())
 701    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
 702    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
 703    projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag())
 704    standardLatitude1: float = field(init=False, repr=False, default=StandardLatitude1())
 705    standardLatitude2: float = field(init=False, repr=False, default=StandardLatitude2())
 706    latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole())
 707    longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole())
 708    projParameters: dict = field(init=False, repr=False, default=ProjParameters())
 709    @classmethod
 710    @property
 711    def _attrs(cls):
 712        return list(cls.__dataclass_fields__.keys())
 713
 714@dataclass(init=False)
 715class GridDefinitionTemplate31():
 716    """[Grid Definition Template 31](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-31.shtml)"""
 717    _len = 22
 718    _num = 31
 719    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
 720    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
 721    latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale())
 722    gridOrientation: float = field(init=False, repr=False, default=GridOrientation())
 723    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
 724    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
 725    projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag())
 726    standardLatitude1: float = field(init=False, repr=False, default=StandardLatitude1())
 727    standardLatitude2: float = field(init=False, repr=False, default=StandardLatitude2())
 728    latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole())
 729    longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole())
 730    @classmethod
 731    @property
 732    def _attrs(cls):
 733        return list(cls.__dataclass_fields__.keys())
 734
 735@dataclass(init=False)
 736class GridDefinitionTemplate40():
 737    """[Grid Definition Template 40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-40.shtml)"""
 738    _len = 19
 739    _num = 40
 740    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
 741    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
 742    latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint())
 743    longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint())
 744    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
 745    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
 746    @classmethod
 747    @property
 748    def _attrs(cls):
 749        return list(cls.__dataclass_fields__.keys())
 750
 751@dataclass(init=False)
 752class GridDefinitionTemplate41():
 753    """[Grid Definition Template 41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-41.shtml)"""
 754    _len = 22
 755    _num = 41
 756    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
 757    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
 758    latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint())
 759    longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint())
 760    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
 761    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
 762    latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole())
 763    longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole())
 764    anglePoleRotation: float = field(init=False, repr=False, default=AnglePoleRotation())
 765    @classmethod
 766    @property
 767    def _attrs(cls):
 768        return list(cls.__dataclass_fields__.keys())
 769
 770@dataclass(init=False)
 771class GridDefinitionTemplate50():
 772    """[Grid Definition Template 50](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-50.shtml)"""
 773    _len = 5
 774    _num = 50
 775    spectralFunctionParameters: list = field(init=False, repr=False, default=SpectralFunctionParameters())
 776    @classmethod
 777    @property
 778    def _attrs(cls):
 779        return list(cls.__dataclass_fields__.keys())
 780
 781@dataclass(init=False)
 782class GridDefinitionTemplate32768():
 783    """[Grid Definition Template 32768](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32768.shtml)"""
 784    _len = 19
 785    _num = 32768
 786    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
 787    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
 788    latitudeCenterGridpoint: float = field(init=False, repr=False, default=LatitudeCenterGridpoint())
 789    longitudeCenterGridpoint: float = field(init=False, repr=False, default=LongitudeCenterGridpoint())
 790    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
 791    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
 792    @classmethod
 793    @property
 794    def _attrs(cls):
 795        return list(cls.__dataclass_fields__.keys())
 796
 797@dataclass(init=False)
 798class GridDefinitionTemplate32769():
 799    """[Grid Definition Template 32769](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32769.shtml)"""
 800    _len = 19
 801    _num = 32769
 802    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
 803    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
 804    latitudeCenterGridpoint: float = field(init=False, repr=False, default=LatitudeCenterGridpoint())
 805    longitudeCenterGridpoint: float = field(init=False, repr=False, default=LongitudeCenterGridpoint())
 806    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
 807    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
 808    latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint())
 809    longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint())
 810    @classmethod
 811    @property
 812    def _attrs(cls):
 813        return list(cls.__dataclass_fields__.keys())
 814
 815_gdt_by_gdtn = {0: GridDefinitionTemplate0,
 816    1: GridDefinitionTemplate1,
 817    10: GridDefinitionTemplate10,
 818    20: GridDefinitionTemplate20,
 819    30: GridDefinitionTemplate30,
 820    31: GridDefinitionTemplate31,
 821    40: GridDefinitionTemplate40,
 822    41: GridDefinitionTemplate41,
 823    50: GridDefinitionTemplate50,
 824    32768: GridDefinitionTemplate32768,
 825    32769: GridDefinitionTemplate32769,
 826    }
 827
 828def gdt_class_by_gdtn(gdtn):
 829    """
 830    Provides a Grid Definition Template class via the template number
 831
 832    Parameters
 833    ----------
 834    **`gdtn : int`**
 835        Grid definition template number.
 836
 837    Returns
 838    -------
 839    Grid definition template class object (not an instance).
 840    """
 841    return _gdt_by_gdtn[gdtn]
 842
 843# ----------------------------------------------------------------------------------------
 844# Descriptor Classes for Section 4 metadata.
 845# ----------------------------------------------------------------------------------------
 846class ProductDefinitionTemplateNumber:
 847    """[Product Definition Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-0.shtml)"""
 848    def __get__(self, obj, objtype=None):
 849        return Grib2Metadata(obj.section4[1],table='4.0')
 850    def __set__(self, obj, value):
 851        raise RuntimeError
 852
 853#  since PDT begins at position 2 of section4, code written with +2 for added readability with grib2 documentation
 854class ProductDefinitionTemplate:
 855    """Product Definition Template"""
 856    def __get__(self, obj, objtype=None):
 857        return obj.section4[2:]
 858    def __set__(self, obj, value):
 859        raise RuntimeError
 860
 861class ParameterCategory:
 862    """[Parameter Category](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-1.shtml)"""
 863    _key = defaultdict(lambda: 0)
 864    def __get__(self, obj, objtype=None):
 865        return obj.section4[0+2]
 866    def __set__(self, obj, value):
 867        obj.section4[self._key[obj.pdtn]+2] = value
 868
 869class ParameterNumber:
 870    """[Parameter Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-2.shtml)"""
 871    _key = defaultdict(lambda: 1)
 872    def __get__(self, obj, objtype=None):
 873        return obj.section4[1+2]
 874    def __set__(self, obj, value):
 875        obj.section4[self._key[obj.pdtn]+2] = value
 876
 877class VarInfo:
 878    """
 879    Variable Information.  These are the metadata returned for a specific variable according
 880    to discipline, parameter category, and parameter number.
 881    """ 
 882    def __get__(self, obj, objtype=None):
 883        return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)
 884    def __set__(self, obj, value):
 885        raise RuntimeError
 886
 887class FullName:
 888    """Full name of the Variable"""
 889    def __get__(self, obj, objtype=None):
 890        return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[0]
 891    def __set__(self, obj, value):
 892        raise RuntimeError
 893
 894class Units:
 895    """Units of the Variable"""
 896    def __get__(self, obj, objtype=None):
 897        return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[1]
 898    def __set__(self, obj, value):
 899        raise RuntimeError
 900
 901class ShortName:
 902    """ Short name of the variable (i.e. the variable abbreviation)"""
 903    def __get__(self, obj, objtype=None):
 904        return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[2]
 905    def __set__(self, obj, value):
 906        raise RuntimeError
 907
 908class TypeOfGeneratingProcess:
 909    """[Type of Generating Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-3.shtml)"""
 910    _key = defaultdict(lambda: 2, {48:13})
 911    #_key = {0:2, 1:2, 2:2, 5:2, 6:2, 8:2, 9:2, 10:2, 11:2, 12:2, 15:2, 48:13}
 912    def __get__(self, obj, objtype=None):
 913        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.3')
 914    def __set__(self, obj, value):
 915        obj.section4[self._key[obj.pdtn]+2] = value
 916
 917class BackgroundGeneratingProcessIdentifier:
 918    """Background Generating Process Identifier"""
 919    _key = defaultdict(lambda: 3, {48:14})
 920    #_key = {0:3, 1:3, 2:3, 5:3, 6:3, 8:3, 9:3, 10:3, 11:3, 12:3, 15:3, 48:14}
 921    def __get__(self, obj, objtype=None):
 922        return obj.section4[self._key[obj.pdtn]+2]
 923    def __set__(self, obj, value):
 924        obj.section4[self._key[obj.pdtn]+2] = value
 925
 926class GeneratingProcess:
 927    """[Generating Process](https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablea.html)"""
 928    _key = defaultdict(lambda: 4, {48:15})
 929    #_key = {0:4, 1:4, 2:4, 5:4, 6:4, 8:4, 9:4, 10:4, 11:4, 12:4, 15:4, 48:15}
 930    def __get__(self, obj, objtype=None):
 931        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='generating_process')
 932    def __set__(self, obj, value):
 933        obj.section4[self._key[obj.pdtn]+2] = value
 934
 935class HoursAfterDataCutoff:
 936    """Hours of observational data cutoff after reference time"""
 937    _key = defaultdict(lambda: 5, {48:16})
 938    def __get__(self, obj, objtype=None):
 939        return obj.section4[self._key[obj.pdtn]+2]
 940    def __set__(self, obj, value):
 941        obj.section4[self._key[obj.pdtn]+2] = value
 942
 943class MinutesAfterDataCutoff:
 944    """Minutes of observational data cutoff after reference time"""
 945    _key = defaultdict(lambda: 6, {48:17})
 946    def __get__(self, obj, objtype=None):
 947        return obj.section4[self._key[obj.pdtn]+2]
 948    def __set__(self, obj, value):
 949        obj.section4[self._key[obj.pdtn]+2] = value
 950
 951class UnitOfForecastTime:
 952    """[Units of Forecast Time](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-4.shtml)"""
 953    _key = defaultdict(lambda: 7, {48:18})
 954    #_key = {0:7, 1:7, 2:7, 5:7, 6:7, 8:7, 9:7, 10:7, 11:7, 12:7, 15:7, 48:18}
 955    def __get__(self, obj, objtype=None):
 956        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.4')
 957    def __set__(self, obj, value):
 958        obj.section4[self._key[obj.pdtn]+2] = value
 959
 960class ValueOfForecastTime:
 961    """Value of forecast time in units defined by `UnitofForecastTime`"""
 962    _key = defaultdict(lambda: 8, {48:19})
 963    def __get__(self, obj, objtype=None):
 964        return obj.section4[self._key[obj.pdtn]+2]
 965    def __set__(self, obj, value):
 966        obj.section4[self._key[obj.pdtn]+2] = value
 967
 968class LeadTime:
 969    """Forecast Lead Time. NOTE: This is a `datetime.timedelta` object."""
 970    def __get__(self, obj, objtype=None):
 971        return utils.get_leadtime(obj.section1,obj.section4[1],
 972                                  obj.section4[2:])
 973    def __set__(self, obj, value):
 974        raise NotImplementedError
 975
 976class FixedSfc1Info:
 977    """Information of the first fixed surface via [table 4.5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)"""
 978    _key = defaultdict(lambda: 9, {48:20})
 979    #_key = {0:9, 1:9, 2:9, 5:9, 6:9, 8:9, 9:9, 10:9, 11:9, 12:9, 15:9, 48:20}
 980    def __get__(self, obj, objtype=None):
 981        if obj.section4[self._key[obj.pdtn]+2] == 255:
 982            return [None, None]
 983        return tables.get_value_from_table(obj.section4[self._key[obj.pdtn]+2],'4.5')
 984    def __set__(self, obj, value):
 985        raise NotImplementedError
 986
 987class FixedSfc2Info:
 988    """Information of the seconds fixed surface via [table 4.5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)"""
 989    _key = defaultdict(lambda: 12, {48:23})
 990    #_key = {0:12, 1:12, 2:12, 5:12, 6:12, 8:12, 9:12, 10:12, 11:12, 12:12, 15:12, 48:23}
 991    def __get__(self, obj, objtype=None):
 992        if obj.section4[self._key[obj.pdtn]+2] == 255:
 993            return [None, None]
 994        return tables.get_value_from_table(obj.section4[self._key[obj.pdtn]+2],'4.5')
 995    def __set__(self, obj, value):
 996        raise NotImplementedError
 997
 998class TypeOfFirstFixedSurface:
 999    """[Type of First Fixed Surface](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)"""
1000    _key = defaultdict(lambda: 9, {48:20})
1001    #_key = {0:9, 1:9, 2:9, 5:9, 6:9, 8:9, 9:9, 10:9, 11:9, 12:9, 15:9, 48:20}
1002    def __get__(self, obj, objtype=None):
1003        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.5')
1004    def __set__(self, obj, value):
1005        obj.section4[self._key[obj.pdtn]+2] = value
1006
1007class ScaleFactorOfFirstFixedSurface:
1008    """Scale Factor of First Fixed Surface"""
1009    _key = defaultdict(lambda: 10, {48:21})
1010    #_key = {0:10, 1:10, 2:10, 5:10, 6:10, 8:10, 9:10, 10:10, 11:10, 12:10, 15:10, 48:21}
1011    def __get__(self, obj, objtype=None):
1012        return obj.section4[self._key[obj.pdtn]+2]
1013    def __set__(self, obj, value):
1014        obj.section4[self._key[obj.pdtn]+2] = value
1015
1016class ScaledValueOfFirstFixedSurface:
1017    """Scaled Value Of First Fixed Surface"""
1018    _key = defaultdict(lambda: 11, {48:22})
1019    #_key = {0:11, 1:11, 2:11, 5:11, 6:11, 8:11, 9:11, 10:11, 11:11, 12:11, 15:11, 48:22}
1020    def __get__(self, obj, objtype=None):
1021        return obj.section4[self._key[obj.pdtn]+2]
1022    def __set__(self, obj, value):
1023        obj.section4[self._key[obj.pdtn]+2] = value
1024
1025class UnitOfFirstFixedSurface:
1026    """Units of First Fixed Surface"""
1027    def __get__(self, obj, objtype=None):
1028        return obj._fixedsfc1info[1]
1029    def __set__(self, obj, value):
1030        pass
1031
1032class ValueOfFirstFixedSurface:
1033    """Value of First Fixed Surface"""
1034    def __get__(self, obj, objtype=None):
1035        return obj.section4[ScaledValueOfFirstFixedSurface._key[obj.pdtn]+2]/\
1036                            (10.**obj.section4[ScaleFactorOfFirstFixedSurface._key[obj.pdtn]+2])
1037    def __set__(self, obj, value):
1038        pass
1039
1040class TypeOfSecondFixedSurface:
1041    """[Type of Second Fixed Surface](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)"""
1042    _key = defaultdict(lambda: 12, {48:23})
1043    #_key = {0:12, 1:12, 2:12, 5:12, 6:12, 8:12, 9:12, 10:12, 11:12, 12:12, 15:12, 48:23}
1044    def __get__(self, obj, objtype=None):
1045        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.5')
1046    def __set__(self, obj, value):
1047        obj.section4[self._key[obj.pdtn]+2] = value
1048
1049class ScaleFactorOfSecondFixedSurface:
1050    """Scale Factor of Second Fixed Surface"""
1051    _key = defaultdict(lambda: 13, {48:24})
1052    #_key = {0:13, 1:13, 2:13, 5:13, 6:13, 8:13, 9:13, 10:13, 11:13, 12:13, 15:13, 48:24}
1053    def __get__(self, obj, objtype=None):
1054        return obj.section4[self._key[obj.pdtn]+2]
1055    def __set__(self, obj, value):
1056        obj.section4[self._key[obj.pdtn]+2] = value
1057
1058class ScaledValueOfSecondFixedSurface:
1059    """Scaled Value Of Second Fixed Surface"""
1060    _key = defaultdict(lambda: 14, {48:25})
1061    #_key = {0:14, 1:14, 2:14, 5:14, 6:14, 8:14, 9:14, 10:14, 11:14, 12:14, 15:14, 48:25}
1062    def __get__(self, obj, objtype=None):
1063        return obj.section4[self._key[obj.pdtn]+2]
1064    def __set__(self, obj, value):
1065        obj.section4[self._key[obj.pdtn]+2] = value
1066
1067class UnitOfSecondFixedSurface:
1068    """Units of Second Fixed Surface"""
1069    def __get__(self, obj, objtype=None):
1070        return obj._fixedsfc2info[1]
1071    def __set__(self, obj, value):
1072        pass
1073
1074class ValueOfSecondFixedSurface:
1075    """Value of Second Fixed Surface"""
1076    def __get__(self, obj, objtype=None):
1077        return obj.section4[ScaledValueOfFirstFixedSurface._key[obj.pdtn]+2]/\
1078                            (10.**obj.section4[ScaleFactorOfFirstFixedSurface._key[obj.pdtn]+2])
1079    def __set__(self, obj, value):
1080        pass
1081
1082class Level:
1083    """Level (same as provided by [wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Level.c))"""
1084    def __get__(self, obj, objtype=None):
1085        return tables.get_wgrib2_level_string(obj.pdtn,obj.section4[2:])
1086    def __set__(self, obj, value):
1087        pass
1088
1089class TypeOfEnsembleForecast:
1090    """[Type of Ensemble Forecast](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-6.shtml)"""
1091    _key = {1:15, 11:15}
1092    def __get__(self, obj, objtype=None):
1093        pdtn = obj.section4[1]
1094        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.6')
1095    def __set__(self, obj, value):
1096        pdtn = obj.section4[1]
1097        obj.section4[self._key[pdtn]+2] = value
1098
1099class PerturbationNumber:
1100    """Ensemble Perturbation Number"""
1101    _key = {1:16, 11:16}
1102    def __get__(self, obj, objtype=None):
1103        pdtn = obj.section4[1]
1104        return obj.section4[self._key[pdtn]+2]
1105    def __set__(self, obj, value):
1106        pdtn = obj.section4[1]
1107        obj.section4[self._key[pdtn]+2] = value
1108
1109class NumberOfEnsembleForecasts:
1110    """Total Number of Ensemble Forecasts"""
1111    _key = {1:17, 2:16, 11:17, 12:16}
1112    def __get__(self, obj, objtype=None):
1113        pdtn = obj.section4[1]
1114        return obj.section4[self._key[pdtn]+2]
1115    def __set__(self, obj, value):
1116        pdtn = obj.section4[1]
1117        obj.section4[self._key[pdtn]+2] = value
1118
1119class TypeOfDerivedForecast:
1120    """[Type of Derived Forecast](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-7.shtml)"""
1121    _key = {2:15, 12:15}
1122    def __get__(self, obj, objtype=None):
1123        pdtn = obj.section4[1]
1124        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.7')
1125    def __set__(self, obj, value):
1126        pdtn = obj.section4[1]
1127        obj.section4[self._key[pdtn]+2] = value
1128
1129class ForecastProbabilityNumber:
1130    """Forecast Probability Number"""
1131    _key = {5:15, 9:15}
1132    def __get__(self, obj, objtype=None):
1133        pdtn = obj.section4[1]
1134        return obj.section4[self._key[pdtn]+2]
1135    def __set__(self, obj, value):
1136        pdtn = obj.section4[1]
1137        obj.section4[self._key[pdtn]+2] = value
1138
1139class TotalNumberOfForecastProbabilities:
1140    """Total Number of Forecast Probabilities"""
1141    _key = {5:16, 9:16}
1142    def __get__(self, obj, objtype=None):
1143        pdtn = obj.section4[1]
1144        return obj.section4[self._key[pdtn]+2]
1145    def __set__(self, obj, value):
1146        pdtn = obj.section4[1]
1147        obj.section4[self._key[pdtn]+2] = value
1148
1149class TypeOfProbability:
1150    """[Type of Probability](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-9.shtml)"""
1151    _key = {5:17, 9:17}
1152    def __get__(self, obj, objtype=None):
1153        pdtn = obj.section4[1]
1154        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.9')
1155    def __set__(self, obj, value):
1156        pdtn = obj.section4[1]
1157        obj.section4[self._key[pdtn]+2] = value
1158
1159class ScaleFactorOfThresholdLowerLimit:
1160    """Scale Factor of Threshold Lower Limit"""
1161    _key = {5:18, 9:18}
1162    def __get__(self, obj, objtype=None):
1163        pdtn = obj.section4[1]
1164        return obj.section4[self._key[pdtn]+2]
1165    def __set__(self, obj, value):
1166        pdtn = obj.section4[1]
1167        obj.section4[self._key[pdtn]+2] = value
1168
1169class ScaledValueOfThresholdLowerLimit:
1170    """Scaled Value of Threshold Lower Limit"""
1171    _key = {5:19, 9:19}
1172    def __get__(self, obj, objtype=None):
1173        pdtn = obj.section4[1]
1174        return obj.section4[self._key[pdtn]+2]
1175    def __set__(self, obj, value):
1176        pdtn = obj.section4[1]
1177        obj.section4[self._key[pdtn]+2] = value
1178
1179class ScaleFactorOfThresholdUpperLimit:
1180    """Scale Factor of Threshold Upper Limit"""
1181    _key = {5:20, 9:20}
1182    def __get__(self, obj, objtype=None):
1183        pdtn = obj.section4[1]
1184        return obj.section4[self._key[pdtn]+2]
1185    def __set__(self, obj, value):
1186        pdtn = obj.section4[1]
1187        obj.section4[self._key[pdtn]+2] = value
1188
1189class ScaledValueOfThresholdUpperLimit:
1190    """Scaled Value of Threshold Upper Limit"""
1191    _key = {5:21, 9:21}
1192    def __get__(self, obj, objtype=None):
1193        pdtn = obj.section4[1]
1194        return obj.section4[self._key[pdtn]+2]
1195    def __set__(self, obj, value):
1196        pdtn = obj.section4[1]
1197        obj.section4[self._key[pdtn]+2] = value
1198
1199class ThresholdLowerLimit:
1200    """Threshold Lower Limit"""
1201    def __get__(self, obj, objtype=None):
1202        if obj.section4[18+2] == -127 and \
1203           obj.section4[19+2] == 255:
1204            return 0.0
1205        else:
1206            return obj.section4[19+2]/(10.**obj.section4[18+2])
1207    def __set__(self, obj, value):
1208        pass
1209
1210class ThresholdUpperLimit:
1211    """Threshold Upper Limit"""
1212    def __get__(self, obj, objtype=None):
1213        if obj.section4[20+2] == -127 and \
1214           obj.section4[21+2] == 255:
1215            return 0.0
1216        else:
1217            return obj.section4[21+2]/(10.**obj.section4[20+2])
1218    def __set__(self, obj, value):
1219        pass
1220
1221class Threshold:
1222    """Threshold string (same as [wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Prob.c))"""
1223    def __get__(self, obj, objtype=None):
1224        return utils.get_wgrib2_prob_string(*obj.section4[17+2:22+2])
1225    def __set__(self, obj, value):
1226        pass
1227
1228class PercentileValue:
1229    """Percentile Value"""
1230    _key = {6:15, 10:15}
1231    def __get__(self, obj, objtype=None):
1232        pdtn = obj.section4[1]
1233        return obj.section4[self._key[pdtn]+2]
1234    def __set__(self, obj, value):
1235        pdtn = obj.section4[1]
1236        obj.section4[self._key[pdtn]+2] = value
1237
1238class YearOfEndOfTimePeriod:
1239    """Year of End of Forecast Time Period"""
1240    _key = {8:15, 9:22, 10:16, 11:18, 12:17}
1241    def __get__(self, obj, objtype=None):
1242        pdtn = obj.section4[1]
1243        return obj.section4[self._key[pdtn]+2]
1244    def __set__(self, obj, value):
1245        pdtn = obj.section4[1]
1246        obj.section4[self._key[pdtn]+2] = value
1247
1248class MonthOfEndOfTimePeriod:
1249    """Month Year of End of Forecast Time Period"""
1250    _key = {8:16, 9:23, 10:17, 11:19, 12:18}
1251    def __get__(self, obj, objtype=None):
1252        pdtn = obj.section4[1]
1253        return obj.section4[self._key[pdtn]+2]
1254    def __set__(self, obj, value):
1255        pdtn = obj.section4[1]
1256        obj.section4[self._key[pdtn]+2] = value
1257
1258class DayOfEndOfTimePeriod:
1259    """Day Year of End of Forecast Time Period"""
1260    _key = {8:17, 9:24, 10:18, 11:20, 12:19}
1261    def __get__(self, obj, objtype=None):
1262        pdtn = obj.section4[1]
1263        return obj.section4[self._key[pdtn]+2]
1264    def __set__(self, obj, value):
1265        pdtn = obj.section4[1]
1266        obj.section4[self._key[pdtn]+2] = value
1267
1268class HourOfEndOfTimePeriod:
1269    """Hour Year of End of Forecast Time Period"""
1270    _key = {8:18, 9:25, 10:19, 11:21, 12:20}
1271    def __get__(self, obj, objtype=None):
1272        pdtn = obj.section4[1]
1273        return obj.section4[self._key[pdtn]+2]
1274    def __set__(self, obj, value):
1275        pdtn = obj.section4[1]
1276        obj.section4[self._key[pdtn]+2] = value
1277
1278class MinuteOfEndOfTimePeriod:
1279    """Minute Year of End of Forecast Time Period"""
1280    _key = {8:19, 9:26, 10:20, 11:22, 12:21}
1281    def __get__(self, obj, objtype=None):
1282        pdtn = obj.section4[1]
1283        return obj.section4[self._key[pdtn]+2]
1284    def __set__(self, obj, value):
1285        pdtn = obj.section4[1]
1286        obj.section4[self._key[pdtn]+2] = value
1287
1288class SecondOfEndOfTimePeriod:
1289    """Second Year of End of Forecast Time Period"""
1290    _key = {8:20, 9:27, 10:21, 11:23, 12:22}
1291    def __get__(self, obj, objtype=None):
1292        pdtn = obj.section4[1]
1293        return obj.section4[self._key[pdtn]+2]
1294    def __set__(self, obj, value):
1295        pdtn = obj.section4[1]
1296        obj.section4[self._key[pdtn]+2] = value
1297
1298class Duration:
1299    """Duration of time period. NOTE: This is a `datetime.timedelta` object."""
1300    def __get__(self, obj, objtype=None):
1301        return utils.get_duration(obj.section4[1],obj.section4[2:])
1302    def __set__(self, obj, value):
1303        pass
1304
1305class ValidDate:
1306    """Valid Date of the forecast. NOTE: This is a `datetime.datetime` object."""
1307    _key = {8:slice(15,21), 9:slice(22,28), 10:slice(16,22), 11:slice(18,24), 12:slice(17,23)}
1308    def __get__(self, obj, objtype=None):
1309        pdtn = obj.section4[1]
1310        try:
1311            s = slice(self._key[pdtn].start+2,self._key[pdtn].stop+2)
1312            return datetime.datetime(*obj.section4[s])
1313        except(KeyError):
1314            return obj.refDate + obj.leadTime
1315    def __set__(self, obj, value):
1316        pass
1317
1318class NumberOfTimeRanges:
1319    """Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field"""
1320    _key = {8:21, 9:28, 10:22, 11:24, 12:23}
1321    def __get__(self, obj, objtype=None):
1322        pdtn = obj.section4[1]
1323        return obj.section4[self._key[pdtn]+2]
1324    def __set__(self, obj, value):
1325        pdtn = obj.section4[1]
1326        obj.section4[self._key[pdtn]+2] = value
1327
1328class NumberOfMissingValues:
1329    """Total number of data values missing in statistical process"""
1330    _key = {8:22, 9:29, 10:23, 11:25, 12:24}
1331    def __get__(self, obj, objtype=None):
1332        pdtn = obj.section4[1]
1333        return obj.section4[self._key[pdtn]+2]
1334    def __set__(self, obj, value):
1335        pdtn = obj.section4[1]
1336        obj.section4[self._key[pdtn]+2] = value
1337
1338class StatisticalProcess:
1339    """[Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-10.shtml)"""
1340    _key = {8:23, 9:30, 10:24, 11:26, 12:25, 15:15}
1341    def __get__(self, obj, objtype=None):
1342        pdtn = obj.section4[1]
1343        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.10')
1344    def __set__(self, obj, value):
1345        pdtn = obj.section4[1]
1346        obj.section4[self._key[pdtn]+2] = value
1347
1348class TypeOfTimeIncrementOfStatisticalProcess:
1349    """[Type of Time Increment of Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-11.shtml)"""
1350    _key = {8:24, 9:31, 10:25, 11:27, 12:26}
1351    def __get__(self, obj, objtype=None):
1352        pdtn = obj.section4[1]
1353        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.11')
1354    def __set__(self, obj, value):
1355        pdtn = obj.section4[1]
1356        obj.section4[self._key[pdtn]+2] = value
1357
1358class UnitOfTimeRangeOfStatisticalProcess:
1359    """[Unit of Time Range of Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-11.shtml)"""
1360    _key = {8:25, 9:32, 10:26, 11:28, 12:27}
1361    def __get__(self, obj, objtype=None):
1362        pdtn = obj.section4[1]
1363        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.4')
1364    def __set__(self, obj, value):
1365        pdtn = obj.section4[1]
1366        obj.section4[self._key[pdtn]+2] = value
1367
1368class TimeRangeOfStatisticalProcess:
1369    """Time Range of Statistical Process"""
1370    _key = {8:26, 9:33, 10:27, 11:29, 12:28}
1371    def __get__(self, obj, objtype=None):
1372        pdtn = obj.section4[1]
1373        return obj.section4[self._key[pdtn]+2]
1374    def __set__(self, obj, value):
1375        pdtn = obj.section4[1]
1376        obj.section4[self._key[pdtn]+2] = value
1377
1378class UnitOfTimeRangeOfSuccessiveFields:
1379    """[Unit of Time Range of Successive Fields](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-4.shtml)"""
1380    _key = {8:27, 9:34, 10:28, 11:30, 12:29}
1381    def __get__(self, obj, objtype=None):
1382        pdtn = obj.section4[1]
1383        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.4')
1384    def __set__(self, obj, value):
1385        pdtn = obj.section4[1]
1386        obj.section4[self._key[pdtn]+2] = value
1387
1388class TimeIncrementOfSuccessiveFields:
1389    """Time Increment of Successive Fields"""
1390    _key = {8:28, 9:35, 10:29, 11:31, 12:30}
1391    def __get__(self, obj, objtype=None):
1392        pdtn = obj.section4[1]
1393        return obj.section4[self._key[pdtn]+2]
1394    def __set__(self, obj, value):
1395        pdtn = obj.section4[1]
1396        obj.section4[self._key[pdtn]+2] = value
1397
1398class TypeOfStatisticalProcessing:
1399    """[Type of Statistical Processing](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-15.shtml)"""
1400    _key = {15:16}
1401    def __get__(self, obj, objtype=None):
1402        pdtn = obj.section4[1]
1403        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.15')
1404    def __set__(self, obj, value):
1405        pdtn = obj.section4[1]
1406        obj.section4[self._key[pdtn]+2] = value
1407
1408class NumberOfDataPointsForSpatialProcessing:
1409    """Number of Data Points for Spatial Processing"""
1410    _key = {15:17}
1411    def __get__(self, obj, objtype=None):
1412        pdtn = obj.section4[1]
1413        return obj.section4[self._key[pdtn]+2]
1414    def __set__(self, obj, value):
1415        pdtn = obj.section4[1]
1416        obj.section4[self._key[pdtn]+2] = value
1417
1418class TypeOfAerosol:
1419    """[Type of Aerosol](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-233.shtml)"""
1420    _key = {48:2}
1421    def __get__(self, obj, objtype=None):
1422        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.233')
1423    def __set__(self, obj, value):
1424        obj.section4[self._key[obj.pdtn]+2] = value
1425
1426class TypeOfIntervalForAerosolSize:
1427    """[Type of Interval for Aerosol Size](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-91.shtml)"""
1428    _key = {48:3}
1429    def __get__(self, obj, objtype=None):
1430        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.91')
1431    def __set__(self, obj, value):
1432        obj.section4[self._key[obj.pdtn]+2] = value
1433
1434class ScaleFactorOfFirstSize:
1435    """Scale Factor of First Size"""
1436    _key = {48:4}
1437    def __get__(self, obj, objtype=None):
1438        return obj.section4[self._key[obj.pdtn]+2]
1439    def __set__(self, obj, value):
1440        obj.section4[self._key[obj.pdtn]+2] = value
1441
1442class ScaledValueOfFirstSize:
1443    """Scaled Value of First Size"""
1444    _key = {48:5}
1445    def __get__(self, obj, objtype=None):
1446        return obj.section4[self._key[obj.pdtn]+2]
1447    def __set__(self, obj, value):
1448        obj.section4[self._key[obj.pdtn]+2] = value
1449
1450class ScaleFactorOfSecondSize:
1451    """Scale Factor of Second Size"""
1452    _key = {48:6}
1453    def __get__(self, obj, objtype=None):
1454        return obj.section4[self._key[obj.pdtn]+2]
1455    def __set__(self, obj, value):
1456        obj.section4[self._key[obj.pdtn]+2] = value
1457
1458class ScaledValueOfSecondSize:
1459    """Scaled Value of Second Size"""
1460    _key = {48:7}
1461    def __get__(self, obj, objtype=None):
1462        return obj.section4[self._key[obj.pdtn]+2]
1463    def __set__(self, obj, value):
1464        obj.section4[self._key[obj.pdtn]+2] = value
1465
1466class TypeOfIntervalForAerosolWavelength:
1467    """[Type of Interval for Aerosol Wavelength](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-91.shtml)"""
1468    _key = {48:8}
1469    def __get__(self, obj, objtype=None):
1470        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.91')
1471    def __set__(self, obj, value):
1472        obj.section4[self._key[obj.pdtn]+2] = value
1473
1474class ScaleFactorOfFirstWavelength:
1475    """Scale Factor of First Wavelength"""
1476    _key = {48:9}
1477    def __get__(self, obj, objtype=None):
1478        return obj.section4[self._key[obj.pdtn]+2]
1479    def __set__(self, obj, value):
1480        obj.section4[self._key[obj.pdtn]+2] = value
1481
1482class ScaledValueOfFirstWavelength:
1483    """Scaled Value of First Wavelength"""
1484    _key = {48:10}
1485    def __get__(self, obj, objtype=None):
1486        return obj.section4[self._key[obj.pdtn]+2]
1487    def __set__(self, obj, value):
1488        obj.section4[self._key[obj.pdtn]+2] = value
1489
1490class ScaleFactorOfSecondWavelength:
1491    """Scale Factor of Second Wavelength"""
1492    _key = {48:11}
1493    def __get__(self, obj, objtype=None):
1494        return obj.section4[self._key[obj.pdtn]+2]
1495    def __set__(self, obj, value):
1496        obj.section4[self._key[obj.pdtn]+2] = value
1497
1498class ScaledValueOfSecondWavelength:
1499    """Scaled Value of Second Wavelength"""
1500    _key = {48:12}
1501    def __get__(self, obj, objtype=None):
1502        return obj.section4[self._key[obj.pdtn]+2]
1503    def __set__(self, obj, value):
1504        obj.section4[self._key[obj.pdtn]+2] = value
1505
1506@dataclass(init=False)
1507class ProductDefinitionTemplate0():
1508    """[Product Definition Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-0.shtml)"""
1509    _len = 15
1510    _num = 0
1511    parameterCategory: int = field(init=False,repr=False,default=ParameterCategory())
1512    parameterNumber: int = field(init=False,repr=False,default=ParameterNumber())
1513    typeOfGeneratingProcess: Grib2Metadata = field(init=False,repr=False,default=TypeOfGeneratingProcess())
1514    generatingProcess: Grib2Metadata = field(init=False, repr=False, default=GeneratingProcess())
1515    backgroundGeneratingProcessIdentifier: int = field(init=False,repr=False,default=BackgroundGeneratingProcessIdentifier())
1516    hoursAfterDataCutoff: int = field(init=False,repr=False,default=HoursAfterDataCutoff())
1517    minutesAfterDataCutoff: int = field(init=False,repr=False,default=MinutesAfterDataCutoff())
1518    unitOfForecastTime: Grib2Metadata = field(init=False,repr=False,default=UnitOfForecastTime())
1519    valueOfForecastTime: int = field(init=False,repr=False,default=ValueOfForecastTime())
1520    typeOfFirstFixedSurface: Grib2Metadata = field(init=False,repr=False,default=TypeOfFirstFixedSurface())
1521    scaleFactorOfFirstFixedSurface: int = field(init=False,repr=False,default=ScaleFactorOfFirstFixedSurface())
1522    scaledValueOfFirstFixedSurface: int = field(init=False,repr=False,default=ScaledValueOfFirstFixedSurface())
1523    typeOfSecondFixedSurface: Grib2Metadata = field(init=False,repr=False,default=TypeOfSecondFixedSurface())
1524    scaleFactorOfSecondFixedSurface: int = field(init=False,repr=False,default=ScaleFactorOfSecondFixedSurface())
1525    scaledValueOfSecondFixedSurface: int = field(init=False,repr=False,default=ScaledValueOfSecondFixedSurface())
1526    @classmethod
1527    @property
1528    def _attrs(cls):
1529        return list(cls.__dataclass_fields__.keys())
1530
1531@dataclass(init=False)
1532class ProductDefinitionTemplate1(ProductDefinitionTemplate0):
1533    """[Product Definition Template 1](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-1.shtml)"""
1534    _len = 18
1535    _num = 1
1536    typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast())
1537    perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber())
1538    numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts())
1539    @classmethod
1540    @property
1541    def _attrs(cls):
1542        return list(cls.__dataclass_fields__.keys())
1543
1544@dataclass(init=False)
1545class ProductDefinitionTemplate2(ProductDefinitionTemplate0):
1546    """[Product Definition Template 2](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-2.shtml)"""
1547    _len = 17
1548    _num = 2
1549    typeOfDerivedForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfDerivedForecast())
1550    numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts())
1551    @classmethod
1552    @property
1553    def _attrs(cls):
1554        return list(cls.__dataclass_fields__.keys())
1555
1556@dataclass(init=False)
1557class ProductDefinitionTemplate5(ProductDefinitionTemplate0):
1558    """[Product Definition Template 5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-5.shtml)"""
1559    _len = 22
1560    _num = 5
1561    forecastProbabilityNumber: int = field(init=False, repr=False, default=ForecastProbabilityNumber())
1562    totalNumberOfForecastProbabilities: int = field(init=False, repr=False, default=TotalNumberOfForecastProbabilities())
1563    typeOfProbability: Grib2Metadata = field(init=False, repr=False, default=TypeOfProbability())
1564    scaleFactorOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdLowerLimit())
1565    scaledValueOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdLowerLimit())
1566    scaleFactorOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdUpperLimit())
1567    scaledValueOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdUpperLimit())
1568    thresholdLowerLimit: float = field(init=False, repr=False, default=ThresholdLowerLimit())
1569    thresholdUpperLimit: float = field(init=False, repr=False, default=ThresholdUpperLimit())
1570    threshold: str = field(init=False, repr=False, default=Threshold())
1571    @classmethod
1572    @property
1573    def _attrs(cls):
1574        return list(cls.__dataclass_fields__.keys())
1575
1576@dataclass(init=False)
1577class ProductDefinitionTemplate6(ProductDefinitionTemplate0):
1578    """[Product Definition Template 6](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-6.shtml)"""
1579    _len = 16
1580    _num = 6
1581    percentileValue: int = field(init=False, repr=False, default=PercentileValue())
1582    @classmethod
1583    @property
1584    def _attrs(cls):
1585        return list(cls.__dataclass_fields__.keys())
1586
1587@dataclass(init=False)
1588class ProductDefinitionTemplate8(ProductDefinitionTemplate0):
1589    """[Product Definition Template 8](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-8.shtml)"""
1590    _len = 29
1591    _num = 8
1592    yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod())
1593    monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod())
1594    dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod())
1595    hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod())
1596    minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod())
1597    secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod())
1598    numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges())
1599    numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues())
1600    statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess())
1601    typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess())
1602    unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess())
1603    timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess())
1604    unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields())
1605    timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields())
1606    @classmethod
1607    @property
1608    def _attrs(cls):
1609        return list(cls.__dataclass_fields__.keys())
1610
1611@dataclass(init=False)
1612class ProductDefinitionTemplate9(ProductDefinitionTemplate0):
1613    """[Product Definition Template 9](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-9.shtml)"""
1614    _len = 36
1615    _num = 9
1616    forecastProbabilityNumber: int = field(init=False, repr=False, default=ForecastProbabilityNumber())
1617    totalNumberOfForecastProbabilities: int = field(init=False, repr=False, default=TotalNumberOfForecastProbabilities())
1618    typeOfProbability: Grib2Metadata = field(init=False, repr=False, default=TypeOfProbability())
1619    scaleFactorOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdLowerLimit())
1620    scaledValueOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdLowerLimit())
1621    scaleFactorOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdUpperLimit())
1622    scaledValueOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdUpperLimit())
1623    thresholdLowerLimit: float = field(init=False, repr=False, default=ThresholdLowerLimit())
1624    thresholdUpperLimit: float = field(init=False, repr=False, default=ThresholdUpperLimit())
1625    threshold: str = field(init=False, repr=False, default=Threshold())
1626    yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod())
1627    monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod())
1628    dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod())
1629    hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod())
1630    minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod())
1631    secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod())
1632    numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges())
1633    numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues())
1634    statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess())
1635    typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess())
1636    unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess())
1637    timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess())
1638    unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields())
1639    timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields())
1640    @classmethod
1641    @property
1642    def _attrs(cls):
1643        return list(cls.__dataclass_fields__.keys())
1644
1645@dataclass(init=False)
1646class ProductDefinitionTemplate10(ProductDefinitionTemplate0):
1647    """[Product Definition Template 10](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-10.shtml)"""
1648    _len = 30
1649    _num = 10
1650    percentileValue: int = field(init=False, repr=False, default=PercentileValue())
1651    yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod())
1652    monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod())
1653    dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod())
1654    hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod())
1655    minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod())
1656    secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod())
1657    numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges())
1658    numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues())
1659    statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess())
1660    typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess())
1661    unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess())
1662    timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess())
1663    unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields())
1664    timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields())
1665    @classmethod
1666    @property
1667    def _attrs(cls):
1668        return list(cls.__dataclass_fields__.keys())
1669
1670@dataclass(init=False)
1671class ProductDefinitionTemplate11(ProductDefinitionTemplate0):
1672    """[Product Definition Template 11](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-11.shtml)"""
1673    _len = 32
1674    _num = 11
1675    typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast())
1676    perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber())
1677    numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts())
1678    yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod())
1679    monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod())
1680    dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod())
1681    hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod())
1682    minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod())
1683    secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod())
1684    numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges())
1685    numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues())
1686    statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess())
1687    typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess())
1688    unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess())
1689    timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess())
1690    unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields())
1691    timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields())
1692    @classmethod
1693    @property
1694    def _attrs(cls):
1695        return list(cls.__dataclass_fields__.keys())
1696
1697@dataclass(init=False)
1698class ProductDefinitionTemplate12(ProductDefinitionTemplate0):
1699    """[Product Definition Template 12](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-12.shtml)"""
1700    _len = 31
1701    _num = 12
1702    typeOfDerivedForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfDerivedForecast())
1703    numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts())
1704    yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod())
1705    monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod())
1706    dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod())
1707    hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod())
1708    minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod())
1709    secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod())
1710    numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges())
1711    numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues())
1712    statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess())
1713    typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess())
1714    unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess())
1715    timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess())
1716    unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields())
1717    timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields())
1718    @classmethod
1719    @property
1720    def _attrs(cls):
1721        return list(cls.__dataclass_fields__.keys())
1722
1723@dataclass(init=False)
1724class ProductDefinitionTemplate15(ProductDefinitionTemplate0):
1725    """[Product Definition Template 15](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-15.shtml)"""
1726    _len = 18
1727    _num = 15
1728    statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess())
1729    typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing())
1730    numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing())
1731    @classmethod
1732    @property
1733    def _attrs(cls):
1734        return list(cls.__dataclass_fields__.keys())
1735
1736@dataclass(init=False)
1737class ProductDefinitionTemplate48(ProductDefinitionTemplate0):
1738    """[Product Definition Template 48](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-48.shtml)"""
1739    _len = 26
1740    _num = 48
1741    typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol())
1742    typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize())
1743    scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize())
1744    scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize())
1745    scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize())
1746    scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize())
1747    typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength())
1748    scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength())
1749    scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength())
1750    scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength())
1751    scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength())
1752    @classmethod
1753    @property
1754    def _attrs(cls):
1755        return list(cls.__dataclass_fields__.keys())
1756
1757_pdt_by_pdtn = {
1758    0: ProductDefinitionTemplate0,
1759    1: ProductDefinitionTemplate1,
1760    2: ProductDefinitionTemplate2,
1761    5: ProductDefinitionTemplate5,
1762    6: ProductDefinitionTemplate6,
1763    8: ProductDefinitionTemplate8,
1764    9: ProductDefinitionTemplate9,
1765    10: ProductDefinitionTemplate10,
1766    11: ProductDefinitionTemplate11,
1767    12: ProductDefinitionTemplate12,
1768    15: ProductDefinitionTemplate15,
1769    48: ProductDefinitionTemplate48,
1770    }
1771
1772def pdt_class_by_pdtn(pdtn):
1773    """
1774    Provides a Product Definition Template class via the template number
1775
1776    Parameters
1777    ----------
1778    **`pdtn : int`**
1779        Product definition template number.
1780
1781    Returns
1782    -------
1783    Product definition template class object (not an instance).
1784    """
1785    return _pdt_by_pdtn[pdtn]
1786
1787# ----------------------------------------------------------------------------------------
1788# Descriptor Classes for Section 5 metadata.
1789# ----------------------------------------------------------------------------------------
1790class NumberOfPackedValues:
1791    """Number of Packed Values"""
1792    def __get__(self, obj, objtype=None):
1793        return obj.section5[0]
1794    def __set__(self, obj, value):
1795        pass
1796
1797class DataRepresentationTemplateNumber:
1798    """[Data Representation Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-0.shtml)"""
1799    def __get__(self, obj, objtype=None):
1800        return Grib2Metadata(obj.section5[1],table='5.0')
1801    def __set__(self, obj, value):
1802        pass
1803
1804class DataRepresentationTemplate:
1805    """Data Representation Template"""
1806    def __get__(self, obj, objtype=None):
1807        return obj.section5[2:]
1808    def __set__(self, obj, value):
1809        raise NotImplementedError
1810
1811class RefValue:
1812    """Reference Value (represented as an IEEE 32-bit floating point value)"""
1813    def __get__(self, obj, objtype=None):
1814        return utils.ieee_int_to_float(obj.section5[0+2])
1815    def __set__(self, obj, value):
1816        pass
1817
1818class BinScaleFactor:
1819    """Binary Scale Factor"""
1820    def __get__(self, obj, objtype=None):
1821        return obj.section5[1+2]
1822    def __set__(self, obj, value):
1823        obj.section5[1+2] = value
1824
1825class DecScaleFactor:
1826    """Decimal Scale Factor"""
1827    def __get__(self, obj, objtype=None):
1828        return obj.section5[2+2]
1829    def __set__(self, obj, value):
1830        obj.section5[2+2] = value
1831
1832class NBitsPacking:
1833    """Minimum number of bits for packing"""
1834    def __get__(self, obj, objtype=None):
1835        return obj.section5[3+2]
1836    def __set__(self, obj, value):
1837        obj.section5[3+2] = value
1838
1839class TypeOfValues:
1840    """[Type of Original Field Values](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-1.shtml)"""
1841    def __get__(self, obj, objtype=None):
1842        return Grib2Metadata(obj.section5[4+2],table='5.1')
1843    def __set__(self, obj, value):
1844        obj.section5[4+2] = value
1845
1846class GroupSplittingMethod:
1847    """[Group Splitting Method](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-4.shtml)"""
1848    def __get__(self, obj, objtype=None):
1849        return Grib2Metadata(obj.section5[5+2],table='5.4')
1850    def __set__(self, obj, value):
1851        obj.section5[5+2] = value
1852
1853class TypeOfMissingValueManagement:
1854    """[Type of Missing Value Management](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-5.shtml)"""
1855    def __get__(self, obj, objtype=None):
1856        return Grib2Metadata(obj.section5[6+2],table='5.5')
1857    def __set__(self, obj, value):
1858        obj.section5[6+2] = value
1859
1860class PriMissingValue:
1861    """Primary Missing Value"""
1862    def __get__(self, obj, objtype=None):
1863        if obj.typeOfValues == 0:
1864            return utils.ieee_int_to_float(obj.section5[7+2]) if obj.section5[6+2] in {1,2} and obj.section5[7+2] != 255 else None
1865        elif obj.typeOfValues == 1:
1866            return obj.section5[7+2] if obj.section5[6+2] in [1,2] else None
1867    def __set__(self, obj, value):
1868        if obj.typeOfValues == 0:
1869            obj.section5[7+2] = utils.ieee_float_to_int(value)
1870        elif self.typeOfValues == 1:
1871            obj.section5[7+2] = int(value)
1872        obj.section5[6+2] = 1
1873
1874class SecMissingValue:
1875    """Secondary Missing Value"""
1876    def __get__(self, obj, objtype=None):
1877        if obj.typeOfValues == 0:
1878            return utils.ieee_int_to_float(obj.section5[8+2]) if obj.section5[6+2] in {1,2} and obj.section5[8+2] != 255 else None
1879        elif obj.typeOfValues == 1:
1880            return obj.section5[8+2] if obj.section5[6+2] in {1,2} else None
1881    def __set__(self, obj, value):
1882        if obj.typeOfValues == 0:
1883            obj.section5[8+2] = utils.ieee_float_to_int(value)
1884        elif self.typeOfValues == 1:
1885            obj.section5[8+2] = int(value)
1886        obj.section5[6+2] = 2
1887
1888class NGroups:
1889    """Number of Groups"""
1890    def __get__(self, obj, objtype=None):
1891        return obj.section5[9+2]
1892    def __set__(self, obj, value):
1893        pass
1894
1895class RefGroupWidth:
1896    """Reference Group Width"""
1897    def __get__(self, obj, objtype=None):
1898        return obj.section5[10+2]
1899    def __set__(self, obj, value):
1900        pass
1901
1902class NBitsGroupWidth:
1903    """Number of bits for Group Width"""
1904    def __get__(self, obj, objtype=None):
1905        return obj.section5[11+2]
1906    def __set__(self, obj, value):
1907        pass
1908
1909class RefGroupLength:
1910    """Reference Group Length"""
1911    def __get__(self, obj, objtype=None):
1912        return obj.section5[12+2]
1913    def __set__(self, obj, value):
1914        pass
1915
1916class GroupLengthIncrement:
1917    """Group Length Increment"""
1918    def __get__(self, obj, objtype=None):
1919        return obj.section5[13+2]
1920    def __set__(self, obj, value):
1921        pass
1922
1923class LengthOfLastGroup:
1924    """Length of Last Group"""
1925    def __get__(self, obj, objtype=None):
1926        return obj.section5[14+2]
1927    def __set__(self, obj, value):
1928        pass
1929
1930class NBitsScaledGroupLength:
1931    """Number of bits of Scaled Group Length"""
1932    def __get__(self, obj, objtype=None):
1933        return obj.section5[15+2]
1934    def __set__(self, obj, value):
1935        pass
1936
1937class SpatialDifferenceOrder:
1938    """[Spatial Difference Order](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-6.shtml)"""
1939    def __get__(self, obj, objtype=None):
1940        return Grib2Metadata(obj.section5[16+2],table='5.6')
1941    def __set__(self, obj, value):
1942        obj.section5[16+2] = value
1943
1944class NBytesSpatialDifference:
1945    """Number of bytes for Spatial Differencing"""
1946    def __get__(self, obj, objtype=None):
1947        return obj.section5[17+2]
1948    def __set__(self, obj, value):
1949        pass
1950
1951class Precision:
1952    """[Precision for IEEE Floating Point Data](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-7.shtml)"""
1953    def __get__(self, obj, objtype=None):
1954        return Grib2Metadata(obj.section5[0+2],table='5.7')
1955    def __set__(self, obj, value):
1956        obj.section5[0+2] = value
1957
1958class TypeOfCompression:
1959    """[Type of Compression](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-40.shtml)"""
1960    def __get__(self, obj, objtype=None):
1961        return Grib2Metadata(obj.section5[5+2],table='5.40')
1962    def __set__(self, obj, value):
1963        obj.section5[5+2] = value
1964
1965class TargetCompressionRatio:
1966    """Target Compression Ratio"""
1967    def __get__(self, obj, objtype=None):
1968        return obj.section5[6+2]
1969    def __set__(self, obj, value):
1970        pass
1971
1972class RealOfCoefficient:
1973    """Real of Coefficient"""
1974    def __get__(self, obj, objtype=None):
1975        return utils.ieee_int_to_float(obj.section5[4+2])
1976    def __set__(self, obj, value):
1977        obj.section5[4+2] = utils.ieee_float_to_int(float(value))
1978
1979class CompressionOptionsMask:
1980    """Compression Options Mask for AEC/CCSDS"""
1981    def __get__(self, obj, objtype=None):
1982        return obj.section5[5+2]
1983    def __set__(self, obj, value):
1984        obj.section5[5+2] = value
1985
1986class BlockSize:
1987    """Block Size for AEC/CCSDS"""
1988    def __get__(self, obj, objtype=None):
1989        return obj.section5[6+2]
1990    def __set__(self, obj, value):
1991        obj.section5[6+2] = value
1992
1993class RefSampleInterval:
1994    """Reference Sample Interval for AEC/CCSDS"""
1995    def __get__(self, obj, objtype=None):
1996        return obj.section5[7+2]
1997    def __set__(self, obj, value):
1998        obj.section5[7+2] = value
1999
2000@dataclass(init=False)
2001class DataRepresentationTemplate0():
2002    """[Data Representation Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-0.shtml)"""
2003    _len = 5
2004    _num = 0
2005    _packingScheme = 'simple'
2006    refValue: float = field(init=False, repr=False, default=RefValue())
2007    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2008    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2009    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2010    @classmethod
2011    @property
2012    def _attrs(cls):
2013        return list(cls.__dataclass_fields__.keys())
2014
2015@dataclass(init=False)
2016class DataRepresentationTemplate2():
2017    """[Data Representation Template 2](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-2.shtml)"""
2018    _len = 16
2019    _num = 2
2020    _packingScheme = 'complex'
2021    refValue: float = field(init=False, repr=False, default=RefValue())
2022    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2023    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2024    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2025    groupSplittingMethod: Grib2Metadata = field(init=False, repr=False, default=GroupSplittingMethod())
2026    typeOfMissingValueManagement: Grib2Metadata = field(init=False, repr=False, default=TypeOfMissingValueManagement())
2027    priMissingValue: [float, int] = field(init=False, repr=False, default=PriMissingValue())
2028    secMissingValue: [float, int] = field(init=False, repr=False, default=SecMissingValue())
2029    nGroups: int = field(init=False, repr=False, default=NGroups())
2030    refGroupWidth: int = field(init=False, repr=False, default=RefGroupWidth())
2031    nBitsGroupWidth: int = field(init=False, repr=False, default=NBitsGroupWidth())
2032    refGroupLength: int = field(init=False, repr=False, default=RefGroupLength())
2033    groupLengthIncrement: int = field(init=False, repr=False, default=GroupLengthIncrement())
2034    lengthOfLastGroup: int = field(init=False, repr=False, default=LengthOfLastGroup())
2035    nBitsScaledGroupLength: int = field(init=False, repr=False, default=NBitsScaledGroupLength())
2036    @classmethod
2037    @property
2038    def _attrs(cls):
2039        return list(cls.__dataclass_fields__.keys())
2040
2041@dataclass(init=False)
2042class DataRepresentationTemplate3():
2043    """[Data Representation Template 3](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-3.shtml)"""
2044    _len = 18
2045    _num = 3
2046    _packingScheme = 'complex-spdiff'
2047    refValue: float = field(init=False, repr=False, default=RefValue())
2048    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2049    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2050    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2051    groupSplittingMethod: Grib2Metadata = field(init=False, repr=False, default=GroupSplittingMethod())
2052    typeOfMissingValueManagement: Grib2Metadata = field(init=False, repr=False, default=TypeOfMissingValueManagement())
2053    priMissingValue: [float, int] = field(init=False, repr=False, default=PriMissingValue())
2054    secMissingValue: [float, int] = field(init=False, repr=False, default=SecMissingValue())
2055    nGroups: int = field(init=False, repr=False, default=NGroups())
2056    refGroupWidth: int = field(init=False, repr=False, default=RefGroupWidth())
2057    nBitsGroupWidth: int = field(init=False, repr=False, default=NBitsGroupWidth())
2058    refGroupLength: int = field(init=False, repr=False, default=RefGroupLength())
2059    groupLengthIncrement: int = field(init=False, repr=False, default=GroupLengthIncrement())
2060    lengthOfLastGroup: int = field(init=False, repr=False, default=LengthOfLastGroup())
2061    nBitsScaledGroupLength: int = field(init=False, repr=False, default=NBitsScaledGroupLength())
2062    spatialDifferenceOrder: Grib2Metadata = field(init=False, repr=False, default=SpatialDifferenceOrder())
2063    nBytesSpatialDifference: int = field(init=False, repr=False, default=NBytesSpatialDifference())
2064    @classmethod
2065    @property
2066    def _attrs(cls):
2067        return list(cls.__dataclass_fields__.keys())
2068
2069@dataclass(init=False)
2070class DataRepresentationTemplate4():
2071    """[Data Representation Template 4](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-4.shtml)"""
2072    _len = 1
2073    _num = 4
2074    _packingScheme = 'ieee-float'
2075    precision: Grib2Metadata = field(init=False, repr=False, default=Precision())
2076    @classmethod
2077    @property
2078    def _attrs(cls):
2079        return list(cls.__dataclass_fields__.keys())
2080
2081@dataclass(init=False)
2082class DataRepresentationTemplate40():
2083    """[Data Representation Template 40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-40.shtml)"""
2084    _len = 7
2085    _num = 40
2086    _packingScheme = 'jpeg'
2087    refValue: float = field(init=False, repr=False, default=RefValue())
2088    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2089    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2090    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2091    typeOfCompression: Grib2Metadata = field(init=False, repr=False, default=TypeOfCompression())
2092    targetCompressionRatio: int = field(init=False, repr=False, default=TargetCompressionRatio())
2093    @classmethod
2094    @property
2095    def _attrs(cls):
2096        return list(cls.__dataclass_fields__.keys())
2097
2098@dataclass(init=False)
2099class DataRepresentationTemplate41():
2100    """[Data Representation Template 41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-41.shtml)"""
2101    _len = 5
2102    _num = 41
2103    _packingScheme = 'png'
2104    refValue: float = field(init=False, repr=False, default=RefValue())
2105    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2106    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2107    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2108    @classmethod
2109    @property
2110    def _attrs(cls):
2111        return list(cls.__dataclass_fields__.keys())
2112
2113@dataclass(init=False)
2114class DataRepresentationTemplate42():
2115    """[Data Representation Template 42](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-42.shtml)"""
2116    _len = 8
2117    _num = 42
2118    _packingScheme = 'aec'
2119    refValue: float = field(init=False, repr=False, default=RefValue())
2120    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2121    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2122    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2123    compressionOptionsMask: int = field(init=False, repr=False, default=CompressionOptionsMask())
2124    blockSize: int = field(init=False, repr=False, default=BlockSize())
2125    refSampleInterval: int = field(init=False, repr=False, default=RefSampleInterval())
2126    @classmethod
2127    @property
2128    def _attrs(cls):
2129        return list(cls.__dataclass_fields__.keys())
2130
2131@dataclass(init=False)
2132class DataRepresentationTemplate50():
2133    """[Data Representation Template 50](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-50.shtml)"""
2134    _len = 5
2135    _num = 0
2136    _packingScheme = 'spectral-simple'
2137    refValue: float = field(init=False, repr=False, default=RefValue())
2138    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2139    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2140    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2141    realOfCoefficient: float = field(init=False, repr=False, default=RealOfCoefficient())
2142    @classmethod
2143    @property
2144    def _attrs(cls):
2145        return list(cls.__dataclass_fields__.keys())
2146
2147_drt_by_drtn = {
2148    0: DataRepresentationTemplate0,
2149    2: DataRepresentationTemplate2,
2150    3: DataRepresentationTemplate3,
2151    4: DataRepresentationTemplate4,
2152    40: DataRepresentationTemplate40,
2153    41: DataRepresentationTemplate41,
2154    42: DataRepresentationTemplate42,
2155    50: DataRepresentationTemplate50,
2156    }
2157
2158def drt_class_by_drtn(drtn):
2159    """
2160    Provides a Data Representation Template class via the template number
2161
2162    Parameters
2163    ----------
2164    **`drtn : int`**
2165        Data Representation template number.
2166
2167    Returns
2168    -------
2169    Data Representation template class object (not an instance).
2170    """
2171    return _drt_by_drtn[drtn]
class Grib2Metadata:
30class Grib2Metadata():
31    """
32    Class to hold GRIB2 metadata both as numeric code value as stored in
33    GRIB2 and its plain langauge definition.
34
35    Attributes
36    ----------
37    **`value : int`**
38        GRIB2 metadata integer code value.
39
40    **`table : str, optional`**
41        GRIB2 table to lookup the `value`. Default is None.
42
43    **`definition : str`**
44        Plain language description of numeric metadata.
45    """
46    __slots__ = ('value','table')
47    def __init__(self, value, table=None):
48        self.value = value
49        self.table = table
50    def __call__(self):
51        return self.value
52    def __hash__(self):
53        return hash(self.value)   # AS- added hash() to self.value as pandas was raising error about some non integer returns from hash method
54    def __repr__(self):
55        return f"{self.__class__.__name__}({self.value}, table = '{self.table}')"
56    def __str__(self):
57        return f'{self.value} - {self.definition}'
58    def __eq__(self,other):
59        return self.value == other or self.definition[0] == other
60    def __gt__(self,other):
61        return self.value > other
62    def __ge__(self,other):
63        return self.value >= other
64    def __lt__(self,other):
65        return self.value < other
66    def __le__(self,other):
67        return self.value <= other
68    def __contains__(self,other):
69        return other in self.definition
70    def __hash__(self):
71        return hash(self.value)
72    def __index__(self):
73        return int(self.value)
74    @property
75    def definition(self):
76        return tables.get_value_from_table(self.value,self.table)
77    def show_table(self):
78        """
79        Provide the table related to this metadata.
80        """
81        return tables.get_table(self.table)

Class to hold GRIB2 metadata both as numeric code value as stored in GRIB2 and its plain langauge definition.

Attributes

value : int GRIB2 metadata integer code value.

table : str, optional GRIB2 table to lookup the value. Default is None.

definition : str Plain language description of numeric metadata.

Grib2Metadata(value, table=None)
47    def __init__(self, value, table=None):
48        self.value = value
49        self.table = table
value
table
definition
def show_table(self):
77    def show_table(self):
78        """
79        Provide the table related to this metadata.
80        """
81        return tables.get_table(self.table)

Provide the table related to this metadata.

class IndicatorSection:
86class IndicatorSection:
87    """
88    [GRIB2 Indicator Section (0)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect0.shtml)
89    """
90    def __get__(self, obj, objtype=None):
91        return obj.section0
92    def __set__(self, obj, value):
93        obj.section0 = value
class Discipline:
 95class Discipline:
 96    """[Discipline](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table0-0.shtml)"""
 97    def __get__(self, obj, objtype=None):
 98        return Grib2Metadata(obj.indicatorSection[2],table='0.0')
 99    def __set__(self, obj, value):
100        obj.section0[2] = value
class IdentificationSection:
106class IdentificationSection:
107    """
108    GRIB2 Section 1, [Identification Section](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect1.shtml)
109    """
110    def __get__(self, obj, objtype=None):
111        return obj.section1
112    def __set__(self, obj, value):
113        obj.section1 = value

GRIB2 Section 1, Identification Section

class OriginatingCenter:
115class OriginatingCenter:
116    """[Originating Center](https://www.nco.ncep.noaa.gov/pmb/docs/on388/table0.html)"""
117    def __get__(self, obj, objtype=None):
118        return Grib2Metadata(obj.section1[0],table='originating_centers')
119    def __set__(self, obj, value):
120        obj.section1[0] = value
class OriginatingSubCenter:
122class OriginatingSubCenter:
123    """[Originating SubCenter](https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablec.html)"""
124    def __get__(self, obj, objtype=None):
125        return Grib2Metadata(obj.section1[1],table='originating_subcenters')
126    def __set__(self, obj, value):
127        obj.section1[1] = value
class MasterTableInfo:
129class MasterTableInfo:
130    """[GRIB2 Master Table Version](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-0.shtml)"""
131    def __get__(self, obj, objtype=None):
132        return Grib2Metadata(obj.section1[2],table='1.0')
133    def __set__(self, obj, value):
134        obj.section1[2] = value
class LocalTableInfo:
136class LocalTableInfo:
137    """[GRIB2 Local Tables Version Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-1.shtml)"""
138    def __get__(self, obj, objtype=None):
139        return Grib2Metadata(obj.section1[3],table='1.1')
140    def __set__(self, obj, value):
141        obj.section1[3] = value
class SignificanceOfReferenceTime:
143class SignificanceOfReferenceTime:
144    """[Significance of Reference Time](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-2.shtml)"""
145    def __get__(self, obj, objtype=None):
146        return Grib2Metadata(obj.section1[4],table='1.2')
147    def __set__(self, obj, value):
148        obj.section1[4] = value
class Year:
150class Year:
151    """Year of reference time"""
152    def __get__(self, obj, objtype=None):
153        return obj.section1[5]
154    def __set__(self, obj, value):
155        obj.section1[5] = value

Year of reference time

class Month:
157class Month:
158    """Month of reference time"""
159    def __get__(self, obj, objtype=None):
160        return obj.section1[6]
161    def __set__(self, obj, value):
162        obj.section1[6] = value

Month of reference time

class Day:
164class Day:
165    """Day of reference time"""
166    def __get__(self, obj, objtype=None):
167        return obj.section1[7]
168    def __set__(self, obj, value):
169        obj.section1[7] = value

Day of reference time

class Hour:
171class Hour:
172    """Hour of reference time"""
173    def __get__(self, obj, objtype=None):
174        return obj.section1[8]
175    def __set__(self, obj, value):
176        obj.section1[8] = value

Hour of reference time

class Minute:
178class Minute:
179    """Minute of reference time"""
180    def __get__(self, obj, objtype=None):
181        return obj.section1[9]
182    def __set__(self, obj, value):
183        obj.section1[9] = value

Minute of reference time

class Second:
185class Second:
186    """Second of reference time"""
187    def __get__(self, obj, objtype=None):
188        return obj.section1[10]
189    def __set__(self, obj, value):
190        obj.section1[10] = value

Second of reference time

class RefDate:
192class RefDate:
193    """Reference Date. NOTE: This is a `datetime.datetime` object."""
194    def __get__(self, obj, objtype=None):
195        return datetime.datetime(*obj.section1[5:11])
196    def __set__(self, obj, value):
197        if isinstance(value,datetime.datetime):
198            obj.section1[5] = value.year
199            obj.section1[6] = value.month
200            obj.section1[7] = value.day
201            obj.section1[8] = value.hour
202            obj.section1[9] = value.minute
203            obj.section1[10] = value.second
204        else:
205            msg = 'Reference date must be a datetime.datetime object.'
206            raise TypeError(msg)

Reference Date. NOTE: This is a datetime.datetime object.

class ProductionStatus:
208class ProductionStatus:
209    """[Production Status of Processed Data](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-3.shtml)"""
210    def __get__(self, obj, objtype=None):
211        return Grib2Metadata(obj.section1[11],table='1.3')
212    def __set__(self, obj, value):
213        obj.section1[11] = value
class TypeOfData:
215class TypeOfData:
216    """[Type of Processed Data in this GRIB message](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-4.shtml)"""
217    def __get__(self, obj, objtype=None):
218        return Grib2Metadata(obj.section1[12],table='1.4')
219    def __set__(self, obj, value):
220        obj.section1[12] = value
class GridDefinitionSection:
229class GridDefinitionSection:
230    """
231    GRIB2 Section 3, [Grid Definition Section](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml)
232    """
233    def __get__(self, obj, objtype=None):
234        return obj.section3[0:5]
235    def __set__(self, obj, value):
236        raise RuntimeError

GRIB2 Section 3, Grid Definition Section

class SourceOfGridDefinition:
238class SourceOfGridDefinition:
239    """[Source of Grid Definition](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-0.shtml)"""
240    def __get__(self, obj, objtype=None):
241        return Grib2Metadata(obj.section3[0],table='3.0')
242    def __set__(self, obj, value):
243        raise RuntimeError
class NumberOfDataPoints:
245class NumberOfDataPoints:
246    """Number of Data Points"""
247    def __get__(self, obj, objtype=None):
248        return obj.section3[1]
249    def __set__(self, obj, value):
250        raise RuntimeError

Number of Data Points

class InterpretationOfListOfNumbers:
252class InterpretationOfListOfNumbers:
253    """Interpretation of List of Numbers"""
254    def __get__(self, obj, objtype=None):
255        return Grib2Metadata(obj.section3[3],table='3.11')
256    def __set__(self, obj, value):
257        raise RuntimeError

Interpretation of List of Numbers

class GridDefinitionTemplateNumber:
259class GridDefinitionTemplateNumber:
260    """[Grid Definition Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-1.shtml)"""
261    def __get__(self, obj, objtype=None):
262        return Grib2Metadata(obj.section3[4],table='3.1')
263    def __set__(self, obj, value):
264        raise RuntimeError
class GridDefinitionTemplate:
266class GridDefinitionTemplate:
267    """Grid definition template"""
268    def __get__(self, obj, objtype=None):
269        return obj.section3[5:]
270    def __set__(self, obj, value):
271        raise RuntimeError

Grid definition template

class EarthParams:
273class EarthParams:
274    """Metadata about the shape of the Earth"""
275    def __get__(self, obj, objtype=None):
276        if obj.section3[5] in {50,51,52,1200}:
277            return None
278        return tables.get_table('earth_params')[str(obj.section3[5])]
279    def __set__(self, obj, value):
280        raise RuntimeError

Metadata about the shape of the Earth

class DxSign:
282class DxSign:
283    """Sign of Grid Length in X-Direction"""
284    def __get__(self, obj, objtype=None):
285        if obj.section3[4] in {0,1,203,205,32768,32769} and \
286        obj.section3[17] > obj.section3[20]:
287            return -1.0
288        return 1.0
289    def __set__(self, obj, value):
290        raise RuntimeError

Sign of Grid Length in X-Direction

class DySign:
292class DySign:
293    """Sign of Grid Length in Y-Direction"""
294    def __get__(self, obj, objtype=None):
295        if obj.section3[4] in {0,1,203,205,32768,32769} and \
296        obj.section3[16] > obj.section3[19]:
297            return -1.0
298        return 1.0
299    def __set__(self, obj, value):
300        raise RuntimeError

Sign of Grid Length in Y-Direction

class LLScaleFactor:
302class LLScaleFactor:
303    """Scale Factor for Lats/Lons"""
304    def __get__(self, obj, objtype=None):
305        if obj.section3[4] in {0,1,203,205,32768,32769}:
306            llscalefactor = float(obj.section3[14])
307            if llscalefactor == 0:
308                return 1
309            return llscalefactor
310        return 1
311    def __set__(self, obj, value):
312        raise RuntimeError

Scale Factor for Lats/Lons

class LLDivisor:
314class LLDivisor:
315    """Divisor Value for scaling Lats/Lons"""
316    def __get__(self, obj, objtype=None):
317        if obj.section3[4] in {0,1,203,205,32768,32769}:
318            lldivisor = float(obj.section3[15])
319            if lldivisor <= 0:
320                return 1.e6
321            return lldivisor
322        return 1.e6
323    def __set__(self, obj, value):
324        raise RuntimeError

Divisor Value for scaling Lats/Lons

class XYDivisor:
326class XYDivisor:
327    """Divisor Value for scaling grid lengths"""
328    def __get__(self, obj, objtype=None):
329        if obj.section3[4] in {0,1,203,205,32768,32769}:
330            return obj._lldivisor
331        return 1.e3
332    def __set__(self, obj, value):
333        raise RuntimeError

Divisor Value for scaling grid lengths

class ShapeOfEarth:
335class ShapeOfEarth:
336    """[Shape of the Reference System](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-2.shtml)"""
337    def __get__(self, obj, objtype=None):
338        return Grib2Metadata(obj.section3[5],table='3.2')
339    def __set__(self, obj, value):
340        obj.section3[5] = value
class EarthShape:
342class EarthShape:
343    """Description of the shape of the Earth"""
344    def __get__(self, obj, objtype=None):
345        return obj._earthparams['shape']
346    def __set__(self, obj, value):
347        raise RuntimeError

Description of the shape of the Earth

class EarthRadius:
349class EarthRadius:
350    """Radius of the Earth (Assumes "spherical")"""
351    def __get__(self, obj, objtype=None):
352        ep = obj._earthparams
353        if ep['shape'] == 'spherical':
354            if ep['radius'] is None:
355                return obj.section3[7]/(10.**obj.section3[6])
356            else:
357                return ep['radius']
358        elif ep['shape'] in {'ellipsoid','oblateSpheriod'}:
359            return None
360    def __set__(self, obj, value):
361        raise RuntimeError

Radius of the Earth (Assumes "spherical")

class EarthMajorAxis:
363class EarthMajorAxis:
364    """Major Axis of the Earth (Assumes "oblate spheroid" or "ellipsoid")"""
365    def __get__(self, obj, objtype=None):
366        ep = obj._earthparams
367        if ep['shape'] == 'spherical':
368            return None
369        elif ep['shape'] in {'ellipsoid','oblateSpheriod'}:
370            if ep['major_axis'] is None and ep['minor_axis'] is None:
371                return obj.section3[9]/(10.**obj.section3[8])
372            else:
373                return ep['major_axis']
374    def __set__(self, obj, value):
375        raise RuntimeError

Major Axis of the Earth (Assumes "oblate spheroid" or "ellipsoid")

class EarthMinorAxis:
377class EarthMinorAxis:
378    """Minor Axis of the Earth (Assumes "oblate spheroid" or "ellipsoid")"""
379    def __get__(self, obj, objtype=None):
380        ep = obj._earthparams
381        if ep['shape'] == 'spherical':
382            return None
383        if ep['shape'] in {'ellipsoid','oblateSpheriod'}:
384            if ep['major_axis'] is None and ep['minor_axis'] is None:
385                return obj.section3[11]/(10.**section3[10])
386            else:
387                return ep['minor_axis']
388    def __set__(self, obj, value):
389        raise RuntimeError

Minor Axis of the Earth (Assumes "oblate spheroid" or "ellipsoid")

class Nx:
391class Nx:
392    """Number of grid points in the X-direction (generally East-West)"""
393    def __get__(self, obj, objtype=None):
394        return obj.section3[12]
395    def __set__(self, obj, value):
396        obj.section3[12] = value
397        obj.section3[1] = value * obj.section3[13]

Number of grid points in the X-direction (generally East-West)

class Ny:
399class Ny:
400    """Number of grid points in the Y-direction (generally North-South)"""
401    def __get__(self, obj, objtype=None):
402        return obj.section3[13]
403    def __set__(self, obj, value):
404        obj.section3[13] = value
405        obj.section3[1] = value * obj.section3[12]

Number of grid points in the Y-direction (generally North-South)

class ScanModeFlags:
407class ScanModeFlags:
408    """[Scanning Mode](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-4.shtml)"""
409    _key = {0:18, 1:18, 10:15, 20:17, 30:17, 31:17, 40:18, 41:18, 90:16, 110:15, 203:18, 204:18, 205:18, 32768:18, 32769:18}
410    def __get__(self, obj, objtype=None):
411        if obj.gdtn == 50:
412            return [None, None, None, None]
413        else:
414            return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list)[0:8]
415    def __set__(self, obj, value):
416        obj.section3[self._key[obj.gdtn]+5] = value
class ResolutionAndComponentFlags:
418class ResolutionAndComponentFlags:
419    """[Resolution and Component Flags](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-3.shtml)"""
420    _key = {0:13, 1:13, 10:11, 20:11, 30:11, 31:11, 40:13, 41:13, 90:11, 110:11, 203:13, 204:13, 205:13, 32768:13, 32769:13}
421    def __get__(self, obj, objtype=None):
422        if obj.gdtn == 50:
423            return [None for i in range(8)]
424        else:
425            return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list)
426    def __set__(self, obj, value):
427        obj.section3[self._key[obj.gdtn]+5] = value
class LatitudeFirstGridpoint:
429class LatitudeFirstGridpoint:
430    """Latitude of first gridpoint"""
431    _key = {0:11, 1:11, 10:9, 20:9, 30:9, 31:9, 40:11, 41:11, 110:9, 203:11, 204:11, 205:11, 32768:11, 32769:11}
432    def __get__(self, obj, objtype=None):
433        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
434    def __set__(self, obj, value):
435        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)

Latitude of first gridpoint

class LongitudeFirstGridpoint:
437class LongitudeFirstGridpoint:
438    """Longitude of first gridpoint"""
439    _key = {0:12, 1:12, 10:10, 20:10, 30:10, 31:10, 40:12, 41:12, 110:10, 203:12, 204:12, 205:12, 32768:12, 32769:12}
440    def __get__(self, obj, objtype=None):
441        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
442    def __set__(self, obj, value):
443        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)

Longitude of first gridpoint

class LatitudeLastGridpoint:
445class LatitudeLastGridpoint:
446    """Latitude of last gridpoint"""
447    _key = {0:14, 1:14, 10:13, 40:14, 41:14, 203:14, 204:14, 205:14, 32768:14, 32769:19}
448    def __get__(self, obj, objtype=None):
449        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
450    def __set__(self, obj, value):
451        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)

Latitude of last gridpoint

class LongitudeLastGridpoint:
453class LongitudeLastGridpoint:
454    """Longitude of last gridpoint"""
455    _key = {0:15, 1:15, 10:14, 40:15, 41:15, 203:15, 204:15, 205:15, 32768:15, 32769:20}
456    def __get__(self, obj, objtype=None):
457        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
458    def __set__(self, obj, value):
459        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)

Longitude of last gridpoint

class LatitudeCenterGridpoint:
461class LatitudeCenterGridpoint:
462    """Latitude of center gridpoint"""
463    _key = {32768:14, 32769:14}
464    def __get__(self, obj, objtype=None):
465        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
466    def __set__(self, obj, value):
467        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)

Latitude of center gridpoint

class LongitudeCenterGridpoint:
469class LongitudeCenterGridpoint:
470    """Longitude of center gridpoint"""
471    _key = {32768:15, 32769:15}
472    def __get__(self, obj, objtype=None):
473        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
474    def __set__(self, obj, value):
475        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)

Longitude of center gridpoint

class GridlengthXDirection:
477class GridlengthXDirection:
478    """Grid lenth in the X-Direction"""
479    _key = {0:16, 1:16, 10:17, 20:14, 30:14, 31:14, 40:16, 41:16, 203:16, 204:16, 205:16, 32768:16, 32769:16}
480    def __get__(self, obj, objtype=None):
481        return (obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._xydivisor)*obj._dxsign
482    def __set__(self, obj, value):
483        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._xydivisor/obj._llscalefactor)

Grid lenth in the X-Direction

class GridlengthYDirection:
485class GridlengthYDirection:
486    """Grid lenth in the Y-Direction"""
487    _key = {0:17, 1:17, 10:18, 20:15, 30:15, 31:15, 40:17, 41:17, 203:17, 204:17, 205:17, 32768:17, 32769:17}
488    def __get__(self, obj, objtype=None):
489        return (obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._xydivisor)*obj._dysign
490    def __set__(self, obj, value):
491        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._xydivisor/obj._llscalefactor)

Grid lenth in the Y-Direction

class LatitudeSouthernPole:
493class LatitudeSouthernPole:
494    """Latitude of the Southern Pole for a Rotated Lat/Lon Grid"""
495    _key = {1:19, 30:20, 31:20, 41:19}
496    def __get__(self, obj, objtype=None):
497        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
498    def __set__(self, obj, value):
499        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)

Latitude of the Southern Pole for a Rotated Lat/Lon Grid

class LongitudeSouthernPole:
501class LongitudeSouthernPole:
502    """Longitude of the Southern Pole for a Rotated Lat/Lon Grid"""
503    _key = {1:20, 30:21, 31:21, 41:20}
504    def __get__(self, obj, objtype=None):
505        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
506    def __set__(self, obj, value):
507        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)

Longitude of the Southern Pole for a Rotated Lat/Lon Grid

class AnglePoleRotation:
509class AnglePoleRotation:
510    """Angle of Pole Rotation for a Rotated Lat/Lon Grid"""
511    _key = {1:21, 41:21}
512    def __get__(self, obj, objtype=None):
513        return obj.section3[self._key[obj.gdtn]+5]
514    def __set__(self, obj, value):
515        obj.section3[self._key[obj.gdtn]+5] = int(value)

Angle of Pole Rotation for a Rotated Lat/Lon Grid

class LatitudeTrueScale:
517class LatitudeTrueScale:
518    """Latitude at which grid lengths are specified"""
519    _key = {10:12, 20:12, 30:12, 31:12}
520    def __get__(self, obj, objtype=None):
521        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
522    def __set__(self, obj, value):
523        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)

Latitude at which grid lengths are specified

class GridOrientation:
525class GridOrientation:
526    """Longitude at which the grid is oriented"""
527    _key = {10:16, 20:13, 30:13, 31:13}
528    def __get__(self, obj, objtype=None):
529        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
530    def __set__(self, obj, value):
531        if obj.gdtn == 10 and (value < 0 or value > 90):
532            raise ValueError("Grid orientation is limited to range of 0 to 90 degrees.")
533        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)

Longitude at which the grid is oriented

class ProjectionCenterFlag:
535class ProjectionCenterFlag:
536    """[Projection Center](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-5.shtml)"""
537    _key = {20:16, 30:16, 31:16}
538    def __get__(self, obj, objtype=None):
539        return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list)[0]
540    def __set__(self, obj, value):
541        obj.section3[self._key[obj.gdtn]+5] = value
class StandardLatitude1:
543class StandardLatitude1:
544    """First Standard Latitude (from the pole at which the secant cone cuts the sphere)"""
545    _key = {30:18, 31:18}
546    def __get__(self, obj, objtype=None):
547        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
548    def __set__(self, obj, value):
549        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)

First Standard Latitude (from the pole at which the secant cone cuts the sphere)

class StandardLatitude2:
551class StandardLatitude2:
552    """Second Standard Latitude (from the pole at which the secant cone cuts the sphere)"""
553    _key = {30:19, 31:19}
554    def __get__(self, obj, objtype=None):
555        return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor
556    def __set__(self, obj, value):
557        obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)

Second Standard Latitude (from the pole at which the secant cone cuts the sphere)

class SpectralFunctionParameters:
559class SpectralFunctionParameters:
560    """Spectral Function Parameters"""
561    def __get__(self, obj, objtype=None):
562        return obj.section3[0:3]
563    def __set__(self, obj, value):
564        obj.section3[0:3] = value[0:3]

Spectral Function Parameters

class ProjParameters:
566class ProjParameters:
567    """PROJ Parameters to define the reference system"""
568    def __get__(self, obj, objtype=None):
569        projparams = {}
570        projparams['a'] = 1.0
571        projparams['b'] = 1.0
572        if obj.earthRadius is not None:
573            projparams['a'] = obj.earthRadius
574            projparams['b'] = obj.earthRadius
575        else:
576            if obj.earthMajorAxis is not None: projparams['a'] = obj.earthMajorAxis
577            if obj.earthMajorAxis is not None: projparams['b'] = obj.earthMinorAxis
578        if obj.gdtn == 0:
579            projparams['proj'] = 'longlat'
580        elif obj.gdtn == 1:
581            projparams['o_proj'] = 'longlat'
582            projparams['proj'] = 'ob_tran'
583            projparams['o_lat_p'] = -1.0*obj.latitudeSouthernPole
584            projparams['o_lon_p'] = obj.anglePoleRotation
585            projparams['lon_0'] = obj.longitudeSouthernPole
586        elif obj.gdtn == 10:
587            projparams['proj'] = 'merc'
588            projparams['lat_ts'] = obj.latitudeTrueScale
589            projparams['lon_0'] = 0.5*(obj.longitudeFirstGridpoint+obj.longitudeLastGridpoint)
590        elif obj.gdtn == 20:
591            if obj.projectionCenterFlag == 0:
592                lat0 = 90.0
593            elif obj.projectionCenterFlag == 1:
594                lat0 = -90.0
595            projparams['proj'] = 'stere'
596            projparams['lat_ts'] = obj.latitudeTrueScale
597            projparams['lat_0'] = lat0
598            projparams['lon_0'] = obj.gridOrientation
599        elif obj.gdtn == 30:
600            projparams['proj'] = 'lcc'
601            projparams['lat_1'] = obj.standardLatitude1
602            projparams['lat_2'] = obj.standardLatitude2
603            projparams['lat_0'] = obj.latitudeTrueScale
604            projparams['lon_0'] = obj.gridOrientation
605        elif obj.gdtn == 31:
606            projparams['proj'] = 'aea'
607            projparams['lat_1'] = obj.standardLatitude1
608            projparams['lat_2'] = obj.standardLatitude2
609            projparams['lat_0'] = obj.latitudeTrueScale
610            projparams['lon_0'] = obj.gridOrientation
611        elif obj.gdtn == 40:
612            projparams['proj'] = 'eqc'
613        elif obj.gdtn == 32769:
614            projparams['proj'] = 'aeqd'
615            projparams['lon_0'] = obj.longitudeCenterGridpoint
616            projparams['lat_0'] = obj.latitudeCenterGridpoint
617        return projparams
618    def __set__(self, obj, value):
619        raise RuntimeError

PROJ Parameters to define the reference system

@dataclass(init=False)
class GridDefinitionTemplate0:
621@dataclass(init=False)
622class GridDefinitionTemplate0():
623    """[Grid Definition Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-0.shtml)"""
624    _len = 19
625    _num = 0
626    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
627    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
628    latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint())
629    longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint())
630    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
631    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
632    @classmethod
633    @property
634    def _attrs(cls):
635        return list(cls.__dataclass_fields__.keys())
latitudeFirstGridpoint: float

Latitude of first gridpoint

longitudeFirstGridpoint: float

Longitude of first gridpoint

latitudeLastGridpoint: float

Latitude of last gridpoint

longitudeLastGridpoint: float

Longitude of last gridpoint

gridlengthXDirection: float

Grid lenth in the X-Direction

gridlengthYDirection: float

Grid lenth in the Y-Direction

@dataclass(init=False)
class GridDefinitionTemplate1:
637@dataclass(init=False)
638class GridDefinitionTemplate1():
639    """[Grid Definition Template 1](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-1.shtml)"""
640    _len = 22
641    _num = 1
642    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
643    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
644    latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint())
645    longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint())
646    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
647    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
648    latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole())
649    longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole())
650    anglePoleRotation: float = field(init=False, repr=False, default=AnglePoleRotation())
651    @classmethod
652    @property
653    def _attrs(cls):
654        return list(cls.__dataclass_fields__.keys())
latitudeFirstGridpoint: float

Latitude of first gridpoint

longitudeFirstGridpoint: float

Longitude of first gridpoint

latitudeLastGridpoint: float

Latitude of last gridpoint

longitudeLastGridpoint: float

Longitude of last gridpoint

gridlengthXDirection: float

Grid lenth in the X-Direction

gridlengthYDirection: float

Grid lenth in the Y-Direction

latitudeSouthernPole: float

Latitude of the Southern Pole for a Rotated Lat/Lon Grid

longitudeSouthernPole: float

Longitude of the Southern Pole for a Rotated Lat/Lon Grid

anglePoleRotation: float

Angle of Pole Rotation for a Rotated Lat/Lon Grid

@dataclass(init=False)
class GridDefinitionTemplate10:
656@dataclass(init=False)
657class GridDefinitionTemplate10():
658    """[Grid Definition Template 10](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-10.shtml)"""
659    _len = 19
660    _num = 10
661    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
662    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
663    latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale())
664    latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint())
665    longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint())
666    gridOrientation: float = field(init=False, repr=False, default=GridOrientation())
667    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
668    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
669    projParameters: dict = field(init=False, repr=False, default=ProjParameters())
670    @classmethod
671    @property
672    def _attrs(cls):
673        return list(cls.__dataclass_fields__.keys())
latitudeFirstGridpoint: float

Latitude of first gridpoint

longitudeFirstGridpoint: float

Longitude of first gridpoint

latitudeTrueScale: float

Latitude at which grid lengths are specified

latitudeLastGridpoint: float

Latitude of last gridpoint

longitudeLastGridpoint: float

Longitude of last gridpoint

gridOrientation: float

Longitude at which the grid is oriented

gridlengthXDirection: float

Grid lenth in the X-Direction

gridlengthYDirection: float

Grid lenth in the Y-Direction

projParameters: dict

PROJ Parameters to define the reference system

@dataclass(init=False)
class GridDefinitionTemplate20:
675@dataclass(init=False)
676class GridDefinitionTemplate20():
677    """[Grid Definition Template 20](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-20.shtml)"""
678    _len = 18
679    _num = 20
680    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
681    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
682    latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale())
683    gridOrientation: float = field(init=False, repr=False, default=GridOrientation())
684    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
685    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
686    projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag())
687    projParameters: dict = field(init=False, repr=False, default=ProjParameters())
688    @classmethod
689    @property
690    def _attrs(cls):
691        return list(cls.__dataclass_fields__.keys())
latitudeFirstGridpoint: float

Latitude of first gridpoint

longitudeFirstGridpoint: float

Longitude of first gridpoint

latitudeTrueScale: float

Latitude at which grid lengths are specified

gridOrientation: float

Longitude at which the grid is oriented

gridlengthXDirection: float

Grid lenth in the X-Direction

gridlengthYDirection: float

Grid lenth in the Y-Direction

projectionCenterFlag: list
projParameters: dict

PROJ Parameters to define the reference system

@dataclass(init=False)
class GridDefinitionTemplate30:
693@dataclass(init=False)
694class GridDefinitionTemplate30():
695    """[Grid Definition Template 30](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-30.shtml)"""
696    _len = 22
697    _num = 30
698    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
699    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
700    latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale())
701    gridOrientation: float = field(init=False, repr=False, default=GridOrientation())
702    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
703    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
704    projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag())
705    standardLatitude1: float = field(init=False, repr=False, default=StandardLatitude1())
706    standardLatitude2: float = field(init=False, repr=False, default=StandardLatitude2())
707    latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole())
708    longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole())
709    projParameters: dict = field(init=False, repr=False, default=ProjParameters())
710    @classmethod
711    @property
712    def _attrs(cls):
713        return list(cls.__dataclass_fields__.keys())
latitudeFirstGridpoint: float

Latitude of first gridpoint

longitudeFirstGridpoint: float

Longitude of first gridpoint

latitudeTrueScale: float

Latitude at which grid lengths are specified

gridOrientation: float

Longitude at which the grid is oriented

gridlengthXDirection: float

Grid lenth in the X-Direction

gridlengthYDirection: float

Grid lenth in the Y-Direction

projectionCenterFlag: list
standardLatitude1: float

First Standard Latitude (from the pole at which the secant cone cuts the sphere)

standardLatitude2: float

Second Standard Latitude (from the pole at which the secant cone cuts the sphere)

latitudeSouthernPole: float

Latitude of the Southern Pole for a Rotated Lat/Lon Grid

longitudeSouthernPole: float

Longitude of the Southern Pole for a Rotated Lat/Lon Grid

projParameters: dict

PROJ Parameters to define the reference system

@dataclass(init=False)
class GridDefinitionTemplate31:
715@dataclass(init=False)
716class GridDefinitionTemplate31():
717    """[Grid Definition Template 31](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-31.shtml)"""
718    _len = 22
719    _num = 31
720    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
721    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
722    latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale())
723    gridOrientation: float = field(init=False, repr=False, default=GridOrientation())
724    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
725    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
726    projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag())
727    standardLatitude1: float = field(init=False, repr=False, default=StandardLatitude1())
728    standardLatitude2: float = field(init=False, repr=False, default=StandardLatitude2())
729    latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole())
730    longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole())
731    @classmethod
732    @property
733    def _attrs(cls):
734        return list(cls.__dataclass_fields__.keys())
latitudeFirstGridpoint: float

Latitude of first gridpoint

longitudeFirstGridpoint: float

Longitude of first gridpoint

latitudeTrueScale: float

Latitude at which grid lengths are specified

gridOrientation: float

Longitude at which the grid is oriented

gridlengthXDirection: float

Grid lenth in the X-Direction

gridlengthYDirection: float

Grid lenth in the Y-Direction

projectionCenterFlag: list
standardLatitude1: float

First Standard Latitude (from the pole at which the secant cone cuts the sphere)

standardLatitude2: float

Second Standard Latitude (from the pole at which the secant cone cuts the sphere)

latitudeSouthernPole: float

Latitude of the Southern Pole for a Rotated Lat/Lon Grid

longitudeSouthernPole: float

Longitude of the Southern Pole for a Rotated Lat/Lon Grid

@dataclass(init=False)
class GridDefinitionTemplate40:
736@dataclass(init=False)
737class GridDefinitionTemplate40():
738    """[Grid Definition Template 40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-40.shtml)"""
739    _len = 19
740    _num = 40
741    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
742    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
743    latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint())
744    longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint())
745    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
746    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
747    @classmethod
748    @property
749    def _attrs(cls):
750        return list(cls.__dataclass_fields__.keys())
latitudeFirstGridpoint: float

Latitude of first gridpoint

longitudeFirstGridpoint: float

Longitude of first gridpoint

latitudeLastGridpoint: float

Latitude of last gridpoint

longitudeLastGridpoint: float

Longitude of last gridpoint

gridlengthXDirection: float

Grid lenth in the X-Direction

gridlengthYDirection: float

Grid lenth in the Y-Direction

@dataclass(init=False)
class GridDefinitionTemplate41:
752@dataclass(init=False)
753class GridDefinitionTemplate41():
754    """[Grid Definition Template 41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-41.shtml)"""
755    _len = 22
756    _num = 41
757    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
758    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
759    latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint())
760    longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint())
761    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
762    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
763    latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole())
764    longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole())
765    anglePoleRotation: float = field(init=False, repr=False, default=AnglePoleRotation())
766    @classmethod
767    @property
768    def _attrs(cls):
769        return list(cls.__dataclass_fields__.keys())
latitudeFirstGridpoint: float

Latitude of first gridpoint

longitudeFirstGridpoint: float

Longitude of first gridpoint

latitudeLastGridpoint: float

Latitude of last gridpoint

longitudeLastGridpoint: float

Longitude of last gridpoint

gridlengthXDirection: float

Grid lenth in the X-Direction

gridlengthYDirection: float

Grid lenth in the Y-Direction

latitudeSouthernPole: float

Latitude of the Southern Pole for a Rotated Lat/Lon Grid

longitudeSouthernPole: float

Longitude of the Southern Pole for a Rotated Lat/Lon Grid

anglePoleRotation: float

Angle of Pole Rotation for a Rotated Lat/Lon Grid

@dataclass(init=False)
class GridDefinitionTemplate50:
771@dataclass(init=False)
772class GridDefinitionTemplate50():
773    """[Grid Definition Template 50](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-50.shtml)"""
774    _len = 5
775    _num = 50
776    spectralFunctionParameters: list = field(init=False, repr=False, default=SpectralFunctionParameters())
777    @classmethod
778    @property
779    def _attrs(cls):
780        return list(cls.__dataclass_fields__.keys())
spectralFunctionParameters: list

Spectral Function Parameters

@dataclass(init=False)
class GridDefinitionTemplate32768:
782@dataclass(init=False)
783class GridDefinitionTemplate32768():
784    """[Grid Definition Template 32768](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32768.shtml)"""
785    _len = 19
786    _num = 32768
787    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
788    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
789    latitudeCenterGridpoint: float = field(init=False, repr=False, default=LatitudeCenterGridpoint())
790    longitudeCenterGridpoint: float = field(init=False, repr=False, default=LongitudeCenterGridpoint())
791    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
792    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
793    @classmethod
794    @property
795    def _attrs(cls):
796        return list(cls.__dataclass_fields__.keys())
latitudeFirstGridpoint: float

Latitude of first gridpoint

longitudeFirstGridpoint: float

Longitude of first gridpoint

latitudeCenterGridpoint: float

Latitude of center gridpoint

longitudeCenterGridpoint: float

Longitude of center gridpoint

gridlengthXDirection: float

Grid lenth in the X-Direction

gridlengthYDirection: float

Grid lenth in the Y-Direction

@dataclass(init=False)
class GridDefinitionTemplate32769:
798@dataclass(init=False)
799class GridDefinitionTemplate32769():
800    """[Grid Definition Template 32769](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32769.shtml)"""
801    _len = 19
802    _num = 32769
803    latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint())
804    longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint())
805    latitudeCenterGridpoint: float = field(init=False, repr=False, default=LatitudeCenterGridpoint())
806    longitudeCenterGridpoint: float = field(init=False, repr=False, default=LongitudeCenterGridpoint())
807    gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection())
808    gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection())
809    latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint())
810    longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint())
811    @classmethod
812    @property
813    def _attrs(cls):
814        return list(cls.__dataclass_fields__.keys())
latitudeFirstGridpoint: float

Latitude of first gridpoint

longitudeFirstGridpoint: float

Longitude of first gridpoint

latitudeCenterGridpoint: float

Latitude of center gridpoint

longitudeCenterGridpoint: float

Longitude of center gridpoint

gridlengthXDirection: float

Grid lenth in the X-Direction

gridlengthYDirection: float

Grid lenth in the Y-Direction

latitudeLastGridpoint: float

Latitude of last gridpoint

longitudeLastGridpoint: float

Longitude of last gridpoint

def gdt_class_by_gdtn(gdtn):
829def gdt_class_by_gdtn(gdtn):
830    """
831    Provides a Grid Definition Template class via the template number
832
833    Parameters
834    ----------
835    **`gdtn : int`**
836        Grid definition template number.
837
838    Returns
839    -------
840    Grid definition template class object (not an instance).
841    """
842    return _gdt_by_gdtn[gdtn]

Provides a Grid Definition Template class via the template number

Parameters

gdtn : int Grid definition template number.

Returns

Grid definition template class object (not an instance).

class ProductDefinitionTemplateNumber:
847class ProductDefinitionTemplateNumber:
848    """[Product Definition Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-0.shtml)"""
849    def __get__(self, obj, objtype=None):
850        return Grib2Metadata(obj.section4[1],table='4.0')
851    def __set__(self, obj, value):
852        raise RuntimeError
class ProductDefinitionTemplate:
855class ProductDefinitionTemplate:
856    """Product Definition Template"""
857    def __get__(self, obj, objtype=None):
858        return obj.section4[2:]
859    def __set__(self, obj, value):
860        raise RuntimeError

Product Definition Template

class ParameterCategory:
862class ParameterCategory:
863    """[Parameter Category](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-1.shtml)"""
864    _key = defaultdict(lambda: 0)
865    def __get__(self, obj, objtype=None):
866        return obj.section4[0+2]
867    def __set__(self, obj, value):
868        obj.section4[self._key[obj.pdtn]+2] = value
class ParameterNumber:
870class ParameterNumber:
871    """[Parameter Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-2.shtml)"""
872    _key = defaultdict(lambda: 1)
873    def __get__(self, obj, objtype=None):
874        return obj.section4[1+2]
875    def __set__(self, obj, value):
876        obj.section4[self._key[obj.pdtn]+2] = value
class VarInfo:
878class VarInfo:
879    """
880    Variable Information.  These are the metadata returned for a specific variable according
881    to discipline, parameter category, and parameter number.
882    """ 
883    def __get__(self, obj, objtype=None):
884        return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)
885    def __set__(self, obj, value):
886        raise RuntimeError

Variable Information. These are the metadata returned for a specific variable according to discipline, parameter category, and parameter number.

class FullName:
888class FullName:
889    """Full name of the Variable"""
890    def __get__(self, obj, objtype=None):
891        return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[0]
892    def __set__(self, obj, value):
893        raise RuntimeError

Full name of the Variable

class Units:
895class Units:
896    """Units of the Variable"""
897    def __get__(self, obj, objtype=None):
898        return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[1]
899    def __set__(self, obj, value):
900        raise RuntimeError

Units of the Variable

class ShortName:
902class ShortName:
903    """ Short name of the variable (i.e. the variable abbreviation)"""
904    def __get__(self, obj, objtype=None):
905        return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[2]
906    def __set__(self, obj, value):
907        raise RuntimeError

Short name of the variable (i.e. the variable abbreviation)

class TypeOfGeneratingProcess:
909class TypeOfGeneratingProcess:
910    """[Type of Generating Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-3.shtml)"""
911    _key = defaultdict(lambda: 2, {48:13})
912    #_key = {0:2, 1:2, 2:2, 5:2, 6:2, 8:2, 9:2, 10:2, 11:2, 12:2, 15:2, 48:13}
913    def __get__(self, obj, objtype=None):
914        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.3')
915    def __set__(self, obj, value):
916        obj.section4[self._key[obj.pdtn]+2] = value
class BackgroundGeneratingProcessIdentifier:
918class BackgroundGeneratingProcessIdentifier:
919    """Background Generating Process Identifier"""
920    _key = defaultdict(lambda: 3, {48:14})
921    #_key = {0:3, 1:3, 2:3, 5:3, 6:3, 8:3, 9:3, 10:3, 11:3, 12:3, 15:3, 48:14}
922    def __get__(self, obj, objtype=None):
923        return obj.section4[self._key[obj.pdtn]+2]
924    def __set__(self, obj, value):
925        obj.section4[self._key[obj.pdtn]+2] = value

Background Generating Process Identifier

class GeneratingProcess:
927class GeneratingProcess:
928    """[Generating Process](https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablea.html)"""
929    _key = defaultdict(lambda: 4, {48:15})
930    #_key = {0:4, 1:4, 2:4, 5:4, 6:4, 8:4, 9:4, 10:4, 11:4, 12:4, 15:4, 48:15}
931    def __get__(self, obj, objtype=None):
932        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='generating_process')
933    def __set__(self, obj, value):
934        obj.section4[self._key[obj.pdtn]+2] = value
class HoursAfterDataCutoff:
936class HoursAfterDataCutoff:
937    """Hours of observational data cutoff after reference time"""
938    _key = defaultdict(lambda: 5, {48:16})
939    def __get__(self, obj, objtype=None):
940        return obj.section4[self._key[obj.pdtn]+2]
941    def __set__(self, obj, value):
942        obj.section4[self._key[obj.pdtn]+2] = value

Hours of observational data cutoff after reference time

class MinutesAfterDataCutoff:
944class MinutesAfterDataCutoff:
945    """Minutes of observational data cutoff after reference time"""
946    _key = defaultdict(lambda: 6, {48:17})
947    def __get__(self, obj, objtype=None):
948        return obj.section4[self._key[obj.pdtn]+2]
949    def __set__(self, obj, value):
950        obj.section4[self._key[obj.pdtn]+2] = value

Minutes of observational data cutoff after reference time

class UnitOfForecastTime:
952class UnitOfForecastTime:
953    """[Units of Forecast Time](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-4.shtml)"""
954    _key = defaultdict(lambda: 7, {48:18})
955    #_key = {0:7, 1:7, 2:7, 5:7, 6:7, 8:7, 9:7, 10:7, 11:7, 12:7, 15:7, 48:18}
956    def __get__(self, obj, objtype=None):
957        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.4')
958    def __set__(self, obj, value):
959        obj.section4[self._key[obj.pdtn]+2] = value
class ValueOfForecastTime:
961class ValueOfForecastTime:
962    """Value of forecast time in units defined by `UnitofForecastTime`"""
963    _key = defaultdict(lambda: 8, {48:19})
964    def __get__(self, obj, objtype=None):
965        return obj.section4[self._key[obj.pdtn]+2]
966    def __set__(self, obj, value):
967        obj.section4[self._key[obj.pdtn]+2] = value

Value of forecast time in units defined by UnitofForecastTime

class LeadTime:
969class LeadTime:
970    """Forecast Lead Time. NOTE: This is a `datetime.timedelta` object."""
971    def __get__(self, obj, objtype=None):
972        return utils.get_leadtime(obj.section1,obj.section4[1],
973                                  obj.section4[2:])
974    def __set__(self, obj, value):
975        raise NotImplementedError

Forecast Lead Time. NOTE: This is a datetime.timedelta object.

class FixedSfc1Info:
977class FixedSfc1Info:
978    """Information of the first fixed surface via [table 4.5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)"""
979    _key = defaultdict(lambda: 9, {48:20})
980    #_key = {0:9, 1:9, 2:9, 5:9, 6:9, 8:9, 9:9, 10:9, 11:9, 12:9, 15:9, 48:20}
981    def __get__(self, obj, objtype=None):
982        if obj.section4[self._key[obj.pdtn]+2] == 255:
983            return [None, None]
984        return tables.get_value_from_table(obj.section4[self._key[obj.pdtn]+2],'4.5')
985    def __set__(self, obj, value):
986        raise NotImplementedError

Information of the first fixed surface via table 4.5

class FixedSfc2Info:
988class FixedSfc2Info:
989    """Information of the seconds fixed surface via [table 4.5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)"""
990    _key = defaultdict(lambda: 12, {48:23})
991    #_key = {0:12, 1:12, 2:12, 5:12, 6:12, 8:12, 9:12, 10:12, 11:12, 12:12, 15:12, 48:23}
992    def __get__(self, obj, objtype=None):
993        if obj.section4[self._key[obj.pdtn]+2] == 255:
994            return [None, None]
995        return tables.get_value_from_table(obj.section4[self._key[obj.pdtn]+2],'4.5')
996    def __set__(self, obj, value):
997        raise NotImplementedError

Information of the seconds fixed surface via table 4.5

class TypeOfFirstFixedSurface:
 999class TypeOfFirstFixedSurface:
1000    """[Type of First Fixed Surface](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)"""
1001    _key = defaultdict(lambda: 9, {48:20})
1002    #_key = {0:9, 1:9, 2:9, 5:9, 6:9, 8:9, 9:9, 10:9, 11:9, 12:9, 15:9, 48:20}
1003    def __get__(self, obj, objtype=None):
1004        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.5')
1005    def __set__(self, obj, value):
1006        obj.section4[self._key[obj.pdtn]+2] = value
class ScaleFactorOfFirstFixedSurface:
1008class ScaleFactorOfFirstFixedSurface:
1009    """Scale Factor of First Fixed Surface"""
1010    _key = defaultdict(lambda: 10, {48:21})
1011    #_key = {0:10, 1:10, 2:10, 5:10, 6:10, 8:10, 9:10, 10:10, 11:10, 12:10, 15:10, 48:21}
1012    def __get__(self, obj, objtype=None):
1013        return obj.section4[self._key[obj.pdtn]+2]
1014    def __set__(self, obj, value):
1015        obj.section4[self._key[obj.pdtn]+2] = value

Scale Factor of First Fixed Surface

class ScaledValueOfFirstFixedSurface:
1017class ScaledValueOfFirstFixedSurface:
1018    """Scaled Value Of First Fixed Surface"""
1019    _key = defaultdict(lambda: 11, {48:22})
1020    #_key = {0:11, 1:11, 2:11, 5:11, 6:11, 8:11, 9:11, 10:11, 11:11, 12:11, 15:11, 48:22}
1021    def __get__(self, obj, objtype=None):
1022        return obj.section4[self._key[obj.pdtn]+2]
1023    def __set__(self, obj, value):
1024        obj.section4[self._key[obj.pdtn]+2] = value

Scaled Value Of First Fixed Surface

class UnitOfFirstFixedSurface:
1026class UnitOfFirstFixedSurface:
1027    """Units of First Fixed Surface"""
1028    def __get__(self, obj, objtype=None):
1029        return obj._fixedsfc1info[1]
1030    def __set__(self, obj, value):
1031        pass

Units of First Fixed Surface

class ValueOfFirstFixedSurface:
1033class ValueOfFirstFixedSurface:
1034    """Value of First Fixed Surface"""
1035    def __get__(self, obj, objtype=None):
1036        return obj.section4[ScaledValueOfFirstFixedSurface._key[obj.pdtn]+2]/\
1037                            (10.**obj.section4[ScaleFactorOfFirstFixedSurface._key[obj.pdtn]+2])
1038    def __set__(self, obj, value):
1039        pass

Value of First Fixed Surface

class TypeOfSecondFixedSurface:
1041class TypeOfSecondFixedSurface:
1042    """[Type of Second Fixed Surface](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)"""
1043    _key = defaultdict(lambda: 12, {48:23})
1044    #_key = {0:12, 1:12, 2:12, 5:12, 6:12, 8:12, 9:12, 10:12, 11:12, 12:12, 15:12, 48:23}
1045    def __get__(self, obj, objtype=None):
1046        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.5')
1047    def __set__(self, obj, value):
1048        obj.section4[self._key[obj.pdtn]+2] = value
class ScaleFactorOfSecondFixedSurface:
1050class ScaleFactorOfSecondFixedSurface:
1051    """Scale Factor of Second Fixed Surface"""
1052    _key = defaultdict(lambda: 13, {48:24})
1053    #_key = {0:13, 1:13, 2:13, 5:13, 6:13, 8:13, 9:13, 10:13, 11:13, 12:13, 15:13, 48:24}
1054    def __get__(self, obj, objtype=None):
1055        return obj.section4[self._key[obj.pdtn]+2]
1056    def __set__(self, obj, value):
1057        obj.section4[self._key[obj.pdtn]+2] = value

Scale Factor of Second Fixed Surface

class ScaledValueOfSecondFixedSurface:
1059class ScaledValueOfSecondFixedSurface:
1060    """Scaled Value Of Second Fixed Surface"""
1061    _key = defaultdict(lambda: 14, {48:25})
1062    #_key = {0:14, 1:14, 2:14, 5:14, 6:14, 8:14, 9:14, 10:14, 11:14, 12:14, 15:14, 48:25}
1063    def __get__(self, obj, objtype=None):
1064        return obj.section4[self._key[obj.pdtn]+2]
1065    def __set__(self, obj, value):
1066        obj.section4[self._key[obj.pdtn]+2] = value

Scaled Value Of Second Fixed Surface

class UnitOfSecondFixedSurface:
1068class UnitOfSecondFixedSurface:
1069    """Units of Second Fixed Surface"""
1070    def __get__(self, obj, objtype=None):
1071        return obj._fixedsfc2info[1]
1072    def __set__(self, obj, value):
1073        pass

Units of Second Fixed Surface

class ValueOfSecondFixedSurface:
1075class ValueOfSecondFixedSurface:
1076    """Value of Second Fixed Surface"""
1077    def __get__(self, obj, objtype=None):
1078        return obj.section4[ScaledValueOfFirstFixedSurface._key[obj.pdtn]+2]/\
1079                            (10.**obj.section4[ScaleFactorOfFirstFixedSurface._key[obj.pdtn]+2])
1080    def __set__(self, obj, value):
1081        pass

Value of Second Fixed Surface

class Level:
1083class Level:
1084    """Level (same as provided by [wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Level.c))"""
1085    def __get__(self, obj, objtype=None):
1086        return tables.get_wgrib2_level_string(obj.pdtn,obj.section4[2:])
1087    def __set__(self, obj, value):
1088        pass

Level (same as provided by wgrib2)

class TypeOfEnsembleForecast:
1090class TypeOfEnsembleForecast:
1091    """[Type of Ensemble Forecast](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-6.shtml)"""
1092    _key = {1:15, 11:15}
1093    def __get__(self, obj, objtype=None):
1094        pdtn = obj.section4[1]
1095        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.6')
1096    def __set__(self, obj, value):
1097        pdtn = obj.section4[1]
1098        obj.section4[self._key[pdtn]+2] = value
class PerturbationNumber:
1100class PerturbationNumber:
1101    """Ensemble Perturbation Number"""
1102    _key = {1:16, 11:16}
1103    def __get__(self, obj, objtype=None):
1104        pdtn = obj.section4[1]
1105        return obj.section4[self._key[pdtn]+2]
1106    def __set__(self, obj, value):
1107        pdtn = obj.section4[1]
1108        obj.section4[self._key[pdtn]+2] = value

Ensemble Perturbation Number

class NumberOfEnsembleForecasts:
1110class NumberOfEnsembleForecasts:
1111    """Total Number of Ensemble Forecasts"""
1112    _key = {1:17, 2:16, 11:17, 12:16}
1113    def __get__(self, obj, objtype=None):
1114        pdtn = obj.section4[1]
1115        return obj.section4[self._key[pdtn]+2]
1116    def __set__(self, obj, value):
1117        pdtn = obj.section4[1]
1118        obj.section4[self._key[pdtn]+2] = value

Total Number of Ensemble Forecasts

class TypeOfDerivedForecast:
1120class TypeOfDerivedForecast:
1121    """[Type of Derived Forecast](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-7.shtml)"""
1122    _key = {2:15, 12:15}
1123    def __get__(self, obj, objtype=None):
1124        pdtn = obj.section4[1]
1125        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.7')
1126    def __set__(self, obj, value):
1127        pdtn = obj.section4[1]
1128        obj.section4[self._key[pdtn]+2] = value
class ForecastProbabilityNumber:
1130class ForecastProbabilityNumber:
1131    """Forecast Probability Number"""
1132    _key = {5:15, 9:15}
1133    def __get__(self, obj, objtype=None):
1134        pdtn = obj.section4[1]
1135        return obj.section4[self._key[pdtn]+2]
1136    def __set__(self, obj, value):
1137        pdtn = obj.section4[1]
1138        obj.section4[self._key[pdtn]+2] = value

Forecast Probability Number

class TotalNumberOfForecastProbabilities:
1140class TotalNumberOfForecastProbabilities:
1141    """Total Number of Forecast Probabilities"""
1142    _key = {5:16, 9:16}
1143    def __get__(self, obj, objtype=None):
1144        pdtn = obj.section4[1]
1145        return obj.section4[self._key[pdtn]+2]
1146    def __set__(self, obj, value):
1147        pdtn = obj.section4[1]
1148        obj.section4[self._key[pdtn]+2] = value

Total Number of Forecast Probabilities

class TypeOfProbability:
1150class TypeOfProbability:
1151    """[Type of Probability](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-9.shtml)"""
1152    _key = {5:17, 9:17}
1153    def __get__(self, obj, objtype=None):
1154        pdtn = obj.section4[1]
1155        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.9')
1156    def __set__(self, obj, value):
1157        pdtn = obj.section4[1]
1158        obj.section4[self._key[pdtn]+2] = value
class ScaleFactorOfThresholdLowerLimit:
1160class ScaleFactorOfThresholdLowerLimit:
1161    """Scale Factor of Threshold Lower Limit"""
1162    _key = {5:18, 9:18}
1163    def __get__(self, obj, objtype=None):
1164        pdtn = obj.section4[1]
1165        return obj.section4[self._key[pdtn]+2]
1166    def __set__(self, obj, value):
1167        pdtn = obj.section4[1]
1168        obj.section4[self._key[pdtn]+2] = value

Scale Factor of Threshold Lower Limit

class ScaledValueOfThresholdLowerLimit:
1170class ScaledValueOfThresholdLowerLimit:
1171    """Scaled Value of Threshold Lower Limit"""
1172    _key = {5:19, 9:19}
1173    def __get__(self, obj, objtype=None):
1174        pdtn = obj.section4[1]
1175        return obj.section4[self._key[pdtn]+2]
1176    def __set__(self, obj, value):
1177        pdtn = obj.section4[1]
1178        obj.section4[self._key[pdtn]+2] = value

Scaled Value of Threshold Lower Limit

class ScaleFactorOfThresholdUpperLimit:
1180class ScaleFactorOfThresholdUpperLimit:
1181    """Scale Factor of Threshold Upper Limit"""
1182    _key = {5:20, 9:20}
1183    def __get__(self, obj, objtype=None):
1184        pdtn = obj.section4[1]
1185        return obj.section4[self._key[pdtn]+2]
1186    def __set__(self, obj, value):
1187        pdtn = obj.section4[1]
1188        obj.section4[self._key[pdtn]+2] = value

Scale Factor of Threshold Upper Limit

class ScaledValueOfThresholdUpperLimit:
1190class ScaledValueOfThresholdUpperLimit:
1191    """Scaled Value of Threshold Upper Limit"""
1192    _key = {5:21, 9:21}
1193    def __get__(self, obj, objtype=None):
1194        pdtn = obj.section4[1]
1195        return obj.section4[self._key[pdtn]+2]
1196    def __set__(self, obj, value):
1197        pdtn = obj.section4[1]
1198        obj.section4[self._key[pdtn]+2] = value

Scaled Value of Threshold Upper Limit

class ThresholdLowerLimit:
1200class ThresholdLowerLimit:
1201    """Threshold Lower Limit"""
1202    def __get__(self, obj, objtype=None):
1203        if obj.section4[18+2] == -127 and \
1204           obj.section4[19+2] == 255:
1205            return 0.0
1206        else:
1207            return obj.section4[19+2]/(10.**obj.section4[18+2])
1208    def __set__(self, obj, value):
1209        pass

Threshold Lower Limit

class ThresholdUpperLimit:
1211class ThresholdUpperLimit:
1212    """Threshold Upper Limit"""
1213    def __get__(self, obj, objtype=None):
1214        if obj.section4[20+2] == -127 and \
1215           obj.section4[21+2] == 255:
1216            return 0.0
1217        else:
1218            return obj.section4[21+2]/(10.**obj.section4[20+2])
1219    def __set__(self, obj, value):
1220        pass

Threshold Upper Limit

class Threshold:
1222class Threshold:
1223    """Threshold string (same as [wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Prob.c))"""
1224    def __get__(self, obj, objtype=None):
1225        return utils.get_wgrib2_prob_string(*obj.section4[17+2:22+2])
1226    def __set__(self, obj, value):
1227        pass

Threshold string (same as wgrib2)

class PercentileValue:
1229class PercentileValue:
1230    """Percentile Value"""
1231    _key = {6:15, 10:15}
1232    def __get__(self, obj, objtype=None):
1233        pdtn = obj.section4[1]
1234        return obj.section4[self._key[pdtn]+2]
1235    def __set__(self, obj, value):
1236        pdtn = obj.section4[1]
1237        obj.section4[self._key[pdtn]+2] = value

Percentile Value

class YearOfEndOfTimePeriod:
1239class YearOfEndOfTimePeriod:
1240    """Year of End of Forecast Time Period"""
1241    _key = {8:15, 9:22, 10:16, 11:18, 12:17}
1242    def __get__(self, obj, objtype=None):
1243        pdtn = obj.section4[1]
1244        return obj.section4[self._key[pdtn]+2]
1245    def __set__(self, obj, value):
1246        pdtn = obj.section4[1]
1247        obj.section4[self._key[pdtn]+2] = value

Year of End of Forecast Time Period

class MonthOfEndOfTimePeriod:
1249class MonthOfEndOfTimePeriod:
1250    """Month Year of End of Forecast Time Period"""
1251    _key = {8:16, 9:23, 10:17, 11:19, 12:18}
1252    def __get__(self, obj, objtype=None):
1253        pdtn = obj.section4[1]
1254        return obj.section4[self._key[pdtn]+2]
1255    def __set__(self, obj, value):
1256        pdtn = obj.section4[1]
1257        obj.section4[self._key[pdtn]+2] = value

Month Year of End of Forecast Time Period

class DayOfEndOfTimePeriod:
1259class DayOfEndOfTimePeriod:
1260    """Day Year of End of Forecast Time Period"""
1261    _key = {8:17, 9:24, 10:18, 11:20, 12:19}
1262    def __get__(self, obj, objtype=None):
1263        pdtn = obj.section4[1]
1264        return obj.section4[self._key[pdtn]+2]
1265    def __set__(self, obj, value):
1266        pdtn = obj.section4[1]
1267        obj.section4[self._key[pdtn]+2] = value

Day Year of End of Forecast Time Period

class HourOfEndOfTimePeriod:
1269class HourOfEndOfTimePeriod:
1270    """Hour Year of End of Forecast Time Period"""
1271    _key = {8:18, 9:25, 10:19, 11:21, 12:20}
1272    def __get__(self, obj, objtype=None):
1273        pdtn = obj.section4[1]
1274        return obj.section4[self._key[pdtn]+2]
1275    def __set__(self, obj, value):
1276        pdtn = obj.section4[1]
1277        obj.section4[self._key[pdtn]+2] = value

Hour Year of End of Forecast Time Period

class MinuteOfEndOfTimePeriod:
1279class MinuteOfEndOfTimePeriod:
1280    """Minute Year of End of Forecast Time Period"""
1281    _key = {8:19, 9:26, 10:20, 11:22, 12:21}
1282    def __get__(self, obj, objtype=None):
1283        pdtn = obj.section4[1]
1284        return obj.section4[self._key[pdtn]+2]
1285    def __set__(self, obj, value):
1286        pdtn = obj.section4[1]
1287        obj.section4[self._key[pdtn]+2] = value

Minute Year of End of Forecast Time Period

class SecondOfEndOfTimePeriod:
1289class SecondOfEndOfTimePeriod:
1290    """Second Year of End of Forecast Time Period"""
1291    _key = {8:20, 9:27, 10:21, 11:23, 12:22}
1292    def __get__(self, obj, objtype=None):
1293        pdtn = obj.section4[1]
1294        return obj.section4[self._key[pdtn]+2]
1295    def __set__(self, obj, value):
1296        pdtn = obj.section4[1]
1297        obj.section4[self._key[pdtn]+2] = value

Second Year of End of Forecast Time Period

class Duration:
1299class Duration:
1300    """Duration of time period. NOTE: This is a `datetime.timedelta` object."""
1301    def __get__(self, obj, objtype=None):
1302        return utils.get_duration(obj.section4[1],obj.section4[2:])
1303    def __set__(self, obj, value):
1304        pass

Duration of time period. NOTE: This is a datetime.timedelta object.

class ValidDate:
1306class ValidDate:
1307    """Valid Date of the forecast. NOTE: This is a `datetime.datetime` object."""
1308    _key = {8:slice(15,21), 9:slice(22,28), 10:slice(16,22), 11:slice(18,24), 12:slice(17,23)}
1309    def __get__(self, obj, objtype=None):
1310        pdtn = obj.section4[1]
1311        try:
1312            s = slice(self._key[pdtn].start+2,self._key[pdtn].stop+2)
1313            return datetime.datetime(*obj.section4[s])
1314        except(KeyError):
1315            return obj.refDate + obj.leadTime
1316    def __set__(self, obj, value):
1317        pass

Valid Date of the forecast. NOTE: This is a datetime.datetime object.

class NumberOfTimeRanges:
1319class NumberOfTimeRanges:
1320    """Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field"""
1321    _key = {8:21, 9:28, 10:22, 11:24, 12:23}
1322    def __get__(self, obj, objtype=None):
1323        pdtn = obj.section4[1]
1324        return obj.section4[self._key[pdtn]+2]
1325    def __set__(self, obj, value):
1326        pdtn = obj.section4[1]
1327        obj.section4[self._key[pdtn]+2] = value

Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field

class NumberOfMissingValues:
1329class NumberOfMissingValues:
1330    """Total number of data values missing in statistical process"""
1331    _key = {8:22, 9:29, 10:23, 11:25, 12:24}
1332    def __get__(self, obj, objtype=None):
1333        pdtn = obj.section4[1]
1334        return obj.section4[self._key[pdtn]+2]
1335    def __set__(self, obj, value):
1336        pdtn = obj.section4[1]
1337        obj.section4[self._key[pdtn]+2] = value

Total number of data values missing in statistical process

class StatisticalProcess:
1339class StatisticalProcess:
1340    """[Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-10.shtml)"""
1341    _key = {8:23, 9:30, 10:24, 11:26, 12:25, 15:15}
1342    def __get__(self, obj, objtype=None):
1343        pdtn = obj.section4[1]
1344        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.10')
1345    def __set__(self, obj, value):
1346        pdtn = obj.section4[1]
1347        obj.section4[self._key[pdtn]+2] = value
class TypeOfTimeIncrementOfStatisticalProcess:
1349class TypeOfTimeIncrementOfStatisticalProcess:
1350    """[Type of Time Increment of Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-11.shtml)"""
1351    _key = {8:24, 9:31, 10:25, 11:27, 12:26}
1352    def __get__(self, obj, objtype=None):
1353        pdtn = obj.section4[1]
1354        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.11')
1355    def __set__(self, obj, value):
1356        pdtn = obj.section4[1]
1357        obj.section4[self._key[pdtn]+2] = value
class UnitOfTimeRangeOfStatisticalProcess:
1359class UnitOfTimeRangeOfStatisticalProcess:
1360    """[Unit of Time Range of Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-11.shtml)"""
1361    _key = {8:25, 9:32, 10:26, 11:28, 12:27}
1362    def __get__(self, obj, objtype=None):
1363        pdtn = obj.section4[1]
1364        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.4')
1365    def __set__(self, obj, value):
1366        pdtn = obj.section4[1]
1367        obj.section4[self._key[pdtn]+2] = value
class TimeRangeOfStatisticalProcess:
1369class TimeRangeOfStatisticalProcess:
1370    """Time Range of Statistical Process"""
1371    _key = {8:26, 9:33, 10:27, 11:29, 12:28}
1372    def __get__(self, obj, objtype=None):
1373        pdtn = obj.section4[1]
1374        return obj.section4[self._key[pdtn]+2]
1375    def __set__(self, obj, value):
1376        pdtn = obj.section4[1]
1377        obj.section4[self._key[pdtn]+2] = value

Time Range of Statistical Process

class UnitOfTimeRangeOfSuccessiveFields:
1379class UnitOfTimeRangeOfSuccessiveFields:
1380    """[Unit of Time Range of Successive Fields](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-4.shtml)"""
1381    _key = {8:27, 9:34, 10:28, 11:30, 12:29}
1382    def __get__(self, obj, objtype=None):
1383        pdtn = obj.section4[1]
1384        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.4')
1385    def __set__(self, obj, value):
1386        pdtn = obj.section4[1]
1387        obj.section4[self._key[pdtn]+2] = value
class TimeIncrementOfSuccessiveFields:
1389class TimeIncrementOfSuccessiveFields:
1390    """Time Increment of Successive Fields"""
1391    _key = {8:28, 9:35, 10:29, 11:31, 12:30}
1392    def __get__(self, obj, objtype=None):
1393        pdtn = obj.section4[1]
1394        return obj.section4[self._key[pdtn]+2]
1395    def __set__(self, obj, value):
1396        pdtn = obj.section4[1]
1397        obj.section4[self._key[pdtn]+2] = value

Time Increment of Successive Fields

class TypeOfStatisticalProcessing:
1399class TypeOfStatisticalProcessing:
1400    """[Type of Statistical Processing](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-15.shtml)"""
1401    _key = {15:16}
1402    def __get__(self, obj, objtype=None):
1403        pdtn = obj.section4[1]
1404        return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.15')
1405    def __set__(self, obj, value):
1406        pdtn = obj.section4[1]
1407        obj.section4[self._key[pdtn]+2] = value
class NumberOfDataPointsForSpatialProcessing:
1409class NumberOfDataPointsForSpatialProcessing:
1410    """Number of Data Points for Spatial Processing"""
1411    _key = {15:17}
1412    def __get__(self, obj, objtype=None):
1413        pdtn = obj.section4[1]
1414        return obj.section4[self._key[pdtn]+2]
1415    def __set__(self, obj, value):
1416        pdtn = obj.section4[1]
1417        obj.section4[self._key[pdtn]+2] = value

Number of Data Points for Spatial Processing

class TypeOfAerosol:
1419class TypeOfAerosol:
1420    """[Type of Aerosol](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-233.shtml)"""
1421    _key = {48:2}
1422    def __get__(self, obj, objtype=None):
1423        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.233')
1424    def __set__(self, obj, value):
1425        obj.section4[self._key[obj.pdtn]+2] = value
class TypeOfIntervalForAerosolSize:
1427class TypeOfIntervalForAerosolSize:
1428    """[Type of Interval for Aerosol Size](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-91.shtml)"""
1429    _key = {48:3}
1430    def __get__(self, obj, objtype=None):
1431        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.91')
1432    def __set__(self, obj, value):
1433        obj.section4[self._key[obj.pdtn]+2] = value
class ScaleFactorOfFirstSize:
1435class ScaleFactorOfFirstSize:
1436    """Scale Factor of First Size"""
1437    _key = {48:4}
1438    def __get__(self, obj, objtype=None):
1439        return obj.section4[self._key[obj.pdtn]+2]
1440    def __set__(self, obj, value):
1441        obj.section4[self._key[obj.pdtn]+2] = value

Scale Factor of First Size

class ScaledValueOfFirstSize:
1443class ScaledValueOfFirstSize:
1444    """Scaled Value of First Size"""
1445    _key = {48:5}
1446    def __get__(self, obj, objtype=None):
1447        return obj.section4[self._key[obj.pdtn]+2]
1448    def __set__(self, obj, value):
1449        obj.section4[self._key[obj.pdtn]+2] = value

Scaled Value of First Size

class ScaleFactorOfSecondSize:
1451class ScaleFactorOfSecondSize:
1452    """Scale Factor of Second Size"""
1453    _key = {48:6}
1454    def __get__(self, obj, objtype=None):
1455        return obj.section4[self._key[obj.pdtn]+2]
1456    def __set__(self, obj, value):
1457        obj.section4[self._key[obj.pdtn]+2] = value

Scale Factor of Second Size

class ScaledValueOfSecondSize:
1459class ScaledValueOfSecondSize:
1460    """Scaled Value of Second Size"""
1461    _key = {48:7}
1462    def __get__(self, obj, objtype=None):
1463        return obj.section4[self._key[obj.pdtn]+2]
1464    def __set__(self, obj, value):
1465        obj.section4[self._key[obj.pdtn]+2] = value

Scaled Value of Second Size

class TypeOfIntervalForAerosolWavelength:
1467class TypeOfIntervalForAerosolWavelength:
1468    """[Type of Interval for Aerosol Wavelength](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-91.shtml)"""
1469    _key = {48:8}
1470    def __get__(self, obj, objtype=None):
1471        return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.91')
1472    def __set__(self, obj, value):
1473        obj.section4[self._key[obj.pdtn]+2] = value
class ScaleFactorOfFirstWavelength:
1475class ScaleFactorOfFirstWavelength:
1476    """Scale Factor of First Wavelength"""
1477    _key = {48:9}
1478    def __get__(self, obj, objtype=None):
1479        return obj.section4[self._key[obj.pdtn]+2]
1480    def __set__(self, obj, value):
1481        obj.section4[self._key[obj.pdtn]+2] = value

Scale Factor of First Wavelength

class ScaledValueOfFirstWavelength:
1483class ScaledValueOfFirstWavelength:
1484    """Scaled Value of First Wavelength"""
1485    _key = {48:10}
1486    def __get__(self, obj, objtype=None):
1487        return obj.section4[self._key[obj.pdtn]+2]
1488    def __set__(self, obj, value):
1489        obj.section4[self._key[obj.pdtn]+2] = value

Scaled Value of First Wavelength

class ScaleFactorOfSecondWavelength:
1491class ScaleFactorOfSecondWavelength:
1492    """Scale Factor of Second Wavelength"""
1493    _key = {48:11}
1494    def __get__(self, obj, objtype=None):
1495        return obj.section4[self._key[obj.pdtn]+2]
1496    def __set__(self, obj, value):
1497        obj.section4[self._key[obj.pdtn]+2] = value

Scale Factor of Second Wavelength

class ScaledValueOfSecondWavelength:
1499class ScaledValueOfSecondWavelength:
1500    """Scaled Value of Second Wavelength"""
1501    _key = {48:12}
1502    def __get__(self, obj, objtype=None):
1503        return obj.section4[self._key[obj.pdtn]+2]
1504    def __set__(self, obj, value):
1505        obj.section4[self._key[obj.pdtn]+2] = value

Scaled Value of Second Wavelength

@dataclass(init=False)
class ProductDefinitionTemplate0:
1507@dataclass(init=False)
1508class ProductDefinitionTemplate0():
1509    """[Product Definition Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-0.shtml)"""
1510    _len = 15
1511    _num = 0
1512    parameterCategory: int = field(init=False,repr=False,default=ParameterCategory())
1513    parameterNumber: int = field(init=False,repr=False,default=ParameterNumber())
1514    typeOfGeneratingProcess: Grib2Metadata = field(init=False,repr=False,default=TypeOfGeneratingProcess())
1515    generatingProcess: Grib2Metadata = field(init=False, repr=False, default=GeneratingProcess())
1516    backgroundGeneratingProcessIdentifier: int = field(init=False,repr=False,default=BackgroundGeneratingProcessIdentifier())
1517    hoursAfterDataCutoff: int = field(init=False,repr=False,default=HoursAfterDataCutoff())
1518    minutesAfterDataCutoff: int = field(init=False,repr=False,default=MinutesAfterDataCutoff())
1519    unitOfForecastTime: Grib2Metadata = field(init=False,repr=False,default=UnitOfForecastTime())
1520    valueOfForecastTime: int = field(init=False,repr=False,default=ValueOfForecastTime())
1521    typeOfFirstFixedSurface: Grib2Metadata = field(init=False,repr=False,default=TypeOfFirstFixedSurface())
1522    scaleFactorOfFirstFixedSurface: int = field(init=False,repr=False,default=ScaleFactorOfFirstFixedSurface())
1523    scaledValueOfFirstFixedSurface: int = field(init=False,repr=False,default=ScaledValueOfFirstFixedSurface())
1524    typeOfSecondFixedSurface: Grib2Metadata = field(init=False,repr=False,default=TypeOfSecondFixedSurface())
1525    scaleFactorOfSecondFixedSurface: int = field(init=False,repr=False,default=ScaleFactorOfSecondFixedSurface())
1526    scaledValueOfSecondFixedSurface: int = field(init=False,repr=False,default=ScaledValueOfSecondFixedSurface())
1527    @classmethod
1528    @property
1529    def _attrs(cls):
1530        return list(cls.__dataclass_fields__.keys())
parameterCategory: int
parameterNumber: int
typeOfGeneratingProcess: Grib2Metadata
generatingProcess: Grib2Metadata
backgroundGeneratingProcessIdentifier: int

Background Generating Process Identifier

hoursAfterDataCutoff: int

Hours of observational data cutoff after reference time

minutesAfterDataCutoff: int

Minutes of observational data cutoff after reference time

valueOfForecastTime: int

Value of forecast time in units defined by UnitofForecastTime

typeOfFirstFixedSurface: Grib2Metadata
scaleFactorOfFirstFixedSurface: int

Scale Factor of First Fixed Surface

scaledValueOfFirstFixedSurface: int

Scaled Value Of First Fixed Surface

typeOfSecondFixedSurface: Grib2Metadata
scaleFactorOfSecondFixedSurface: int

Scale Factor of Second Fixed Surface

scaledValueOfSecondFixedSurface: int

Scaled Value Of Second Fixed Surface

@dataclass(init=False)
class ProductDefinitionTemplate1(ProductDefinitionTemplate0):
1532@dataclass(init=False)
1533class ProductDefinitionTemplate1(ProductDefinitionTemplate0):
1534    """[Product Definition Template 1](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-1.shtml)"""
1535    _len = 18
1536    _num = 1
1537    typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast())
1538    perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber())
1539    numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts())
1540    @classmethod
1541    @property
1542    def _attrs(cls):
1543        return list(cls.__dataclass_fields__.keys())
typeOfEnsembleForecast: Grib2Metadata
perturbationNumber: int

Ensemble Perturbation Number

numberOfEnsembleForecasts: int

Total Number of Ensemble Forecasts

@dataclass(init=False)
class ProductDefinitionTemplate2(ProductDefinitionTemplate0):
1545@dataclass(init=False)
1546class ProductDefinitionTemplate2(ProductDefinitionTemplate0):
1547    """[Product Definition Template 2](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-2.shtml)"""
1548    _len = 17
1549    _num = 2
1550    typeOfDerivedForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfDerivedForecast())
1551    numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts())
1552    @classmethod
1553    @property
1554    def _attrs(cls):
1555        return list(cls.__dataclass_fields__.keys())
typeOfDerivedForecast: Grib2Metadata
numberOfEnsembleForecasts: int

Total Number of Ensemble Forecasts

@dataclass(init=False)
class ProductDefinitionTemplate5(ProductDefinitionTemplate0):
1557@dataclass(init=False)
1558class ProductDefinitionTemplate5(ProductDefinitionTemplate0):
1559    """[Product Definition Template 5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-5.shtml)"""
1560    _len = 22
1561    _num = 5
1562    forecastProbabilityNumber: int = field(init=False, repr=False, default=ForecastProbabilityNumber())
1563    totalNumberOfForecastProbabilities: int = field(init=False, repr=False, default=TotalNumberOfForecastProbabilities())
1564    typeOfProbability: Grib2Metadata = field(init=False, repr=False, default=TypeOfProbability())
1565    scaleFactorOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdLowerLimit())
1566    scaledValueOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdLowerLimit())
1567    scaleFactorOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdUpperLimit())
1568    scaledValueOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdUpperLimit())
1569    thresholdLowerLimit: float = field(init=False, repr=False, default=ThresholdLowerLimit())
1570    thresholdUpperLimit: float = field(init=False, repr=False, default=ThresholdUpperLimit())
1571    threshold: str = field(init=False, repr=False, default=Threshold())
1572    @classmethod
1573    @property
1574    def _attrs(cls):
1575        return list(cls.__dataclass_fields__.keys())
forecastProbabilityNumber: int

Forecast Probability Number

totalNumberOfForecastProbabilities: int

Total Number of Forecast Probabilities

typeOfProbability: Grib2Metadata
scaleFactorOfThresholdLowerLimit: float

Scale Factor of Threshold Lower Limit

scaledValueOfThresholdLowerLimit: float

Scaled Value of Threshold Lower Limit

scaleFactorOfThresholdUpperLimit: float

Scale Factor of Threshold Upper Limit

scaledValueOfThresholdUpperLimit: float

Scaled Value of Threshold Upper Limit

thresholdLowerLimit: float

Threshold Lower Limit

thresholdUpperLimit: float

Threshold Upper Limit

threshold: str

Threshold string (same as wgrib2)

@dataclass(init=False)
class ProductDefinitionTemplate6(ProductDefinitionTemplate0):
1577@dataclass(init=False)
1578class ProductDefinitionTemplate6(ProductDefinitionTemplate0):
1579    """[Product Definition Template 6](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-6.shtml)"""
1580    _len = 16
1581    _num = 6
1582    percentileValue: int = field(init=False, repr=False, default=PercentileValue())
1583    @classmethod
1584    @property
1585    def _attrs(cls):
1586        return list(cls.__dataclass_fields__.keys())
percentileValue: int

Percentile Value

@dataclass(init=False)
class ProductDefinitionTemplate8(ProductDefinitionTemplate0):
1588@dataclass(init=False)
1589class ProductDefinitionTemplate8(ProductDefinitionTemplate0):
1590    """[Product Definition Template 8](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-8.shtml)"""
1591    _len = 29
1592    _num = 8
1593    yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod())
1594    monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod())
1595    dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod())
1596    hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod())
1597    minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod())
1598    secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod())
1599    numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges())
1600    numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues())
1601    statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess())
1602    typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess())
1603    unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess())
1604    timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess())
1605    unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields())
1606    timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields())
1607    @classmethod
1608    @property
1609    def _attrs(cls):
1610        return list(cls.__dataclass_fields__.keys())
yearOfEndOfTimePeriod: int

Year of End of Forecast Time Period

monthOfEndOfTimePeriod: int

Month Year of End of Forecast Time Period

dayOfEndOfTimePeriod: int

Day Year of End of Forecast Time Period

hourOfEndOfTimePeriod: int

Hour Year of End of Forecast Time Period

minuteOfEndOfTimePeriod: int

Minute Year of End of Forecast Time Period

secondOfEndOfTimePeriod: int

Second Year of End of Forecast Time Period

numberOfTimeRanges: int

Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field

numberOfMissingValues: int

Total number of data values missing in statistical process

statisticalProcess: Grib2Metadata
typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata
unitOfTimeRangeOfStatisticalProcess: Grib2Metadata
timeRangeOfStatisticalProcess: int

Time Range of Statistical Process

unitOfTimeRangeOfSuccessiveFields: Grib2Metadata
timeIncrementOfSuccessiveFields: int

Time Increment of Successive Fields

@dataclass(init=False)
class ProductDefinitionTemplate9(ProductDefinitionTemplate0):
1612@dataclass(init=False)
1613class ProductDefinitionTemplate9(ProductDefinitionTemplate0):
1614    """[Product Definition Template 9](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-9.shtml)"""
1615    _len = 36
1616    _num = 9
1617    forecastProbabilityNumber: int = field(init=False, repr=False, default=ForecastProbabilityNumber())
1618    totalNumberOfForecastProbabilities: int = field(init=False, repr=False, default=TotalNumberOfForecastProbabilities())
1619    typeOfProbability: Grib2Metadata = field(init=False, repr=False, default=TypeOfProbability())
1620    scaleFactorOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdLowerLimit())
1621    scaledValueOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdLowerLimit())
1622    scaleFactorOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdUpperLimit())
1623    scaledValueOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdUpperLimit())
1624    thresholdLowerLimit: float = field(init=False, repr=False, default=ThresholdLowerLimit())
1625    thresholdUpperLimit: float = field(init=False, repr=False, default=ThresholdUpperLimit())
1626    threshold: str = field(init=False, repr=False, default=Threshold())
1627    yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod())
1628    monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod())
1629    dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod())
1630    hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod())
1631    minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod())
1632    secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod())
1633    numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges())
1634    numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues())
1635    statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess())
1636    typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess())
1637    unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess())
1638    timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess())
1639    unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields())
1640    timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields())
1641    @classmethod
1642    @property
1643    def _attrs(cls):
1644        return list(cls.__dataclass_fields__.keys())
forecastProbabilityNumber: int

Forecast Probability Number

totalNumberOfForecastProbabilities: int

Total Number of Forecast Probabilities

typeOfProbability: Grib2Metadata
scaleFactorOfThresholdLowerLimit: float

Scale Factor of Threshold Lower Limit

scaledValueOfThresholdLowerLimit: float

Scaled Value of Threshold Lower Limit

scaleFactorOfThresholdUpperLimit: float

Scale Factor of Threshold Upper Limit

scaledValueOfThresholdUpperLimit: float

Scaled Value of Threshold Upper Limit

thresholdLowerLimit: float

Threshold Lower Limit

thresholdUpperLimit: float

Threshold Upper Limit

threshold: str

Threshold string (same as wgrib2)

yearOfEndOfTimePeriod: int

Year of End of Forecast Time Period

monthOfEndOfTimePeriod: int

Month Year of End of Forecast Time Period

dayOfEndOfTimePeriod: int

Day Year of End of Forecast Time Period

hourOfEndOfTimePeriod: int

Hour Year of End of Forecast Time Period

minuteOfEndOfTimePeriod: int

Minute Year of End of Forecast Time Period

secondOfEndOfTimePeriod: int

Second Year of End of Forecast Time Period

numberOfTimeRanges: int

Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field

numberOfMissingValues: int

Total number of data values missing in statistical process

statisticalProcess: Grib2Metadata
typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata
unitOfTimeRangeOfStatisticalProcess: Grib2Metadata
timeRangeOfStatisticalProcess: int

Time Range of Statistical Process

unitOfTimeRangeOfSuccessiveFields: Grib2Metadata
timeIncrementOfSuccessiveFields: int

Time Increment of Successive Fields

@dataclass(init=False)
class ProductDefinitionTemplate10(ProductDefinitionTemplate0):
1646@dataclass(init=False)
1647class ProductDefinitionTemplate10(ProductDefinitionTemplate0):
1648    """[Product Definition Template 10](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-10.shtml)"""
1649    _len = 30
1650    _num = 10
1651    percentileValue: int = field(init=False, repr=False, default=PercentileValue())
1652    yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod())
1653    monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod())
1654    dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod())
1655    hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod())
1656    minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod())
1657    secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod())
1658    numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges())
1659    numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues())
1660    statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess())
1661    typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess())
1662    unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess())
1663    timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess())
1664    unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields())
1665    timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields())
1666    @classmethod
1667    @property
1668    def _attrs(cls):
1669        return list(cls.__dataclass_fields__.keys())
percentileValue: int

Percentile Value

yearOfEndOfTimePeriod: int

Year of End of Forecast Time Period

monthOfEndOfTimePeriod: int

Month Year of End of Forecast Time Period

dayOfEndOfTimePeriod: int

Day Year of End of Forecast Time Period

hourOfEndOfTimePeriod: int

Hour Year of End of Forecast Time Period

minuteOfEndOfTimePeriod: int

Minute Year of End of Forecast Time Period

secondOfEndOfTimePeriod: int

Second Year of End of Forecast Time Period

numberOfTimeRanges: int

Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field

numberOfMissingValues: int

Total number of data values missing in statistical process

statisticalProcess: Grib2Metadata
typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata
unitOfTimeRangeOfStatisticalProcess: Grib2Metadata
timeRangeOfStatisticalProcess: int

Time Range of Statistical Process

unitOfTimeRangeOfSuccessiveFields: Grib2Metadata
timeIncrementOfSuccessiveFields: int

Time Increment of Successive Fields

@dataclass(init=False)
class ProductDefinitionTemplate11(ProductDefinitionTemplate0):
1671@dataclass(init=False)
1672class ProductDefinitionTemplate11(ProductDefinitionTemplate0):
1673    """[Product Definition Template 11](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-11.shtml)"""
1674    _len = 32
1675    _num = 11
1676    typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast())
1677    perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber())
1678    numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts())
1679    yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod())
1680    monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod())
1681    dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod())
1682    hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod())
1683    minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod())
1684    secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod())
1685    numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges())
1686    numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues())
1687    statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess())
1688    typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess())
1689    unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess())
1690    timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess())
1691    unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields())
1692    timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields())
1693    @classmethod
1694    @property
1695    def _attrs(cls):
1696        return list(cls.__dataclass_fields__.keys())
typeOfEnsembleForecast: Grib2Metadata
perturbationNumber: int

Ensemble Perturbation Number

numberOfEnsembleForecasts: int

Total Number of Ensemble Forecasts

yearOfEndOfTimePeriod: int

Year of End of Forecast Time Period

monthOfEndOfTimePeriod: int

Month Year of End of Forecast Time Period

dayOfEndOfTimePeriod: int

Day Year of End of Forecast Time Period

hourOfEndOfTimePeriod: int

Hour Year of End of Forecast Time Period

minuteOfEndOfTimePeriod: int

Minute Year of End of Forecast Time Period

secondOfEndOfTimePeriod: int

Second Year of End of Forecast Time Period

numberOfTimeRanges: int

Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field

numberOfMissingValues: int

Total number of data values missing in statistical process

statisticalProcess: Grib2Metadata
typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata
unitOfTimeRangeOfStatisticalProcess: Grib2Metadata
timeRangeOfStatisticalProcess: int

Time Range of Statistical Process

unitOfTimeRangeOfSuccessiveFields: Grib2Metadata
timeIncrementOfSuccessiveFields: int

Time Increment of Successive Fields

@dataclass(init=False)
class ProductDefinitionTemplate12(ProductDefinitionTemplate0):
1698@dataclass(init=False)
1699class ProductDefinitionTemplate12(ProductDefinitionTemplate0):
1700    """[Product Definition Template 12](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-12.shtml)"""
1701    _len = 31
1702    _num = 12
1703    typeOfDerivedForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfDerivedForecast())
1704    numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts())
1705    yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod())
1706    monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod())
1707    dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod())
1708    hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod())
1709    minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod())
1710    secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod())
1711    numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges())
1712    numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues())
1713    statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess())
1714    typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess())
1715    unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess())
1716    timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess())
1717    unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields())
1718    timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields())
1719    @classmethod
1720    @property
1721    def _attrs(cls):
1722        return list(cls.__dataclass_fields__.keys())
typeOfDerivedForecast: Grib2Metadata
numberOfEnsembleForecasts: int

Total Number of Ensemble Forecasts

yearOfEndOfTimePeriod: int

Year of End of Forecast Time Period

monthOfEndOfTimePeriod: int

Month Year of End of Forecast Time Period

dayOfEndOfTimePeriod: int

Day Year of End of Forecast Time Period

hourOfEndOfTimePeriod: int

Hour Year of End of Forecast Time Period

minuteOfEndOfTimePeriod: int

Minute Year of End of Forecast Time Period

secondOfEndOfTimePeriod: int

Second Year of End of Forecast Time Period

numberOfTimeRanges: int

Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field

numberOfMissingValues: int

Total number of data values missing in statistical process

statisticalProcess: Grib2Metadata
typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata
unitOfTimeRangeOfStatisticalProcess: Grib2Metadata
timeRangeOfStatisticalProcess: int

Time Range of Statistical Process

unitOfTimeRangeOfSuccessiveFields: Grib2Metadata
timeIncrementOfSuccessiveFields: int

Time Increment of Successive Fields

@dataclass(init=False)
class ProductDefinitionTemplate15(ProductDefinitionTemplate0):
1724@dataclass(init=False)
1725class ProductDefinitionTemplate15(ProductDefinitionTemplate0):
1726    """[Product Definition Template 15](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-15.shtml)"""
1727    _len = 18
1728    _num = 15
1729    statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess())
1730    typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing())
1731    numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing())
1732    @classmethod
1733    @property
1734    def _attrs(cls):
1735        return list(cls.__dataclass_fields__.keys())
statisticalProcess: Grib2Metadata
typeOfStatisticalProcessing: Grib2Metadata
numberOfDataPointsForSpatialProcessing: int

Number of Data Points for Spatial Processing

@dataclass(init=False)
class ProductDefinitionTemplate48(ProductDefinitionTemplate0):
1737@dataclass(init=False)
1738class ProductDefinitionTemplate48(ProductDefinitionTemplate0):
1739    """[Product Definition Template 48](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-48.shtml)"""
1740    _len = 26
1741    _num = 48
1742    typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol())
1743    typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize())
1744    scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize())
1745    scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize())
1746    scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize())
1747    scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize())
1748    typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength())
1749    scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength())
1750    scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength())
1751    scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength())
1752    scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength())
1753    @classmethod
1754    @property
1755    def _attrs(cls):
1756        return list(cls.__dataclass_fields__.keys())
typeOfIntervalForAerosolSize: Grib2Metadata
scaleFactorOfFirstSize: int

Scale Factor of First Size

scaledValueOfFirstSize: int

Scaled Value of First Size

scaleFactorOfSecondSize: int

Scale Factor of Second Size

scaledValueOfSecondSize: int

Scaled Value of Second Size

typeOfIntervalForAerosolWavelength: Grib2Metadata
scaleFactorOfFirstWavelength: int

Scale Factor of First Wavelength

scaledValueOfFirstWavelength: int

Scaled Value of First Wavelength

scaleFactorOfSecondWavelength: int

Scale Factor of Second Wavelength

scaledValueOfSecondWavelength: int

Scaled Value of Second Wavelength

def pdt_class_by_pdtn(pdtn):
1773def pdt_class_by_pdtn(pdtn):
1774    """
1775    Provides a Product Definition Template class via the template number
1776
1777    Parameters
1778    ----------
1779    **`pdtn : int`**
1780        Product definition template number.
1781
1782    Returns
1783    -------
1784    Product definition template class object (not an instance).
1785    """
1786    return _pdt_by_pdtn[pdtn]

Provides a Product Definition Template class via the template number

Parameters

pdtn : int Product definition template number.

Returns

Product definition template class object (not an instance).

class NumberOfPackedValues:
1791class NumberOfPackedValues:
1792    """Number of Packed Values"""
1793    def __get__(self, obj, objtype=None):
1794        return obj.section5[0]
1795    def __set__(self, obj, value):
1796        pass

Number of Packed Values

class DataRepresentationTemplateNumber:
1798class DataRepresentationTemplateNumber:
1799    """[Data Representation Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-0.shtml)"""
1800    def __get__(self, obj, objtype=None):
1801        return Grib2Metadata(obj.section5[1],table='5.0')
1802    def __set__(self, obj, value):
1803        pass
class DataRepresentationTemplate:
1805class DataRepresentationTemplate:
1806    """Data Representation Template"""
1807    def __get__(self, obj, objtype=None):
1808        return obj.section5[2:]
1809    def __set__(self, obj, value):
1810        raise NotImplementedError

Data Representation Template

class RefValue:
1812class RefValue:
1813    """Reference Value (represented as an IEEE 32-bit floating point value)"""
1814    def __get__(self, obj, objtype=None):
1815        return utils.ieee_int_to_float(obj.section5[0+2])
1816    def __set__(self, obj, value):
1817        pass

Reference Value (represented as an IEEE 32-bit floating point value)

class BinScaleFactor:
1819class BinScaleFactor:
1820    """Binary Scale Factor"""
1821    def __get__(self, obj, objtype=None):
1822        return obj.section5[1+2]
1823    def __set__(self, obj, value):
1824        obj.section5[1+2] = value

Binary Scale Factor

class DecScaleFactor:
1826class DecScaleFactor:
1827    """Decimal Scale Factor"""
1828    def __get__(self, obj, objtype=None):
1829        return obj.section5[2+2]
1830    def __set__(self, obj, value):
1831        obj.section5[2+2] = value

Decimal Scale Factor

class NBitsPacking:
1833class NBitsPacking:
1834    """Minimum number of bits for packing"""
1835    def __get__(self, obj, objtype=None):
1836        return obj.section5[3+2]
1837    def __set__(self, obj, value):
1838        obj.section5[3+2] = value

Minimum number of bits for packing

class TypeOfValues:
1840class TypeOfValues:
1841    """[Type of Original Field Values](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-1.shtml)"""
1842    def __get__(self, obj, objtype=None):
1843        return Grib2Metadata(obj.section5[4+2],table='5.1')
1844    def __set__(self, obj, value):
1845        obj.section5[4+2] = value
class GroupSplittingMethod:
1847class GroupSplittingMethod:
1848    """[Group Splitting Method](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-4.shtml)"""
1849    def __get__(self, obj, objtype=None):
1850        return Grib2Metadata(obj.section5[5+2],table='5.4')
1851    def __set__(self, obj, value):
1852        obj.section5[5+2] = value
class TypeOfMissingValueManagement:
1854class TypeOfMissingValueManagement:
1855    """[Type of Missing Value Management](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-5.shtml)"""
1856    def __get__(self, obj, objtype=None):
1857        return Grib2Metadata(obj.section5[6+2],table='5.5')
1858    def __set__(self, obj, value):
1859        obj.section5[6+2] = value
class PriMissingValue:
1861class PriMissingValue:
1862    """Primary Missing Value"""
1863    def __get__(self, obj, objtype=None):
1864        if obj.typeOfValues == 0:
1865            return utils.ieee_int_to_float(obj.section5[7+2]) if obj.section5[6+2] in {1,2} and obj.section5[7+2] != 255 else None
1866        elif obj.typeOfValues == 1:
1867            return obj.section5[7+2] if obj.section5[6+2] in [1,2] else None
1868    def __set__(self, obj, value):
1869        if obj.typeOfValues == 0:
1870            obj.section5[7+2] = utils.ieee_float_to_int(value)
1871        elif self.typeOfValues == 1:
1872            obj.section5[7+2] = int(value)
1873        obj.section5[6+2] = 1

Primary Missing Value

class SecMissingValue:
1875class SecMissingValue:
1876    """Secondary Missing Value"""
1877    def __get__(self, obj, objtype=None):
1878        if obj.typeOfValues == 0:
1879            return utils.ieee_int_to_float(obj.section5[8+2]) if obj.section5[6+2] in {1,2} and obj.section5[8+2] != 255 else None
1880        elif obj.typeOfValues == 1:
1881            return obj.section5[8+2] if obj.section5[6+2] in {1,2} else None
1882    def __set__(self, obj, value):
1883        if obj.typeOfValues == 0:
1884            obj.section5[8+2] = utils.ieee_float_to_int(value)
1885        elif self.typeOfValues == 1:
1886            obj.section5[8+2] = int(value)
1887        obj.section5[6+2] = 2

Secondary Missing Value

class NGroups:
1889class NGroups:
1890    """Number of Groups"""
1891    def __get__(self, obj, objtype=None):
1892        return obj.section5[9+2]
1893    def __set__(self, obj, value):
1894        pass

Number of Groups

class RefGroupWidth:
1896class RefGroupWidth:
1897    """Reference Group Width"""
1898    def __get__(self, obj, objtype=None):
1899        return obj.section5[10+2]
1900    def __set__(self, obj, value):
1901        pass

Reference Group Width

class NBitsGroupWidth:
1903class NBitsGroupWidth:
1904    """Number of bits for Group Width"""
1905    def __get__(self, obj, objtype=None):
1906        return obj.section5[11+2]
1907    def __set__(self, obj, value):
1908        pass

Number of bits for Group Width

class RefGroupLength:
1910class RefGroupLength:
1911    """Reference Group Length"""
1912    def __get__(self, obj, objtype=None):
1913        return obj.section5[12+2]
1914    def __set__(self, obj, value):
1915        pass

Reference Group Length

class GroupLengthIncrement:
1917class GroupLengthIncrement:
1918    """Group Length Increment"""
1919    def __get__(self, obj, objtype=None):
1920        return obj.section5[13+2]
1921    def __set__(self, obj, value):
1922        pass

Group Length Increment

class LengthOfLastGroup:
1924class LengthOfLastGroup:
1925    """Length of Last Group"""
1926    def __get__(self, obj, objtype=None):
1927        return obj.section5[14+2]
1928    def __set__(self, obj, value):
1929        pass

Length of Last Group

class NBitsScaledGroupLength:
1931class NBitsScaledGroupLength:
1932    """Number of bits of Scaled Group Length"""
1933    def __get__(self, obj, objtype=None):
1934        return obj.section5[15+2]
1935    def __set__(self, obj, value):
1936        pass

Number of bits of Scaled Group Length

class SpatialDifferenceOrder:
1938class SpatialDifferenceOrder:
1939    """[Spatial Difference Order](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-6.shtml)"""
1940    def __get__(self, obj, objtype=None):
1941        return Grib2Metadata(obj.section5[16+2],table='5.6')
1942    def __set__(self, obj, value):
1943        obj.section5[16+2] = value
class NBytesSpatialDifference:
1945class NBytesSpatialDifference:
1946    """Number of bytes for Spatial Differencing"""
1947    def __get__(self, obj, objtype=None):
1948        return obj.section5[17+2]
1949    def __set__(self, obj, value):
1950        pass

Number of bytes for Spatial Differencing

class Precision:
1952class Precision:
1953    """[Precision for IEEE Floating Point Data](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-7.shtml)"""
1954    def __get__(self, obj, objtype=None):
1955        return Grib2Metadata(obj.section5[0+2],table='5.7')
1956    def __set__(self, obj, value):
1957        obj.section5[0+2] = value
class TypeOfCompression:
1959class TypeOfCompression:
1960    """[Type of Compression](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-40.shtml)"""
1961    def __get__(self, obj, objtype=None):
1962        return Grib2Metadata(obj.section5[5+2],table='5.40')
1963    def __set__(self, obj, value):
1964        obj.section5[5+2] = value
class TargetCompressionRatio:
1966class TargetCompressionRatio:
1967    """Target Compression Ratio"""
1968    def __get__(self, obj, objtype=None):
1969        return obj.section5[6+2]
1970    def __set__(self, obj, value):
1971        pass

Target Compression Ratio

class RealOfCoefficient:
1973class RealOfCoefficient:
1974    """Real of Coefficient"""
1975    def __get__(self, obj, objtype=None):
1976        return utils.ieee_int_to_float(obj.section5[4+2])
1977    def __set__(self, obj, value):
1978        obj.section5[4+2] = utils.ieee_float_to_int(float(value))

Real of Coefficient

class CompressionOptionsMask:
1980class CompressionOptionsMask:
1981    """Compression Options Mask for AEC/CCSDS"""
1982    def __get__(self, obj, objtype=None):
1983        return obj.section5[5+2]
1984    def __set__(self, obj, value):
1985        obj.section5[5+2] = value

Compression Options Mask for AEC/CCSDS

class BlockSize:
1987class BlockSize:
1988    """Block Size for AEC/CCSDS"""
1989    def __get__(self, obj, objtype=None):
1990        return obj.section5[6+2]
1991    def __set__(self, obj, value):
1992        obj.section5[6+2] = value

Block Size for AEC/CCSDS

class RefSampleInterval:
1994class RefSampleInterval:
1995    """Reference Sample Interval for AEC/CCSDS"""
1996    def __get__(self, obj, objtype=None):
1997        return obj.section5[7+2]
1998    def __set__(self, obj, value):
1999        obj.section5[7+2] = value

Reference Sample Interval for AEC/CCSDS

@dataclass(init=False)
class DataRepresentationTemplate0:
2001@dataclass(init=False)
2002class DataRepresentationTemplate0():
2003    """[Data Representation Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-0.shtml)"""
2004    _len = 5
2005    _num = 0
2006    _packingScheme = 'simple'
2007    refValue: float = field(init=False, repr=False, default=RefValue())
2008    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2009    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2010    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2011    @classmethod
2012    @property
2013    def _attrs(cls):
2014        return list(cls.__dataclass_fields__.keys())
refValue: float

Reference Value (represented as an IEEE 32-bit floating point value)

binScaleFactor: int

Binary Scale Factor

decScaleFactor: int

Decimal Scale Factor

nBitsPacking: int

Minimum number of bits for packing

@dataclass(init=False)
class DataRepresentationTemplate2:
2016@dataclass(init=False)
2017class DataRepresentationTemplate2():
2018    """[Data Representation Template 2](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-2.shtml)"""
2019    _len = 16
2020    _num = 2
2021    _packingScheme = 'complex'
2022    refValue: float = field(init=False, repr=False, default=RefValue())
2023    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2024    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2025    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2026    groupSplittingMethod: Grib2Metadata = field(init=False, repr=False, default=GroupSplittingMethod())
2027    typeOfMissingValueManagement: Grib2Metadata = field(init=False, repr=False, default=TypeOfMissingValueManagement())
2028    priMissingValue: [float, int] = field(init=False, repr=False, default=PriMissingValue())
2029    secMissingValue: [float, int] = field(init=False, repr=False, default=SecMissingValue())
2030    nGroups: int = field(init=False, repr=False, default=NGroups())
2031    refGroupWidth: int = field(init=False, repr=False, default=RefGroupWidth())
2032    nBitsGroupWidth: int = field(init=False, repr=False, default=NBitsGroupWidth())
2033    refGroupLength: int = field(init=False, repr=False, default=RefGroupLength())
2034    groupLengthIncrement: int = field(init=False, repr=False, default=GroupLengthIncrement())
2035    lengthOfLastGroup: int = field(init=False, repr=False, default=LengthOfLastGroup())
2036    nBitsScaledGroupLength: int = field(init=False, repr=False, default=NBitsScaledGroupLength())
2037    @classmethod
2038    @property
2039    def _attrs(cls):
2040        return list(cls.__dataclass_fields__.keys())
refValue: float

Reference Value (represented as an IEEE 32-bit floating point value)

binScaleFactor: int

Binary Scale Factor

decScaleFactor: int

Decimal Scale Factor

nBitsPacking: int

Minimum number of bits for packing

groupSplittingMethod: Grib2Metadata
typeOfMissingValueManagement: Grib2Metadata
priMissingValue: [<class 'float'>, <class 'int'>]

Primary Missing Value

secMissingValue: [<class 'float'>, <class 'int'>]

Secondary Missing Value

nGroups: int

Number of Groups

refGroupWidth: int

Reference Group Width

nBitsGroupWidth: int

Number of bits for Group Width

refGroupLength: int

Reference Group Length

groupLengthIncrement: int

Group Length Increment

lengthOfLastGroup: int

Length of Last Group

nBitsScaledGroupLength: int

Number of bits of Scaled Group Length

@dataclass(init=False)
class DataRepresentationTemplate3:
2042@dataclass(init=False)
2043class DataRepresentationTemplate3():
2044    """[Data Representation Template 3](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-3.shtml)"""
2045    _len = 18
2046    _num = 3
2047    _packingScheme = 'complex-spdiff'
2048    refValue: float = field(init=False, repr=False, default=RefValue())
2049    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2050    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2051    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2052    groupSplittingMethod: Grib2Metadata = field(init=False, repr=False, default=GroupSplittingMethod())
2053    typeOfMissingValueManagement: Grib2Metadata = field(init=False, repr=False, default=TypeOfMissingValueManagement())
2054    priMissingValue: [float, int] = field(init=False, repr=False, default=PriMissingValue())
2055    secMissingValue: [float, int] = field(init=False, repr=False, default=SecMissingValue())
2056    nGroups: int = field(init=False, repr=False, default=NGroups())
2057    refGroupWidth: int = field(init=False, repr=False, default=RefGroupWidth())
2058    nBitsGroupWidth: int = field(init=False, repr=False, default=NBitsGroupWidth())
2059    refGroupLength: int = field(init=False, repr=False, default=RefGroupLength())
2060    groupLengthIncrement: int = field(init=False, repr=False, default=GroupLengthIncrement())
2061    lengthOfLastGroup: int = field(init=False, repr=False, default=LengthOfLastGroup())
2062    nBitsScaledGroupLength: int = field(init=False, repr=False, default=NBitsScaledGroupLength())
2063    spatialDifferenceOrder: Grib2Metadata = field(init=False, repr=False, default=SpatialDifferenceOrder())
2064    nBytesSpatialDifference: int = field(init=False, repr=False, default=NBytesSpatialDifference())
2065    @classmethod
2066    @property
2067    def _attrs(cls):
2068        return list(cls.__dataclass_fields__.keys())
refValue: float

Reference Value (represented as an IEEE 32-bit floating point value)

binScaleFactor: int

Binary Scale Factor

decScaleFactor: int

Decimal Scale Factor

nBitsPacking: int

Minimum number of bits for packing

groupSplittingMethod: Grib2Metadata
typeOfMissingValueManagement: Grib2Metadata
priMissingValue: [<class 'float'>, <class 'int'>]

Primary Missing Value

secMissingValue: [<class 'float'>, <class 'int'>]

Secondary Missing Value

nGroups: int

Number of Groups

refGroupWidth: int

Reference Group Width

nBitsGroupWidth: int

Number of bits for Group Width

refGroupLength: int

Reference Group Length

groupLengthIncrement: int

Group Length Increment

lengthOfLastGroup: int

Length of Last Group

nBitsScaledGroupLength: int

Number of bits of Scaled Group Length

spatialDifferenceOrder: Grib2Metadata
nBytesSpatialDifference: int

Number of bytes for Spatial Differencing

@dataclass(init=False)
class DataRepresentationTemplate4:
2070@dataclass(init=False)
2071class DataRepresentationTemplate4():
2072    """[Data Representation Template 4](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-4.shtml)"""
2073    _len = 1
2074    _num = 4
2075    _packingScheme = 'ieee-float'
2076    precision: Grib2Metadata = field(init=False, repr=False, default=Precision())
2077    @classmethod
2078    @property
2079    def _attrs(cls):
2080        return list(cls.__dataclass_fields__.keys())
@dataclass(init=False)
class DataRepresentationTemplate40:
2082@dataclass(init=False)
2083class DataRepresentationTemplate40():
2084    """[Data Representation Template 40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-40.shtml)"""
2085    _len = 7
2086    _num = 40
2087    _packingScheme = 'jpeg'
2088    refValue: float = field(init=False, repr=False, default=RefValue())
2089    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2090    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2091    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2092    typeOfCompression: Grib2Metadata = field(init=False, repr=False, default=TypeOfCompression())
2093    targetCompressionRatio: int = field(init=False, repr=False, default=TargetCompressionRatio())
2094    @classmethod
2095    @property
2096    def _attrs(cls):
2097        return list(cls.__dataclass_fields__.keys())
refValue: float

Reference Value (represented as an IEEE 32-bit floating point value)

binScaleFactor: int

Binary Scale Factor

decScaleFactor: int

Decimal Scale Factor

nBitsPacking: int

Minimum number of bits for packing

typeOfCompression: Grib2Metadata
targetCompressionRatio: int

Target Compression Ratio

@dataclass(init=False)
class DataRepresentationTemplate41:
2099@dataclass(init=False)
2100class DataRepresentationTemplate41():
2101    """[Data Representation Template 41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-41.shtml)"""
2102    _len = 5
2103    _num = 41
2104    _packingScheme = 'png'
2105    refValue: float = field(init=False, repr=False, default=RefValue())
2106    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2107    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2108    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2109    @classmethod
2110    @property
2111    def _attrs(cls):
2112        return list(cls.__dataclass_fields__.keys())
refValue: float

Reference Value (represented as an IEEE 32-bit floating point value)

binScaleFactor: int

Binary Scale Factor

decScaleFactor: int

Decimal Scale Factor

nBitsPacking: int

Minimum number of bits for packing

@dataclass(init=False)
class DataRepresentationTemplate42:
2114@dataclass(init=False)
2115class DataRepresentationTemplate42():
2116    """[Data Representation Template 42](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-42.shtml)"""
2117    _len = 8
2118    _num = 42
2119    _packingScheme = 'aec'
2120    refValue: float = field(init=False, repr=False, default=RefValue())
2121    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2122    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2123    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2124    compressionOptionsMask: int = field(init=False, repr=False, default=CompressionOptionsMask())
2125    blockSize: int = field(init=False, repr=False, default=BlockSize())
2126    refSampleInterval: int = field(init=False, repr=False, default=RefSampleInterval())
2127    @classmethod
2128    @property
2129    def _attrs(cls):
2130        return list(cls.__dataclass_fields__.keys())
refValue: float

Reference Value (represented as an IEEE 32-bit floating point value)

binScaleFactor: int

Binary Scale Factor

decScaleFactor: int

Decimal Scale Factor

nBitsPacking: int

Minimum number of bits for packing

compressionOptionsMask: int

Compression Options Mask for AEC/CCSDS

blockSize: int

Block Size for AEC/CCSDS

refSampleInterval: int

Reference Sample Interval for AEC/CCSDS

@dataclass(init=False)
class DataRepresentationTemplate50:
2132@dataclass(init=False)
2133class DataRepresentationTemplate50():
2134    """[Data Representation Template 50](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-50.shtml)"""
2135    _len = 5
2136    _num = 0
2137    _packingScheme = 'spectral-simple'
2138    refValue: float = field(init=False, repr=False, default=RefValue())
2139    binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor())
2140    decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor())
2141    nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking())
2142    realOfCoefficient: float = field(init=False, repr=False, default=RealOfCoefficient())
2143    @classmethod
2144    @property
2145    def _attrs(cls):
2146        return list(cls.__dataclass_fields__.keys())
refValue: float

Reference Value (represented as an IEEE 32-bit floating point value)

binScaleFactor: int

Binary Scale Factor

decScaleFactor: int

Decimal Scale Factor

nBitsPacking: int

Minimum number of bits for packing

realOfCoefficient: float

Real of Coefficient

def drt_class_by_drtn(drtn):
2159def drt_class_by_drtn(drtn):
2160    """
2161    Provides a Data Representation Template class via the template number
2162
2163    Parameters
2164    ----------
2165    **`drtn : int`**
2166        Data Representation template number.
2167
2168    Returns
2169    -------
2170    Data Representation template class object (not an instance).
2171    """
2172    return _drt_by_drtn[drtn]

Provides a Data Representation Template class via the template number

Parameters

drtn : int Data Representation template number.

Returns

Data Representation template class object (not an instance).