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,40,41,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,40,41,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,40,41,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, 203:17, 204:17, 205:17, 32768:17, 32769:17} 487 def __get__(self, obj, objtype=None): 488 if obj.gdtn in {40, 41}: 489 return obj.gridlengthXDirection 490 else: 491 return (obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._xydivisor)*obj._dysign 492 def __set__(self, obj, value): 493 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._xydivisor/obj._llscalefactor) 494 495class NumberOfParallels: 496 """Number of parallels between a pole and the equator""" 497 _key = {40:17, 41:17} 498 def __get__(self, obj, objtype=None): 499 return obj.section3[self._key[obj.gdtn]+5] 500 def __set__(self, obj, value): 501 raise RuntimeError 502 503class LatitudeSouthernPole: 504 """Latitude of the Southern Pole for a Rotated Lat/Lon Grid""" 505 _key = {1:19, 30:20, 31:20, 41:19} 506 def __get__(self, obj, objtype=None): 507 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 508 def __set__(self, obj, value): 509 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 510 511class LongitudeSouthernPole: 512 """Longitude of the Southern Pole for a Rotated Lat/Lon Grid""" 513 _key = {1:20, 30:21, 31:21, 41:20} 514 def __get__(self, obj, objtype=None): 515 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 516 def __set__(self, obj, value): 517 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 518 519class AnglePoleRotation: 520 """Angle of Pole Rotation for a Rotated Lat/Lon Grid""" 521 _key = {1:21, 41:21} 522 def __get__(self, obj, objtype=None): 523 return obj.section3[self._key[obj.gdtn]+5] 524 def __set__(self, obj, value): 525 obj.section3[self._key[obj.gdtn]+5] = int(value) 526 527class LatitudeTrueScale: 528 """Latitude at which grid lengths are specified""" 529 _key = {10:12, 20:12, 30:12, 31:12} 530 def __get__(self, obj, objtype=None): 531 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 532 def __set__(self, obj, value): 533 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 534 535class GridOrientation: 536 """Longitude at which the grid is oriented""" 537 _key = {10:16, 20:13, 30:13, 31:13} 538 def __get__(self, obj, objtype=None): 539 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 540 def __set__(self, obj, value): 541 if obj.gdtn == 10 and (value < 0 or value > 90): 542 raise ValueError("Grid orientation is limited to range of 0 to 90 degrees.") 543 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 544 545class ProjectionCenterFlag: 546 """[Projection Center](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-5.shtml)""" 547 _key = {20:16, 30:16, 31:16} 548 def __get__(self, obj, objtype=None): 549 return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list)[0] 550 def __set__(self, obj, value): 551 obj.section3[self._key[obj.gdtn]+5] = value 552 553class StandardLatitude1: 554 """First Standard Latitude (from the pole at which the secant cone cuts the sphere)""" 555 _key = {30:18, 31:18} 556 def __get__(self, obj, objtype=None): 557 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 558 def __set__(self, obj, value): 559 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 560 561class StandardLatitude2: 562 """Second Standard Latitude (from the pole at which the secant cone cuts the sphere)""" 563 _key = {30:19, 31:19} 564 def __get__(self, obj, objtype=None): 565 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 566 def __set__(self, obj, value): 567 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 568 569class SpectralFunctionParameters: 570 """Spectral Function Parameters""" 571 def __get__(self, obj, objtype=None): 572 return obj.section3[0:3] 573 def __set__(self, obj, value): 574 obj.section3[0:3] = value[0:3] 575 576class ProjParameters: 577 """PROJ Parameters to define the reference system""" 578 def __get__(self, obj, objtype=None): 579 projparams = {} 580 projparams['a'] = 1.0 581 projparams['b'] = 1.0 582 if obj.earthRadius is not None: 583 projparams['a'] = obj.earthRadius 584 projparams['b'] = obj.earthRadius 585 else: 586 if obj.earthMajorAxis is not None: projparams['a'] = obj.earthMajorAxis 587 if obj.earthMajorAxis is not None: projparams['b'] = obj.earthMinorAxis 588 if obj.gdtn == 0: 589 projparams['proj'] = 'longlat' 590 elif obj.gdtn == 1: 591 projparams['o_proj'] = 'longlat' 592 projparams['proj'] = 'ob_tran' 593 projparams['o_lat_p'] = -1.0*obj.latitudeSouthernPole 594 projparams['o_lon_p'] = obj.anglePoleRotation 595 projparams['lon_0'] = obj.longitudeSouthernPole 596 elif obj.gdtn == 10: 597 projparams['proj'] = 'merc' 598 projparams['lat_ts'] = obj.latitudeTrueScale 599 projparams['lon_0'] = 0.5*(obj.longitudeFirstGridpoint+obj.longitudeLastGridpoint) 600 elif obj.gdtn == 20: 601 if obj.projectionCenterFlag == 0: 602 lat0 = 90.0 603 elif obj.projectionCenterFlag == 1: 604 lat0 = -90.0 605 projparams['proj'] = 'stere' 606 projparams['lat_ts'] = obj.latitudeTrueScale 607 projparams['lat_0'] = lat0 608 projparams['lon_0'] = obj.gridOrientation 609 elif obj.gdtn == 30: 610 projparams['proj'] = 'lcc' 611 projparams['lat_1'] = obj.standardLatitude1 612 projparams['lat_2'] = obj.standardLatitude2 613 projparams['lat_0'] = obj.latitudeTrueScale 614 projparams['lon_0'] = obj.gridOrientation 615 elif obj.gdtn == 31: 616 projparams['proj'] = 'aea' 617 projparams['lat_1'] = obj.standardLatitude1 618 projparams['lat_2'] = obj.standardLatitude2 619 projparams['lat_0'] = obj.latitudeTrueScale 620 projparams['lon_0'] = obj.gridOrientation 621 elif obj.gdtn == 40: 622 projparams['proj'] = 'eqc' 623 elif obj.gdtn == 32769: 624 projparams['proj'] = 'aeqd' 625 projparams['lon_0'] = obj.longitudeCenterGridpoint 626 projparams['lat_0'] = obj.latitudeCenterGridpoint 627 return projparams 628 def __set__(self, obj, value): 629 raise RuntimeError 630 631@dataclass(init=False) 632class GridDefinitionTemplate0(): 633 """[Grid Definition Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-0.shtml)""" 634 _len = 19 635 _num = 0 636 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 637 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 638 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 639 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 640 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 641 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 642 @classmethod 643 @property 644 def _attrs(cls): 645 return list(cls.__dataclass_fields__.keys()) 646 647@dataclass(init=False) 648class GridDefinitionTemplate1(): 649 """[Grid Definition Template 1](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-1.shtml)""" 650 _len = 22 651 _num = 1 652 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 653 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 654 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 655 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 656 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 657 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 658 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 659 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 660 anglePoleRotation: float = field(init=False, repr=False, default=AnglePoleRotation()) 661 @classmethod 662 @property 663 def _attrs(cls): 664 return list(cls.__dataclass_fields__.keys()) 665 666@dataclass(init=False) 667class GridDefinitionTemplate10(): 668 """[Grid Definition Template 10](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-10.shtml)""" 669 _len = 19 670 _num = 10 671 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 672 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 673 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 674 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 675 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 676 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 677 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 678 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 679 projParameters: dict = field(init=False, repr=False, default=ProjParameters()) 680 @classmethod 681 @property 682 def _attrs(cls): 683 return list(cls.__dataclass_fields__.keys()) 684 685@dataclass(init=False) 686class GridDefinitionTemplate20(): 687 """[Grid Definition Template 20](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-20.shtml)""" 688 _len = 18 689 _num = 20 690 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 691 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 692 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 693 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 694 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 695 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 696 projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag()) 697 projParameters: dict = field(init=False, repr=False, default=ProjParameters()) 698 @classmethod 699 @property 700 def _attrs(cls): 701 return list(cls.__dataclass_fields__.keys()) 702 703@dataclass(init=False) 704class GridDefinitionTemplate30(): 705 """[Grid Definition Template 30](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-30.shtml)""" 706 _len = 22 707 _num = 30 708 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 709 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 710 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 711 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 712 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 713 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 714 projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag()) 715 standardLatitude1: float = field(init=False, repr=False, default=StandardLatitude1()) 716 standardLatitude2: float = field(init=False, repr=False, default=StandardLatitude2()) 717 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 718 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 719 projParameters: dict = field(init=False, repr=False, default=ProjParameters()) 720 @classmethod 721 @property 722 def _attrs(cls): 723 return list(cls.__dataclass_fields__.keys()) 724 725@dataclass(init=False) 726class GridDefinitionTemplate31(): 727 """[Grid Definition Template 31](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-31.shtml)""" 728 _len = 22 729 _num = 31 730 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 731 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 732 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 733 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 734 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 735 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 736 projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag()) 737 standardLatitude1: float = field(init=False, repr=False, default=StandardLatitude1()) 738 standardLatitude2: float = field(init=False, repr=False, default=StandardLatitude2()) 739 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 740 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 741 @classmethod 742 @property 743 def _attrs(cls): 744 return list(cls.__dataclass_fields__.keys()) 745 746@dataclass(init=False) 747class GridDefinitionTemplate40(): 748 """[Grid Definition Template 40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-40.shtml)""" 749 _len = 19 750 _num = 40 751 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 752 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 753 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 754 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 755 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 756 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 757 numberOfParallels: int = field(init=False, repr=False, default=NumberOfParallels()) 758 @classmethod 759 @property 760 def _attrs(cls): 761 return list(cls.__dataclass_fields__.keys()) 762 763@dataclass(init=False) 764class GridDefinitionTemplate41(): 765 """[Grid Definition Template 41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-41.shtml)""" 766 _len = 22 767 _num = 41 768 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 769 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 770 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 771 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 772 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 773 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 774 numberOfParallels: int = field(init=False, repr=False, default=NumberOfParallels()) 775 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 776 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 777 anglePoleRotation: float = field(init=False, repr=False, default=AnglePoleRotation()) 778 @classmethod 779 @property 780 def _attrs(cls): 781 return list(cls.__dataclass_fields__.keys()) 782 783@dataclass(init=False) 784class GridDefinitionTemplate50(): 785 """[Grid Definition Template 50](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-50.shtml)""" 786 _len = 5 787 _num = 50 788 spectralFunctionParameters: list = field(init=False, repr=False, default=SpectralFunctionParameters()) 789 @classmethod 790 @property 791 def _attrs(cls): 792 return list(cls.__dataclass_fields__.keys()) 793 794@dataclass(init=False) 795class GridDefinitionTemplate32768(): 796 """[Grid Definition Template 32768](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32768.shtml)""" 797 _len = 19 798 _num = 32768 799 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 800 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 801 latitudeCenterGridpoint: float = field(init=False, repr=False, default=LatitudeCenterGridpoint()) 802 longitudeCenterGridpoint: float = field(init=False, repr=False, default=LongitudeCenterGridpoint()) 803 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 804 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 805 @classmethod 806 @property 807 def _attrs(cls): 808 return list(cls.__dataclass_fields__.keys()) 809 810@dataclass(init=False) 811class GridDefinitionTemplate32769(): 812 """[Grid Definition Template 32769](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32769.shtml)""" 813 _len = 19 814 _num = 32769 815 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 816 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 817 latitudeCenterGridpoint: float = field(init=False, repr=False, default=LatitudeCenterGridpoint()) 818 longitudeCenterGridpoint: float = field(init=False, repr=False, default=LongitudeCenterGridpoint()) 819 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 820 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 821 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 822 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 823 @classmethod 824 @property 825 def _attrs(cls): 826 return list(cls.__dataclass_fields__.keys()) 827 828_gdt_by_gdtn = {0: GridDefinitionTemplate0, 829 1: GridDefinitionTemplate1, 830 10: GridDefinitionTemplate10, 831 20: GridDefinitionTemplate20, 832 30: GridDefinitionTemplate30, 833 31: GridDefinitionTemplate31, 834 40: GridDefinitionTemplate40, 835 41: GridDefinitionTemplate41, 836 50: GridDefinitionTemplate50, 837 32768: GridDefinitionTemplate32768, 838 32769: GridDefinitionTemplate32769, 839 } 840 841def gdt_class_by_gdtn(gdtn): 842 """ 843 Provides a Grid Definition Template class via the template number 844 845 Parameters 846 ---------- 847 **`gdtn : int`** 848 Grid definition template number. 849 850 Returns 851 ------- 852 Grid definition template class object (not an instance). 853 """ 854 return _gdt_by_gdtn[gdtn] 855 856# ---------------------------------------------------------------------------------------- 857# Descriptor Classes for Section 4 metadata. 858# ---------------------------------------------------------------------------------------- 859class ProductDefinitionTemplateNumber: 860 """[Product Definition Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-0.shtml)""" 861 def __get__(self, obj, objtype=None): 862 return Grib2Metadata(obj.section4[1],table='4.0') 863 def __set__(self, obj, value): 864 raise RuntimeError 865 866# since PDT begins at position 2 of section4, code written with +2 for added readability with grib2 documentation 867class ProductDefinitionTemplate: 868 """Product Definition Template""" 869 def __get__(self, obj, objtype=None): 870 return obj.section4[2:] 871 def __set__(self, obj, value): 872 raise RuntimeError 873 874class ParameterCategory: 875 """[Parameter Category](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-1.shtml)""" 876 _key = defaultdict(lambda: 0) 877 def __get__(self, obj, objtype=None): 878 return obj.section4[0+2] 879 def __set__(self, obj, value): 880 obj.section4[self._key[obj.pdtn]+2] = value 881 882class ParameterNumber: 883 """[Parameter Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-2.shtml)""" 884 _key = defaultdict(lambda: 1) 885 def __get__(self, obj, objtype=None): 886 return obj.section4[1+2] 887 def __set__(self, obj, value): 888 obj.section4[self._key[obj.pdtn]+2] = value 889 890class VarInfo: 891 """ 892 Variable Information. These are the metadata returned for a specific variable according 893 to discipline, parameter category, and parameter number. 894 """ 895 def __get__(self, obj, objtype=None): 896 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD) 897 def __set__(self, obj, value): 898 raise RuntimeError 899 900class FullName: 901 """Full name of the Variable""" 902 def __get__(self, obj, objtype=None): 903 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[0] 904 def __set__(self, obj, value): 905 raise RuntimeError 906 907class Units: 908 """Units of the Variable""" 909 def __get__(self, obj, objtype=None): 910 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[1] 911 def __set__(self, obj, value): 912 raise RuntimeError 913 914class ShortName: 915 """ Short name of the variable (i.e. the variable abbreviation)""" 916 def __get__(self, obj, objtype=None): 917 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[2] 918 def __set__(self, obj, value): 919 raise RuntimeError 920 921class TypeOfGeneratingProcess: 922 """[Type of Generating Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-3.shtml)""" 923 _key = defaultdict(lambda: 2, {48:13}) 924 #_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} 925 def __get__(self, obj, objtype=None): 926 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.3') 927 def __set__(self, obj, value): 928 obj.section4[self._key[obj.pdtn]+2] = value 929 930class BackgroundGeneratingProcessIdentifier: 931 """Background Generating Process Identifier""" 932 _key = defaultdict(lambda: 3, {48:14}) 933 #_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} 934 def __get__(self, obj, objtype=None): 935 return obj.section4[self._key[obj.pdtn]+2] 936 def __set__(self, obj, value): 937 obj.section4[self._key[obj.pdtn]+2] = value 938 939class GeneratingProcess: 940 """[Generating Process](https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablea.html)""" 941 _key = defaultdict(lambda: 4, {48:15}) 942 #_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} 943 def __get__(self, obj, objtype=None): 944 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='generating_process') 945 def __set__(self, obj, value): 946 obj.section4[self._key[obj.pdtn]+2] = value 947 948class HoursAfterDataCutoff: 949 """Hours of observational data cutoff after reference time""" 950 _key = defaultdict(lambda: 5, {48:16}) 951 def __get__(self, obj, objtype=None): 952 return obj.section4[self._key[obj.pdtn]+2] 953 def __set__(self, obj, value): 954 obj.section4[self._key[obj.pdtn]+2] = value 955 956class MinutesAfterDataCutoff: 957 """Minutes of observational data cutoff after reference time""" 958 _key = defaultdict(lambda: 6, {48:17}) 959 def __get__(self, obj, objtype=None): 960 return obj.section4[self._key[obj.pdtn]+2] 961 def __set__(self, obj, value): 962 obj.section4[self._key[obj.pdtn]+2] = value 963 964class UnitOfForecastTime: 965 """[Units of Forecast Time](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-4.shtml)""" 966 _key = defaultdict(lambda: 7, {48:18}) 967 #_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} 968 def __get__(self, obj, objtype=None): 969 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.4') 970 def __set__(self, obj, value): 971 obj.section4[self._key[obj.pdtn]+2] = value 972 973class ValueOfForecastTime: 974 """Value of forecast time in units defined by `UnitofForecastTime`""" 975 _key = defaultdict(lambda: 8, {48:19}) 976 def __get__(self, obj, objtype=None): 977 return obj.section4[self._key[obj.pdtn]+2] 978 def __set__(self, obj, value): 979 obj.section4[self._key[obj.pdtn]+2] = value 980 981class LeadTime: 982 """Forecast Lead Time. NOTE: This is a `datetime.timedelta` object.""" 983 def __get__(self, obj, objtype=None): 984 return utils.get_leadtime(obj.section1,obj.section4[1], 985 obj.section4[2:]) 986 def __set__(self, obj, value): 987 raise NotImplementedError 988 989class FixedSfc1Info: 990 """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)""" 991 _key = defaultdict(lambda: 9, {48:20}) 992 #_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} 993 def __get__(self, obj, objtype=None): 994 if obj.section4[self._key[obj.pdtn]+2] == 255: 995 return [None, None] 996 return tables.get_value_from_table(obj.section4[self._key[obj.pdtn]+2],'4.5') 997 def __set__(self, obj, value): 998 raise NotImplementedError 999 1000class FixedSfc2Info: 1001 """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)""" 1002 _key = defaultdict(lambda: 12, {48:23}) 1003 #_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} 1004 def __get__(self, obj, objtype=None): 1005 if obj.section4[self._key[obj.pdtn]+2] == 255: 1006 return [None, None] 1007 return tables.get_value_from_table(obj.section4[self._key[obj.pdtn]+2],'4.5') 1008 def __set__(self, obj, value): 1009 raise NotImplementedError 1010 1011class TypeOfFirstFixedSurface: 1012 """[Type of First Fixed Surface](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)""" 1013 _key = defaultdict(lambda: 9, {48:20}) 1014 #_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} 1015 def __get__(self, obj, objtype=None): 1016 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.5') 1017 def __set__(self, obj, value): 1018 obj.section4[self._key[obj.pdtn]+2] = value 1019 1020class ScaleFactorOfFirstFixedSurface: 1021 """Scale Factor of First Fixed Surface""" 1022 _key = defaultdict(lambda: 10, {48:21}) 1023 #_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} 1024 def __get__(self, obj, objtype=None): 1025 return obj.section4[self._key[obj.pdtn]+2] 1026 def __set__(self, obj, value): 1027 obj.section4[self._key[obj.pdtn]+2] = value 1028 1029class ScaledValueOfFirstFixedSurface: 1030 """Scaled Value Of First Fixed Surface""" 1031 _key = defaultdict(lambda: 11, {48:22}) 1032 #_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} 1033 def __get__(self, obj, objtype=None): 1034 return obj.section4[self._key[obj.pdtn]+2] 1035 def __set__(self, obj, value): 1036 obj.section4[self._key[obj.pdtn]+2] = value 1037 1038class UnitOfFirstFixedSurface: 1039 """Units of First Fixed Surface""" 1040 def __get__(self, obj, objtype=None): 1041 return obj._fixedsfc1info[1] 1042 def __set__(self, obj, value): 1043 pass 1044 1045class ValueOfFirstFixedSurface: 1046 """Value of First Fixed Surface""" 1047 def __get__(self, obj, objtype=None): 1048 return obj.section4[ScaledValueOfFirstFixedSurface._key[obj.pdtn]+2]/\ 1049 (10.**obj.section4[ScaleFactorOfFirstFixedSurface._key[obj.pdtn]+2]) 1050 def __set__(self, obj, value): 1051 pass 1052 1053class TypeOfSecondFixedSurface: 1054 """[Type of Second Fixed Surface](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)""" 1055 _key = defaultdict(lambda: 12, {48:23}) 1056 #_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} 1057 def __get__(self, obj, objtype=None): 1058 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.5') 1059 def __set__(self, obj, value): 1060 obj.section4[self._key[obj.pdtn]+2] = value 1061 1062class ScaleFactorOfSecondFixedSurface: 1063 """Scale Factor of Second Fixed Surface""" 1064 _key = defaultdict(lambda: 13, {48:24}) 1065 #_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} 1066 def __get__(self, obj, objtype=None): 1067 return obj.section4[self._key[obj.pdtn]+2] 1068 def __set__(self, obj, value): 1069 obj.section4[self._key[obj.pdtn]+2] = value 1070 1071class ScaledValueOfSecondFixedSurface: 1072 """Scaled Value Of Second Fixed Surface""" 1073 _key = defaultdict(lambda: 14, {48:25}) 1074 #_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} 1075 def __get__(self, obj, objtype=None): 1076 return obj.section4[self._key[obj.pdtn]+2] 1077 def __set__(self, obj, value): 1078 obj.section4[self._key[obj.pdtn]+2] = value 1079 1080class UnitOfSecondFixedSurface: 1081 """Units of Second Fixed Surface""" 1082 def __get__(self, obj, objtype=None): 1083 return obj._fixedsfc2info[1] 1084 def __set__(self, obj, value): 1085 pass 1086 1087class ValueOfSecondFixedSurface: 1088 """Value of Second Fixed Surface""" 1089 def __get__(self, obj, objtype=None): 1090 return obj.section4[ScaledValueOfFirstFixedSurface._key[obj.pdtn]+2]/\ 1091 (10.**obj.section4[ScaleFactorOfFirstFixedSurface._key[obj.pdtn]+2]) 1092 def __set__(self, obj, value): 1093 pass 1094 1095class Level: 1096 """Level (same as provided by [wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Level.c))""" 1097 def __get__(self, obj, objtype=None): 1098 return tables.get_wgrib2_level_string(obj.pdtn,obj.section4[2:]) 1099 def __set__(self, obj, value): 1100 pass 1101 1102class TypeOfEnsembleForecast: 1103 """[Type of Ensemble Forecast](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-6.shtml)""" 1104 _key = {1:15, 11:15} 1105 def __get__(self, obj, objtype=None): 1106 pdtn = obj.section4[1] 1107 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.6') 1108 def __set__(self, obj, value): 1109 pdtn = obj.section4[1] 1110 obj.section4[self._key[pdtn]+2] = value 1111 1112class PerturbationNumber: 1113 """Ensemble Perturbation Number""" 1114 _key = {1:16, 11:16} 1115 def __get__(self, obj, objtype=None): 1116 pdtn = obj.section4[1] 1117 return obj.section4[self._key[pdtn]+2] 1118 def __set__(self, obj, value): 1119 pdtn = obj.section4[1] 1120 obj.section4[self._key[pdtn]+2] = value 1121 1122class NumberOfEnsembleForecasts: 1123 """Total Number of Ensemble Forecasts""" 1124 _key = {1:17, 2:16, 11:17, 12:16} 1125 def __get__(self, obj, objtype=None): 1126 pdtn = obj.section4[1] 1127 return obj.section4[self._key[pdtn]+2] 1128 def __set__(self, obj, value): 1129 pdtn = obj.section4[1] 1130 obj.section4[self._key[pdtn]+2] = value 1131 1132class TypeOfDerivedForecast: 1133 """[Type of Derived Forecast](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-7.shtml)""" 1134 _key = {2:15, 12:15} 1135 def __get__(self, obj, objtype=None): 1136 pdtn = obj.section4[1] 1137 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.7') 1138 def __set__(self, obj, value): 1139 pdtn = obj.section4[1] 1140 obj.section4[self._key[pdtn]+2] = value 1141 1142class ForecastProbabilityNumber: 1143 """Forecast Probability Number""" 1144 _key = {5:15, 9:15} 1145 def __get__(self, obj, objtype=None): 1146 pdtn = obj.section4[1] 1147 return obj.section4[self._key[pdtn]+2] 1148 def __set__(self, obj, value): 1149 pdtn = obj.section4[1] 1150 obj.section4[self._key[pdtn]+2] = value 1151 1152class TotalNumberOfForecastProbabilities: 1153 """Total Number of Forecast Probabilities""" 1154 _key = {5:16, 9:16} 1155 def __get__(self, obj, objtype=None): 1156 pdtn = obj.section4[1] 1157 return obj.section4[self._key[pdtn]+2] 1158 def __set__(self, obj, value): 1159 pdtn = obj.section4[1] 1160 obj.section4[self._key[pdtn]+2] = value 1161 1162class TypeOfProbability: 1163 """[Type of Probability](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-9.shtml)""" 1164 _key = {5:17, 9:17} 1165 def __get__(self, obj, objtype=None): 1166 pdtn = obj.section4[1] 1167 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.9') 1168 def __set__(self, obj, value): 1169 pdtn = obj.section4[1] 1170 obj.section4[self._key[pdtn]+2] = value 1171 1172class ScaleFactorOfThresholdLowerLimit: 1173 """Scale Factor of Threshold Lower Limit""" 1174 _key = {5:18, 9:18} 1175 def __get__(self, obj, objtype=None): 1176 pdtn = obj.section4[1] 1177 return obj.section4[self._key[pdtn]+2] 1178 def __set__(self, obj, value): 1179 pdtn = obj.section4[1] 1180 obj.section4[self._key[pdtn]+2] = value 1181 1182class ScaledValueOfThresholdLowerLimit: 1183 """Scaled Value of Threshold Lower Limit""" 1184 _key = {5:19, 9:19} 1185 def __get__(self, obj, objtype=None): 1186 pdtn = obj.section4[1] 1187 return obj.section4[self._key[pdtn]+2] 1188 def __set__(self, obj, value): 1189 pdtn = obj.section4[1] 1190 obj.section4[self._key[pdtn]+2] = value 1191 1192class ScaleFactorOfThresholdUpperLimit: 1193 """Scale Factor of Threshold Upper Limit""" 1194 _key = {5:20, 9:20} 1195 def __get__(self, obj, objtype=None): 1196 pdtn = obj.section4[1] 1197 return obj.section4[self._key[pdtn]+2] 1198 def __set__(self, obj, value): 1199 pdtn = obj.section4[1] 1200 obj.section4[self._key[pdtn]+2] = value 1201 1202class ScaledValueOfThresholdUpperLimit: 1203 """Scaled Value of Threshold Upper Limit""" 1204 _key = {5:21, 9:21} 1205 def __get__(self, obj, objtype=None): 1206 pdtn = obj.section4[1] 1207 return obj.section4[self._key[pdtn]+2] 1208 def __set__(self, obj, value): 1209 pdtn = obj.section4[1] 1210 obj.section4[self._key[pdtn]+2] = value 1211 1212class ThresholdLowerLimit: 1213 """Threshold Lower Limit""" 1214 def __get__(self, obj, objtype=None): 1215 if obj.section4[18+2] == -127 and \ 1216 obj.section4[19+2] == 255: 1217 return 0.0 1218 else: 1219 return obj.section4[19+2]/(10.**obj.section4[18+2]) 1220 def __set__(self, obj, value): 1221 pass 1222 1223class ThresholdUpperLimit: 1224 """Threshold Upper Limit""" 1225 def __get__(self, obj, objtype=None): 1226 if obj.section4[20+2] == -127 and \ 1227 obj.section4[21+2] == 255: 1228 return 0.0 1229 else: 1230 return obj.section4[21+2]/(10.**obj.section4[20+2]) 1231 def __set__(self, obj, value): 1232 pass 1233 1234class Threshold: 1235 """Threshold string (same as [wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Prob.c))""" 1236 def __get__(self, obj, objtype=None): 1237 return utils.get_wgrib2_prob_string(*obj.section4[17+2:22+2]) 1238 def __set__(self, obj, value): 1239 pass 1240 1241class PercentileValue: 1242 """Percentile Value""" 1243 _key = {6:15, 10:15} 1244 def __get__(self, obj, objtype=None): 1245 pdtn = obj.section4[1] 1246 return obj.section4[self._key[pdtn]+2] 1247 def __set__(self, obj, value): 1248 pdtn = obj.section4[1] 1249 obj.section4[self._key[pdtn]+2] = value 1250 1251class YearOfEndOfTimePeriod: 1252 """Year of End of Forecast Time Period""" 1253 _key = {8:15, 9:22, 10:16, 11:18, 12:17} 1254 def __get__(self, obj, objtype=None): 1255 pdtn = obj.section4[1] 1256 return obj.section4[self._key[pdtn]+2] 1257 def __set__(self, obj, value): 1258 pdtn = obj.section4[1] 1259 obj.section4[self._key[pdtn]+2] = value 1260 1261class MonthOfEndOfTimePeriod: 1262 """Month Year of End of Forecast Time Period""" 1263 _key = {8:16, 9:23, 10:17, 11:19, 12:18} 1264 def __get__(self, obj, objtype=None): 1265 pdtn = obj.section4[1] 1266 return obj.section4[self._key[pdtn]+2] 1267 def __set__(self, obj, value): 1268 pdtn = obj.section4[1] 1269 obj.section4[self._key[pdtn]+2] = value 1270 1271class DayOfEndOfTimePeriod: 1272 """Day Year of End of Forecast Time Period""" 1273 _key = {8:17, 9:24, 10:18, 11:20, 12:19} 1274 def __get__(self, obj, objtype=None): 1275 pdtn = obj.section4[1] 1276 return obj.section4[self._key[pdtn]+2] 1277 def __set__(self, obj, value): 1278 pdtn = obj.section4[1] 1279 obj.section4[self._key[pdtn]+2] = value 1280 1281class HourOfEndOfTimePeriod: 1282 """Hour Year of End of Forecast Time Period""" 1283 _key = {8:18, 9:25, 10:19, 11:21, 12:20} 1284 def __get__(self, obj, objtype=None): 1285 pdtn = obj.section4[1] 1286 return obj.section4[self._key[pdtn]+2] 1287 def __set__(self, obj, value): 1288 pdtn = obj.section4[1] 1289 obj.section4[self._key[pdtn]+2] = value 1290 1291class MinuteOfEndOfTimePeriod: 1292 """Minute Year of End of Forecast Time Period""" 1293 _key = {8:19, 9:26, 10:20, 11:22, 12:21} 1294 def __get__(self, obj, objtype=None): 1295 pdtn = obj.section4[1] 1296 return obj.section4[self._key[pdtn]+2] 1297 def __set__(self, obj, value): 1298 pdtn = obj.section4[1] 1299 obj.section4[self._key[pdtn]+2] = value 1300 1301class SecondOfEndOfTimePeriod: 1302 """Second Year of End of Forecast Time Period""" 1303 _key = {8:20, 9:27, 10:21, 11:23, 12:22} 1304 def __get__(self, obj, objtype=None): 1305 pdtn = obj.section4[1] 1306 return obj.section4[self._key[pdtn]+2] 1307 def __set__(self, obj, value): 1308 pdtn = obj.section4[1] 1309 obj.section4[self._key[pdtn]+2] = value 1310 1311class Duration: 1312 """Duration of time period. NOTE: This is a `datetime.timedelta` object.""" 1313 def __get__(self, obj, objtype=None): 1314 return utils.get_duration(obj.section4[1],obj.section4[2:]) 1315 def __set__(self, obj, value): 1316 pass 1317 1318class ValidDate: 1319 """Valid Date of the forecast. NOTE: This is a `datetime.datetime` object.""" 1320 _key = {8:slice(15,21), 9:slice(22,28), 10:slice(16,22), 11:slice(18,24), 12:slice(17,23)} 1321 def __get__(self, obj, objtype=None): 1322 pdtn = obj.section4[1] 1323 try: 1324 s = slice(self._key[pdtn].start+2,self._key[pdtn].stop+2) 1325 return datetime.datetime(*obj.section4[s]) 1326 except(KeyError): 1327 return obj.refDate + obj.leadTime 1328 def __set__(self, obj, value): 1329 pass 1330 1331class NumberOfTimeRanges: 1332 """Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field""" 1333 _key = {8:21, 9:28, 10:22, 11:24, 12:23} 1334 def __get__(self, obj, objtype=None): 1335 pdtn = obj.section4[1] 1336 return obj.section4[self._key[pdtn]+2] 1337 def __set__(self, obj, value): 1338 pdtn = obj.section4[1] 1339 obj.section4[self._key[pdtn]+2] = value 1340 1341class NumberOfMissingValues: 1342 """Total number of data values missing in statistical process""" 1343 _key = {8:22, 9:29, 10:23, 11:25, 12:24} 1344 def __get__(self, obj, objtype=None): 1345 pdtn = obj.section4[1] 1346 return obj.section4[self._key[pdtn]+2] 1347 def __set__(self, obj, value): 1348 pdtn = obj.section4[1] 1349 obj.section4[self._key[pdtn]+2] = value 1350 1351class StatisticalProcess: 1352 """[Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-10.shtml)""" 1353 _key = {8:23, 9:30, 10:24, 11:26, 12:25, 15:15} 1354 def __get__(self, obj, objtype=None): 1355 pdtn = obj.section4[1] 1356 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.10') 1357 def __set__(self, obj, value): 1358 pdtn = obj.section4[1] 1359 obj.section4[self._key[pdtn]+2] = value 1360 1361class TypeOfTimeIncrementOfStatisticalProcess: 1362 """[Type of Time Increment of Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-11.shtml)""" 1363 _key = {8:24, 9:31, 10:25, 11:27, 12:26} 1364 def __get__(self, obj, objtype=None): 1365 pdtn = obj.section4[1] 1366 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.11') 1367 def __set__(self, obj, value): 1368 pdtn = obj.section4[1] 1369 obj.section4[self._key[pdtn]+2] = value 1370 1371class UnitOfTimeRangeOfStatisticalProcess: 1372 """[Unit of Time Range of Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-11.shtml)""" 1373 _key = {8:25, 9:32, 10:26, 11:28, 12:27} 1374 def __get__(self, obj, objtype=None): 1375 pdtn = obj.section4[1] 1376 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.4') 1377 def __set__(self, obj, value): 1378 pdtn = obj.section4[1] 1379 obj.section4[self._key[pdtn]+2] = value 1380 1381class TimeRangeOfStatisticalProcess: 1382 """Time Range of Statistical Process""" 1383 _key = {8:26, 9:33, 10:27, 11:29, 12:28} 1384 def __get__(self, obj, objtype=None): 1385 pdtn = obj.section4[1] 1386 return obj.section4[self._key[pdtn]+2] 1387 def __set__(self, obj, value): 1388 pdtn = obj.section4[1] 1389 obj.section4[self._key[pdtn]+2] = value 1390 1391class UnitOfTimeRangeOfSuccessiveFields: 1392 """[Unit of Time Range of Successive Fields](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-4.shtml)""" 1393 _key = {8:27, 9:34, 10:28, 11:30, 12:29} 1394 def __get__(self, obj, objtype=None): 1395 pdtn = obj.section4[1] 1396 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.4') 1397 def __set__(self, obj, value): 1398 pdtn = obj.section4[1] 1399 obj.section4[self._key[pdtn]+2] = value 1400 1401class TimeIncrementOfSuccessiveFields: 1402 """Time Increment of Successive Fields""" 1403 _key = {8:28, 9:35, 10:29, 11:31, 12:30} 1404 def __get__(self, obj, objtype=None): 1405 pdtn = obj.section4[1] 1406 return obj.section4[self._key[pdtn]+2] 1407 def __set__(self, obj, value): 1408 pdtn = obj.section4[1] 1409 obj.section4[self._key[pdtn]+2] = value 1410 1411class TypeOfStatisticalProcessing: 1412 """[Type of Statistical Processing](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-15.shtml)""" 1413 _key = {15:16} 1414 def __get__(self, obj, objtype=None): 1415 pdtn = obj.section4[1] 1416 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.15') 1417 def __set__(self, obj, value): 1418 pdtn = obj.section4[1] 1419 obj.section4[self._key[pdtn]+2] = value 1420 1421class NumberOfDataPointsForSpatialProcessing: 1422 """Number of Data Points for Spatial Processing""" 1423 _key = {15:17} 1424 def __get__(self, obj, objtype=None): 1425 pdtn = obj.section4[1] 1426 return obj.section4[self._key[pdtn]+2] 1427 def __set__(self, obj, value): 1428 pdtn = obj.section4[1] 1429 obj.section4[self._key[pdtn]+2] = value 1430 1431class TypeOfAerosol: 1432 """[Type of Aerosol](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-233.shtml)""" 1433 _key = {48:2} 1434 def __get__(self, obj, objtype=None): 1435 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.233') 1436 def __set__(self, obj, value): 1437 obj.section4[self._key[obj.pdtn]+2] = value 1438 1439class TypeOfIntervalForAerosolSize: 1440 """[Type of Interval for Aerosol Size](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-91.shtml)""" 1441 _key = {48:3} 1442 def __get__(self, obj, objtype=None): 1443 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.91') 1444 def __set__(self, obj, value): 1445 obj.section4[self._key[obj.pdtn]+2] = value 1446 1447class ScaleFactorOfFirstSize: 1448 """Scale Factor of First Size""" 1449 _key = {48:4} 1450 def __get__(self, obj, objtype=None): 1451 return obj.section4[self._key[obj.pdtn]+2] 1452 def __set__(self, obj, value): 1453 obj.section4[self._key[obj.pdtn]+2] = value 1454 1455class ScaledValueOfFirstSize: 1456 """Scaled Value of First Size""" 1457 _key = {48:5} 1458 def __get__(self, obj, objtype=None): 1459 return obj.section4[self._key[obj.pdtn]+2] 1460 def __set__(self, obj, value): 1461 obj.section4[self._key[obj.pdtn]+2] = value 1462 1463class ScaleFactorOfSecondSize: 1464 """Scale Factor of Second Size""" 1465 _key = {48:6} 1466 def __get__(self, obj, objtype=None): 1467 return obj.section4[self._key[obj.pdtn]+2] 1468 def __set__(self, obj, value): 1469 obj.section4[self._key[obj.pdtn]+2] = value 1470 1471class ScaledValueOfSecondSize: 1472 """Scaled Value of Second Size""" 1473 _key = {48:7} 1474 def __get__(self, obj, objtype=None): 1475 return obj.section4[self._key[obj.pdtn]+2] 1476 def __set__(self, obj, value): 1477 obj.section4[self._key[obj.pdtn]+2] = value 1478 1479class TypeOfIntervalForAerosolWavelength: 1480 """[Type of Interval for Aerosol Wavelength](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-91.shtml)""" 1481 _key = {48:8} 1482 def __get__(self, obj, objtype=None): 1483 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.91') 1484 def __set__(self, obj, value): 1485 obj.section4[self._key[obj.pdtn]+2] = value 1486 1487class ScaleFactorOfFirstWavelength: 1488 """Scale Factor of First Wavelength""" 1489 _key = {48:9} 1490 def __get__(self, obj, objtype=None): 1491 return obj.section4[self._key[obj.pdtn]+2] 1492 def __set__(self, obj, value): 1493 obj.section4[self._key[obj.pdtn]+2] = value 1494 1495class ScaledValueOfFirstWavelength: 1496 """Scaled Value of First Wavelength""" 1497 _key = {48:10} 1498 def __get__(self, obj, objtype=None): 1499 return obj.section4[self._key[obj.pdtn]+2] 1500 def __set__(self, obj, value): 1501 obj.section4[self._key[obj.pdtn]+2] = value 1502 1503class ScaleFactorOfSecondWavelength: 1504 """Scale Factor of Second Wavelength""" 1505 _key = {48:11} 1506 def __get__(self, obj, objtype=None): 1507 return obj.section4[self._key[obj.pdtn]+2] 1508 def __set__(self, obj, value): 1509 obj.section4[self._key[obj.pdtn]+2] = value 1510 1511class ScaledValueOfSecondWavelength: 1512 """Scaled Value of Second Wavelength""" 1513 _key = {48:12} 1514 def __get__(self, obj, objtype=None): 1515 return obj.section4[self._key[obj.pdtn]+2] 1516 def __set__(self, obj, value): 1517 obj.section4[self._key[obj.pdtn]+2] = value 1518 1519@dataclass(init=False) 1520class ProductDefinitionTemplate0(): 1521 """[Product Definition Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-0.shtml)""" 1522 _len = 15 1523 _num = 0 1524 parameterCategory: int = field(init=False,repr=False,default=ParameterCategory()) 1525 parameterNumber: int = field(init=False,repr=False,default=ParameterNumber()) 1526 typeOfGeneratingProcess: Grib2Metadata = field(init=False,repr=False,default=TypeOfGeneratingProcess()) 1527 generatingProcess: Grib2Metadata = field(init=False, repr=False, default=GeneratingProcess()) 1528 backgroundGeneratingProcessIdentifier: int = field(init=False,repr=False,default=BackgroundGeneratingProcessIdentifier()) 1529 hoursAfterDataCutoff: int = field(init=False,repr=False,default=HoursAfterDataCutoff()) 1530 minutesAfterDataCutoff: int = field(init=False,repr=False,default=MinutesAfterDataCutoff()) 1531 unitOfForecastTime: Grib2Metadata = field(init=False,repr=False,default=UnitOfForecastTime()) 1532 valueOfForecastTime: int = field(init=False,repr=False,default=ValueOfForecastTime()) 1533 typeOfFirstFixedSurface: Grib2Metadata = field(init=False,repr=False,default=TypeOfFirstFixedSurface()) 1534 scaleFactorOfFirstFixedSurface: int = field(init=False,repr=False,default=ScaleFactorOfFirstFixedSurface()) 1535 scaledValueOfFirstFixedSurface: int = field(init=False,repr=False,default=ScaledValueOfFirstFixedSurface()) 1536 typeOfSecondFixedSurface: Grib2Metadata = field(init=False,repr=False,default=TypeOfSecondFixedSurface()) 1537 scaleFactorOfSecondFixedSurface: int = field(init=False,repr=False,default=ScaleFactorOfSecondFixedSurface()) 1538 scaledValueOfSecondFixedSurface: int = field(init=False,repr=False,default=ScaledValueOfSecondFixedSurface()) 1539 @classmethod 1540 @property 1541 def _attrs(cls): 1542 return list(cls.__dataclass_fields__.keys()) 1543 1544@dataclass(init=False) 1545class ProductDefinitionTemplate1(ProductDefinitionTemplate0): 1546 """[Product Definition Template 1](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-1.shtml)""" 1547 _len = 18 1548 _num = 1 1549 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 1550 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 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()) 1556 1557@dataclass(init=False) 1558class ProductDefinitionTemplate2(ProductDefinitionTemplate0): 1559 """[Product Definition Template 2](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-2.shtml)""" 1560 _len = 17 1561 _num = 2 1562 typeOfDerivedForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfDerivedForecast()) 1563 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 1564 @classmethod 1565 @property 1566 def _attrs(cls): 1567 return list(cls.__dataclass_fields__.keys()) 1568 1569@dataclass(init=False) 1570class ProductDefinitionTemplate5(ProductDefinitionTemplate0): 1571 """[Product Definition Template 5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-5.shtml)""" 1572 _len = 22 1573 _num = 5 1574 forecastProbabilityNumber: int = field(init=False, repr=False, default=ForecastProbabilityNumber()) 1575 totalNumberOfForecastProbabilities: int = field(init=False, repr=False, default=TotalNumberOfForecastProbabilities()) 1576 typeOfProbability: Grib2Metadata = field(init=False, repr=False, default=TypeOfProbability()) 1577 scaleFactorOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdLowerLimit()) 1578 scaledValueOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdLowerLimit()) 1579 scaleFactorOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdUpperLimit()) 1580 scaledValueOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdUpperLimit()) 1581 thresholdLowerLimit: float = field(init=False, repr=False, default=ThresholdLowerLimit()) 1582 thresholdUpperLimit: float = field(init=False, repr=False, default=ThresholdUpperLimit()) 1583 threshold: str = field(init=False, repr=False, default=Threshold()) 1584 @classmethod 1585 @property 1586 def _attrs(cls): 1587 return list(cls.__dataclass_fields__.keys()) 1588 1589@dataclass(init=False) 1590class ProductDefinitionTemplate6(ProductDefinitionTemplate0): 1591 """[Product Definition Template 6](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-6.shtml)""" 1592 _len = 16 1593 _num = 6 1594 percentileValue: int = field(init=False, repr=False, default=PercentileValue()) 1595 @classmethod 1596 @property 1597 def _attrs(cls): 1598 return list(cls.__dataclass_fields__.keys()) 1599 1600@dataclass(init=False) 1601class ProductDefinitionTemplate8(ProductDefinitionTemplate0): 1602 """[Product Definition Template 8](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-8.shtml)""" 1603 _len = 29 1604 _num = 8 1605 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 1606 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 1607 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 1608 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 1609 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 1610 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 1611 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 1612 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 1613 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 1614 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 1615 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 1616 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 1617 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 1618 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 1619 @classmethod 1620 @property 1621 def _attrs(cls): 1622 return list(cls.__dataclass_fields__.keys()) 1623 1624@dataclass(init=False) 1625class ProductDefinitionTemplate9(ProductDefinitionTemplate0): 1626 """[Product Definition Template 9](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-9.shtml)""" 1627 _len = 36 1628 _num = 9 1629 forecastProbabilityNumber: int = field(init=False, repr=False, default=ForecastProbabilityNumber()) 1630 totalNumberOfForecastProbabilities: int = field(init=False, repr=False, default=TotalNumberOfForecastProbabilities()) 1631 typeOfProbability: Grib2Metadata = field(init=False, repr=False, default=TypeOfProbability()) 1632 scaleFactorOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdLowerLimit()) 1633 scaledValueOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdLowerLimit()) 1634 scaleFactorOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdUpperLimit()) 1635 scaledValueOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdUpperLimit()) 1636 thresholdLowerLimit: float = field(init=False, repr=False, default=ThresholdLowerLimit()) 1637 thresholdUpperLimit: float = field(init=False, repr=False, default=ThresholdUpperLimit()) 1638 threshold: str = field(init=False, repr=False, default=Threshold()) 1639 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 1640 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 1641 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 1642 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 1643 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 1644 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 1645 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 1646 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 1647 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 1648 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 1649 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 1650 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 1651 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 1652 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 1653 @classmethod 1654 @property 1655 def _attrs(cls): 1656 return list(cls.__dataclass_fields__.keys()) 1657 1658@dataclass(init=False) 1659class ProductDefinitionTemplate10(ProductDefinitionTemplate0): 1660 """[Product Definition Template 10](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-10.shtml)""" 1661 _len = 30 1662 _num = 10 1663 percentileValue: int = field(init=False, repr=False, default=PercentileValue()) 1664 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 1665 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 1666 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 1667 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 1668 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 1669 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 1670 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 1671 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 1672 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 1673 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 1674 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 1675 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 1676 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 1677 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 1678 @classmethod 1679 @property 1680 def _attrs(cls): 1681 return list(cls.__dataclass_fields__.keys()) 1682 1683@dataclass(init=False) 1684class ProductDefinitionTemplate11(ProductDefinitionTemplate0): 1685 """[Product Definition Template 11](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-11.shtml)""" 1686 _len = 32 1687 _num = 11 1688 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 1689 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 1690 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 1691 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 1692 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 1693 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 1694 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 1695 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 1696 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 1697 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 1698 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 1699 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 1700 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 1701 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 1702 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 1703 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 1704 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 1705 @classmethod 1706 @property 1707 def _attrs(cls): 1708 return list(cls.__dataclass_fields__.keys()) 1709 1710@dataclass(init=False) 1711class ProductDefinitionTemplate12(ProductDefinitionTemplate0): 1712 """[Product Definition Template 12](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-12.shtml)""" 1713 _len = 31 1714 _num = 12 1715 typeOfDerivedForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfDerivedForecast()) 1716 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 1717 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 1718 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 1719 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 1720 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 1721 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 1722 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 1723 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 1724 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 1725 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 1726 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 1727 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 1728 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 1729 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 1730 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 1731 @classmethod 1732 @property 1733 def _attrs(cls): 1734 return list(cls.__dataclass_fields__.keys()) 1735 1736@dataclass(init=False) 1737class ProductDefinitionTemplate15(ProductDefinitionTemplate0): 1738 """[Product Definition Template 15](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-15.shtml)""" 1739 _len = 18 1740 _num = 15 1741 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 1742 typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing()) 1743 numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing()) 1744 @classmethod 1745 @property 1746 def _attrs(cls): 1747 return list(cls.__dataclass_fields__.keys()) 1748 1749@dataclass(init=False) 1750class ProductDefinitionTemplate48(ProductDefinitionTemplate0): 1751 """[Product Definition Template 48](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-48.shtml)""" 1752 _len = 26 1753 _num = 48 1754 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 1755 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 1756 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 1757 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 1758 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 1759 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 1760 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 1761 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 1762 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 1763 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 1764 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 1765 @classmethod 1766 @property 1767 def _attrs(cls): 1768 return list(cls.__dataclass_fields__.keys()) 1769 1770_pdt_by_pdtn = { 1771 0: ProductDefinitionTemplate0, 1772 1: ProductDefinitionTemplate1, 1773 2: ProductDefinitionTemplate2, 1774 5: ProductDefinitionTemplate5, 1775 6: ProductDefinitionTemplate6, 1776 8: ProductDefinitionTemplate8, 1777 9: ProductDefinitionTemplate9, 1778 10: ProductDefinitionTemplate10, 1779 11: ProductDefinitionTemplate11, 1780 12: ProductDefinitionTemplate12, 1781 15: ProductDefinitionTemplate15, 1782 48: ProductDefinitionTemplate48, 1783 } 1784 1785def pdt_class_by_pdtn(pdtn): 1786 """ 1787 Provides a Product Definition Template class via the template number 1788 1789 Parameters 1790 ---------- 1791 **`pdtn : int`** 1792 Product definition template number. 1793 1794 Returns 1795 ------- 1796 Product definition template class object (not an instance). 1797 """ 1798 return _pdt_by_pdtn[pdtn] 1799 1800# ---------------------------------------------------------------------------------------- 1801# Descriptor Classes for Section 5 metadata. 1802# ---------------------------------------------------------------------------------------- 1803class NumberOfPackedValues: 1804 """Number of Packed Values""" 1805 def __get__(self, obj, objtype=None): 1806 return obj.section5[0] 1807 def __set__(self, obj, value): 1808 pass 1809 1810class DataRepresentationTemplateNumber: 1811 """[Data Representation Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-0.shtml)""" 1812 def __get__(self, obj, objtype=None): 1813 return Grib2Metadata(obj.section5[1],table='5.0') 1814 def __set__(self, obj, value): 1815 pass 1816 1817class DataRepresentationTemplate: 1818 """Data Representation Template""" 1819 def __get__(self, obj, objtype=None): 1820 return obj.section5[2:] 1821 def __set__(self, obj, value): 1822 raise NotImplementedError 1823 1824class RefValue: 1825 """Reference Value (represented as an IEEE 32-bit floating point value)""" 1826 def __get__(self, obj, objtype=None): 1827 return utils.ieee_int_to_float(obj.section5[0+2]) 1828 def __set__(self, obj, value): 1829 pass 1830 1831class BinScaleFactor: 1832 """Binary Scale Factor""" 1833 def __get__(self, obj, objtype=None): 1834 return obj.section5[1+2] 1835 def __set__(self, obj, value): 1836 obj.section5[1+2] = value 1837 1838class DecScaleFactor: 1839 """Decimal Scale Factor""" 1840 def __get__(self, obj, objtype=None): 1841 return obj.section5[2+2] 1842 def __set__(self, obj, value): 1843 obj.section5[2+2] = value 1844 1845class NBitsPacking: 1846 """Minimum number of bits for packing""" 1847 def __get__(self, obj, objtype=None): 1848 return obj.section5[3+2] 1849 def __set__(self, obj, value): 1850 obj.section5[3+2] = value 1851 1852class TypeOfValues: 1853 """[Type of Original Field Values](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-1.shtml)""" 1854 def __get__(self, obj, objtype=None): 1855 return Grib2Metadata(obj.section5[4+2],table='5.1') 1856 def __set__(self, obj, value): 1857 obj.section5[4+2] = value 1858 1859class GroupSplittingMethod: 1860 """[Group Splitting Method](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-4.shtml)""" 1861 def __get__(self, obj, objtype=None): 1862 return Grib2Metadata(obj.section5[5+2],table='5.4') 1863 def __set__(self, obj, value): 1864 obj.section5[5+2] = value 1865 1866class TypeOfMissingValueManagement: 1867 """[Type of Missing Value Management](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-5.shtml)""" 1868 def __get__(self, obj, objtype=None): 1869 return Grib2Metadata(obj.section5[6+2],table='5.5') 1870 def __set__(self, obj, value): 1871 obj.section5[6+2] = value 1872 1873class PriMissingValue: 1874 """Primary Missing Value""" 1875 def __get__(self, obj, objtype=None): 1876 if obj.typeOfValues == 0: 1877 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 1878 elif obj.typeOfValues == 1: 1879 return obj.section5[7+2] if obj.section5[6+2] in [1,2] else None 1880 def __set__(self, obj, value): 1881 if obj.typeOfValues == 0: 1882 obj.section5[7+2] = utils.ieee_float_to_int(value) 1883 elif self.typeOfValues == 1: 1884 obj.section5[7+2] = int(value) 1885 obj.section5[6+2] = 1 1886 1887class SecMissingValue: 1888 """Secondary Missing Value""" 1889 def __get__(self, obj, objtype=None): 1890 if obj.typeOfValues == 0: 1891 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 1892 elif obj.typeOfValues == 1: 1893 return obj.section5[8+2] if obj.section5[6+2] in {1,2} else None 1894 def __set__(self, obj, value): 1895 if obj.typeOfValues == 0: 1896 obj.section5[8+2] = utils.ieee_float_to_int(value) 1897 elif self.typeOfValues == 1: 1898 obj.section5[8+2] = int(value) 1899 obj.section5[6+2] = 2 1900 1901class NGroups: 1902 """Number of Groups""" 1903 def __get__(self, obj, objtype=None): 1904 return obj.section5[9+2] 1905 def __set__(self, obj, value): 1906 pass 1907 1908class RefGroupWidth: 1909 """Reference Group Width""" 1910 def __get__(self, obj, objtype=None): 1911 return obj.section5[10+2] 1912 def __set__(self, obj, value): 1913 pass 1914 1915class NBitsGroupWidth: 1916 """Number of bits for Group Width""" 1917 def __get__(self, obj, objtype=None): 1918 return obj.section5[11+2] 1919 def __set__(self, obj, value): 1920 pass 1921 1922class RefGroupLength: 1923 """Reference Group Length""" 1924 def __get__(self, obj, objtype=None): 1925 return obj.section5[12+2] 1926 def __set__(self, obj, value): 1927 pass 1928 1929class GroupLengthIncrement: 1930 """Group Length Increment""" 1931 def __get__(self, obj, objtype=None): 1932 return obj.section5[13+2] 1933 def __set__(self, obj, value): 1934 pass 1935 1936class LengthOfLastGroup: 1937 """Length of Last Group""" 1938 def __get__(self, obj, objtype=None): 1939 return obj.section5[14+2] 1940 def __set__(self, obj, value): 1941 pass 1942 1943class NBitsScaledGroupLength: 1944 """Number of bits of Scaled Group Length""" 1945 def __get__(self, obj, objtype=None): 1946 return obj.section5[15+2] 1947 def __set__(self, obj, value): 1948 pass 1949 1950class SpatialDifferenceOrder: 1951 """[Spatial Difference Order](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-6.shtml)""" 1952 def __get__(self, obj, objtype=None): 1953 return Grib2Metadata(obj.section5[16+2],table='5.6') 1954 def __set__(self, obj, value): 1955 obj.section5[16+2] = value 1956 1957class NBytesSpatialDifference: 1958 """Number of bytes for Spatial Differencing""" 1959 def __get__(self, obj, objtype=None): 1960 return obj.section5[17+2] 1961 def __set__(self, obj, value): 1962 pass 1963 1964class Precision: 1965 """[Precision for IEEE Floating Point Data](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-7.shtml)""" 1966 def __get__(self, obj, objtype=None): 1967 return Grib2Metadata(obj.section5[0+2],table='5.7') 1968 def __set__(self, obj, value): 1969 obj.section5[0+2] = value 1970 1971class TypeOfCompression: 1972 """[Type of Compression](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-40.shtml)""" 1973 def __get__(self, obj, objtype=None): 1974 return Grib2Metadata(obj.section5[5+2],table='5.40') 1975 def __set__(self, obj, value): 1976 obj.section5[5+2] = value 1977 1978class TargetCompressionRatio: 1979 """Target Compression Ratio""" 1980 def __get__(self, obj, objtype=None): 1981 return obj.section5[6+2] 1982 def __set__(self, obj, value): 1983 pass 1984 1985class RealOfCoefficient: 1986 """Real of Coefficient""" 1987 def __get__(self, obj, objtype=None): 1988 return utils.ieee_int_to_float(obj.section5[4+2]) 1989 def __set__(self, obj, value): 1990 obj.section5[4+2] = utils.ieee_float_to_int(float(value)) 1991 1992class CompressionOptionsMask: 1993 """Compression Options Mask for AEC/CCSDS""" 1994 def __get__(self, obj, objtype=None): 1995 return obj.section5[5+2] 1996 def __set__(self, obj, value): 1997 obj.section5[5+2] = value 1998 1999class BlockSize: 2000 """Block Size for AEC/CCSDS""" 2001 def __get__(self, obj, objtype=None): 2002 return obj.section5[6+2] 2003 def __set__(self, obj, value): 2004 obj.section5[6+2] = value 2005 2006class RefSampleInterval: 2007 """Reference Sample Interval for AEC/CCSDS""" 2008 def __get__(self, obj, objtype=None): 2009 return obj.section5[7+2] 2010 def __set__(self, obj, value): 2011 obj.section5[7+2] = value 2012 2013@dataclass(init=False) 2014class DataRepresentationTemplate0(): 2015 """[Data Representation Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-0.shtml)""" 2016 _len = 5 2017 _num = 0 2018 _packingScheme = 'simple' 2019 refValue: float = field(init=False, repr=False, default=RefValue()) 2020 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2021 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2022 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2023 @classmethod 2024 @property 2025 def _attrs(cls): 2026 return list(cls.__dataclass_fields__.keys()) 2027 2028@dataclass(init=False) 2029class DataRepresentationTemplate2(): 2030 """[Data Representation Template 2](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-2.shtml)""" 2031 _len = 16 2032 _num = 2 2033 _packingScheme = 'complex' 2034 refValue: float = field(init=False, repr=False, default=RefValue()) 2035 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2036 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2037 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2038 groupSplittingMethod: Grib2Metadata = field(init=False, repr=False, default=GroupSplittingMethod()) 2039 typeOfMissingValueManagement: Grib2Metadata = field(init=False, repr=False, default=TypeOfMissingValueManagement()) 2040 priMissingValue: [float, int] = field(init=False, repr=False, default=PriMissingValue()) 2041 secMissingValue: [float, int] = field(init=False, repr=False, default=SecMissingValue()) 2042 nGroups: int = field(init=False, repr=False, default=NGroups()) 2043 refGroupWidth: int = field(init=False, repr=False, default=RefGroupWidth()) 2044 nBitsGroupWidth: int = field(init=False, repr=False, default=NBitsGroupWidth()) 2045 refGroupLength: int = field(init=False, repr=False, default=RefGroupLength()) 2046 groupLengthIncrement: int = field(init=False, repr=False, default=GroupLengthIncrement()) 2047 lengthOfLastGroup: int = field(init=False, repr=False, default=LengthOfLastGroup()) 2048 nBitsScaledGroupLength: int = field(init=False, repr=False, default=NBitsScaledGroupLength()) 2049 @classmethod 2050 @property 2051 def _attrs(cls): 2052 return list(cls.__dataclass_fields__.keys()) 2053 2054@dataclass(init=False) 2055class DataRepresentationTemplate3(): 2056 """[Data Representation Template 3](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-3.shtml)""" 2057 _len = 18 2058 _num = 3 2059 _packingScheme = 'complex-spdiff' 2060 refValue: float = field(init=False, repr=False, default=RefValue()) 2061 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2062 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2063 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2064 groupSplittingMethod: Grib2Metadata = field(init=False, repr=False, default=GroupSplittingMethod()) 2065 typeOfMissingValueManagement: Grib2Metadata = field(init=False, repr=False, default=TypeOfMissingValueManagement()) 2066 priMissingValue: [float, int] = field(init=False, repr=False, default=PriMissingValue()) 2067 secMissingValue: [float, int] = field(init=False, repr=False, default=SecMissingValue()) 2068 nGroups: int = field(init=False, repr=False, default=NGroups()) 2069 refGroupWidth: int = field(init=False, repr=False, default=RefGroupWidth()) 2070 nBitsGroupWidth: int = field(init=False, repr=False, default=NBitsGroupWidth()) 2071 refGroupLength: int = field(init=False, repr=False, default=RefGroupLength()) 2072 groupLengthIncrement: int = field(init=False, repr=False, default=GroupLengthIncrement()) 2073 lengthOfLastGroup: int = field(init=False, repr=False, default=LengthOfLastGroup()) 2074 nBitsScaledGroupLength: int = field(init=False, repr=False, default=NBitsScaledGroupLength()) 2075 spatialDifferenceOrder: Grib2Metadata = field(init=False, repr=False, default=SpatialDifferenceOrder()) 2076 nBytesSpatialDifference: int = field(init=False, repr=False, default=NBytesSpatialDifference()) 2077 @classmethod 2078 @property 2079 def _attrs(cls): 2080 return list(cls.__dataclass_fields__.keys()) 2081 2082@dataclass(init=False) 2083class DataRepresentationTemplate4(): 2084 """[Data Representation Template 4](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-4.shtml)""" 2085 _len = 1 2086 _num = 4 2087 _packingScheme = 'ieee-float' 2088 precision: Grib2Metadata = field(init=False, repr=False, default=Precision()) 2089 @classmethod 2090 @property 2091 def _attrs(cls): 2092 return list(cls.__dataclass_fields__.keys()) 2093 2094@dataclass(init=False) 2095class DataRepresentationTemplate40(): 2096 """[Data Representation Template 40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-40.shtml)""" 2097 _len = 7 2098 _num = 40 2099 _packingScheme = 'jpeg' 2100 refValue: float = field(init=False, repr=False, default=RefValue()) 2101 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2102 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2103 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2104 typeOfCompression: Grib2Metadata = field(init=False, repr=False, default=TypeOfCompression()) 2105 targetCompressionRatio: int = field(init=False, repr=False, default=TargetCompressionRatio()) 2106 @classmethod 2107 @property 2108 def _attrs(cls): 2109 return list(cls.__dataclass_fields__.keys()) 2110 2111@dataclass(init=False) 2112class DataRepresentationTemplate41(): 2113 """[Data Representation Template 41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-41.shtml)""" 2114 _len = 5 2115 _num = 41 2116 _packingScheme = 'png' 2117 refValue: float = field(init=False, repr=False, default=RefValue()) 2118 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2119 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2120 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2121 @classmethod 2122 @property 2123 def _attrs(cls): 2124 return list(cls.__dataclass_fields__.keys()) 2125 2126@dataclass(init=False) 2127class DataRepresentationTemplate42(): 2128 """[Data Representation Template 42](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-42.shtml)""" 2129 _len = 8 2130 _num = 42 2131 _packingScheme = 'aec' 2132 refValue: float = field(init=False, repr=False, default=RefValue()) 2133 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2134 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2135 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2136 compressionOptionsMask: int = field(init=False, repr=False, default=CompressionOptionsMask()) 2137 blockSize: int = field(init=False, repr=False, default=BlockSize()) 2138 refSampleInterval: int = field(init=False, repr=False, default=RefSampleInterval()) 2139 @classmethod 2140 @property 2141 def _attrs(cls): 2142 return list(cls.__dataclass_fields__.keys()) 2143 2144@dataclass(init=False) 2145class DataRepresentationTemplate50(): 2146 """[Data Representation Template 50](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-50.shtml)""" 2147 _len = 5 2148 _num = 0 2149 _packingScheme = 'spectral-simple' 2150 refValue: float = field(init=False, repr=False, default=RefValue()) 2151 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2152 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2153 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2154 realOfCoefficient: float = field(init=False, repr=False, default=RealOfCoefficient()) 2155 @classmethod 2156 @property 2157 def _attrs(cls): 2158 return list(cls.__dataclass_fields__.keys()) 2159 2160_drt_by_drtn = { 2161 0: DataRepresentationTemplate0, 2162 2: DataRepresentationTemplate2, 2163 3: DataRepresentationTemplate3, 2164 4: DataRepresentationTemplate4, 2165 40: DataRepresentationTemplate40, 2166 41: DataRepresentationTemplate41, 2167 42: DataRepresentationTemplate42, 2168 50: DataRepresentationTemplate50, 2169 } 2170 2171def drt_class_by_drtn(drtn): 2172 """ 2173 Provides a Data Representation Template class via the template number 2174 2175 Parameters 2176 ---------- 2177 **`drtn : int`** 2178 Data Representation template number. 2179 2180 Returns 2181 ------- 2182 Data Representation template class object (not an instance). 2183 """ 2184 return _drt_by_drtn[drtn]
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.
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
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
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
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
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
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
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
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
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
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
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
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.
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
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
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
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
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
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
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
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
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
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
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
302class LLScaleFactor: 303 """Scale Factor for Lats/Lons""" 304 def __get__(self, obj, objtype=None): 305 if obj.section3[4] in {0,1,40,41,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
314class LLDivisor: 315 """Divisor Value for scaling Lats/Lons""" 316 def __get__(self, obj, objtype=None): 317 if obj.section3[4] in {0,1,40,41,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
326class XYDivisor: 327 """Divisor Value for scaling grid lengths""" 328 def __get__(self, obj, objtype=None): 329 if obj.section3[4] in {0,1,40,41,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
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
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
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")
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")
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")
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)
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)
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
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
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
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
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
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
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
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
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
485class GridlengthYDirection: 486 """Grid lenth in the Y-Direction""" 487 _key = {0:17, 1:17, 10:18, 20:15, 30:15, 31:15, 203:17, 204:17, 205:17, 32768:17, 32769:17} 488 def __get__(self, obj, objtype=None): 489 if obj.gdtn in {40, 41}: 490 return obj.gridlengthXDirection 491 else: 492 return (obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._xydivisor)*obj._dysign 493 def __set__(self, obj, value): 494 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._xydivisor/obj._llscalefactor)
Grid lenth in the Y-Direction
496class NumberOfParallels: 497 """Number of parallels between a pole and the equator""" 498 _key = {40:17, 41:17} 499 def __get__(self, obj, objtype=None): 500 return obj.section3[self._key[obj.gdtn]+5] 501 def __set__(self, obj, value): 502 raise RuntimeError
Number of parallels between a pole and the equator
504class LatitudeSouthernPole: 505 """Latitude of the Southern Pole for a Rotated Lat/Lon Grid""" 506 _key = {1:19, 30:20, 31:20, 41:19} 507 def __get__(self, obj, objtype=None): 508 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 509 def __set__(self, obj, value): 510 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Latitude of the Southern Pole for a Rotated Lat/Lon Grid
512class LongitudeSouthernPole: 513 """Longitude of the Southern Pole for a Rotated Lat/Lon Grid""" 514 _key = {1:20, 30:21, 31:21, 41:20} 515 def __get__(self, obj, objtype=None): 516 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 517 def __set__(self, obj, value): 518 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Longitude of the Southern Pole for a Rotated Lat/Lon Grid
520class AnglePoleRotation: 521 """Angle of Pole Rotation for a Rotated Lat/Lon Grid""" 522 _key = {1:21, 41:21} 523 def __get__(self, obj, objtype=None): 524 return obj.section3[self._key[obj.gdtn]+5] 525 def __set__(self, obj, value): 526 obj.section3[self._key[obj.gdtn]+5] = int(value)
Angle of Pole Rotation for a Rotated Lat/Lon Grid
528class LatitudeTrueScale: 529 """Latitude at which grid lengths are specified""" 530 _key = {10:12, 20:12, 30:12, 31:12} 531 def __get__(self, obj, objtype=None): 532 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 533 def __set__(self, obj, value): 534 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Latitude at which grid lengths are specified
536class GridOrientation: 537 """Longitude at which the grid is oriented""" 538 _key = {10:16, 20:13, 30:13, 31:13} 539 def __get__(self, obj, objtype=None): 540 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 541 def __set__(self, obj, value): 542 if obj.gdtn == 10 and (value < 0 or value > 90): 543 raise ValueError("Grid orientation is limited to range of 0 to 90 degrees.") 544 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Longitude at which the grid is oriented
546class ProjectionCenterFlag: 547 """[Projection Center](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-5.shtml)""" 548 _key = {20:16, 30:16, 31:16} 549 def __get__(self, obj, objtype=None): 550 return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list)[0] 551 def __set__(self, obj, value): 552 obj.section3[self._key[obj.gdtn]+5] = value
554class StandardLatitude1: 555 """First Standard Latitude (from the pole at which the secant cone cuts the sphere)""" 556 _key = {30:18, 31:18} 557 def __get__(self, obj, objtype=None): 558 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 559 def __set__(self, obj, value): 560 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)
562class StandardLatitude2: 563 """Second Standard Latitude (from the pole at which the secant cone cuts the sphere)""" 564 _key = {30:19, 31:19} 565 def __get__(self, obj, objtype=None): 566 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 567 def __set__(self, obj, value): 568 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)
570class SpectralFunctionParameters: 571 """Spectral Function Parameters""" 572 def __get__(self, obj, objtype=None): 573 return obj.section3[0:3] 574 def __set__(self, obj, value): 575 obj.section3[0:3] = value[0:3]
Spectral Function Parameters
577class ProjParameters: 578 """PROJ Parameters to define the reference system""" 579 def __get__(self, obj, objtype=None): 580 projparams = {} 581 projparams['a'] = 1.0 582 projparams['b'] = 1.0 583 if obj.earthRadius is not None: 584 projparams['a'] = obj.earthRadius 585 projparams['b'] = obj.earthRadius 586 else: 587 if obj.earthMajorAxis is not None: projparams['a'] = obj.earthMajorAxis 588 if obj.earthMajorAxis is not None: projparams['b'] = obj.earthMinorAxis 589 if obj.gdtn == 0: 590 projparams['proj'] = 'longlat' 591 elif obj.gdtn == 1: 592 projparams['o_proj'] = 'longlat' 593 projparams['proj'] = 'ob_tran' 594 projparams['o_lat_p'] = -1.0*obj.latitudeSouthernPole 595 projparams['o_lon_p'] = obj.anglePoleRotation 596 projparams['lon_0'] = obj.longitudeSouthernPole 597 elif obj.gdtn == 10: 598 projparams['proj'] = 'merc' 599 projparams['lat_ts'] = obj.latitudeTrueScale 600 projparams['lon_0'] = 0.5*(obj.longitudeFirstGridpoint+obj.longitudeLastGridpoint) 601 elif obj.gdtn == 20: 602 if obj.projectionCenterFlag == 0: 603 lat0 = 90.0 604 elif obj.projectionCenterFlag == 1: 605 lat0 = -90.0 606 projparams['proj'] = 'stere' 607 projparams['lat_ts'] = obj.latitudeTrueScale 608 projparams['lat_0'] = lat0 609 projparams['lon_0'] = obj.gridOrientation 610 elif obj.gdtn == 30: 611 projparams['proj'] = 'lcc' 612 projparams['lat_1'] = obj.standardLatitude1 613 projparams['lat_2'] = obj.standardLatitude2 614 projparams['lat_0'] = obj.latitudeTrueScale 615 projparams['lon_0'] = obj.gridOrientation 616 elif obj.gdtn == 31: 617 projparams['proj'] = 'aea' 618 projparams['lat_1'] = obj.standardLatitude1 619 projparams['lat_2'] = obj.standardLatitude2 620 projparams['lat_0'] = obj.latitudeTrueScale 621 projparams['lon_0'] = obj.gridOrientation 622 elif obj.gdtn == 40: 623 projparams['proj'] = 'eqc' 624 elif obj.gdtn == 32769: 625 projparams['proj'] = 'aeqd' 626 projparams['lon_0'] = obj.longitudeCenterGridpoint 627 projparams['lat_0'] = obj.latitudeCenterGridpoint 628 return projparams 629 def __set__(self, obj, value): 630 raise RuntimeError
PROJ Parameters to define the reference system
632@dataclass(init=False) 633class GridDefinitionTemplate0(): 634 """[Grid Definition Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-0.shtml)""" 635 _len = 19 636 _num = 0 637 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 638 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 639 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 640 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 641 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 642 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 643 @classmethod 644 @property 645 def _attrs(cls): 646 return list(cls.__dataclass_fields__.keys())
648@dataclass(init=False) 649class GridDefinitionTemplate1(): 650 """[Grid Definition Template 1](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-1.shtml)""" 651 _len = 22 652 _num = 1 653 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 654 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 655 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 656 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 657 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 658 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 659 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 660 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 661 anglePoleRotation: float = field(init=False, repr=False, default=AnglePoleRotation()) 662 @classmethod 663 @property 664 def _attrs(cls): 665 return list(cls.__dataclass_fields__.keys())
667@dataclass(init=False) 668class GridDefinitionTemplate10(): 669 """[Grid Definition Template 10](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-10.shtml)""" 670 _len = 19 671 _num = 10 672 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 673 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 674 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 675 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 676 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 677 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 678 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 679 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 680 projParameters: dict = field(init=False, repr=False, default=ProjParameters()) 681 @classmethod 682 @property 683 def _attrs(cls): 684 return list(cls.__dataclass_fields__.keys())
686@dataclass(init=False) 687class GridDefinitionTemplate20(): 688 """[Grid Definition Template 20](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-20.shtml)""" 689 _len = 18 690 _num = 20 691 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 692 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 693 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 694 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 695 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 696 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 697 projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag()) 698 projParameters: dict = field(init=False, repr=False, default=ProjParameters()) 699 @classmethod 700 @property 701 def _attrs(cls): 702 return list(cls.__dataclass_fields__.keys())
704@dataclass(init=False) 705class GridDefinitionTemplate30(): 706 """[Grid Definition Template 30](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-30.shtml)""" 707 _len = 22 708 _num = 30 709 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 710 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 711 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 712 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 713 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 714 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 715 projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag()) 716 standardLatitude1: float = field(init=False, repr=False, default=StandardLatitude1()) 717 standardLatitude2: float = field(init=False, repr=False, default=StandardLatitude2()) 718 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 719 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 720 projParameters: dict = field(init=False, repr=False, default=ProjParameters()) 721 @classmethod 722 @property 723 def _attrs(cls): 724 return list(cls.__dataclass_fields__.keys())
First Standard Latitude (from the pole at which the secant cone cuts the sphere)
726@dataclass(init=False) 727class GridDefinitionTemplate31(): 728 """[Grid Definition Template 31](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-31.shtml)""" 729 _len = 22 730 _num = 31 731 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 732 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 733 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 734 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 735 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 736 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 737 projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag()) 738 standardLatitude1: float = field(init=False, repr=False, default=StandardLatitude1()) 739 standardLatitude2: float = field(init=False, repr=False, default=StandardLatitude2()) 740 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 741 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 742 @classmethod 743 @property 744 def _attrs(cls): 745 return list(cls.__dataclass_fields__.keys())
First Standard Latitude (from the pole at which the secant cone cuts the sphere)
747@dataclass(init=False) 748class GridDefinitionTemplate40(): 749 """[Grid Definition Template 40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-40.shtml)""" 750 _len = 19 751 _num = 40 752 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 753 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 754 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 755 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 756 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 757 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 758 numberOfParallels: int = field(init=False, repr=False, default=NumberOfParallels()) 759 @classmethod 760 @property 761 def _attrs(cls): 762 return list(cls.__dataclass_fields__.keys())
764@dataclass(init=False) 765class GridDefinitionTemplate41(): 766 """[Grid Definition Template 41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-41.shtml)""" 767 _len = 22 768 _num = 41 769 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 770 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 771 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 772 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 773 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 774 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 775 numberOfParallels: int = field(init=False, repr=False, default=NumberOfParallels()) 776 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 777 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 778 anglePoleRotation: float = field(init=False, repr=False, default=AnglePoleRotation()) 779 @classmethod 780 @property 781 def _attrs(cls): 782 return list(cls.__dataclass_fields__.keys())
784@dataclass(init=False) 785class GridDefinitionTemplate50(): 786 """[Grid Definition Template 50](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-50.shtml)""" 787 _len = 5 788 _num = 50 789 spectralFunctionParameters: list = field(init=False, repr=False, default=SpectralFunctionParameters()) 790 @classmethod 791 @property 792 def _attrs(cls): 793 return list(cls.__dataclass_fields__.keys())
795@dataclass(init=False) 796class GridDefinitionTemplate32768(): 797 """[Grid Definition Template 32768](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32768.shtml)""" 798 _len = 19 799 _num = 32768 800 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 801 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 802 latitudeCenterGridpoint: float = field(init=False, repr=False, default=LatitudeCenterGridpoint()) 803 longitudeCenterGridpoint: float = field(init=False, repr=False, default=LongitudeCenterGridpoint()) 804 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 805 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 806 @classmethod 807 @property 808 def _attrs(cls): 809 return list(cls.__dataclass_fields__.keys())
811@dataclass(init=False) 812class GridDefinitionTemplate32769(): 813 """[Grid Definition Template 32769](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32769.shtml)""" 814 _len = 19 815 _num = 32769 816 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 817 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 818 latitudeCenterGridpoint: float = field(init=False, repr=False, default=LatitudeCenterGridpoint()) 819 longitudeCenterGridpoint: float = field(init=False, repr=False, default=LongitudeCenterGridpoint()) 820 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 821 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 822 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 823 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 824 @classmethod 825 @property 826 def _attrs(cls): 827 return list(cls.__dataclass_fields__.keys())
842def gdt_class_by_gdtn(gdtn): 843 """ 844 Provides a Grid Definition Template class via the template number 845 846 Parameters 847 ---------- 848 **`gdtn : int`** 849 Grid definition template number. 850 851 Returns 852 ------- 853 Grid definition template class object (not an instance). 854 """ 855 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).
860class ProductDefinitionTemplateNumber: 861 """[Product Definition Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-0.shtml)""" 862 def __get__(self, obj, objtype=None): 863 return Grib2Metadata(obj.section4[1],table='4.0') 864 def __set__(self, obj, value): 865 raise RuntimeError
868class ProductDefinitionTemplate: 869 """Product Definition Template""" 870 def __get__(self, obj, objtype=None): 871 return obj.section4[2:] 872 def __set__(self, obj, value): 873 raise RuntimeError
Product Definition Template
875class ParameterCategory: 876 """[Parameter Category](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-1.shtml)""" 877 _key = defaultdict(lambda: 0) 878 def __get__(self, obj, objtype=None): 879 return obj.section4[0+2] 880 def __set__(self, obj, value): 881 obj.section4[self._key[obj.pdtn]+2] = value
883class ParameterNumber: 884 """[Parameter Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-2.shtml)""" 885 _key = defaultdict(lambda: 1) 886 def __get__(self, obj, objtype=None): 887 return obj.section4[1+2] 888 def __set__(self, obj, value): 889 obj.section4[self._key[obj.pdtn]+2] = value
891class VarInfo: 892 """ 893 Variable Information. These are the metadata returned for a specific variable according 894 to discipline, parameter category, and parameter number. 895 """ 896 def __get__(self, obj, objtype=None): 897 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD) 898 def __set__(self, obj, value): 899 raise RuntimeError
Variable Information. These are the metadata returned for a specific variable according to discipline, parameter category, and parameter number.
901class FullName: 902 """Full name of the Variable""" 903 def __get__(self, obj, objtype=None): 904 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[0] 905 def __set__(self, obj, value): 906 raise RuntimeError
Full name of the Variable
908class Units: 909 """Units of the Variable""" 910 def __get__(self, obj, objtype=None): 911 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[1] 912 def __set__(self, obj, value): 913 raise RuntimeError
Units of the Variable
915class ShortName: 916 """ Short name of the variable (i.e. the variable abbreviation)""" 917 def __get__(self, obj, objtype=None): 918 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[2] 919 def __set__(self, obj, value): 920 raise RuntimeError
Short name of the variable (i.e. the variable abbreviation)
922class TypeOfGeneratingProcess: 923 """[Type of Generating Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-3.shtml)""" 924 _key = defaultdict(lambda: 2, {48:13}) 925 #_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} 926 def __get__(self, obj, objtype=None): 927 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.3') 928 def __set__(self, obj, value): 929 obj.section4[self._key[obj.pdtn]+2] = value
931class BackgroundGeneratingProcessIdentifier: 932 """Background Generating Process Identifier""" 933 _key = defaultdict(lambda: 3, {48:14}) 934 #_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} 935 def __get__(self, obj, objtype=None): 936 return obj.section4[self._key[obj.pdtn]+2] 937 def __set__(self, obj, value): 938 obj.section4[self._key[obj.pdtn]+2] = value
Background Generating Process Identifier
940class GeneratingProcess: 941 """[Generating Process](https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablea.html)""" 942 _key = defaultdict(lambda: 4, {48:15}) 943 #_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} 944 def __get__(self, obj, objtype=None): 945 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='generating_process') 946 def __set__(self, obj, value): 947 obj.section4[self._key[obj.pdtn]+2] = value
949class HoursAfterDataCutoff: 950 """Hours of observational data cutoff after reference time""" 951 _key = defaultdict(lambda: 5, {48:16}) 952 def __get__(self, obj, objtype=None): 953 return obj.section4[self._key[obj.pdtn]+2] 954 def __set__(self, obj, value): 955 obj.section4[self._key[obj.pdtn]+2] = value
Hours of observational data cutoff after reference time
957class MinutesAfterDataCutoff: 958 """Minutes of observational data cutoff after reference time""" 959 _key = defaultdict(lambda: 6, {48:17}) 960 def __get__(self, obj, objtype=None): 961 return obj.section4[self._key[obj.pdtn]+2] 962 def __set__(self, obj, value): 963 obj.section4[self._key[obj.pdtn]+2] = value
Minutes of observational data cutoff after reference time
965class UnitOfForecastTime: 966 """[Units of Forecast Time](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-4.shtml)""" 967 _key = defaultdict(lambda: 7, {48:18}) 968 #_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} 969 def __get__(self, obj, objtype=None): 970 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.4') 971 def __set__(self, obj, value): 972 obj.section4[self._key[obj.pdtn]+2] = value
974class ValueOfForecastTime: 975 """Value of forecast time in units defined by `UnitofForecastTime`""" 976 _key = defaultdict(lambda: 8, {48:19}) 977 def __get__(self, obj, objtype=None): 978 return obj.section4[self._key[obj.pdtn]+2] 979 def __set__(self, obj, value): 980 obj.section4[self._key[obj.pdtn]+2] = value
Value of forecast time in units defined by UnitofForecastTime
982class LeadTime: 983 """Forecast Lead Time. NOTE: This is a `datetime.timedelta` object.""" 984 def __get__(self, obj, objtype=None): 985 return utils.get_leadtime(obj.section1,obj.section4[1], 986 obj.section4[2:]) 987 def __set__(self, obj, value): 988 raise NotImplementedError
Forecast Lead Time. NOTE: This is a datetime.timedelta
object.
990class FixedSfc1Info: 991 """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)""" 992 _key = defaultdict(lambda: 9, {48:20}) 993 #_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} 994 def __get__(self, obj, objtype=None): 995 if obj.section4[self._key[obj.pdtn]+2] == 255: 996 return [None, None] 997 return tables.get_value_from_table(obj.section4[self._key[obj.pdtn]+2],'4.5') 998 def __set__(self, obj, value): 999 raise NotImplementedError
Information of the first fixed surface via table 4.5
1001class FixedSfc2Info: 1002 """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)""" 1003 _key = defaultdict(lambda: 12, {48:23}) 1004 #_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} 1005 def __get__(self, obj, objtype=None): 1006 if obj.section4[self._key[obj.pdtn]+2] == 255: 1007 return [None, None] 1008 return tables.get_value_from_table(obj.section4[self._key[obj.pdtn]+2],'4.5') 1009 def __set__(self, obj, value): 1010 raise NotImplementedError
Information of the seconds fixed surface via table 4.5
1012class TypeOfFirstFixedSurface: 1013 """[Type of First Fixed Surface](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)""" 1014 _key = defaultdict(lambda: 9, {48:20}) 1015 #_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} 1016 def __get__(self, obj, objtype=None): 1017 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.5') 1018 def __set__(self, obj, value): 1019 obj.section4[self._key[obj.pdtn]+2] = value
1021class ScaleFactorOfFirstFixedSurface: 1022 """Scale Factor of First Fixed Surface""" 1023 _key = defaultdict(lambda: 10, {48:21}) 1024 #_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} 1025 def __get__(self, obj, objtype=None): 1026 return obj.section4[self._key[obj.pdtn]+2] 1027 def __set__(self, obj, value): 1028 obj.section4[self._key[obj.pdtn]+2] = value
Scale Factor of First Fixed Surface
1030class ScaledValueOfFirstFixedSurface: 1031 """Scaled Value Of First Fixed Surface""" 1032 _key = defaultdict(lambda: 11, {48:22}) 1033 #_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} 1034 def __get__(self, obj, objtype=None): 1035 return obj.section4[self._key[obj.pdtn]+2] 1036 def __set__(self, obj, value): 1037 obj.section4[self._key[obj.pdtn]+2] = value
Scaled Value Of First Fixed Surface
1039class UnitOfFirstFixedSurface: 1040 """Units of First Fixed Surface""" 1041 def __get__(self, obj, objtype=None): 1042 return obj._fixedsfc1info[1] 1043 def __set__(self, obj, value): 1044 pass
Units of First Fixed Surface
1046class ValueOfFirstFixedSurface: 1047 """Value of First Fixed Surface""" 1048 def __get__(self, obj, objtype=None): 1049 return obj.section4[ScaledValueOfFirstFixedSurface._key[obj.pdtn]+2]/\ 1050 (10.**obj.section4[ScaleFactorOfFirstFixedSurface._key[obj.pdtn]+2]) 1051 def __set__(self, obj, value): 1052 pass
Value of First Fixed Surface
1054class TypeOfSecondFixedSurface: 1055 """[Type of Second Fixed Surface](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)""" 1056 _key = defaultdict(lambda: 12, {48:23}) 1057 #_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} 1058 def __get__(self, obj, objtype=None): 1059 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.5') 1060 def __set__(self, obj, value): 1061 obj.section4[self._key[obj.pdtn]+2] = value
1063class ScaleFactorOfSecondFixedSurface: 1064 """Scale Factor of Second Fixed Surface""" 1065 _key = defaultdict(lambda: 13, {48:24}) 1066 #_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} 1067 def __get__(self, obj, objtype=None): 1068 return obj.section4[self._key[obj.pdtn]+2] 1069 def __set__(self, obj, value): 1070 obj.section4[self._key[obj.pdtn]+2] = value
Scale Factor of Second Fixed Surface
1072class ScaledValueOfSecondFixedSurface: 1073 """Scaled Value Of Second Fixed Surface""" 1074 _key = defaultdict(lambda: 14, {48:25}) 1075 #_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} 1076 def __get__(self, obj, objtype=None): 1077 return obj.section4[self._key[obj.pdtn]+2] 1078 def __set__(self, obj, value): 1079 obj.section4[self._key[obj.pdtn]+2] = value
Scaled Value Of Second Fixed Surface
1081class UnitOfSecondFixedSurface: 1082 """Units of Second Fixed Surface""" 1083 def __get__(self, obj, objtype=None): 1084 return obj._fixedsfc2info[1] 1085 def __set__(self, obj, value): 1086 pass
Units of Second Fixed Surface
1088class ValueOfSecondFixedSurface: 1089 """Value of Second Fixed Surface""" 1090 def __get__(self, obj, objtype=None): 1091 return obj.section4[ScaledValueOfFirstFixedSurface._key[obj.pdtn]+2]/\ 1092 (10.**obj.section4[ScaleFactorOfFirstFixedSurface._key[obj.pdtn]+2]) 1093 def __set__(self, obj, value): 1094 pass
Value of Second Fixed Surface
1096class Level: 1097 """Level (same as provided by [wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Level.c))""" 1098 def __get__(self, obj, objtype=None): 1099 return tables.get_wgrib2_level_string(obj.pdtn,obj.section4[2:]) 1100 def __set__(self, obj, value): 1101 pass
Level (same as provided by wgrib2)
1103class TypeOfEnsembleForecast: 1104 """[Type of Ensemble Forecast](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-6.shtml)""" 1105 _key = {1:15, 11:15} 1106 def __get__(self, obj, objtype=None): 1107 pdtn = obj.section4[1] 1108 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.6') 1109 def __set__(self, obj, value): 1110 pdtn = obj.section4[1] 1111 obj.section4[self._key[pdtn]+2] = value
1113class PerturbationNumber: 1114 """Ensemble Perturbation Number""" 1115 _key = {1:16, 11:16} 1116 def __get__(self, obj, objtype=None): 1117 pdtn = obj.section4[1] 1118 return obj.section4[self._key[pdtn]+2] 1119 def __set__(self, obj, value): 1120 pdtn = obj.section4[1] 1121 obj.section4[self._key[pdtn]+2] = value
Ensemble Perturbation Number
1123class NumberOfEnsembleForecasts: 1124 """Total Number of Ensemble Forecasts""" 1125 _key = {1:17, 2:16, 11:17, 12:16} 1126 def __get__(self, obj, objtype=None): 1127 pdtn = obj.section4[1] 1128 return obj.section4[self._key[pdtn]+2] 1129 def __set__(self, obj, value): 1130 pdtn = obj.section4[1] 1131 obj.section4[self._key[pdtn]+2] = value
Total Number of Ensemble Forecasts
1133class TypeOfDerivedForecast: 1134 """[Type of Derived Forecast](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-7.shtml)""" 1135 _key = {2:15, 12:15} 1136 def __get__(self, obj, objtype=None): 1137 pdtn = obj.section4[1] 1138 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.7') 1139 def __set__(self, obj, value): 1140 pdtn = obj.section4[1] 1141 obj.section4[self._key[pdtn]+2] = value
1143class ForecastProbabilityNumber: 1144 """Forecast Probability Number""" 1145 _key = {5:15, 9:15} 1146 def __get__(self, obj, objtype=None): 1147 pdtn = obj.section4[1] 1148 return obj.section4[self._key[pdtn]+2] 1149 def __set__(self, obj, value): 1150 pdtn = obj.section4[1] 1151 obj.section4[self._key[pdtn]+2] = value
Forecast Probability Number
1153class TotalNumberOfForecastProbabilities: 1154 """Total Number of Forecast Probabilities""" 1155 _key = {5:16, 9:16} 1156 def __get__(self, obj, objtype=None): 1157 pdtn = obj.section4[1] 1158 return obj.section4[self._key[pdtn]+2] 1159 def __set__(self, obj, value): 1160 pdtn = obj.section4[1] 1161 obj.section4[self._key[pdtn]+2] = value
Total Number of Forecast Probabilities
1163class TypeOfProbability: 1164 """[Type of Probability](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-9.shtml)""" 1165 _key = {5:17, 9:17} 1166 def __get__(self, obj, objtype=None): 1167 pdtn = obj.section4[1] 1168 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.9') 1169 def __set__(self, obj, value): 1170 pdtn = obj.section4[1] 1171 obj.section4[self._key[pdtn]+2] = value
1173class ScaleFactorOfThresholdLowerLimit: 1174 """Scale Factor of Threshold Lower Limit""" 1175 _key = {5:18, 9:18} 1176 def __get__(self, obj, objtype=None): 1177 pdtn = obj.section4[1] 1178 return obj.section4[self._key[pdtn]+2] 1179 def __set__(self, obj, value): 1180 pdtn = obj.section4[1] 1181 obj.section4[self._key[pdtn]+2] = value
Scale Factor of Threshold Lower Limit
1183class ScaledValueOfThresholdLowerLimit: 1184 """Scaled Value of Threshold Lower Limit""" 1185 _key = {5:19, 9:19} 1186 def __get__(self, obj, objtype=None): 1187 pdtn = obj.section4[1] 1188 return obj.section4[self._key[pdtn]+2] 1189 def __set__(self, obj, value): 1190 pdtn = obj.section4[1] 1191 obj.section4[self._key[pdtn]+2] = value
Scaled Value of Threshold Lower Limit
1193class ScaleFactorOfThresholdUpperLimit: 1194 """Scale Factor of Threshold Upper Limit""" 1195 _key = {5:20, 9:20} 1196 def __get__(self, obj, objtype=None): 1197 pdtn = obj.section4[1] 1198 return obj.section4[self._key[pdtn]+2] 1199 def __set__(self, obj, value): 1200 pdtn = obj.section4[1] 1201 obj.section4[self._key[pdtn]+2] = value
Scale Factor of Threshold Upper Limit
1203class ScaledValueOfThresholdUpperLimit: 1204 """Scaled Value of Threshold Upper Limit""" 1205 _key = {5:21, 9:21} 1206 def __get__(self, obj, objtype=None): 1207 pdtn = obj.section4[1] 1208 return obj.section4[self._key[pdtn]+2] 1209 def __set__(self, obj, value): 1210 pdtn = obj.section4[1] 1211 obj.section4[self._key[pdtn]+2] = value
Scaled Value of Threshold Upper Limit
1213class ThresholdLowerLimit: 1214 """Threshold Lower Limit""" 1215 def __get__(self, obj, objtype=None): 1216 if obj.section4[18+2] == -127 and \ 1217 obj.section4[19+2] == 255: 1218 return 0.0 1219 else: 1220 return obj.section4[19+2]/(10.**obj.section4[18+2]) 1221 def __set__(self, obj, value): 1222 pass
Threshold Lower Limit
1224class ThresholdUpperLimit: 1225 """Threshold Upper Limit""" 1226 def __get__(self, obj, objtype=None): 1227 if obj.section4[20+2] == -127 and \ 1228 obj.section4[21+2] == 255: 1229 return 0.0 1230 else: 1231 return obj.section4[21+2]/(10.**obj.section4[20+2]) 1232 def __set__(self, obj, value): 1233 pass
Threshold Upper Limit
1235class Threshold: 1236 """Threshold string (same as [wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Prob.c))""" 1237 def __get__(self, obj, objtype=None): 1238 return utils.get_wgrib2_prob_string(*obj.section4[17+2:22+2]) 1239 def __set__(self, obj, value): 1240 pass
Threshold string (same as wgrib2)
1242class PercentileValue: 1243 """Percentile Value""" 1244 _key = {6:15, 10:15} 1245 def __get__(self, obj, objtype=None): 1246 pdtn = obj.section4[1] 1247 return obj.section4[self._key[pdtn]+2] 1248 def __set__(self, obj, value): 1249 pdtn = obj.section4[1] 1250 obj.section4[self._key[pdtn]+2] = value
Percentile Value
1252class YearOfEndOfTimePeriod: 1253 """Year of End of Forecast Time Period""" 1254 _key = {8:15, 9:22, 10:16, 11:18, 12:17} 1255 def __get__(self, obj, objtype=None): 1256 pdtn = obj.section4[1] 1257 return obj.section4[self._key[pdtn]+2] 1258 def __set__(self, obj, value): 1259 pdtn = obj.section4[1] 1260 obj.section4[self._key[pdtn]+2] = value
Year of End of Forecast Time Period
1262class MonthOfEndOfTimePeriod: 1263 """Month Year of End of Forecast Time Period""" 1264 _key = {8:16, 9:23, 10:17, 11:19, 12:18} 1265 def __get__(self, obj, objtype=None): 1266 pdtn = obj.section4[1] 1267 return obj.section4[self._key[pdtn]+2] 1268 def __set__(self, obj, value): 1269 pdtn = obj.section4[1] 1270 obj.section4[self._key[pdtn]+2] = value
Month Year of End of Forecast Time Period
1272class DayOfEndOfTimePeriod: 1273 """Day Year of End of Forecast Time Period""" 1274 _key = {8:17, 9:24, 10:18, 11:20, 12:19} 1275 def __get__(self, obj, objtype=None): 1276 pdtn = obj.section4[1] 1277 return obj.section4[self._key[pdtn]+2] 1278 def __set__(self, obj, value): 1279 pdtn = obj.section4[1] 1280 obj.section4[self._key[pdtn]+2] = value
Day Year of End of Forecast Time Period
1282class HourOfEndOfTimePeriod: 1283 """Hour Year of End of Forecast Time Period""" 1284 _key = {8:18, 9:25, 10:19, 11:21, 12:20} 1285 def __get__(self, obj, objtype=None): 1286 pdtn = obj.section4[1] 1287 return obj.section4[self._key[pdtn]+2] 1288 def __set__(self, obj, value): 1289 pdtn = obj.section4[1] 1290 obj.section4[self._key[pdtn]+2] = value
Hour Year of End of Forecast Time Period
1292class MinuteOfEndOfTimePeriod: 1293 """Minute Year of End of Forecast Time Period""" 1294 _key = {8:19, 9:26, 10:20, 11:22, 12:21} 1295 def __get__(self, obj, objtype=None): 1296 pdtn = obj.section4[1] 1297 return obj.section4[self._key[pdtn]+2] 1298 def __set__(self, obj, value): 1299 pdtn = obj.section4[1] 1300 obj.section4[self._key[pdtn]+2] = value
Minute Year of End of Forecast Time Period
1302class SecondOfEndOfTimePeriod: 1303 """Second Year of End of Forecast Time Period""" 1304 _key = {8:20, 9:27, 10:21, 11:23, 12:22} 1305 def __get__(self, obj, objtype=None): 1306 pdtn = obj.section4[1] 1307 return obj.section4[self._key[pdtn]+2] 1308 def __set__(self, obj, value): 1309 pdtn = obj.section4[1] 1310 obj.section4[self._key[pdtn]+2] = value
Second Year of End of Forecast Time Period
1312class Duration: 1313 """Duration of time period. NOTE: This is a `datetime.timedelta` object.""" 1314 def __get__(self, obj, objtype=None): 1315 return utils.get_duration(obj.section4[1],obj.section4[2:]) 1316 def __set__(self, obj, value): 1317 pass
Duration of time period. NOTE: This is a datetime.timedelta
object.
1319class ValidDate: 1320 """Valid Date of the forecast. NOTE: This is a `datetime.datetime` object.""" 1321 _key = {8:slice(15,21), 9:slice(22,28), 10:slice(16,22), 11:slice(18,24), 12:slice(17,23)} 1322 def __get__(self, obj, objtype=None): 1323 pdtn = obj.section4[1] 1324 try: 1325 s = slice(self._key[pdtn].start+2,self._key[pdtn].stop+2) 1326 return datetime.datetime(*obj.section4[s]) 1327 except(KeyError): 1328 return obj.refDate + obj.leadTime 1329 def __set__(self, obj, value): 1330 pass
Valid Date of the forecast. NOTE: This is a datetime.datetime
object.
1332class NumberOfTimeRanges: 1333 """Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field""" 1334 _key = {8:21, 9:28, 10:22, 11:24, 12:23} 1335 def __get__(self, obj, objtype=None): 1336 pdtn = obj.section4[1] 1337 return obj.section4[self._key[pdtn]+2] 1338 def __set__(self, obj, value): 1339 pdtn = obj.section4[1] 1340 obj.section4[self._key[pdtn]+2] = value
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
1342class NumberOfMissingValues: 1343 """Total number of data values missing in statistical process""" 1344 _key = {8:22, 9:29, 10:23, 11:25, 12:24} 1345 def __get__(self, obj, objtype=None): 1346 pdtn = obj.section4[1] 1347 return obj.section4[self._key[pdtn]+2] 1348 def __set__(self, obj, value): 1349 pdtn = obj.section4[1] 1350 obj.section4[self._key[pdtn]+2] = value
Total number of data values missing in statistical process
1352class StatisticalProcess: 1353 """[Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-10.shtml)""" 1354 _key = {8:23, 9:30, 10:24, 11:26, 12:25, 15:15} 1355 def __get__(self, obj, objtype=None): 1356 pdtn = obj.section4[1] 1357 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.10') 1358 def __set__(self, obj, value): 1359 pdtn = obj.section4[1] 1360 obj.section4[self._key[pdtn]+2] = value
1362class TypeOfTimeIncrementOfStatisticalProcess: 1363 """[Type of Time Increment of Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-11.shtml)""" 1364 _key = {8:24, 9:31, 10:25, 11:27, 12:26} 1365 def __get__(self, obj, objtype=None): 1366 pdtn = obj.section4[1] 1367 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.11') 1368 def __set__(self, obj, value): 1369 pdtn = obj.section4[1] 1370 obj.section4[self._key[pdtn]+2] = value
1372class UnitOfTimeRangeOfStatisticalProcess: 1373 """[Unit of Time Range of Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-11.shtml)""" 1374 _key = {8:25, 9:32, 10:26, 11:28, 12:27} 1375 def __get__(self, obj, objtype=None): 1376 pdtn = obj.section4[1] 1377 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.4') 1378 def __set__(self, obj, value): 1379 pdtn = obj.section4[1] 1380 obj.section4[self._key[pdtn]+2] = value
1382class TimeRangeOfStatisticalProcess: 1383 """Time Range of Statistical Process""" 1384 _key = {8:26, 9:33, 10:27, 11:29, 12:28} 1385 def __get__(self, obj, objtype=None): 1386 pdtn = obj.section4[1] 1387 return obj.section4[self._key[pdtn]+2] 1388 def __set__(self, obj, value): 1389 pdtn = obj.section4[1] 1390 obj.section4[self._key[pdtn]+2] = value
Time Range of Statistical Process
1392class UnitOfTimeRangeOfSuccessiveFields: 1393 """[Unit of Time Range of Successive Fields](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-4.shtml)""" 1394 _key = {8:27, 9:34, 10:28, 11:30, 12:29} 1395 def __get__(self, obj, objtype=None): 1396 pdtn = obj.section4[1] 1397 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.4') 1398 def __set__(self, obj, value): 1399 pdtn = obj.section4[1] 1400 obj.section4[self._key[pdtn]+2] = value
1402class TimeIncrementOfSuccessiveFields: 1403 """Time Increment of Successive Fields""" 1404 _key = {8:28, 9:35, 10:29, 11:31, 12:30} 1405 def __get__(self, obj, objtype=None): 1406 pdtn = obj.section4[1] 1407 return obj.section4[self._key[pdtn]+2] 1408 def __set__(self, obj, value): 1409 pdtn = obj.section4[1] 1410 obj.section4[self._key[pdtn]+2] = value
Time Increment of Successive Fields
1412class TypeOfStatisticalProcessing: 1413 """[Type of Statistical Processing](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-15.shtml)""" 1414 _key = {15:16} 1415 def __get__(self, obj, objtype=None): 1416 pdtn = obj.section4[1] 1417 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.15') 1418 def __set__(self, obj, value): 1419 pdtn = obj.section4[1] 1420 obj.section4[self._key[pdtn]+2] = value
1422class NumberOfDataPointsForSpatialProcessing: 1423 """Number of Data Points for Spatial Processing""" 1424 _key = {15:17} 1425 def __get__(self, obj, objtype=None): 1426 pdtn = obj.section4[1] 1427 return obj.section4[self._key[pdtn]+2] 1428 def __set__(self, obj, value): 1429 pdtn = obj.section4[1] 1430 obj.section4[self._key[pdtn]+2] = value
Number of Data Points for Spatial Processing
1432class TypeOfAerosol: 1433 """[Type of Aerosol](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-233.shtml)""" 1434 _key = {48:2} 1435 def __get__(self, obj, objtype=None): 1436 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.233') 1437 def __set__(self, obj, value): 1438 obj.section4[self._key[obj.pdtn]+2] = value
1440class TypeOfIntervalForAerosolSize: 1441 """[Type of Interval for Aerosol Size](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-91.shtml)""" 1442 _key = {48:3} 1443 def __get__(self, obj, objtype=None): 1444 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.91') 1445 def __set__(self, obj, value): 1446 obj.section4[self._key[obj.pdtn]+2] = value
1448class ScaleFactorOfFirstSize: 1449 """Scale Factor of First Size""" 1450 _key = {48:4} 1451 def __get__(self, obj, objtype=None): 1452 return obj.section4[self._key[obj.pdtn]+2] 1453 def __set__(self, obj, value): 1454 obj.section4[self._key[obj.pdtn]+2] = value
Scale Factor of First Size
1456class ScaledValueOfFirstSize: 1457 """Scaled Value of First Size""" 1458 _key = {48:5} 1459 def __get__(self, obj, objtype=None): 1460 return obj.section4[self._key[obj.pdtn]+2] 1461 def __set__(self, obj, value): 1462 obj.section4[self._key[obj.pdtn]+2] = value
Scaled Value of First Size
1464class ScaleFactorOfSecondSize: 1465 """Scale Factor of Second Size""" 1466 _key = {48:6} 1467 def __get__(self, obj, objtype=None): 1468 return obj.section4[self._key[obj.pdtn]+2] 1469 def __set__(self, obj, value): 1470 obj.section4[self._key[obj.pdtn]+2] = value
Scale Factor of Second Size
1472class ScaledValueOfSecondSize: 1473 """Scaled Value of Second Size""" 1474 _key = {48:7} 1475 def __get__(self, obj, objtype=None): 1476 return obj.section4[self._key[obj.pdtn]+2] 1477 def __set__(self, obj, value): 1478 obj.section4[self._key[obj.pdtn]+2] = value
Scaled Value of Second Size
1480class TypeOfIntervalForAerosolWavelength: 1481 """[Type of Interval for Aerosol Wavelength](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-91.shtml)""" 1482 _key = {48:8} 1483 def __get__(self, obj, objtype=None): 1484 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.91') 1485 def __set__(self, obj, value): 1486 obj.section4[self._key[obj.pdtn]+2] = value
1488class ScaleFactorOfFirstWavelength: 1489 """Scale Factor of First Wavelength""" 1490 _key = {48:9} 1491 def __get__(self, obj, objtype=None): 1492 return obj.section4[self._key[obj.pdtn]+2] 1493 def __set__(self, obj, value): 1494 obj.section4[self._key[obj.pdtn]+2] = value
Scale Factor of First Wavelength
1496class ScaledValueOfFirstWavelength: 1497 """Scaled Value of First Wavelength""" 1498 _key = {48:10} 1499 def __get__(self, obj, objtype=None): 1500 return obj.section4[self._key[obj.pdtn]+2] 1501 def __set__(self, obj, value): 1502 obj.section4[self._key[obj.pdtn]+2] = value
Scaled Value of First Wavelength
1504class ScaleFactorOfSecondWavelength: 1505 """Scale Factor of Second Wavelength""" 1506 _key = {48:11} 1507 def __get__(self, obj, objtype=None): 1508 return obj.section4[self._key[obj.pdtn]+2] 1509 def __set__(self, obj, value): 1510 obj.section4[self._key[obj.pdtn]+2] = value
Scale Factor of Second Wavelength
1512class ScaledValueOfSecondWavelength: 1513 """Scaled Value of Second Wavelength""" 1514 _key = {48:12} 1515 def __get__(self, obj, objtype=None): 1516 return obj.section4[self._key[obj.pdtn]+2] 1517 def __set__(self, obj, value): 1518 obj.section4[self._key[obj.pdtn]+2] = value
Scaled Value of Second Wavelength
1520@dataclass(init=False) 1521class ProductDefinitionTemplate0(): 1522 """[Product Definition Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-0.shtml)""" 1523 _len = 15 1524 _num = 0 1525 parameterCategory: int = field(init=False,repr=False,default=ParameterCategory()) 1526 parameterNumber: int = field(init=False,repr=False,default=ParameterNumber()) 1527 typeOfGeneratingProcess: Grib2Metadata = field(init=False,repr=False,default=TypeOfGeneratingProcess()) 1528 generatingProcess: Grib2Metadata = field(init=False, repr=False, default=GeneratingProcess()) 1529 backgroundGeneratingProcessIdentifier: int = field(init=False,repr=False,default=BackgroundGeneratingProcessIdentifier()) 1530 hoursAfterDataCutoff: int = field(init=False,repr=False,default=HoursAfterDataCutoff()) 1531 minutesAfterDataCutoff: int = field(init=False,repr=False,default=MinutesAfterDataCutoff()) 1532 unitOfForecastTime: Grib2Metadata = field(init=False,repr=False,default=UnitOfForecastTime()) 1533 valueOfForecastTime: int = field(init=False,repr=False,default=ValueOfForecastTime()) 1534 typeOfFirstFixedSurface: Grib2Metadata = field(init=False,repr=False,default=TypeOfFirstFixedSurface()) 1535 scaleFactorOfFirstFixedSurface: int = field(init=False,repr=False,default=ScaleFactorOfFirstFixedSurface()) 1536 scaledValueOfFirstFixedSurface: int = field(init=False,repr=False,default=ScaledValueOfFirstFixedSurface()) 1537 typeOfSecondFixedSurface: Grib2Metadata = field(init=False,repr=False,default=TypeOfSecondFixedSurface()) 1538 scaleFactorOfSecondFixedSurface: int = field(init=False,repr=False,default=ScaleFactorOfSecondFixedSurface()) 1539 scaledValueOfSecondFixedSurface: int = field(init=False,repr=False,default=ScaledValueOfSecondFixedSurface()) 1540 @classmethod 1541 @property 1542 def _attrs(cls): 1543 return list(cls.__dataclass_fields__.keys())
1545@dataclass(init=False) 1546class ProductDefinitionTemplate1(ProductDefinitionTemplate0): 1547 """[Product Definition Template 1](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-1.shtml)""" 1548 _len = 18 1549 _num = 1 1550 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 1551 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 1552 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 1553 @classmethod 1554 @property 1555 def _attrs(cls): 1556 return list(cls.__dataclass_fields__.keys())
Inherited Members
- ProductDefinitionTemplate0
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
1558@dataclass(init=False) 1559class ProductDefinitionTemplate2(ProductDefinitionTemplate0): 1560 """[Product Definition Template 2](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-2.shtml)""" 1561 _len = 17 1562 _num = 2 1563 typeOfDerivedForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfDerivedForecast()) 1564 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 1565 @classmethod 1566 @property 1567 def _attrs(cls): 1568 return list(cls.__dataclass_fields__.keys())
Inherited Members
- ProductDefinitionTemplate0
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
1570@dataclass(init=False) 1571class ProductDefinitionTemplate5(ProductDefinitionTemplate0): 1572 """[Product Definition Template 5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-5.shtml)""" 1573 _len = 22 1574 _num = 5 1575 forecastProbabilityNumber: int = field(init=False, repr=False, default=ForecastProbabilityNumber()) 1576 totalNumberOfForecastProbabilities: int = field(init=False, repr=False, default=TotalNumberOfForecastProbabilities()) 1577 typeOfProbability: Grib2Metadata = field(init=False, repr=False, default=TypeOfProbability()) 1578 scaleFactorOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdLowerLimit()) 1579 scaledValueOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdLowerLimit()) 1580 scaleFactorOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdUpperLimit()) 1581 scaledValueOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdUpperLimit()) 1582 thresholdLowerLimit: float = field(init=False, repr=False, default=ThresholdLowerLimit()) 1583 thresholdUpperLimit: float = field(init=False, repr=False, default=ThresholdUpperLimit()) 1584 threshold: str = field(init=False, repr=False, default=Threshold()) 1585 @classmethod 1586 @property 1587 def _attrs(cls): 1588 return list(cls.__dataclass_fields__.keys())
Inherited Members
- ProductDefinitionTemplate0
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
1590@dataclass(init=False) 1591class ProductDefinitionTemplate6(ProductDefinitionTemplate0): 1592 """[Product Definition Template 6](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-6.shtml)""" 1593 _len = 16 1594 _num = 6 1595 percentileValue: int = field(init=False, repr=False, default=PercentileValue()) 1596 @classmethod 1597 @property 1598 def _attrs(cls): 1599 return list(cls.__dataclass_fields__.keys())
Inherited Members
- ProductDefinitionTemplate0
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
1601@dataclass(init=False) 1602class ProductDefinitionTemplate8(ProductDefinitionTemplate0): 1603 """[Product Definition Template 8](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-8.shtml)""" 1604 _len = 29 1605 _num = 8 1606 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 1607 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 1608 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 1609 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 1610 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 1611 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 1612 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 1613 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 1614 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 1615 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 1616 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 1617 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 1618 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 1619 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 1620 @classmethod 1621 @property 1622 def _attrs(cls): 1623 return list(cls.__dataclass_fields__.keys())
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplate0
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
1625@dataclass(init=False) 1626class ProductDefinitionTemplate9(ProductDefinitionTemplate0): 1627 """[Product Definition Template 9](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-9.shtml)""" 1628 _len = 36 1629 _num = 9 1630 forecastProbabilityNumber: int = field(init=False, repr=False, default=ForecastProbabilityNumber()) 1631 totalNumberOfForecastProbabilities: int = field(init=False, repr=False, default=TotalNumberOfForecastProbabilities()) 1632 typeOfProbability: Grib2Metadata = field(init=False, repr=False, default=TypeOfProbability()) 1633 scaleFactorOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdLowerLimit()) 1634 scaledValueOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdLowerLimit()) 1635 scaleFactorOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdUpperLimit()) 1636 scaledValueOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdUpperLimit()) 1637 thresholdLowerLimit: float = field(init=False, repr=False, default=ThresholdLowerLimit()) 1638 thresholdUpperLimit: float = field(init=False, repr=False, default=ThresholdUpperLimit()) 1639 threshold: str = field(init=False, repr=False, default=Threshold()) 1640 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 1641 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 1642 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 1643 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 1644 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 1645 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 1646 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 1647 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 1648 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 1649 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 1650 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 1651 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 1652 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 1653 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 1654 @classmethod 1655 @property 1656 def _attrs(cls): 1657 return list(cls.__dataclass_fields__.keys())
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplate0
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
1659@dataclass(init=False) 1660class ProductDefinitionTemplate10(ProductDefinitionTemplate0): 1661 """[Product Definition Template 10](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-10.shtml)""" 1662 _len = 30 1663 _num = 10 1664 percentileValue: int = field(init=False, repr=False, default=PercentileValue()) 1665 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 1666 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 1667 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 1668 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 1669 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 1670 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 1671 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 1672 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 1673 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 1674 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 1675 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 1676 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 1677 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 1678 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 1679 @classmethod 1680 @property 1681 def _attrs(cls): 1682 return list(cls.__dataclass_fields__.keys())
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplate0
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
1684@dataclass(init=False) 1685class ProductDefinitionTemplate11(ProductDefinitionTemplate0): 1686 """[Product Definition Template 11](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-11.shtml)""" 1687 _len = 32 1688 _num = 11 1689 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 1690 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 1691 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 1692 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 1693 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 1694 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 1695 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 1696 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 1697 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 1698 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 1699 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 1700 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 1701 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 1702 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 1703 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 1704 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 1705 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 1706 @classmethod 1707 @property 1708 def _attrs(cls): 1709 return list(cls.__dataclass_fields__.keys())
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplate0
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
1711@dataclass(init=False) 1712class ProductDefinitionTemplate12(ProductDefinitionTemplate0): 1713 """[Product Definition Template 12](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-12.shtml)""" 1714 _len = 31 1715 _num = 12 1716 typeOfDerivedForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfDerivedForecast()) 1717 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 1718 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 1719 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 1720 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 1721 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 1722 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 1723 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 1724 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 1725 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 1726 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 1727 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 1728 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 1729 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 1730 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 1731 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 1732 @classmethod 1733 @property 1734 def _attrs(cls): 1735 return list(cls.__dataclass_fields__.keys())
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplate0
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
1737@dataclass(init=False) 1738class ProductDefinitionTemplate15(ProductDefinitionTemplate0): 1739 """[Product Definition Template 15](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-15.shtml)""" 1740 _len = 18 1741 _num = 15 1742 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 1743 typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing()) 1744 numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing()) 1745 @classmethod 1746 @property 1747 def _attrs(cls): 1748 return list(cls.__dataclass_fields__.keys())
Inherited Members
- ProductDefinitionTemplate0
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
1750@dataclass(init=False) 1751class ProductDefinitionTemplate48(ProductDefinitionTemplate0): 1752 """[Product Definition Template 48](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-48.shtml)""" 1753 _len = 26 1754 _num = 48 1755 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 1756 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 1757 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 1758 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 1759 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 1760 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 1761 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 1762 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 1763 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 1764 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 1765 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 1766 @classmethod 1767 @property 1768 def _attrs(cls): 1769 return list(cls.__dataclass_fields__.keys())
Inherited Members
- ProductDefinitionTemplate0
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
1786def pdt_class_by_pdtn(pdtn): 1787 """ 1788 Provides a Product Definition Template class via the template number 1789 1790 Parameters 1791 ---------- 1792 **`pdtn : int`** 1793 Product definition template number. 1794 1795 Returns 1796 ------- 1797 Product definition template class object (not an instance). 1798 """ 1799 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).
1804class NumberOfPackedValues: 1805 """Number of Packed Values""" 1806 def __get__(self, obj, objtype=None): 1807 return obj.section5[0] 1808 def __set__(self, obj, value): 1809 pass
Number of Packed Values
1811class DataRepresentationTemplateNumber: 1812 """[Data Representation Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-0.shtml)""" 1813 def __get__(self, obj, objtype=None): 1814 return Grib2Metadata(obj.section5[1],table='5.0') 1815 def __set__(self, obj, value): 1816 pass
1818class DataRepresentationTemplate: 1819 """Data Representation Template""" 1820 def __get__(self, obj, objtype=None): 1821 return obj.section5[2:] 1822 def __set__(self, obj, value): 1823 raise NotImplementedError
Data Representation Template
1825class RefValue: 1826 """Reference Value (represented as an IEEE 32-bit floating point value)""" 1827 def __get__(self, obj, objtype=None): 1828 return utils.ieee_int_to_float(obj.section5[0+2]) 1829 def __set__(self, obj, value): 1830 pass
Reference Value (represented as an IEEE 32-bit floating point value)
1832class BinScaleFactor: 1833 """Binary Scale Factor""" 1834 def __get__(self, obj, objtype=None): 1835 return obj.section5[1+2] 1836 def __set__(self, obj, value): 1837 obj.section5[1+2] = value
Binary Scale Factor
1839class DecScaleFactor: 1840 """Decimal Scale Factor""" 1841 def __get__(self, obj, objtype=None): 1842 return obj.section5[2+2] 1843 def __set__(self, obj, value): 1844 obj.section5[2+2] = value
Decimal Scale Factor
1846class NBitsPacking: 1847 """Minimum number of bits for packing""" 1848 def __get__(self, obj, objtype=None): 1849 return obj.section5[3+2] 1850 def __set__(self, obj, value): 1851 obj.section5[3+2] = value
Minimum number of bits for packing
1853class TypeOfValues: 1854 """[Type of Original Field Values](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-1.shtml)""" 1855 def __get__(self, obj, objtype=None): 1856 return Grib2Metadata(obj.section5[4+2],table='5.1') 1857 def __set__(self, obj, value): 1858 obj.section5[4+2] = value
1860class GroupSplittingMethod: 1861 """[Group Splitting Method](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-4.shtml)""" 1862 def __get__(self, obj, objtype=None): 1863 return Grib2Metadata(obj.section5[5+2],table='5.4') 1864 def __set__(self, obj, value): 1865 obj.section5[5+2] = value
1867class TypeOfMissingValueManagement: 1868 """[Type of Missing Value Management](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-5.shtml)""" 1869 def __get__(self, obj, objtype=None): 1870 return Grib2Metadata(obj.section5[6+2],table='5.5') 1871 def __set__(self, obj, value): 1872 obj.section5[6+2] = value
1874class PriMissingValue: 1875 """Primary Missing Value""" 1876 def __get__(self, obj, objtype=None): 1877 if obj.typeOfValues == 0: 1878 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 1879 elif obj.typeOfValues == 1: 1880 return obj.section5[7+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[7+2] = utils.ieee_float_to_int(value) 1884 elif self.typeOfValues == 1: 1885 obj.section5[7+2] = int(value) 1886 obj.section5[6+2] = 1
Primary Missing Value
1888class SecMissingValue: 1889 """Secondary Missing Value""" 1890 def __get__(self, obj, objtype=None): 1891 if obj.typeOfValues == 0: 1892 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 1893 elif obj.typeOfValues == 1: 1894 return obj.section5[8+2] if obj.section5[6+2] in {1,2} else None 1895 def __set__(self, obj, value): 1896 if obj.typeOfValues == 0: 1897 obj.section5[8+2] = utils.ieee_float_to_int(value) 1898 elif self.typeOfValues == 1: 1899 obj.section5[8+2] = int(value) 1900 obj.section5[6+2] = 2
Secondary Missing Value
1902class NGroups: 1903 """Number of Groups""" 1904 def __get__(self, obj, objtype=None): 1905 return obj.section5[9+2] 1906 def __set__(self, obj, value): 1907 pass
Number of Groups
1909class RefGroupWidth: 1910 """Reference Group Width""" 1911 def __get__(self, obj, objtype=None): 1912 return obj.section5[10+2] 1913 def __set__(self, obj, value): 1914 pass
Reference Group Width
1916class NBitsGroupWidth: 1917 """Number of bits for Group Width""" 1918 def __get__(self, obj, objtype=None): 1919 return obj.section5[11+2] 1920 def __set__(self, obj, value): 1921 pass
Number of bits for Group Width
1923class RefGroupLength: 1924 """Reference Group Length""" 1925 def __get__(self, obj, objtype=None): 1926 return obj.section5[12+2] 1927 def __set__(self, obj, value): 1928 pass
Reference Group Length
1930class GroupLengthIncrement: 1931 """Group Length Increment""" 1932 def __get__(self, obj, objtype=None): 1933 return obj.section5[13+2] 1934 def __set__(self, obj, value): 1935 pass
Group Length Increment
1937class LengthOfLastGroup: 1938 """Length of Last Group""" 1939 def __get__(self, obj, objtype=None): 1940 return obj.section5[14+2] 1941 def __set__(self, obj, value): 1942 pass
Length of Last Group
1944class NBitsScaledGroupLength: 1945 """Number of bits of Scaled Group Length""" 1946 def __get__(self, obj, objtype=None): 1947 return obj.section5[15+2] 1948 def __set__(self, obj, value): 1949 pass
Number of bits of Scaled Group Length
1951class SpatialDifferenceOrder: 1952 """[Spatial Difference Order](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-6.shtml)""" 1953 def __get__(self, obj, objtype=None): 1954 return Grib2Metadata(obj.section5[16+2],table='5.6') 1955 def __set__(self, obj, value): 1956 obj.section5[16+2] = value
1958class NBytesSpatialDifference: 1959 """Number of bytes for Spatial Differencing""" 1960 def __get__(self, obj, objtype=None): 1961 return obj.section5[17+2] 1962 def __set__(self, obj, value): 1963 pass
Number of bytes for Spatial Differencing
1965class Precision: 1966 """[Precision for IEEE Floating Point Data](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-7.shtml)""" 1967 def __get__(self, obj, objtype=None): 1968 return Grib2Metadata(obj.section5[0+2],table='5.7') 1969 def __set__(self, obj, value): 1970 obj.section5[0+2] = value
1972class TypeOfCompression: 1973 """[Type of Compression](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-40.shtml)""" 1974 def __get__(self, obj, objtype=None): 1975 return Grib2Metadata(obj.section5[5+2],table='5.40') 1976 def __set__(self, obj, value): 1977 obj.section5[5+2] = value
1979class TargetCompressionRatio: 1980 """Target Compression Ratio""" 1981 def __get__(self, obj, objtype=None): 1982 return obj.section5[6+2] 1983 def __set__(self, obj, value): 1984 pass
Target Compression Ratio
1986class RealOfCoefficient: 1987 """Real of Coefficient""" 1988 def __get__(self, obj, objtype=None): 1989 return utils.ieee_int_to_float(obj.section5[4+2]) 1990 def __set__(self, obj, value): 1991 obj.section5[4+2] = utils.ieee_float_to_int(float(value))
Real of Coefficient
1993class CompressionOptionsMask: 1994 """Compression Options Mask for AEC/CCSDS""" 1995 def __get__(self, obj, objtype=None): 1996 return obj.section5[5+2] 1997 def __set__(self, obj, value): 1998 obj.section5[5+2] = value
Compression Options Mask for AEC/CCSDS
2000class BlockSize: 2001 """Block Size for AEC/CCSDS""" 2002 def __get__(self, obj, objtype=None): 2003 return obj.section5[6+2] 2004 def __set__(self, obj, value): 2005 obj.section5[6+2] = value
Block Size for AEC/CCSDS
2007class RefSampleInterval: 2008 """Reference Sample Interval for AEC/CCSDS""" 2009 def __get__(self, obj, objtype=None): 2010 return obj.section5[7+2] 2011 def __set__(self, obj, value): 2012 obj.section5[7+2] = value
Reference Sample Interval for AEC/CCSDS
2014@dataclass(init=False) 2015class DataRepresentationTemplate0(): 2016 """[Data Representation Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-0.shtml)""" 2017 _len = 5 2018 _num = 0 2019 _packingScheme = 'simple' 2020 refValue: float = field(init=False, repr=False, default=RefValue()) 2021 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2022 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2023 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2024 @classmethod 2025 @property 2026 def _attrs(cls): 2027 return list(cls.__dataclass_fields__.keys())
2029@dataclass(init=False) 2030class DataRepresentationTemplate2(): 2031 """[Data Representation Template 2](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-2.shtml)""" 2032 _len = 16 2033 _num = 2 2034 _packingScheme = 'complex' 2035 refValue: float = field(init=False, repr=False, default=RefValue()) 2036 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2037 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2038 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2039 groupSplittingMethod: Grib2Metadata = field(init=False, repr=False, default=GroupSplittingMethod()) 2040 typeOfMissingValueManagement: Grib2Metadata = field(init=False, repr=False, default=TypeOfMissingValueManagement()) 2041 priMissingValue: [float, int] = field(init=False, repr=False, default=PriMissingValue()) 2042 secMissingValue: [float, int] = field(init=False, repr=False, default=SecMissingValue()) 2043 nGroups: int = field(init=False, repr=False, default=NGroups()) 2044 refGroupWidth: int = field(init=False, repr=False, default=RefGroupWidth()) 2045 nBitsGroupWidth: int = field(init=False, repr=False, default=NBitsGroupWidth()) 2046 refGroupLength: int = field(init=False, repr=False, default=RefGroupLength()) 2047 groupLengthIncrement: int = field(init=False, repr=False, default=GroupLengthIncrement()) 2048 lengthOfLastGroup: int = field(init=False, repr=False, default=LengthOfLastGroup()) 2049 nBitsScaledGroupLength: int = field(init=False, repr=False, default=NBitsScaledGroupLength()) 2050 @classmethod 2051 @property 2052 def _attrs(cls): 2053 return list(cls.__dataclass_fields__.keys())
2055@dataclass(init=False) 2056class DataRepresentationTemplate3(): 2057 """[Data Representation Template 3](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-3.shtml)""" 2058 _len = 18 2059 _num = 3 2060 _packingScheme = 'complex-spdiff' 2061 refValue: float = field(init=False, repr=False, default=RefValue()) 2062 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2063 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2064 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2065 groupSplittingMethod: Grib2Metadata = field(init=False, repr=False, default=GroupSplittingMethod()) 2066 typeOfMissingValueManagement: Grib2Metadata = field(init=False, repr=False, default=TypeOfMissingValueManagement()) 2067 priMissingValue: [float, int] = field(init=False, repr=False, default=PriMissingValue()) 2068 secMissingValue: [float, int] = field(init=False, repr=False, default=SecMissingValue()) 2069 nGroups: int = field(init=False, repr=False, default=NGroups()) 2070 refGroupWidth: int = field(init=False, repr=False, default=RefGroupWidth()) 2071 nBitsGroupWidth: int = field(init=False, repr=False, default=NBitsGroupWidth()) 2072 refGroupLength: int = field(init=False, repr=False, default=RefGroupLength()) 2073 groupLengthIncrement: int = field(init=False, repr=False, default=GroupLengthIncrement()) 2074 lengthOfLastGroup: int = field(init=False, repr=False, default=LengthOfLastGroup()) 2075 nBitsScaledGroupLength: int = field(init=False, repr=False, default=NBitsScaledGroupLength()) 2076 spatialDifferenceOrder: Grib2Metadata = field(init=False, repr=False, default=SpatialDifferenceOrder()) 2077 nBytesSpatialDifference: int = field(init=False, repr=False, default=NBytesSpatialDifference()) 2078 @classmethod 2079 @property 2080 def _attrs(cls): 2081 return list(cls.__dataclass_fields__.keys())
2083@dataclass(init=False) 2084class DataRepresentationTemplate4(): 2085 """[Data Representation Template 4](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-4.shtml)""" 2086 _len = 1 2087 _num = 4 2088 _packingScheme = 'ieee-float' 2089 precision: Grib2Metadata = field(init=False, repr=False, default=Precision()) 2090 @classmethod 2091 @property 2092 def _attrs(cls): 2093 return list(cls.__dataclass_fields__.keys())
2095@dataclass(init=False) 2096class DataRepresentationTemplate40(): 2097 """[Data Representation Template 40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-40.shtml)""" 2098 _len = 7 2099 _num = 40 2100 _packingScheme = 'jpeg' 2101 refValue: float = field(init=False, repr=False, default=RefValue()) 2102 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2103 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2104 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2105 typeOfCompression: Grib2Metadata = field(init=False, repr=False, default=TypeOfCompression()) 2106 targetCompressionRatio: int = field(init=False, repr=False, default=TargetCompressionRatio()) 2107 @classmethod 2108 @property 2109 def _attrs(cls): 2110 return list(cls.__dataclass_fields__.keys())
2112@dataclass(init=False) 2113class DataRepresentationTemplate41(): 2114 """[Data Representation Template 41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-41.shtml)""" 2115 _len = 5 2116 _num = 41 2117 _packingScheme = 'png' 2118 refValue: float = field(init=False, repr=False, default=RefValue()) 2119 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2120 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2121 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2122 @classmethod 2123 @property 2124 def _attrs(cls): 2125 return list(cls.__dataclass_fields__.keys())
2127@dataclass(init=False) 2128class DataRepresentationTemplate42(): 2129 """[Data Representation Template 42](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-42.shtml)""" 2130 _len = 8 2131 _num = 42 2132 _packingScheme = 'aec' 2133 refValue: float = field(init=False, repr=False, default=RefValue()) 2134 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2135 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2136 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2137 compressionOptionsMask: int = field(init=False, repr=False, default=CompressionOptionsMask()) 2138 blockSize: int = field(init=False, repr=False, default=BlockSize()) 2139 refSampleInterval: int = field(init=False, repr=False, default=RefSampleInterval()) 2140 @classmethod 2141 @property 2142 def _attrs(cls): 2143 return list(cls.__dataclass_fields__.keys())
2145@dataclass(init=False) 2146class DataRepresentationTemplate50(): 2147 """[Data Representation Template 50](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-50.shtml)""" 2148 _len = 5 2149 _num = 0 2150 _packingScheme = 'spectral-simple' 2151 refValue: float = field(init=False, repr=False, default=RefValue()) 2152 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2153 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2154 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2155 realOfCoefficient: float = field(init=False, repr=False, default=RealOfCoefficient()) 2156 @classmethod 2157 @property 2158 def _attrs(cls): 2159 return list(cls.__dataclass_fields__.keys())
2172def drt_class_by_drtn(drtn): 2173 """ 2174 Provides a Data Representation Template class via the template number 2175 2176 Parameters 2177 ---------- 2178 **`drtn : int`** 2179 Data Representation template number. 2180 2181 Returns 2182 ------- 2183 Data Representation template class object (not an instance). 2184 """ 2185 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).