grib2io.templates
GRIB2 section templates classes and metadata descriptor classes.
1"""GRIB2 section templates classes and metadata descriptor classes.""" 2from dataclasses import dataclass, field 3from collections import defaultdict 4from typing import Union 5import copy 6import datetime 7import numpy as np 8import warnings 9 10from . import tables 11from . import utils 12 13# This dict is used by grib2io.Grib2Message.attrs_by_section() method 14# to get attr names that defined in the Grib2Message base class. 15_section_attrs = {0:['discipline'], 16 1:['originatingCenter', 'originatingSubCenter', 'masterTableInfo', 'localTableInfo', 17 'significanceOfReferenceTime', 'year', 'month', 'day', 'hour', 'minute', 'second', 18 'refDate', 'productionStatus', 'typeOfData'], 19 2:[], 20 3:['sourceOfGridDefinition', 'numberOfDataPoints', 'interpretationOfListOfNumbers', 21 'gridDefinitionTemplateNumber', 'shapeOfEarth', 'earthRadius', 'earthMajorAxis', 22 'earthMinorAxis', 'resolutionAndComponentFlags', 'ny', 'nx', 'scanModeFlags'], 23 4:[], 24 5:['dataRepresentationTemplateNumber','numberOfPackedValues','typeOfValues'], 25 6:['bitMapFlag'], 26 7:[], 27 8:[],} 28 29_continuous_pdtns = [ 30 int(k) for k, v in tables.get_table("4.0").items() if "a point in time" in v 31] 32_timeinterval_pdtns = [ 33 int(k) 34 for k, v in tables.get_table("4.0").items() 35 if "continuous or non-continuous time interval" in v 36] 37 38 39def _calculate_scale_factor(value: float): 40 """ 41 Calculate the scale factor for a given value. 42 43 Parameters 44 ---------- 45 value : float 46 Value for which to calculate the scale factor. 47 48 Returns 49 ------- 50 int 51 Scale factor for the value. 52 """ 53 return len(f"{value}".split(".")[1].rstrip("0")) 54 55 56class Grib2Metadata: 57 """ 58 Class to hold GRIB2 metadata. 59 60 Stores both numeric code value as stored in GRIB2 and its plain language 61 definition. 62 63 Attributes 64 ---------- 65 value : int 66 GRIB2 metadata integer code value. 67 table : str, optional 68 GRIB2 table to lookup the `value`. Default is None. 69 definition : str 70 Plain language description of numeric metadata. 71 """ 72 __slots__ = ('value','table') 73 def __init__(self, value, table=None): 74 self.value = value 75 self.table = table 76 def __call__(self): 77 return self.value 78 def __hash__(self): 79 # AS- added hash() to self.value as pandas was raising error about some 80 # non integer returns from hash method 81 return hash(self.value) 82 def __repr__(self): 83 return f"{self.__class__.__name__}({self.value}, table = '{self.table}')" 84 def __str__(self): 85 return f'{self.value} - {self.definition}' 86 def __eq__(self,other): 87 return self.value == other or self.definition[0] == other 88 def __gt__(self,other): 89 return self.value > other 90 def __ge__(self,other): 91 return self.value >= other 92 def __lt__(self,other): 93 return self.value < other 94 def __le__(self,other): 95 return self.value <= other 96 def __contains__(self,other): 97 return other in self.definition 98 def __hash__(self): 99 return hash(self.value) 100 def __index__(self): 101 return int(self.value) 102 @property 103 def definition(self): 104 """Provide the definition of the numeric metadata.""" 105 return tables.get_value_from_table(self.value,self.table) 106 def show_table(self): 107 """Provide the table related to this metadata.""" 108 return tables.get_table(self.table) 109 110# ---------------------------------------------------------------------------------------- 111# Descriptor Classes for Section 0 metadata. 112# ---------------------------------------------------------------------------------------- 113class IndicatorSection: 114 """ 115 [GRIB2 Indicator Section (0)](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect0.shtml) 116 """ 117 def __get__(self, obj, objtype=None): 118 return obj.section0 119 def __set__(self, obj, value): 120 obj.section0 = value 121 122class Discipline: 123 """[Discipline](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table0-0.shtml)""" 124 def __get__(self, obj, objtype=None): 125 return Grib2Metadata(obj.indicatorSection[2],table='0.0') 126 def __set__(self, obj, value): 127 obj.section0[2] = value 128 129 130# ---------------------------------------------------------------------------------------- 131# Descriptor Classes for Section 1 metadata. 132# ---------------------------------------------------------------------------------------- 133class IdentificationSection: 134 """ 135 GRIB2 Section 1, [Identification Section](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect1.shtml) 136 """ 137 def __get__(self, obj, objtype=None): 138 return obj.section1 139 def __set__(self, obj, value): 140 obj.section1 = value 141 142class OriginatingCenter: 143 """[Originating Center](https://www.nco.ncep.noaa.gov/pmb/docs/on388/table0.html)""" 144 def __get__(self, obj, objtype=None): 145 return Grib2Metadata(obj.section1[0],table='originating_centers') 146 def __set__(self, obj, value): 147 obj.section1[0] = value 148 149class OriginatingSubCenter: 150 """[Originating SubCenter](https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablec.html)""" 151 def __get__(self, obj, objtype=None): 152 return Grib2Metadata(obj.section1[1],table='originating_subcenters') 153 def __set__(self, obj, value): 154 obj.section1[1] = value 155 156class MasterTableInfo: 157 """[GRIB2 Master Table Version](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-0.shtml)""" 158 def __get__(self, obj, objtype=None): 159 return Grib2Metadata(obj.section1[2],table='1.0') 160 def __set__(self, obj, value): 161 obj.section1[2] = value 162 163class LocalTableInfo: 164 """[GRIB2 Local Tables Version Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-1.shtml)""" 165 def __get__(self, obj, objtype=None): 166 return Grib2Metadata(obj.section1[3],table='1.1') 167 def __set__(self, obj, value): 168 obj.section1[3] = value 169 170class SignificanceOfReferenceTime: 171 """[Significance of Reference Time](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-2.shtml)""" 172 def __get__(self, obj, objtype=None): 173 return Grib2Metadata(obj.section1[4],table='1.2') 174 def __set__(self, obj, value): 175 obj.section1[4] = value 176 177class Year: 178 """Year of reference time""" 179 def __get__(self, obj, objtype=None): 180 return obj.section1[5] 181 def __set__(self, obj, value): 182 rd = copy.copy(obj.section1[5:11]) 183 rd[0] = value 184 # Test validity of datetime values 185 _ = datetime.datetime(*rd) 186 obj.section1[5] = value 187 188class Month: 189 """Month of reference time""" 190 def __get__(self, obj, objtype=None): 191 return obj.section1[6] 192 def __set__(self, obj, value): 193 rd = copy.copy(obj.section1[5:11]) 194 rd[1] = value 195 # Test validity of datetime values 196 _ = datetime.datetime(*rd) 197 obj.section1[6] = value 198 199class Day: 200 """Day of reference time""" 201 def __get__(self, obj, objtype=None): 202 return obj.section1[7] 203 def __set__(self, obj, value): 204 rd = copy.copy(obj.section1[5:11]) 205 rd[2] = value 206 # Test validity of datetime values 207 _ = datetime.datetime(*rd) 208 #obj.section1[7] = value 209 210class Hour: 211 """Hour of reference time""" 212 def __get__(self, obj, objtype=None): 213 return obj.section1[8] 214 def __set__(self, obj, value): 215 rd = copy.copy(obj.section1[5:11]) 216 rd[3] = value 217 # Test validity of datetime values 218 _ = datetime.datetime(*rd) 219 obj.section1[8] = value 220 221class Minute: 222 """Minute of reference time""" 223 def __get__(self, obj, objtype=None): 224 return obj.section1[9] 225 def __set__(self, obj, value): 226 rd = copy.copy(obj.section1[5:11]) 227 rd[4] = value 228 # Test validity of datetime values 229 _ = datetime.datetime(*rd) 230 obj.section1[9] = value 231 232class Second: 233 """Second of reference time""" 234 def __get__(self, obj, objtype=None): 235 return obj.section1[10] 236 def __set__(self, obj, value): 237 rd = copy.copy(obj.section1[5:11]) 238 rd[5] = value 239 # Test validity of datetime values 240 _ = datetime.datetime(*rd) 241 obj.section1[10] = value 242 243class RefDate: 244 """Reference Date. NOTE: This is a `datetime.datetime` object.""" 245 def __get__(self, obj, objtype=None): 246 return datetime.datetime(*obj.section1[5:11]) 247 def __set__(self, obj, value): 248 if isinstance(value, np.datetime64): 249 timestamp = (value - np.datetime64("1970-01-01T00:00:00")) / np.timedelta64( 250 1, "s" 251 ) 252 try: 253 # Python >= 3.10 254 value = datetime.datetime.fromtimestamp(timestamp, datetime.UTC) 255 except(AttributeError): 256 # Python < 3.10 257 value = datetime.datetime.utcfromtimestamp(timestamp) 258 if isinstance(value, datetime.datetime): 259 obj.section1[5] = value.year 260 obj.section1[6] = value.month 261 obj.section1[7] = value.day 262 obj.section1[8] = value.hour 263 obj.section1[9] = value.minute 264 obj.section1[10] = value.second 265 # IMPORTANT: Update validDate components when message is time interval 266 if obj.pdtn in _timeinterval_pdtns: 267 vd = value + obj.leadTime + obj.duration 268 obj.yearOfEndOfTimePeriod = vd.year 269 obj.monthOfEndOfTimePeriod = vd.month 270 obj.dayOfEndOfTimePeriod = vd.day 271 obj.hourOfEndOfTimePeriod = vd.hour 272 obj.minuteOfEndOfTimePeriod = vd.minute 273 obj.secondOfEndOfTimePeriod = vd.second 274 else: 275 msg = "Reference date must be a datetime.datetime or np.datetime64 object." 276 raise TypeError(msg) 277 278class ProductionStatus: 279 """[Production Status of Processed Data](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-3.shtml)""" 280 def __get__(self, obj, objtype=None): 281 return Grib2Metadata(obj.section1[11],table='1.3') 282 def __set__(self, obj, value): 283 obj.section1[11] = value 284 285class TypeOfData: 286 """[Type of Processed Data in this GRIB message](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-4.shtml)""" 287 def __get__(self, obj, objtype=None): 288 return Grib2Metadata(obj.section1[12],table='1.4') 289 def __set__(self, obj, value): 290 obj.section1[12] = value 291 292# ---------------------------------------------------------------------------------------- 293# Descriptor Classes for Section 2 metadata. 294# ---------------------------------------------------------------------------------------- 295 296# ---------------------------------------------------------------------------------------- 297# Descriptor Classes for Section 3 metadata. 298# ---------------------------------------------------------------------------------------- 299class GridDefinitionSection: 300 """ 301 GRIB2 Section 3, [Grid Definition Section](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml) 302 """ 303 def __get__(self, obj, objtype=None): 304 return obj.section3[0:5] 305 def __set__(self, obj, value): 306 raise RuntimeError 307 308class SourceOfGridDefinition: 309 """[Source of Grid Definition](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-0.shtml)""" 310 def __get__(self, obj, objtype=None): 311 return Grib2Metadata(obj.section3[0],table='3.0') 312 def __set__(self, obj, value): 313 raise RuntimeError 314 315class NumberOfDataPoints: 316 """Number of Data Points""" 317 def __get__(self, obj, objtype=None): 318 return obj.section3[1] 319 def __set__(self, obj, value): 320 raise RuntimeError 321 322class InterpretationOfListOfNumbers: 323 """Interpretation of List of Numbers""" 324 def __get__(self, obj, objtype=None): 325 return Grib2Metadata(obj.section3[3],table='3.11') 326 def __set__(self, obj, value): 327 raise RuntimeError 328 329class GridDefinitionTemplateNumber: 330 """[Grid Definition Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-1.shtml)""" 331 def __get__(self, obj, objtype=None): 332 return Grib2Metadata(obj.section3[4],table='3.1') 333 def __set__(self, obj, value): 334 raise RuntimeError 335 336class GridDefinitionTemplate: 337 """Grid definition template""" 338 def __get__(self, obj, objtype=None): 339 return obj.section3[5:] 340 def __set__(self, obj, value): 341 raise RuntimeError 342 343class EarthParams: 344 """Metadata about the shape of the Earth""" 345 def __get__(self, obj, objtype=None): 346 if obj.section3[5] in {50,51,52,1200}: 347 return None 348 return tables.get_table('earth_params')[str(obj.section3[5])] 349 def __set__(self, obj, value): 350 raise RuntimeError 351 352class DxSign: 353 """Sign of Grid Length in X-Direction""" 354 def __get__(self, obj, objtype=None): 355 if obj.section3[4] in {0,1,203,205,32768,32769} and \ 356 obj.section3[17] > obj.section3[20]: 357 return -1.0 358 return 1.0 359 def __set__(self, obj, value): 360 raise RuntimeError 361 362class DySign: 363 """Sign of Grid Length in Y-Direction""" 364 def __get__(self, obj, objtype=None): 365 if obj.section3[4] in {0,1,203,205,32768,32769} and \ 366 obj.section3[16] > obj.section3[19]: 367 return -1.0 368 return 1.0 369 def __set__(self, obj, value): 370 raise RuntimeError 371 372class LLScaleFactor: 373 """Scale Factor for Lats/Lons""" 374 def __get__(self, obj, objtype=None): 375 if obj.section3[4] in {0,1,40,41,203,205,32768,32769}: 376 llscalefactor = float(obj.section3[14]) 377 if llscalefactor == 0: 378 return 1 379 return llscalefactor 380 return 1 381 def __set__(self, obj, value): 382 raise RuntimeError 383 384class LLDivisor: 385 """Divisor Value for scaling Lats/Lons""" 386 def __get__(self, obj, objtype=None): 387 if obj.section3[4] in {0,1,40,41,203,205,32768,32769}: 388 lldivisor = float(obj.section3[15]) 389 if lldivisor <= 0: 390 return 1.e6 391 return lldivisor 392 return 1.e6 393 def __set__(self, obj, value): 394 raise RuntimeError 395 396class XYDivisor: 397 """Divisor Value for scaling grid lengths""" 398 def __get__(self, obj, objtype=None): 399 if obj.section3[4] in {0,1,40,41,203,205,32768,32769}: 400 return obj._lldivisor 401 return 1.e3 402 def __set__(self, obj, value): 403 raise RuntimeError 404 405class ShapeOfEarth: 406 """[Shape of the Reference System](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-2.shtml)""" 407 def __get__(self, obj, objtype=None): 408 return Grib2Metadata(obj.section3[5],table='3.2') 409 def __set__(self, obj, value): 410 obj.section3[5] = value 411 412class EarthShape: 413 """Description of the shape of the Earth""" 414 def __get__(self, obj, objtype=None): 415 return obj._earthparams['shape'] 416 def __set__(self, obj, value): 417 raise RuntimeError 418 419class EarthRadius: 420 """Radius of the Earth (Assumes "spherical")""" 421 def __get__(self, obj, objtype=None): 422 ep = obj._earthparams 423 if ep['shape'] == 'spherical': 424 if ep['radius'] is None: 425 return obj.section3[7]/(10.**obj.section3[6]) 426 else: 427 return ep['radius'] 428 elif ep['shape'] in {'ellipsoid','oblateSpheriod'}: 429 return None 430 def __set__(self, obj, value): 431 raise RuntimeError 432 433class EarthMajorAxis: 434 """Major Axis of the Earth (Assumes "oblate spheroid" or "ellipsoid")""" 435 def __get__(self, obj, objtype=None): 436 ep = obj._earthparams 437 if ep['shape'] == 'spherical': 438 return None 439 elif ep['shape'] in {'ellipsoid','oblateSpheriod'}: 440 if ep['major_axis'] is None and ep['minor_axis'] is None: 441 return obj.section3[9]/(10.**obj.section3[8]) 442 else: 443 return ep['major_axis'] 444 def __set__(self, obj, value): 445 raise RuntimeError 446 447class EarthMinorAxis: 448 """Minor Axis of the Earth (Assumes "oblate spheroid" or "ellipsoid")""" 449 def __get__(self, obj, objtype=None): 450 ep = obj._earthparams 451 if ep['shape'] == 'spherical': 452 return None 453 if ep['shape'] in {'ellipsoid','oblateSpheriod'}: 454 if ep['major_axis'] is None and ep['minor_axis'] is None: 455 return obj.section3[11]/(10.**section3[10]) 456 else: 457 return ep['minor_axis'] 458 def __set__(self, obj, value): 459 raise RuntimeError 460 461class Nx: 462 """Number of grid points in the X-direction (generally East-West)""" 463 def __get__(self, obj, objtype=None): 464 return obj.section3[12] 465 def __set__(self, obj, value): 466 obj.section3[12] = value 467 obj.section3[1] = value * obj.section3[13] 468 469class Ny: 470 """Number of grid points in the Y-direction (generally North-South)""" 471 def __get__(self, obj, objtype=None): 472 return obj.section3[13] 473 def __set__(self, obj, value): 474 obj.section3[13] = value 475 obj.section3[1] = value * obj.section3[12] 476 477class ScanModeFlags: 478 """[Scanning Mode](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-4.shtml)""" 479 _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} 480 def __get__(self, obj, objtype=None): 481 if obj.gdtn == 50: 482 return [None, None, None, None] 483 else: 484 return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list)[0:8] 485 def __set__(self, obj, value): 486 obj.section3[self._key[obj.gdtn]+5] = value 487 488class ResolutionAndComponentFlags: 489 """[Resolution and Component Flags](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-3.shtml)""" 490 _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} 491 def __get__(self, obj, objtype=None): 492 if obj.gdtn == 50: 493 return [None for i in range(8)] 494 else: 495 return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list) 496 def __set__(self, obj, value): 497 obj.section3[self._key[obj.gdtn]+5] = value 498 499class LatitudeFirstGridpoint: 500 """Latitude of first gridpoint""" 501 _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} 502 def __get__(self, obj, objtype=None): 503 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 504 def __set__(self, obj, value): 505 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 506 507class LongitudeFirstGridpoint: 508 """Longitude of first gridpoint""" 509 _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} 510 def __get__(self, obj, objtype=None): 511 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 512 def __set__(self, obj, value): 513 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 514 515class LatitudeLastGridpoint: 516 """Latitude of last gridpoint""" 517 _key = {0:14, 1:14, 10:13, 40:14, 41:14, 203:14, 204:14, 205:14, 32768:14, 32769:19} 518 def __get__(self, obj, objtype=None): 519 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 520 def __set__(self, obj, value): 521 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 522 523class LongitudeLastGridpoint: 524 """Longitude of last gridpoint""" 525 _key = {0:15, 1:15, 10:14, 40:15, 41:15, 203:15, 204:15, 205:15, 32768:15, 32769:20} 526 def __get__(self, obj, objtype=None): 527 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 528 def __set__(self, obj, value): 529 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 530 531class LatitudeCenterGridpoint: 532 """Latitude of center gridpoint""" 533 _key = {32768:14, 32769:14} 534 def __get__(self, obj, objtype=None): 535 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 536 def __set__(self, obj, value): 537 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 538 539class LongitudeCenterGridpoint: 540 """Longitude of center gridpoint""" 541 _key = {32768:15, 32769:15} 542 def __get__(self, obj, objtype=None): 543 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 544 def __set__(self, obj, value): 545 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 546 547class GridlengthXDirection: 548 """Grid lenth in the X-Direction""" 549 _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} 550 def __get__(self, obj, objtype=None): 551 return (obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._xydivisor)*obj._dxsign 552 def __set__(self, obj, value): 553 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._xydivisor/obj._llscalefactor) 554 555class GridlengthYDirection: 556 """Grid lenth in the Y-Direction""" 557 _key = {0:17, 1:17, 10:18, 20:15, 30:15, 31:15, 203:17, 204:17, 205:17, 32768:17, 32769:17} 558 def __get__(self, obj, objtype=None): 559 if obj.gdtn in {40, 41}: 560 return obj.gridlengthXDirection 561 else: 562 return (obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._xydivisor)*obj._dysign 563 def __set__(self, obj, value): 564 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._xydivisor/obj._llscalefactor) 565 566class NumberOfParallels: 567 """Number of parallels between a pole and the equator""" 568 _key = {40:17, 41:17} 569 def __get__(self, obj, objtype=None): 570 return obj.section3[self._key[obj.gdtn]+5] 571 def __set__(self, obj, value): 572 raise RuntimeError 573 574class LatitudeSouthernPole: 575 """Latitude of the Southern Pole for a Rotated Lat/Lon Grid""" 576 _key = {1:19, 30:20, 31:20, 41:19} 577 def __get__(self, obj, objtype=None): 578 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 579 def __set__(self, obj, value): 580 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 581 582class LongitudeSouthernPole: 583 """Longitude of the Southern Pole for a Rotated Lat/Lon Grid""" 584 _key = {1:20, 30:21, 31:21, 41:20} 585 def __get__(self, obj, objtype=None): 586 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 587 def __set__(self, obj, value): 588 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 589 590class AnglePoleRotation: 591 """Angle of Pole Rotation for a Rotated Lat/Lon Grid""" 592 _key = {1:21, 41:21} 593 def __get__(self, obj, objtype=None): 594 return obj.section3[self._key[obj.gdtn]+5] 595 def __set__(self, obj, value): 596 obj.section3[self._key[obj.gdtn]+5] = int(value) 597 598class LatitudeTrueScale: 599 """Latitude at which grid lengths are specified""" 600 _key = {10:12, 20:12, 30:12, 31:12} 601 def __get__(self, obj, objtype=None): 602 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 603 def __set__(self, obj, value): 604 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 605 606class GridOrientation: 607 """Longitude at which the grid is oriented""" 608 _key = {10:16, 20:13, 30:13, 31:13} 609 def __get__(self, obj, objtype=None): 610 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 611 def __set__(self, obj, value): 612 if obj.gdtn == 10 and (value < 0 or value > 90): 613 raise ValueError("Grid orientation is limited to range of 0 to 90 degrees.") 614 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 615 616class ProjectionCenterFlag: 617 """[Projection Center](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-5.shtml)""" 618 _key = {20:16, 30:16, 31:16} 619 def __get__(self, obj, objtype=None): 620 return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list)[0] 621 def __set__(self, obj, value): 622 obj.section3[self._key[obj.gdtn]+5] = value 623 624class StandardLatitude1: 625 """First Standard Latitude (from the pole at which the secant cone cuts the sphere)""" 626 _key = {30:18, 31:18} 627 def __get__(self, obj, objtype=None): 628 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 629 def __set__(self, obj, value): 630 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 631 632class StandardLatitude2: 633 """Second Standard Latitude (from the pole at which the secant cone cuts the sphere)""" 634 _key = {30:19, 31:19} 635 def __get__(self, obj, objtype=None): 636 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 637 def __set__(self, obj, value): 638 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor) 639 640class SpectralFunctionParameters: 641 """Spectral Function Parameters""" 642 def __get__(self, obj, objtype=None): 643 return obj.section3[0:3] 644 def __set__(self, obj, value): 645 obj.section3[0:3] = value[0:3] 646 647class ProjParameters: 648 """PROJ Parameters to define the reference system""" 649 def __get__(self, obj, objtype=None): 650 projparams = {} 651 projparams['a'] = 1.0 652 projparams['b'] = 1.0 653 if obj.earthRadius is not None: 654 projparams['a'] = obj.earthRadius 655 projparams['b'] = obj.earthRadius 656 else: 657 if obj.earthMajorAxis is not None: projparams['a'] = obj.earthMajorAxis 658 if obj.earthMajorAxis is not None: projparams['b'] = obj.earthMinorAxis 659 if obj.gdtn == 0: 660 projparams['proj'] = 'longlat' 661 elif obj.gdtn == 1: 662 projparams['o_proj'] = 'longlat' 663 projparams['proj'] = 'ob_tran' 664 projparams['o_lat_p'] = -1.0*obj.latitudeSouthernPole 665 projparams['o_lon_p'] = obj.anglePoleRotation 666 projparams['lon_0'] = obj.longitudeSouthernPole 667 elif obj.gdtn == 10: 668 projparams['proj'] = 'merc' 669 projparams['lat_ts'] = obj.latitudeTrueScale 670 projparams['lon_0'] = 0.5*(obj.longitudeFirstGridpoint+obj.longitudeLastGridpoint) 671 elif obj.gdtn == 20: 672 if obj.projectionCenterFlag == 0: 673 lat0 = 90.0 674 elif obj.projectionCenterFlag == 1: 675 lat0 = -90.0 676 projparams['proj'] = 'stere' 677 projparams['lat_ts'] = obj.latitudeTrueScale 678 projparams['lat_0'] = lat0 679 projparams['lon_0'] = obj.gridOrientation 680 elif obj.gdtn == 30: 681 projparams['proj'] = 'lcc' 682 projparams['lat_1'] = obj.standardLatitude1 683 projparams['lat_2'] = obj.standardLatitude2 684 projparams['lat_0'] = obj.latitudeTrueScale 685 projparams['lon_0'] = obj.gridOrientation 686 elif obj.gdtn == 31: 687 projparams['proj'] = 'aea' 688 projparams['lat_1'] = obj.standardLatitude1 689 projparams['lat_2'] = obj.standardLatitude2 690 projparams['lat_0'] = obj.latitudeTrueScale 691 projparams['lon_0'] = obj.gridOrientation 692 elif obj.gdtn == 40: 693 projparams['proj'] = 'eqc' 694 elif obj.gdtn == 32769: 695 projparams['proj'] = 'aeqd' 696 projparams['lon_0'] = obj.longitudeCenterGridpoint 697 projparams['lat_0'] = obj.latitudeCenterGridpoint 698 return projparams 699 def __set__(self, obj, value): 700 raise RuntimeError 701 702@dataclass(init=False) 703class GridDefinitionTemplate0: 704 """[Grid Definition Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-0.shtml)""" 705 _len = 19 706 _num = 0 707 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 708 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 709 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 710 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 711 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 712 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 713 714 @classmethod 715 def _attrs(cls): 716 return list(cls.__dataclass_fields__.keys()) 717 718@dataclass(init=False) 719class GridDefinitionTemplate1: 720 """[Grid Definition Template 1](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-1.shtml)""" 721 _len = 22 722 _num = 1 723 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 724 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 725 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 726 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 727 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 728 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 729 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 730 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 731 anglePoleRotation: float = field(init=False, repr=False, default=AnglePoleRotation()) 732 @classmethod 733 def _attrs(cls): 734 return list(cls.__dataclass_fields__.keys()) 735 736@dataclass(init=False) 737class GridDefinitionTemplate10: 738 """[Grid Definition Template 10](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-10.shtml)""" 739 _len = 19 740 _num = 10 741 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 742 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 743 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 744 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 745 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 746 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 747 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 748 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 749 projParameters: dict = field(init=False, repr=False, default=ProjParameters()) 750 @classmethod 751 def _attrs(cls): 752 return list(cls.__dataclass_fields__.keys()) 753 754@dataclass(init=False) 755class GridDefinitionTemplate20: 756 """[Grid Definition Template 20](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-20.shtml)""" 757 _len = 18 758 _num = 20 759 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 760 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 761 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 762 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 763 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 764 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 765 projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag()) 766 projParameters: dict = field(init=False, repr=False, default=ProjParameters()) 767 @classmethod 768 def _attrs(cls): 769 return list(cls.__dataclass_fields__.keys()) 770 771@dataclass(init=False) 772class GridDefinitionTemplate30: 773 """[Grid Definition Template 30](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-30.shtml)""" 774 _len = 22 775 _num = 30 776 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 777 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 778 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 779 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 780 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 781 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 782 projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag()) 783 standardLatitude1: float = field(init=False, repr=False, default=StandardLatitude1()) 784 standardLatitude2: float = field(init=False, repr=False, default=StandardLatitude2()) 785 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 786 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 787 projParameters: dict = field(init=False, repr=False, default=ProjParameters()) 788 @classmethod 789 def _attrs(cls): 790 return list(cls.__dataclass_fields__.keys()) 791 792@dataclass(init=False) 793class GridDefinitionTemplate31: 794 """[Grid Definition Template 31](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-31.shtml)""" 795 _len = 22 796 _num = 31 797 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 798 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 799 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 800 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 801 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 802 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 803 projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag()) 804 standardLatitude1: float = field(init=False, repr=False, default=StandardLatitude1()) 805 standardLatitude2: float = field(init=False, repr=False, default=StandardLatitude2()) 806 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 807 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 808 @classmethod 809 def _attrs(cls): 810 return list(cls.__dataclass_fields__.keys()) 811 812@dataclass(init=False) 813class GridDefinitionTemplate40: 814 """[Grid Definition Template 40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-40.shtml)""" 815 _len = 19 816 _num = 40 817 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 818 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 819 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 820 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 821 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 822 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 823 numberOfParallels: int = field(init=False, repr=False, default=NumberOfParallels()) 824 @classmethod 825 def _attrs(cls): 826 return list(cls.__dataclass_fields__.keys()) 827 828@dataclass(init=False) 829class GridDefinitionTemplate41: 830 """[Grid Definition Template 41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-41.shtml)""" 831 _len = 22 832 _num = 41 833 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 834 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 835 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 836 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 837 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 838 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 839 numberOfParallels: int = field(init=False, repr=False, default=NumberOfParallels()) 840 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 841 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 842 anglePoleRotation: float = field(init=False, repr=False, default=AnglePoleRotation()) 843 @classmethod 844 def _attrs(cls): 845 return list(cls.__dataclass_fields__.keys()) 846 847@dataclass(init=False) 848class GridDefinitionTemplate50: 849 """[Grid Definition Template 50](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-50.shtml)""" 850 _len = 5 851 _num = 50 852 spectralFunctionParameters: list = field(init=False, repr=False, default=SpectralFunctionParameters()) 853 @classmethod 854 def _attrs(cls): 855 return list(cls.__dataclass_fields__.keys()) 856 857@dataclass(init=False) 858class GridDefinitionTemplate32768: 859 """[Grid Definition Template 32768](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32768.shtml)""" 860 _len = 19 861 _num = 32768 862 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 863 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 864 latitudeCenterGridpoint: float = field(init=False, repr=False, default=LatitudeCenterGridpoint()) 865 longitudeCenterGridpoint: float = field(init=False, repr=False, default=LongitudeCenterGridpoint()) 866 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 867 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 868 @classmethod 869 def _attrs(cls): 870 return list(cls.__dataclass_fields__.keys()) 871 872@dataclass(init=False) 873class GridDefinitionTemplate32769: 874 """[Grid Definition Template 32769](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32769.shtml)""" 875 _len = 19 876 _num = 32769 877 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 878 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 879 latitudeCenterGridpoint: float = field(init=False, repr=False, default=LatitudeCenterGridpoint()) 880 longitudeCenterGridpoint: float = field(init=False, repr=False, default=LongitudeCenterGridpoint()) 881 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 882 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 883 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 884 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 885 @classmethod 886 def _attrs(cls): 887 return list(cls.__dataclass_fields__.keys()) 888 889_gdt_by_gdtn = {0: GridDefinitionTemplate0, 890 1: GridDefinitionTemplate1, 891 10: GridDefinitionTemplate10, 892 20: GridDefinitionTemplate20, 893 30: GridDefinitionTemplate30, 894 31: GridDefinitionTemplate31, 895 40: GridDefinitionTemplate40, 896 41: GridDefinitionTemplate41, 897 50: GridDefinitionTemplate50, 898 32768: GridDefinitionTemplate32768, 899 32769: GridDefinitionTemplate32769, 900 } 901 902def gdt_class_by_gdtn(gdtn: int): 903 """ 904 Provides a Grid Definition Template class via the template number 905 906 Parameters 907 ---------- 908 gdtn 909 Grid definition template number. 910 911 Returns 912 ------- 913 gdt_class_by_gdtn 914 Grid definition template class object (not an instance). 915 """ 916 return _gdt_by_gdtn[gdtn] 917 918# ---------------------------------------------------------------------------------------- 919# Descriptor Classes for Section 4 metadata. 920# ---------------------------------------------------------------------------------------- 921class ProductDefinitionTemplateNumber: 922 """[Product Definition Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-0.shtml)""" 923 def __get__(self, obj, objtype=None): 924 return Grib2Metadata(obj.section4[1],table='4.0') 925 def __set__(self, obj, value): 926 raise RuntimeError 927 928# since PDT begins at position 2 of section4, code written with +2 for added readability with grib2 documentation 929class ProductDefinitionTemplate: 930 """Product Definition Template""" 931 def __get__(self, obj, objtype=None): 932 return obj.section4[2:] 933 def __set__(self, obj, value): 934 raise RuntimeError 935 936class ParameterCategory: 937 """[Parameter Category](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-1.shtml)""" 938 _key = defaultdict(lambda: 0) 939 def __get__(self, obj, objtype=None): 940 return obj.section4[0+2] 941 def __set__(self, obj, value): 942 obj.section4[self._key[obj.pdtn]+2] = value 943 944class ParameterNumber: 945 """[Parameter Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-2.shtml)""" 946 _key = defaultdict(lambda: 1) 947 def __get__(self, obj, objtype=None): 948 return obj.section4[1+2] 949 def __set__(self, obj, value): 950 obj.section4[self._key[obj.pdtn]+2] = value 951 952class VarInfo: 953 """ 954 Variable Information. 955 956 These are the metadata returned for a specific variable according to 957 discipline, parameter category, and parameter number. 958 """ 959 def __get__(self, obj, objtype=None): 960 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD) 961 def __set__(self, obj, value): 962 raise RuntimeError 963 964class FullName: 965 """Full name of the Variable.""" 966 def __get__(self, obj, objtype=None): 967 full_name = [] 968 969 # Get aerosol type from table 4.233 970 if not hasattr(obj, 'typeOfAerosol'): 971 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[0] 972 elif obj.typeOfAerosol is not None: 973 aero_type = str(obj.typeOfAerosol.value) 974 if aero_type in tables.table_4_233: 975 full_name.append(tables.table_4_233[aero_type][0]) 976 977 # Get base name from GRIB2 table 978 base_name = tables.get_varinfo_from_table( 979 obj.section0[2], 980 *obj.section4[2:4], 981 isNDFD=obj._isNDFD 982 )[0] 983 full_name.append(base_name) 984 985 # Add optical properties with wavelengths if present 986 if hasattr(obj, 'scaledValueOfFirstWavelength'): 987 optical_type = str(obj.parameterNumber) 988 first_wl = obj.scaledValueOfFirstWavelength 989 second_wl = getattr(obj, 'scaledValueOfSecondWavelength', None) 990 991 # Special case for AE between 440-870nm 992 if optical_type == '111' and first_wl == 440 and second_wl == 870: 993 full_name.append("at 440-870nm") 994 995 # Handle wavelength-specific optical properties 996 elif optical_type in ['102', '103', '104', '105', '106']: 997 wavelength = f"{first_wl}nm" 998 if second_wl: 999 wavelength = f"{first_wl}-{second_wl}nm" 1000 full_name.append(f"at {wavelength}") 1001 1002 final = " ".join(full_name) 1003 1004 return final.replace('Aerosol Aerosol', 'Aerosol') 1005 1006 def __set__(self, obj, value): 1007 raise RuntimeError( 1008 "Cannot set the fullName of the message. Instead set shortName OR set the appropriate discipline, " 1009 "parameterCategory, and parameterNumber. The fullName will be set automatically from these other attributes." 1010 ) 1011 1012class Units: 1013 """Units of the Variable.""" 1014 def __get__(self, obj, objtype=None): 1015 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[1] 1016 def __set__(self, obj, value): 1017 raise RuntimeError( 1018 "Cannot set the units of the message. Instead set shortName OR set the appropriate discipline, parameterCategory, and parameterNumber. The units will be set automatically from these other attributes." 1019 ) 1020 1021class ShortName: 1022 """Short name of the variable (i.e. the variable abbreviation).""" 1023 def __get__(self, obj, objtype=None): 1024 if hasattr(obj, 'typeOfAerosol'): 1025 return tables._build_aerosol_shortname(obj) 1026 else: 1027 return tables.get_varinfo_from_table(obj.section0[2], *obj.section4[2:4], isNDFD=obj._isNDFD)[2] 1028 def __set__(self, obj, value): 1029 metadata = tables.get_metadata_from_shortname(value) 1030 if len(metadata) > 1: 1031 raise ValueError( 1032 f"shortName={value} is ambiguous within the GRIB2 standard and you have to set instead with discipline, parameterCategory, and parameterNumber.\n{metadata}" 1033 ) 1034 for attr, val in metadata[0].items(): 1035 if attr in ["fullName", "units"]: 1036 continue 1037 setattr(obj, attr, val) 1038 1039class TypeOfGeneratingProcess: 1040 """[Type of Generating Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-3.shtml)""" 1041 _key = defaultdict(lambda: 2, {48:13}) 1042 #_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} 1043 def __get__(self, obj, objtype=None): 1044 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.3') 1045 def __set__(self, obj, value): 1046 obj.section4[self._key[obj.pdtn]+2] = value 1047 1048class BackgroundGeneratingProcessIdentifier: 1049 """Background Generating Process Identifier""" 1050 _key = defaultdict(lambda: 3, {48:14}) 1051 #_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} 1052 def __get__(self, obj, objtype=None): 1053 return obj.section4[self._key[obj.pdtn]+2] 1054 def __set__(self, obj, value): 1055 obj.section4[self._key[obj.pdtn]+2] = value 1056 1057class GeneratingProcess: 1058 """[Generating Process](https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablea.html)""" 1059 _key = defaultdict(lambda: 4, {48:15}) 1060 #_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} 1061 def __get__(self, obj, objtype=None): 1062 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='generating_process') 1063 def __set__(self, obj, value): 1064 obj.section4[self._key[obj.pdtn]+2] = value 1065 1066class HoursAfterDataCutoff: 1067 """Hours of observational data cutoff after reference time.""" 1068 _key = defaultdict(lambda: 5, {48:16}) 1069 def __get__(self, obj, objtype=None): 1070 return obj.section4[self._key[obj.pdtn]+2] 1071 def __set__(self, obj, value): 1072 obj.section4[self._key[obj.pdtn]+2] = value 1073 1074class MinutesAfterDataCutoff: 1075 """Minutes of observational data cutoff after reference time.""" 1076 _key = defaultdict(lambda: 6, {48:17}) 1077 def __get__(self, obj, objtype=None): 1078 return obj.section4[self._key[obj.pdtn]+2] 1079 def __set__(self, obj, value): 1080 obj.section4[self._key[obj.pdtn]+2] = value 1081 1082class UnitOfForecastTime: 1083 """[Units of Forecast Time](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-4.shtml)""" 1084 _key = defaultdict(lambda: 7, {48:18}) 1085 #_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} 1086 def __get__(self, obj, objtype=None): 1087 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.4') 1088 def __set__(self, obj, value): 1089 obj.section4[self._key[obj.pdtn]+2] = value 1090 1091class ValueOfForecastTime: 1092 """Value of forecast time in units defined by `UnitofForecastTime`.""" 1093 _key = defaultdict(lambda: 8, {48:19}) 1094 def __get__(self, obj, objtype=None): 1095 return obj.section4[self._key[obj.pdtn]+2] 1096 def __set__(self, obj, value): 1097 obj.section4[self._key[obj.pdtn]+2] = value 1098 1099class LeadTime: 1100 """Forecast Lead Time. NOTE: This is a `datetime.timedelta` object.""" 1101 _key = ValueOfForecastTime._key 1102 def __get__(self, obj, objtype=None): 1103 return utils.get_leadtime(obj.section4[1], obj.section4[2:]) 1104 def __set__(self, obj, value): 1105 if isinstance(value, np.timedelta64): 1106 # Allows setting from xarray 1107 value = datetime.timedelta( 1108 seconds=int(value/np.timedelta64(1, 's'))) 1109 obj.section4[self._key[obj.pdtn]+2] = int(value.total_seconds()/3600) 1110 # IMPORTANT: Update validDate components when message is time interval 1111 if obj.pdtn in _timeinterval_pdtns: 1112 vd = obj.refDate + value + obj.duration 1113 obj.yearOfEndOfTimePeriod = vd.year 1114 obj.monthOfEndOfTimePeriod = vd.month 1115 obj.dayOfEndOfTimePeriod = vd.day 1116 obj.hourOfEndOfTimePeriod = vd.hour 1117 obj.minuteOfEndOfTimePeriod = vd.minute 1118 obj.secondOfEndOfTimePeriod = vd.second 1119 1120class FixedSfc1Info: 1121 """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)""" 1122 _key = defaultdict(lambda: 9, {48:20}) 1123 #_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} 1124 def __get__(self, obj, objtype=None): 1125 if obj.section4[self._key[obj.pdtn]+2] == 255: 1126 return [None, None] 1127 return tables.get_value_from_table(obj.section4[self._key[obj.pdtn]+2],'4.5') 1128 def __set__(self, obj, value): 1129 raise NotImplementedError 1130 1131class FixedSfc2Info: 1132 """Information of the second fixed surface via [table 4.5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)""" 1133 _key = defaultdict(lambda: 12, {48:23}) 1134 #_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} 1135 def __get__(self, obj, objtype=None): 1136 if obj.section4[self._key[obj.pdtn]+2] == 255: 1137 return [None, None] 1138 return tables.get_value_from_table(obj.section4[self._key[obj.pdtn]+2],'4.5') 1139 def __set__(self, obj, value): 1140 raise NotImplementedError 1141 1142class TypeOfFirstFixedSurface: 1143 """[Type of First Fixed Surface](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)""" 1144 _key = defaultdict(lambda: 9, {48:20}) 1145 #_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} 1146 def __get__(self, obj, objtype=None): 1147 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.5') 1148 def __set__(self, obj, value): 1149 obj.section4[self._key[obj.pdtn]+2] = value 1150 1151class ScaleFactorOfFirstFixedSurface: 1152 """Scale Factor of First Fixed Surface""" 1153 _key = defaultdict(lambda: 10, {48:21}) 1154 #_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} 1155 def __get__(self, obj, objtype=None): 1156 return obj.section4[self._key[obj.pdtn]+2] 1157 def __set__(self, obj, value): 1158 obj.section4[self._key[obj.pdtn]+2] = value 1159 1160class ScaledValueOfFirstFixedSurface: 1161 """Scaled Value Of First Fixed Surface""" 1162 _key = defaultdict(lambda: 11, {48:22}) 1163 #_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} 1164 def __get__(self, obj, objtype=None): 1165 return obj.section4[self._key[obj.pdtn]+2] 1166 def __set__(self, obj, value): 1167 obj.section4[self._key[obj.pdtn]+2] = value 1168 1169class UnitOfFirstFixedSurface: 1170 """Units of First Fixed Surface""" 1171 def __get__(self, obj, objtype=None): 1172 return obj._fixedsfc1info[1] 1173 def __set__(self, obj, value): 1174 pass 1175 1176class ValueOfFirstFixedSurface: 1177 """Value of First Fixed Surface""" 1178 def __get__(self, obj, objtype=None): 1179 scale_factor = getattr(obj, "scaleFactorOfFirstFixedSurface") 1180 scaled_value = getattr(obj, "scaledValueOfFirstFixedSurface") 1181 return scaled_value / (10.**scale_factor) 1182 def __set__(self, obj, value): 1183 scale = _calculate_scale_factor(value) 1184 setattr(obj, "scaleFactorOfFirstFixedSurface", scale) 1185 setattr(obj, "scaledValueOfFirstFixedSurface", value * 10**scale) 1186 1187class TypeOfSecondFixedSurface: 1188 """[Type of Second Fixed Surface](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)""" 1189 _key = defaultdict(lambda: 12, {48:23}) 1190 #_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} 1191 def __get__(self, obj, objtype=None): 1192 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.5') 1193 def __set__(self, obj, value): 1194 obj.section4[self._key[obj.pdtn]+2] = value 1195 1196class ScaleFactorOfSecondFixedSurface: 1197 """Scale Factor of Second Fixed Surface""" 1198 _key = defaultdict(lambda: 13, {48:24}) 1199 #_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} 1200 def __get__(self, obj, objtype=None): 1201 return obj.section4[self._key[obj.pdtn]+2] 1202 def __set__(self, obj, value): 1203 obj.section4[self._key[obj.pdtn]+2] = value 1204 1205class ScaledValueOfSecondFixedSurface: 1206 """Scaled Value Of Second Fixed Surface""" 1207 _key = defaultdict(lambda: 14, {48:25}) 1208 #_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} 1209 def __get__(self, obj, objtype=None): 1210 return obj.section4[self._key[obj.pdtn]+2] 1211 def __set__(self, obj, value): 1212 obj.section4[self._key[obj.pdtn]+2] = value 1213 1214class UnitOfSecondFixedSurface: 1215 """Units of Second Fixed Surface""" 1216 def __get__(self, obj, objtype=None): 1217 return obj._fixedsfc2info[1] 1218 def __set__(self, obj, value): 1219 pass 1220 1221class ValueOfSecondFixedSurface: 1222 """Value of Second Fixed Surface""" 1223 def __get__(self, obj, objtype=None): 1224 scale_factor = getattr(obj, "scaleFactorOfSecondFixedSurface") 1225 scaled_value = getattr(obj, "scaledValueOfSecondFixedSurface") 1226 return scaled_value / (10.**scale_factor) 1227 def __set__(self, obj, value): 1228 scale = _calculate_scale_factor(value) 1229 setattr(obj, "scaleFactorOfSecondFixedSurface", scale) 1230 setattr(obj, "scaledValueOfSecondFixedSurface", value * 10**scale) 1231 1232class Level: 1233 """Level (same as provided by [wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Level.c))""" 1234 def __get__(self, obj, objtype=None): 1235 return tables.get_wgrib2_level_string(obj.pdtn,obj.section4[2:]) 1236 def __set__(self, obj, value): 1237 pass 1238 1239class TypeOfEnsembleForecast: 1240 """[Type of Ensemble Forecast](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-6.shtml)""" 1241 _key = {1:15, 11:15} 1242 def __get__(self, obj, objtype=None): 1243 pdtn = obj.section4[1] 1244 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.6') 1245 def __set__(self, obj, value): 1246 pdtn = obj.section4[1] 1247 obj.section4[self._key[pdtn]+2] = value 1248 1249class PerturbationNumber: 1250 """Ensemble Perturbation Number""" 1251 _key = {1:16, 11:16} 1252 def __get__(self, obj, objtype=None): 1253 pdtn = obj.section4[1] 1254 return obj.section4[self._key[pdtn]+2] 1255 def __set__(self, obj, value): 1256 pdtn = obj.section4[1] 1257 obj.section4[self._key[pdtn]+2] = value 1258 1259class NumberOfEnsembleForecasts: 1260 """Total Number of Ensemble Forecasts""" 1261 _key = {1:17, 2:16, 11:17, 12:16} 1262 def __get__(self, obj, objtype=None): 1263 pdtn = obj.section4[1] 1264 return obj.section4[self._key[pdtn]+2] 1265 def __set__(self, obj, value): 1266 pdtn = obj.section4[1] 1267 obj.section4[self._key[pdtn]+2] = value 1268 1269class TypeOfDerivedForecast: 1270 """[Type of Derived Forecast](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-7.shtml)""" 1271 _key = {2:15, 12:15} 1272 def __get__(self, obj, objtype=None): 1273 pdtn = obj.section4[1] 1274 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.7') 1275 def __set__(self, obj, value): 1276 pdtn = obj.section4[1] 1277 obj.section4[self._key[pdtn]+2] = value 1278 1279class ForecastProbabilityNumber: 1280 """Forecast Probability Number""" 1281 _key = {5:15, 9:15} 1282 def __get__(self, obj, objtype=None): 1283 pdtn = obj.section4[1] 1284 return obj.section4[self._key[pdtn]+2] 1285 def __set__(self, obj, value): 1286 pdtn = obj.section4[1] 1287 obj.section4[self._key[pdtn]+2] = value 1288 1289class TotalNumberOfForecastProbabilities: 1290 """Total Number of Forecast Probabilities""" 1291 _key = {5:16, 9:16} 1292 def __get__(self, obj, objtype=None): 1293 pdtn = obj.section4[1] 1294 return obj.section4[self._key[pdtn]+2] 1295 def __set__(self, obj, value): 1296 pdtn = obj.section4[1] 1297 obj.section4[self._key[pdtn]+2] = value 1298 1299class TypeOfProbability: 1300 """[Type of Probability](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-9.shtml)""" 1301 _key = {5:17, 9:17} 1302 def __get__(self, obj, objtype=None): 1303 pdtn = obj.section4[1] 1304 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.9') 1305 def __set__(self, obj, value): 1306 pdtn = obj.section4[1] 1307 obj.section4[self._key[pdtn]+2] = value 1308 1309class ScaleFactorOfThresholdLowerLimit: 1310 """Scale Factor of Threshold Lower Limit""" 1311 _key = {5:18, 9:18} 1312 def __get__(self, obj, objtype=None): 1313 pdtn = obj.section4[1] 1314 return obj.section4[self._key[pdtn]+2] 1315 def __set__(self, obj, value): 1316 pdtn = obj.section4[1] 1317 obj.section4[self._key[pdtn]+2] = value 1318 1319class ScaledValueOfThresholdLowerLimit: 1320 """Scaled Value of Threshold Lower Limit""" 1321 _key = {5:19, 9:19} 1322 def __get__(self, obj, objtype=None): 1323 pdtn = obj.section4[1] 1324 return obj.section4[self._key[pdtn]+2] 1325 def __set__(self, obj, value): 1326 pdtn = obj.section4[1] 1327 obj.section4[self._key[pdtn]+2] = value 1328 1329class ScaleFactorOfThresholdUpperLimit: 1330 """Scale Factor of Threshold Upper Limit""" 1331 _key = {5:20, 9:20} 1332 def __get__(self, obj, objtype=None): 1333 pdtn = obj.section4[1] 1334 return obj.section4[self._key[pdtn]+2] 1335 def __set__(self, obj, value): 1336 pdtn = obj.section4[1] 1337 obj.section4[self._key[pdtn]+2] = value 1338 1339class ScaledValueOfThresholdUpperLimit: 1340 """Scaled Value of Threshold Upper Limit""" 1341 _key = {5:21, 9:21} 1342 def __get__(self, obj, objtype=None): 1343 pdtn = obj.section4[1] 1344 return obj.section4[self._key[pdtn]+2] 1345 def __set__(self, obj, value): 1346 pdtn = obj.section4[1] 1347 obj.section4[self._key[pdtn]+2] = value 1348 1349class ThresholdLowerLimit: 1350 """Threshold Lower Limit""" 1351 def __get__(self, obj, objtype=None): 1352 scale_factor = getattr(obj, "scaleFactorOfThresholdLowerLimit") 1353 scaled_value = getattr(obj, "scaledValueOfThresholdLowerLimit") 1354 if scale_factor == -127 and scaled_value == 255: 1355 return 0.0 1356 return scaled_value / (10.**scale_factor) 1357 def __set__(self, obj, value): 1358 scale = _calculate_scale_factor(value) 1359 setattr(obj, "scaleFactorOfThresholdLowerLimit", scale) 1360 setattr(obj, "scaledValueOfThresholdLowerLimit", value * 10**scale) 1361 1362class ThresholdUpperLimit: 1363 """Threshold Upper Limit""" 1364 def __get__(self, obj, objtype=None): 1365 scale_factor = getattr(obj, "scaleFactorOfThresholdUpperLimit") 1366 scaled_value = getattr(obj, "scaledValueOfThresholdUpperLimit") 1367 if scale_factor == -127 and scaled_value == 255: 1368 return 0.0 1369 return scaled_value / (10.**scale_factor) 1370 def __set__(self, obj, value): 1371 scale = _calculate_scale_factor(value) 1372 setattr(obj, "scaleFactorOfThresholdUpperLimit", scale) 1373 setattr(obj, "scaledValueOfThresholdUpperLimit", value * 10**scale) 1374 1375class Threshold: 1376 """Threshold string (same as [wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Prob.c))""" 1377 def __get__(self, obj, objtype=None): 1378 return utils.get_wgrib2_prob_string(*obj.section4[17+2:22+2]) 1379 def __set__(self, obj, value): 1380 pass 1381 1382class PercentileValue: 1383 """Percentile Value""" 1384 _key = {6:15, 10:15} 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 1391 1392class YearOfEndOfTimePeriod: 1393 """Year of End of Forecast Time Period""" 1394 _key = {8:15, 9:22, 10:16, 11:18, 12:17} 1395 def __get__(self, obj, objtype=None): 1396 pdtn = obj.section4[1] 1397 return obj.section4[self._key[pdtn]+2] 1398 def __set__(self, obj, value): 1399 pdtn = obj.section4[1] 1400 obj.section4[self._key[pdtn]+2] = value 1401 1402class MonthOfEndOfTimePeriod: 1403 """Month Year of End of Forecast Time Period""" 1404 _key = {8:16, 9:23, 10:17, 11:19, 12:18} 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 1411 1412class DayOfEndOfTimePeriod: 1413 """Day Year of End of Forecast Time Period""" 1414 _key = {8:17, 9:24, 10:18, 11:20, 12:19} 1415 def __get__(self, obj, objtype=None): 1416 pdtn = obj.section4[1] 1417 return obj.section4[self._key[pdtn]+2] 1418 def __set__(self, obj, value): 1419 pdtn = obj.section4[1] 1420 obj.section4[self._key[pdtn]+2] = value 1421 1422class HourOfEndOfTimePeriod: 1423 """Hour Year of End of Forecast Time Period""" 1424 _key = {8:18, 9:25, 10:19, 11:21, 12:20} 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 1431 1432class MinuteOfEndOfTimePeriod: 1433 """Minute Year of End of Forecast Time Period""" 1434 _key = {8:19, 9:26, 10:20, 11:22, 12:21} 1435 def __get__(self, obj, objtype=None): 1436 pdtn = obj.section4[1] 1437 return obj.section4[self._key[pdtn]+2] 1438 def __set__(self, obj, value): 1439 pdtn = obj.section4[1] 1440 obj.section4[self._key[pdtn]+2] = value 1441 1442class SecondOfEndOfTimePeriod: 1443 """Second Year of End of Forecast Time Period""" 1444 _key = {8:20, 9:27, 10:21, 11:23, 12:22} 1445 def __get__(self, obj, objtype=None): 1446 pdtn = obj.section4[1] 1447 return obj.section4[self._key[pdtn]+2] 1448 def __set__(self, obj, value): 1449 pdtn = obj.section4[1] 1450 obj.section4[self._key[pdtn]+2] = value 1451 1452class Duration: 1453 """Duration of time period. NOTE: This is a `datetime.timedelta` object.""" 1454 def __get__(self, obj, objtype=None): 1455 return utils.get_duration(obj.section4[1],obj.section4[2:]) 1456 def __set__(self, obj, value): 1457 if obj.pdtn in _continuous_pdtns: 1458 pass 1459 elif obj.pdtn in _timeinterval_pdtns: 1460 _key = TimeRangeOfStatisticalProcess._key 1461 if isinstance(value, np.timedelta64): 1462 # Allows setting from xarray 1463 value = datetime.timedelta( 1464 seconds=int(value/np.timedelta64(1, 's'))) 1465 obj.section4[_key[obj.pdtn]+2] = int(value.total_seconds()/3600) 1466 # IMPORTANT: Update validDate components when message is time interval 1467 if obj.pdtn in _timeinterval_pdtns: 1468 print(obj.refDate, value, obj.leadTime) 1469 vd = obj.refDate + value + obj.leadTime 1470 obj.yearOfEndOfTimePeriod = vd.year 1471 obj.monthOfEndOfTimePeriod = vd.month 1472 obj.dayOfEndOfTimePeriod = vd.day 1473 obj.hourOfEndOfTimePeriod = vd.hour 1474 obj.minuteOfEndOfTimePeriod = vd.minute 1475 obj.secondOfEndOfTimePeriod = vd.second 1476 1477class ValidDate: 1478 """Valid Date of the forecast. NOTE: This is a `datetime.datetime` object.""" 1479 _key = {8:slice(15,21), 9:slice(22,28), 10:slice(16,22), 11:slice(18,24), 12:slice(17,23)} 1480 def __get__(self, obj, objtype=None): 1481 pdtn = obj.section4[1] 1482 try: 1483 s = slice(self._key[pdtn].start+2,self._key[pdtn].stop+2) 1484 return datetime.datetime(*obj.section4[s]) 1485 except(KeyError): 1486 return obj.refDate + obj.leadTime 1487 def __set__(self, obj, value): 1488 warnings.warn(f"validDate attribute is read-only.") 1489 1490class NumberOfTimeRanges: 1491 """Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field""" 1492 _key = {8:21, 9:28, 10:22, 11:24, 12:23, 46:27} 1493 def __get__(self, obj, objtype=None): 1494 pdtn = obj.section4[1] 1495 return obj.section4[self._key[pdtn]+2] 1496 def __set__(self, obj, value): 1497 pdtn = obj.section4[1] 1498 obj.section4[self._key[pdtn]+2] = value 1499 1500class NumberOfMissingValues: 1501 """Total number of data values missing in statistical process""" 1502 _key = {8:22, 9:29, 10:23, 11:25, 12:24, 46:28} 1503 def __get__(self, obj, objtype=None): 1504 pdtn = obj.section4[1] 1505 return obj.section4[self._key[pdtn]+2] 1506 def __set__(self, obj, value): 1507 pdtn = obj.section4[1] 1508 obj.section4[self._key[pdtn]+2] = value 1509 1510class StatisticalProcess: 1511 """[Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-10.shtml)""" 1512 _key = { 1513 8: 23, 1514 9: 30, 1515 10: 24, 1516 11: 26, 1517 12: 25, 1518 15: 15, 1519 46: 30, 1520 47: 30, 1521 49: 30, 1522 80: 30, 1523 81: 30, 1524 82: 30, 1525 83: 30, 1526 84: 30, 1527 85: 30 1528 } 1529 1530 def __get__(self, obj, objtype=None): 1531 pdtn = obj.section4[1] 1532 return Grib2Metadata(obj.section4[self._key[pdtn]+2], table='4.10') 1533 1534 def __set__(self, obj, value): 1535 pdtn = obj.section4[1] 1536 obj.section4[self._key[pdtn]+2] = value 1537 1538class TypeOfTimeIncrementOfStatisticalProcess: 1539 """[Type of Time Increment of Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-11.shtml)""" 1540 _key = { 1541 4: 31, 1542 8: 24, 1543 9: 31, 1544 10: 25, 1545 11: 27, 1546 12: 26, 1547 46: 31, 1548 47: 31, 1549 49: 31, 1550 80: 31, 1551 81: 31, 1552 82: 31, 1553 83: 31, 1554 84: 31, 1555 85: 31 1556 } 1557 1558 def __get__(self, obj, objtype=None): 1559 pdtn = obj.section4[1] 1560 return Grib2Metadata(obj.section4[self._key[pdtn]+2], table='4.11') 1561 1562 def __set__(self, obj, value): 1563 pdtn = obj.section4[1] 1564 obj.section4[self._key[pdtn]+2] = value 1565class UnitOfTimeRangeOfStatisticalProcess: 1566 """[Unit of Time Range of Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-11.shtml)""" 1567 _key = { 1568 4: 32, 1569 8: 25, 1570 9: 32, 1571 10: 26, 1572 11: 28, 1573 12: 27, 1574 46: 32, 1575 47: 32, 1576 49: 32, 1577 80: 32, 1578 81: 32, 1579 82: 32, 1580 83: 32, 1581 84: 32, 1582 85: 32 1583 } 1584 1585 def __get__(self, obj, objtype=None): 1586 pdtn = obj.section4[1] 1587 return Grib2Metadata(obj.section4[self._key[pdtn]+2], table='4.4') 1588 1589 def __set__(self, obj, value): 1590 pdtn = obj.section4[1] 1591 obj.section4[self._key[pdtn]+2] = value 1592 1593class TimeRangeOfStatisticalProcess: 1594 """Time Range of Statistical Process""" 1595 _key = { 1596 4: 33, 1597 8: 26, 1598 9: 33, 1599 10: 27, 1600 11: 29, 1601 12: 28, 1602 46: 33, 1603 47: 33, 1604 49: 33, 1605 80: 33, 1606 81: 33, 1607 82: 33, 1608 83: 33, 1609 84: 33, 1610 85: 33 1611 } 1612 1613 def __get__(self, obj, objtype=None): 1614 pdtn = obj.section4[1] 1615 return obj.section4[self._key[pdtn]+2] 1616 1617 def __set__(self, obj, value): 1618 pdtn = obj.section4[1] 1619 obj.section4[self._key[pdtn]+2] = value 1620 1621class UnitOfTimeRangeOfSuccessiveFields: 1622 """[Unit of Time Range of Successive Fields](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-4.shtml)""" 1623 _key = { 1624 4: 34, 1625 8: 27, 1626 9: 34, 1627 10: 28, 1628 11: 30, 1629 12: 29, 1630 46: 34, 1631 47: 34, 1632 49: 34, 1633 80: 34, 1634 81: 34, 1635 82: 34, 1636 83: 34, 1637 84: 34, 1638 85: 34 1639 } 1640 1641 def __get__(self, obj, objtype=None): 1642 pdtn = obj.section4[1] 1643 return Grib2Metadata(obj.section4[self._key[pdtn]+2], table='4.4') 1644 1645 def __set__(self, obj, value): 1646 pdtn = obj.section4[1] 1647 obj.section4[self._key[pdtn]+2] = value 1648 1649class TimeIncrementOfSuccessiveFields: 1650 """Time Increment of Successive Fields""" 1651 _key = { 1652 4: 35, 1653 8: 28, 1654 9: 35, 1655 10: 29, 1656 11: 31, 1657 12: 30, 1658 46: 67, 1659 47: 67, 1660 49: 67, 1661 80: 35, 1662 81: 35, 1663 82: 35, 1664 83: 35, 1665 84: 35, 1666 85: 35 1667 } 1668 1669 def __get__(self, obj, objtype=None): 1670 pdtn = obj.section4[1] 1671 return obj.section4[self._key[pdtn]+2] 1672 1673 def __set__(self, obj, value): 1674 pdtn = obj.section4[1] 1675 obj.section4[self._key[pdtn]+2] = value 1676class TypeOfStatisticalProcessing: 1677 """[Type of Statistical Processing](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-15.shtml)""" 1678 _key = {15:16} 1679 def __get__(self, obj, objtype=None): 1680 pdtn = obj.section4[1] 1681 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.15') 1682 def __set__(self, obj, value): 1683 pdtn = obj.section4[1] 1684 obj.section4[self._key[pdtn]+2] = value 1685 1686class NumberOfDataPointsForSpatialProcessing: 1687 """Number of Data Points for Spatial Processing""" 1688 _key = {15:17} 1689 def __get__(self, obj, objtype=None): 1690 pdtn = obj.section4[1] 1691 return obj.section4[self._key[pdtn]+2] 1692 def __set__(self, obj, value): 1693 pdtn = obj.section4[1] 1694 obj.section4[self._key[pdtn]+2] = value 1695 1696class NumberOfContributingSpectralBands: 1697 """Number of Contributing Spectral Bands (NB)""" 1698 _key = {32:9} 1699 def __get__(self, obj, objtype=None): 1700 pdtn = obj.section4[1] 1701 return obj.section4[self._key[pdtn]+2] 1702 def __set__(self, obj, value): 1703 pdtn = obj.section4[1] 1704 obj.section4[self._key[pdtn]+2] = value 1705 1706class SatelliteSeries: 1707 """Satellte Series of band nb, where nb=1,NB if NB > 0""" 1708 _key = {32:10} 1709 def __get__(self, obj, objtype=None): 1710 pdtn = obj.section4[1] 1711 return obj.section4[self._key[pdtn]+2::5][:obj.section4[9+2]] 1712 def __set__(self, obj, value): 1713 pass 1714 1715class SatelliteNumber: 1716 """Satellte Number of band nb, where nb=1,NB if NB > 0""" 1717 _key = {32:11} 1718 def __get__(self, obj, objtype=None): 1719 pdtn = obj.section4[1] 1720 return obj.section4[self._key[pdtn]+2::5][:obj.section4[9+2]] 1721 def __set__(self, obj, value): 1722 pass 1723 1724class InstrumentType: 1725 """Instrument Type of band nb, where nb=1,NB if NB > 0""" 1726 _key = {32:12} 1727 def __get__(self, obj, objtype=None): 1728 pdtn = obj.section4[1] 1729 return obj.section4[self._key[pdtn]+2::5][:obj.section4[9+2]] 1730 def __set__(self, obj, value): 1731 pass 1732 1733class ScaleFactorOfCentralWaveNumber: 1734 """Scale Factor Of Central WaveNumber of band nb, where nb=1,NB if NB > 0""" 1735 _key = {32:13} 1736 def __get__(self, obj, objtype=None): 1737 pdtn = obj.section4[1] 1738 return obj.section4[self._key[pdtn]+2::5][:obj.section4[9+2]] 1739 def __set__(self, obj, value): 1740 pass 1741 1742class ScaledValueOfCentralWaveNumber: 1743 """Scaled Value Of Central WaveNumber of band NB""" 1744 _key = {32:14} 1745 def __get__(self, obj, objtype=None): 1746 pdtn = obj.section4[1] 1747 return obj.section4[self._key[pdtn]+2::5][:obj.section4[9+2]] 1748 def __set__(self, obj, value): 1749 pass 1750 1751class TypeOfAerosol: 1752 """[Type of Aerosol](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-233.shtml)""" 1753 _key = {46:2, 48:2} 1754 def __get__(self, obj, objtype=None): 1755 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.233') 1756 def __set__(self, obj, value): 1757 obj.section4[self._key[obj.pdtn]+2] = value 1758 1759class TypeOfIntervalForAerosolSize: 1760 """[Type of Interval for Aerosol Size](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-91.shtml)""" 1761 _key = {46:3, 48:3} 1762 def __get__(self, obj, objtype=None): 1763 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.91') 1764 def __set__(self, obj, value): 1765 obj.section4[self._key[obj.pdtn]+2] = value 1766 1767class ScaleFactorOfFirstSize: 1768 """Scale Factor of First Size""" 1769 _key = {46:4, 48:4} 1770 def __get__(self, obj, objtype=None): 1771 return obj.section4[self._key[obj.pdtn]+2] 1772 def __set__(self, obj, value): 1773 obj.section4[self._key[obj.pdtn]+2] = value 1774 1775class ScaledValueOfFirstSize: 1776 """Scaled Value of First Size""" 1777 _key = {46:5, 48:5} 1778 def __get__(self, obj, objtype=None): 1779 return obj.section4[self._key[obj.pdtn]+2] 1780 def __set__(self, obj, value): 1781 obj.section4[self._key[obj.pdtn]+2] = value 1782 1783class ScaleFactorOfSecondSize: 1784 """Scale Factor of Second Size""" 1785 _key = {46:6, 48:6} 1786 def __get__(self, obj, objtype=None): 1787 return obj.section4[self._key[obj.pdtn]+2] 1788 def __set__(self, obj, value): 1789 obj.section4[self._key[obj.pdtn]+2] = value 1790 1791class ScaledValueOfSecondSize: 1792 """Scaled Value of Second Size""" 1793 _key = {46:6, 48:7} 1794 def __get__(self, obj, objtype=None): 1795 return obj.section4[self._key[obj.pdtn]+2] 1796 def __set__(self, obj, value): 1797 obj.section4[self._key[obj.pdtn]+2] = value 1798 1799class TypeOfIntervalForAerosolWavelength: 1800 """[Type of Interval for Aerosol Wavelength](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-91.shtml)""" 1801 _key = {48:8} 1802 def __get__(self, obj, objtype=None): 1803 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.91') 1804 def __set__(self, obj, value): 1805 obj.section4[self._key[obj.pdtn]+2] = value 1806 1807class ScaleFactorOfFirstWavelength: 1808 """Scale Factor of First Wavelength""" 1809 _key = {48:9} 1810 def __get__(self, obj, objtype=None): 1811 return obj.section4[self._key[obj.pdtn]+2] 1812 def __set__(self, obj, value): 1813 obj.section4[self._key[obj.pdtn]+2] = value 1814 1815class ScaledValueOfFirstWavelength: 1816 """Scaled Value of First Wavelength""" 1817 _key = {48:10} 1818 def __get__(self, obj, objtype=None): 1819 return obj.section4[self._key[obj.pdtn]+2] 1820 def __set__(self, obj, value): 1821 obj.section4[self._key[obj.pdtn]+2] = value 1822 1823class ScaleFactorOfSecondWavelength: 1824 """Scale Factor of Second Wavelength""" 1825 _key = {48:11} 1826 def __get__(self, obj, objtype=None): 1827 return obj.section4[self._key[obj.pdtn]+2] 1828 def __set__(self, obj, value): 1829 obj.section4[self._key[obj.pdtn]+2] = value 1830 1831class ScaledValueOfSecondWavelength: 1832 """Scaled Value of Second Wavelength""" 1833 _key = {48:12} 1834 def __get__(self, obj, objtype=None): 1835 return obj.section4[self._key[obj.pdtn]+2] 1836 def __set__(self, obj, value): 1837 obj.section4[self._key[obj.pdtn]+2] = value 1838 1839class SourceSinkIndicator: 1840 """[Source/Sink Indicator](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-238.shtml)""" 1841 _key = {80:3, 81:3, 82:3, 83:3, 84:3, 85:3} 1842 def __get__(self, obj, objtype=None): 1843 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2], table='4.238') 1844 def __set__(self, obj, value): 1845 obj.section4[self._key[obj.pdtn]+2] = value 1846 1847class NumberOfContributingSpectralBands: 1848 """Number of contributing spectral bands (NB)""" 1849 def __get__(self, obj, objtype=None): 1850 return obj.section4[9] 1851 def __set__(self, obj, value): 1852 obj.section4[9] = value 1853 1854class ConstituentType: 1855 """[Constituent Type](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-230.shtml)""" 1856 _key = defaultdict(lambda: 10) 1857 def __get__(self, obj, objtype=None): 1858 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2], table='4.230') 1859 def __set__(self, obj, value): 1860 obj.section4[self._key[obj.pdtn]+2] = value 1861 1862class NumberOfContributingSpectralBands: 1863 """Number of Contributing Spectral Bands""" 1864 _key = defaultdict(lambda: 9) 1865 def __get__(self, obj, objtype=None): 1866 return obj.section4[self._key[obj.pdtn]+2] 1867 def __set__(self, obj, value): 1868 obj.section4[self._key[obj.pdtn]+2] = value 1869 1870class SatelliteSeries: 1871 """Satellite Series""" 1872 def __get__(self, obj, objtype=None): 1873 nb = obj.section4[9] # Get number of bands 1874 values = [] 1875 for i in range(nb): 1876 offset = 11 * i 1877 values.append(obj.section4[11 + offset]) 1878 return values 1879 def __set__(self, obj, value): 1880 nb = obj.section4[9] 1881 for i in range(nb): 1882 offset = 11 * i 1883 obj.section4[11 + offset] = value[i] 1884 1885 1886""" 1887GRIB2 Section 4, Product Definition Template Classes 1888""" 1889 1890@dataclass(init=False) 1891class ProductDefinitionTemplateBase: 1892 """Base attributes for Product Definition Templates""" 1893 _varinfo: list = field(init=False, repr=False, default=VarInfo()) 1894 fullName: str = field(init=False, repr=False, default=FullName()) 1895 units: str = field(init=False, repr=False, default=Units()) 1896 shortName: str = field(init=False, repr=False, default=ShortName()) 1897 leadTime: datetime.timedelta = field(init=False,repr=False,default=LeadTime()) 1898 duration: datetime.timedelta = field(init=False,repr=False,default=Duration()) 1899 validDate: datetime.datetime = field(init=False,repr=False,default=ValidDate()) 1900 level: str = field(init=False, repr=False, default=Level()) 1901 # Begin template here... 1902 parameterCategory: int = field(init=False,repr=False,default=ParameterCategory()) 1903 parameterNumber: int = field(init=False,repr=False,default=ParameterNumber()) 1904 typeOfGeneratingProcess: Grib2Metadata = field(init=False,repr=False,default=TypeOfGeneratingProcess()) 1905 generatingProcess: Grib2Metadata = field(init=False, repr=False, default=GeneratingProcess()) 1906 backgroundGeneratingProcessIdentifier: int = field(init=False,repr=False,default=BackgroundGeneratingProcessIdentifier()) 1907 hoursAfterDataCutoff: int = field(init=False,repr=False,default=HoursAfterDataCutoff()) 1908 minutesAfterDataCutoff: int = field(init=False,repr=False,default=MinutesAfterDataCutoff()) 1909 unitOfForecastTime: Grib2Metadata = field(init=False,repr=False,default=UnitOfForecastTime()) 1910 valueOfForecastTime: int = field(init=False,repr=False,default=ValueOfForecastTime()) 1911 @classmethod 1912 def _attrs(cls): 1913 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 1914 1915@dataclass(init=False) 1916class ProductDefinitionTemplateSurface: 1917 """Surface attributes for Product Definition Templates""" 1918 _fixedsfc1info: list = field(init=False, repr=False, default=FixedSfc1Info()) 1919 _fixedsfc2info: list = field(init=False, repr=False, default=FixedSfc2Info()) 1920 typeOfFirstFixedSurface: Grib2Metadata = field(init=False,repr=False,default=TypeOfFirstFixedSurface()) 1921 scaleFactorOfFirstFixedSurface: int = field(init=False,repr=False,default=ScaleFactorOfFirstFixedSurface()) 1922 scaledValueOfFirstFixedSurface: int = field(init=False,repr=False,default=ScaledValueOfFirstFixedSurface()) 1923 typeOfSecondFixedSurface: Grib2Metadata = field(init=False,repr=False,default=TypeOfSecondFixedSurface()) 1924 scaleFactorOfSecondFixedSurface: int = field(init=False,repr=False,default=ScaleFactorOfSecondFixedSurface()) 1925 scaledValueOfSecondFixedSurface: int = field(init=False,repr=False,default=ScaledValueOfSecondFixedSurface()) 1926 unitOfFirstFixedSurface: str = field(init=False,repr=False,default=UnitOfFirstFixedSurface()) 1927 valueOfFirstFixedSurface: int = field(init=False,repr=False,default=ValueOfFirstFixedSurface()) 1928 unitOfSecondFixedSurface: str = field(init=False,repr=False,default=UnitOfSecondFixedSurface()) 1929 valueOfSecondFixedSurface: int = field(init=False,repr=False,default=ValueOfSecondFixedSurface()) 1930 @classmethod 1931 def _attrs(cls): 1932 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 1933 1934@dataclass(init=False) 1935class ProductDefinitionTemplate0(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 1936 """[Product Definition Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-0.shtml)""" 1937 _len = 15 1938 _num = 0 1939 @classmethod 1940 def _attrs(cls): 1941 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 1942 1943@dataclass(init=False) 1944class ProductDefinitionTemplate1(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 1945 """[Product Definition Template 1](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-1.shtml)""" 1946 _len = 18 1947 _num = 1 1948 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 1949 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 1950 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 1951 @classmethod 1952 def _attrs(cls): 1953 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 1954 1955@dataclass(init=False) 1956class ProductDefinitionTemplate2(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 1957 """[Product Definition Template 2](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-2.shtml)""" 1958 _len = 17 1959 _num = 2 1960 typeOfDerivedForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfDerivedForecast()) 1961 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 1962 @classmethod 1963 def _attrs(cls): 1964 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 1965 1966@dataclass(init=False) 1967class ProductDefinitionTemplate5(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 1968 """[Product Definition Template 5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-5.shtml)""" 1969 _len = 22 1970 _num = 5 1971 forecastProbabilityNumber: int = field(init=False, repr=False, default=ForecastProbabilityNumber()) 1972 totalNumberOfForecastProbabilities: int = field(init=False, repr=False, default=TotalNumberOfForecastProbabilities()) 1973 typeOfProbability: Grib2Metadata = field(init=False, repr=False, default=TypeOfProbability()) 1974 scaleFactorOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdLowerLimit()) 1975 scaledValueOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdLowerLimit()) 1976 scaleFactorOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdUpperLimit()) 1977 scaledValueOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdUpperLimit()) 1978 thresholdLowerLimit: float = field(init=False, repr=False, default=ThresholdLowerLimit()) 1979 thresholdUpperLimit: float = field(init=False, repr=False, default=ThresholdUpperLimit()) 1980 threshold: str = field(init=False, repr=False, default=Threshold()) 1981 @classmethod 1982 def _attrs(cls): 1983 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 1984 1985@dataclass(init=False) 1986class ProductDefinitionTemplate6(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 1987 """[Product Definition Template 6](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-6.shtml)""" 1988 _len = 16 1989 _num = 6 1990 percentileValue: int = field(init=False, repr=False, default=PercentileValue()) 1991 @classmethod 1992 def _attrs(cls): 1993 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 1994 1995@dataclass(init=False) 1996class ProductDefinitionTemplate8(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 1997 """[Product Definition Template 8](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-8.shtml)""" 1998 _len = 29 1999 _num = 8 2000 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2001 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2002 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2003 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2004 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2005 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2006 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2007 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2008 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2009 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2010 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2011 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2012 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2013 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2014 @classmethod 2015 def _attrs(cls): 2016 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2017 2018@dataclass(init=False) 2019class ProductDefinitionTemplate9(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 2020 """[Product Definition Template 9](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-9.shtml)""" 2021 _len = 36 2022 _num = 9 2023 forecastProbabilityNumber: int = field(init=False, repr=False, default=ForecastProbabilityNumber()) 2024 totalNumberOfForecastProbabilities: int = field(init=False, repr=False, default=TotalNumberOfForecastProbabilities()) 2025 typeOfProbability: Grib2Metadata = field(init=False, repr=False, default=TypeOfProbability()) 2026 scaleFactorOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdLowerLimit()) 2027 scaledValueOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdLowerLimit()) 2028 scaleFactorOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdUpperLimit()) 2029 scaledValueOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdUpperLimit()) 2030 thresholdLowerLimit: float = field(init=False, repr=False, default=ThresholdLowerLimit()) 2031 thresholdUpperLimit: float = field(init=False, repr=False, default=ThresholdUpperLimit()) 2032 threshold: str = field(init=False, repr=False, default=Threshold()) 2033 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2034 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2035 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2036 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2037 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2038 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2039 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2040 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2041 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2042 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2043 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2044 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2045 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2046 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2047 @classmethod 2048 def _attrs(cls): 2049 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2050 2051@dataclass(init=False) 2052class ProductDefinitionTemplate10(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 2053 """[Product Definition Template 10](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-10.shtml)""" 2054 _len = 30 2055 _num = 10 2056 percentileValue: int = field(init=False, repr=False, default=PercentileValue()) 2057 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2058 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2059 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2060 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2061 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2062 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2063 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2064 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2065 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2066 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2067 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2068 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2069 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2070 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2071 @classmethod 2072 def _attrs(cls): 2073 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2074 2075@dataclass(init=False) 2076class ProductDefinitionTemplate11(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 2077 """[Product Definition Template 11](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-11.shtml)""" 2078 _len = 32 2079 _num = 11 2080 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2081 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2082 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2083 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2084 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2085 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2086 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2087 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2088 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2089 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2090 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2091 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2092 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2093 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2094 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2095 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2096 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2097 @classmethod 2098 def _attrs(cls): 2099 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2100 2101@dataclass(init=False) 2102class ProductDefinitionTemplate12(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 2103 """[Product Definition Template 12](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-12.shtml)""" 2104 _len = 31 2105 _num = 12 2106 typeOfDerivedForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfDerivedForecast()) 2107 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2108 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2109 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2110 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2111 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2112 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2113 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2114 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2115 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2116 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2117 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2118 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2119 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2120 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2121 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2122 @classmethod 2123 def _attrs(cls): 2124 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2125 2126@dataclass(init=False) 2127class ProductDefinitionTemplate13(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2128 """[Product Definition Template 13](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-13.shtml)""" 2129 _len = 18 2130 _num = 13 2131 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2132 typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing()) 2133 numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing()) 2134 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2135 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2136 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2137 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2138 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2139 @classmethod 2140 def _attrs(cls): 2141 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2142 2143@dataclass(init=False) 2144class ProductDefinitionTemplate14(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2145 """[Product Definition Template 14](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-14.shtml)""" 2146 _len = 18 2147 _num = 14 2148 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2149 typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing()) 2150 numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing()) 2151 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2152 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2153 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2154 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2155 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2156 @classmethod 2157 def _attrs(cls): 2158 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2159 2160@dataclass(init=False) 2161class ProductDefinitionTemplate15(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 2162 """[Product Definition Template 15](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-15.shtml)""" 2163 _len = 18 2164 _num = 15 2165 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2166 typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing()) 2167 numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing()) 2168 @classmethod 2169 def _attrs(cls): 2170 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2171 2172# @dataclass(init=False) 2173# class ProductDefinitionTemplate20(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2174# """[Product Definition Template 20](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-20.shtml)""" 2175# __slots__ = ('section4',) 2176# _len = 19 2177# _num = 20 2178 2179# typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2180# unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2181# timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2182# unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2183# timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2184# statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2185# spatialProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfSpatialProcessing()) 2186# numberOfPointsUsed: int = field(init=False, repr=False, default=NumberOfPointsUsed()) 2187 2188@dataclass(init=False) 2189class ProductDefinitionTemplate31: 2190 """[Product Definition Template 31](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-31.shtml)""" 2191 _len = 5 2192 _num = 31 2193 parameterCategory: int = field(init=False,repr=False,default=ParameterCategory()) 2194 parameterNumber: int = field(init=False,repr=False,default=ParameterNumber()) 2195 typeOfGeneratingProcess: Grib2Metadata = field(init=False,repr=False,default=TypeOfGeneratingProcess()) 2196 generatingProcess: Grib2Metadata = field(init=False, repr=False, default=GeneratingProcess()) 2197 numberOfContributingSpectralBands: int = field(init=False,repr=False,default=NumberOfContributingSpectralBands()) 2198 satelliteSeries: list = field(init=False,repr=False,default=SatelliteSeries()) 2199 satelliteNumber: list = field(init=False,repr=False,default=SatelliteNumber()) 2200 instrumentType: list = field(init=False,repr=False,default=InstrumentType()) 2201 scaleFactorOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaleFactorOfCentralWaveNumber()) 2202 scaledValueOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaledValueOfCentralWaveNumber()) 2203 @classmethod 2204 def _attrs(cls): 2205 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2206 2207@dataclass(init=False) 2208class ProductDefinitionTemplate32(ProductDefinitionTemplateBase): 2209 """[Product Definition Template 32](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-32.shtml)""" 2210 _len = 10 2211 _num = 32 2212 numberOfContributingSpectralBands: int = field(init=False,repr=False,default=NumberOfContributingSpectralBands()) 2213 satelliteSeries: list = field(init=False,repr=False,default=SatelliteSeries()) 2214 satelliteNumber: list = field(init=False,repr=False,default=SatelliteNumber()) 2215 instrumentType: list = field(init=False,repr=False,default=InstrumentType()) 2216 scaleFactorOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaleFactorOfCentralWaveNumber()) 2217 scaledValueOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaledValueOfCentralWaveNumber()) 2218 @classmethod 2219 def _attrs(cls): 2220 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2221 2222# @dataclass(init=False) 2223# class ProductDefinitionTemplate33(ProductDefinitionTemplateBase): 2224# """[Product Definition Template 33] - Individual ensemble forecast, control and perturbed at intervals""" 2225# _len = None # Length depends on number of spectral bands 2226# _num = 33 2227# # Note: parameterCategory through valueOfForecastTime inherited from base class 2228# numberOfContributingSpectralBands: int = field(init=False,repr=False,default=NumberOfContributingSpectralBands()) 2229# # Spectral band fields - these will need special handling since they repeat 2230# satelliteSeries: list = field(init=False,repr=False,default=SatelliteSeries()) 2231# satelliteNumber: list = field(init=False,repr=False,default=SatelliteNumber()) 2232# instrumentTypes: list = field(init=False,repr=False,default=InstrumentTypes()) 2233# scaleFactorOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaleFactorOfCentralWaveNumber()) 2234# scaledValueOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaledValueOfCentralWaveNumber()) 2235# # Continue with remaining fields 2236# typeOfEnsembleForecast: Grib2Metadata = field(init=False,repr=False,default=TypeOfEnsembleForecast()) 2237# perturbationNumber: int = field(init=False,repr=False,default=PerturbationNumber()) 2238# numberOfForecastsInEnsemble: int = field(init=False,repr=False,default=NumberOfForecastsInEnsemble()) 2239# yearOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=YearOfEndOfOverallTimeInterval()) 2240# monthOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=MonthOfEndOfOverallTimeInterval()) 2241# dayOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=DayOfEndOfOverallTimeInterval()) 2242# hourOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=HourOfEndOfOverallTimeInterval()) 2243# minuteOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=MinuteOfEndOfOverallTimeInterval()) 2244# secondOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=SecondOfEndOfOverallTimeInterval()) 2245# numberOfTimeRange: int = field(init=False,repr=False,default=NumberOfTimeRange()) 2246# numberOfMissingInStatisticalProcess: int = field(init=False,repr=False,default=NumberOfMissingInStatisticalProcess()) 2247# @dataclass(init=False) 2248# class ProductDefinitionTemplate34(ProductDefinitionTemplateBase): 2249# """[Product Definition Template 34] - Individual ensemble forecast, control and perturbed at intervals - chemical""" 2250# _len = None # Length depends on number of spectral bands 2251# _num = 34 2252# constituentType: int = field(init=False,repr=False,default=ConstituentType()) 2253# numberOfContributingSpectralBands: int = field(init=False,repr=False,default=NumberOfContributingSpectralBands()) 2254# # For each band nb=1 to NB: 2255# satelliteSeries: list = field(init=False,repr=False,default=SatelliteSeries()) 2256# satelliteNumber: list = field(init=False,repr=False,default=SatelliteNumber()) 2257# instrumentTypes: list = field(init=False,repr=False,default=InstrumentTypes()) 2258# scaleFactorOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaleFactorOfCentralWaveNumber()) 2259# scaledValueOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaledValueOfCentralWaveNumber()) 2260# # After spectral bands: 2261# typeOfEnsembleForecast: int = field(init=False,repr=False,default=TypeOfEnsembleForecast()) 2262# perturbationNumber: int = field(init=False,repr=False,default=PerturbationNumber()) 2263# numberOfForecastsInEnsemble: int = field(init=False,repr=False,default=NumberOfForecastsInEnsemble()) 2264# yearOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=YearOfEndOfOverallTimeInterval()) 2265# monthOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=MonthOfEndOfOverallTimeInterval()) 2266# dayOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=DayOfEndOfOverallTimeInterval()) 2267# hourOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=HourOfEndOfOverallTimeInterval()) 2268# minuteOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=MinuteOfEndOfOverallTimeInterval()) 2269# secondOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=SecondOfEndOfOverallTimeInterval()) 2270# numberOfTimeRange: int = field(init=False,repr=False,default=NumberOfTimeRange()) 2271# numberOfMissingInStatisticalProcess: int = field(init=False,repr=False,default=NumberOfMissingInStatisticalProcess()) 2272 2273# @dataclass(init=False) 2274# class ProductDefinitionTemplate35(ProductDefinitionTemplateBase): 2275# """[Product Definition Template 35] - Individual ensemble forecast, control and perturbed at intervals - aerosol""" 2276# _len = None # Length depends on number of spectral bands 2277# _num = 35 2278# aerosolType: int = field(init=False,repr=False,default=AerosolType()) 2279# numberOfContributingSpectralBands: int = field(init=False,repr=False,default=NumberOfContributingSpectralBands()) 2280# # For each band nb=1 to NB: 2281# satelliteSeries: list = field(init=False,repr=False,default=SatelliteSeries()) 2282# satelliteNumber: list = field(init=False,repr=False,default=SatelliteNumber()) 2283# instrumentTypes: list = field(init=False,repr=False,default=InstrumentTypes()) 2284# scaleFactorOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaleFactorOfCentralWaveNumber()) 2285# scaledValueOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaledValueOfCentralWaveNumber()) 2286# # After spectral bands: 2287# typeOfEnsembleForecast: int = field(init=False,repr=False,default=TypeOfEnsembleForecast()) 2288# perturbationNumber: int = field(init=False,repr=False,default=PerturbationNumber()) 2289# numberOfForecastsInEnsemble: int = field(init=False,repr=False,default=NumberOfForecastsInEnsemble()) 2290# yearOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=YearOfEndOfOverallTimeInterval()) 2291# monthOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=MonthOfEndOfOverallTimeInterval()) 2292# dayOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=DayOfEndOfOverallTimeInterval()) 2293# hourOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=HourOfEndOfOverallTimeInterval()) 2294# minuteOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=MinuteOfEndOfOverallTimeInterval()) 2295# secondOfEndOfOverallTimeInterval: int = field(init=False,repr=False,default=SecondOfEndOfOverallTimeInterval()) 2296# numberOfTimeRange: int = field(init=False,repr=False,default=NumberOfTimeRange()) 2297# numberOfMissingInStatisticalProcess: int = field(init=False,repr=False,default=NumberOfMissingInStatisticalProcess())@dataclass(init=False) 2298 2299@dataclass(init=False) 2300class ProductDefinitionTemplate48(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 2301 """[Product Definition Template 48](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-48.shtml)""" 2302 _len = 26 2303 _num = 48 2304 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2305 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2306 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2307 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2308 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2309 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2310 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2311 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2312 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2313 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2314 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2315 @classmethod 2316 def _attrs(cls): 2317 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2318 2319@dataclass(init=False) 2320class ProductDefinitionTemplate46(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2321 """[Product Definition Template 4.46](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-46.shtml)""" 2322 _len = 38 # Total number of octets 2323 _num = 46 2324 2325 # Aerosol-specific parameters 2326 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2327 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2328 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2329 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2330 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2331 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2332 # Time interval parameters 2333 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2334 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2335 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2336 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2337 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2338 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2339 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2340 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2341 # Statistical processing parameters 2342 typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing()) 2343 numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing()) 2344 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2345 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2346 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2347 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2348 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2349 @classmethod 2350 def _attrs(cls): 2351 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2352 2353 2354 2355@dataclass(init=False) 2356class ProductDefinitionTemplate47(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2357 """[Product Definition Template 4.47](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-47.shtml)""" 2358 _len = 41 # Total number of octets for base template 2359 _num = 47 2360 2361 # Aerosol parameters 2362 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2363 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2364 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2365 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2366 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2367 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2368 2369 # Ensemble parameters 2370 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2371 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2372 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2373 2374 # Time interval parameters 2375 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2376 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2377 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2378 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2379 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2380 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2381 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2382 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2383 # Statistical processing parameters 2384 typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing()) 2385 numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing()) 2386 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2387 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2388 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2389 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2390 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2391 @classmethod 2392 def _attrs(cls): 2393 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')] 2394 2395@dataclass(init=False) 2396class ProductDefinitionTemplate49(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2397 """[Product Definition Template 4.49](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-49.shtml)""" 2398 _len = 28 2399 _num = 49 2400 2401 # Aerosol parameters 2402 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2403 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2404 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2405 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2406 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2407 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2408 2409 # Wavelength parameters 2410 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2411 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2412 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2413 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2414 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2415 2416 # Ensemble parameters 2417 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2418 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2419 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2420 2421@dataclass(init=False) 2422class ProductDefinitionTemplate80(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2423 """[Product Definition Template 4.80](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-80.shtml)""" 2424 _len = 26 2425 _num = 80 2426 2427 # Aerosol parameters 2428 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2429 sourceSinkIndicator: Grib2Metadata = field(init=False, repr=False, default=SourceSinkIndicator()) 2430 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2431 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2432 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2433 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2434 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2435 2436 # Wavelength parameters 2437 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2438 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2439 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2440 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2441 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2442 2443@dataclass(init=False) 2444class ProductDefinitionTemplate81(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2445 """[Product Definition Template 4.81](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-81.shtml)""" 2446 _len = 31 2447 _num = 81 2448 2449 # Aerosol parameters 2450 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2451 sourceSinkIndicator: Grib2Metadata = field(init=False, repr=False, default=SourceSinkIndicator()) 2452 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2453 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2454 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2455 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2456 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2457 2458 # Wavelength parameters 2459 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2460 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2461 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2462 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2463 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2464 2465 # Ensemble parameters 2466 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2467 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2468 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2469 2470@dataclass(init=False) 2471class ProductDefinitionTemplate82(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2472 """[Product Definition Template 4.82](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-82.shtml)""" 2473 _len = 41 2474 _num = 82 2475 2476 # Aerosol parameters 2477 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2478 sourceSinkIndicator: Grib2Metadata = field(init=False, repr=False, default=SourceSinkIndicator()) 2479 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2480 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2481 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2482 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2483 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2484 2485 # Wavelength parameters 2486 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2487 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2488 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2489 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2490 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2491 2492 # Time interval parameters 2493 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2494 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2495 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2496 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2497 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2498 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2499 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2500 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2501 2502 # Statistical processing parameters 2503 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2504 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2505 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2506 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2507 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2508 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2509 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2510 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2511 2512@dataclass(init=False) 2513class ProductDefinitionTemplate83(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2514 """[Product Definition Template 4.83](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-83.shtml)""" 2515 _len = 44 2516 _num = 83 2517 2518 # Aerosol parameters 2519 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2520 sourceSinkIndicator: Grib2Metadata = field(init=False, repr=False, default=SourceSinkIndicator()) 2521 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2522 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2523 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2524 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2525 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2526 2527 # Wavelength parameters 2528 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2529 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2530 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2531 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2532 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2533 2534 # Ensemble parameters 2535 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2536 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2537 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2538 2539 # Time interval parameters 2540 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2541 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2542 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2543 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2544 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2545 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2546 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2547 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2548 2549@dataclass(init=False) 2550class ProductDefinitionTemplate84(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2551 """[Product Definition Template 4.84](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-84.shtml)""" 2552 _len = 44 2553 _num = 84 2554 2555 # Aerosol parameters 2556 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2557 sourceSinkIndicator: Grib2Metadata = field(init=False, repr=False, default=SourceSinkIndicator()) 2558 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2559 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2560 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2561 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2562 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2563 2564 # Wavelength parameters 2565 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2566 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2567 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2568 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2569 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2570 2571 # Ensemble parameters 2572 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2573 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2574 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2575 2576 # Time interval parameters 2577 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2578 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2579 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2580 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2581 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2582 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2583 2584 # Statistical processing parameters 2585 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2586 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2587 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2588 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2589 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2590 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2591 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2592 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2593 2594@dataclass(init=False) 2595class ProductDefinitionTemplate85(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2596 """[Product Definition Template 4.85](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-85.shtml)""" 2597 _len = 33 2598 _num = 85 2599 2600 # Aerosol parameters 2601 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2602 sourceSinkIndicator: Grib2Metadata = field(init=False, repr=False, default=SourceSinkIndicator()) 2603 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2604 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2605 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2606 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2607 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2608 2609 # Wavelength parameters 2610 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2611 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2612 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2613 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2614 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2615 2616 # Ensemble parameters 2617 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2618 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2619 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2620 2621_pdt_by_pdtn = { 2622 0: ProductDefinitionTemplate0, 2623 1: ProductDefinitionTemplate1, 2624 2: ProductDefinitionTemplate2, 2625 5: ProductDefinitionTemplate5, 2626 6: ProductDefinitionTemplate6, 2627 8: ProductDefinitionTemplate8, 2628 9: ProductDefinitionTemplate9, 2629 10: ProductDefinitionTemplate10, 2630 11: ProductDefinitionTemplate11, 2631 12: ProductDefinitionTemplate12, 2632 15: ProductDefinitionTemplate15, 2633 31: ProductDefinitionTemplate31, 2634 32: ProductDefinitionTemplate32, 2635 46: ProductDefinitionTemplate46, 2636 47: ProductDefinitionTemplate47, 2637 48: ProductDefinitionTemplate48, 2638 49: ProductDefinitionTemplate49, 2639 80: ProductDefinitionTemplate80, 2640 81: ProductDefinitionTemplate81, 2641 82: ProductDefinitionTemplate82, 2642 83: ProductDefinitionTemplate83, 2643 84: ProductDefinitionTemplate84, 2644 85: ProductDefinitionTemplate85, 2645 } 2646 2647def pdt_class_by_pdtn(pdtn: int): 2648 """ 2649 Provide a Product Definition Template class via the template number. 2650 2651 Parameters 2652 ---------- 2653 pdtn 2654 Product definition template number. 2655 2656 Returns 2657 ------- 2658 pdt_class_by_pdtn 2659 Product definition template class object (not an instance). 2660 """ 2661 return _pdt_by_pdtn[pdtn] 2662 2663# ---------------------------------------------------------------------------------------- 2664# Descriptor Classes for Section 5 metadata. 2665# ---------------------------------------------------------------------------------------- 2666class NumberOfPackedValues: 2667 """Number of Packed Values""" 2668 def __get__(self, obj, objtype=None): 2669 return obj.section5[0] 2670 def __set__(self, obj, value): 2671 pass 2672 2673class DataRepresentationTemplateNumber: 2674 """[Data Representation Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-0.shtml)""" 2675 def __get__(self, obj, objtype=None): 2676 return Grib2Metadata(obj.section5[1],table='5.0') 2677 def __set__(self, obj, value): 2678 pass 2679 2680class DataRepresentationTemplate: 2681 """Data Representation Template""" 2682 def __get__(self, obj, objtype=None): 2683 return obj.section5[2:] 2684 def __set__(self, obj, value): 2685 raise NotImplementedError 2686 2687class RefValue: 2688 """Reference Value (represented as an IEEE 32-bit floating point value)""" 2689 def __get__(self, obj, objtype=None): 2690 return utils.ieee_int_to_float(obj.section5[0+2]) 2691 def __set__(self, obj, value): 2692 pass 2693 2694class BinScaleFactor: 2695 """Binary Scale Factor""" 2696 def __get__(self, obj, objtype=None): 2697 return obj.section5[1+2] 2698 def __set__(self, obj, value): 2699 obj.section5[1+2] = value 2700 2701class DecScaleFactor: 2702 """Decimal Scale Factor""" 2703 def __get__(self, obj, objtype=None): 2704 return obj.section5[2+2] 2705 def __set__(self, obj, value): 2706 obj.section5[2+2] = value 2707 2708class NBitsPacking: 2709 """Minimum number of bits for packing""" 2710 def __get__(self, obj, objtype=None): 2711 return obj.section5[3+2] 2712 def __set__(self, obj, value): 2713 obj.section5[3+2] = value 2714 2715class TypeOfValues: 2716 """[Type of Original Field Values](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-1.shtml)""" 2717 def __get__(self, obj, objtype=None): 2718 return Grib2Metadata(obj.section5[4+2],table='5.1') 2719 def __set__(self, obj, value): 2720 obj.section5[4+2] = value 2721 2722class GroupSplittingMethod: 2723 """[Group Splitting Method](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-4.shtml)""" 2724 def __get__(self, obj, objtype=None): 2725 return Grib2Metadata(obj.section5[5+2],table='5.4') 2726 def __set__(self, obj, value): 2727 obj.section5[5+2] = value 2728 2729class TypeOfMissingValueManagement: 2730 """[Type of Missing Value Management](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-5.shtml)""" 2731 def __get__(self, obj, objtype=None): 2732 return Grib2Metadata(obj.section5[6+2],table='5.5') 2733 def __set__(self, obj, value): 2734 obj.section5[6+2] = value 2735 2736class PriMissingValue: 2737 """Primary Missing Value""" 2738 def __get__(self, obj, objtype=None): 2739 if obj.typeOfValues == 0: 2740 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 2741 elif obj.typeOfValues == 1: 2742 return obj.section5[7+2] if obj.section5[6+2] in [1,2] else None 2743 def __set__(self, obj, value): 2744 if obj.typeOfValues == 0: 2745 obj.section5[7+2] = utils.ieee_float_to_int(value) 2746 elif self.typeOfValues == 1: 2747 obj.section5[7+2] = int(value) 2748 obj.section5[6+2] = 1 2749 2750class SecMissingValue: 2751 """Secondary Missing Value""" 2752 def __get__(self, obj, objtype=None): 2753 if obj.typeOfValues == 0: 2754 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 2755 elif obj.typeOfValues == 1: 2756 return obj.section5[8+2] if obj.section5[6+2] in {1,2} else None 2757 def __set__(self, obj, value): 2758 if obj.typeOfValues == 0: 2759 obj.section5[8+2] = utils.ieee_float_to_int(value) 2760 elif self.typeOfValues == 1: 2761 obj.section5[8+2] = int(value) 2762 obj.section5[6+2] = 2 2763 2764class NGroups: 2765 """Number of Groups""" 2766 def __get__(self, obj, objtype=None): 2767 return obj.section5[9+2] 2768 def __set__(self, obj, value): 2769 pass 2770 2771class RefGroupWidth: 2772 """Reference Group Width""" 2773 def __get__(self, obj, objtype=None): 2774 return obj.section5[10+2] 2775 def __set__(self, obj, value): 2776 pass 2777 2778class NBitsGroupWidth: 2779 """Number of bits for Group Width""" 2780 def __get__(self, obj, objtype=None): 2781 return obj.section5[11+2] 2782 def __set__(self, obj, value): 2783 pass 2784 2785class RefGroupLength: 2786 """Reference Group Length""" 2787 def __get__(self, obj, objtype=None): 2788 return obj.section5[12+2] 2789 def __set__(self, obj, value): 2790 pass 2791 2792class GroupLengthIncrement: 2793 """Group Length Increment""" 2794 def __get__(self, obj, objtype=None): 2795 return obj.section5[13+2] 2796 def __set__(self, obj, value): 2797 pass 2798 2799class LengthOfLastGroup: 2800 """Length of Last Group""" 2801 def __get__(self, obj, objtype=None): 2802 return obj.section5[14+2] 2803 def __set__(self, obj, value): 2804 pass 2805 2806class NBitsScaledGroupLength: 2807 """Number of bits of Scaled Group Length""" 2808 def __get__(self, obj, objtype=None): 2809 return obj.section5[15+2] 2810 def __set__(self, obj, value): 2811 pass 2812 2813class SpatialDifferenceOrder: 2814 """[Spatial Difference Order](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-6.shtml)""" 2815 def __get__(self, obj, objtype=None): 2816 return Grib2Metadata(obj.section5[16+2],table='5.6') 2817 def __set__(self, obj, value): 2818 obj.section5[16+2] = value 2819 2820class NBytesSpatialDifference: 2821 """Number of bytes for Spatial Differencing""" 2822 def __get__(self, obj, objtype=None): 2823 return obj.section5[17+2] 2824 def __set__(self, obj, value): 2825 pass 2826 2827class Precision: 2828 """[Precision for IEEE Floating Point Data](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-7.shtml)""" 2829 def __get__(self, obj, objtype=None): 2830 return Grib2Metadata(obj.section5[0+2],table='5.7') 2831 def __set__(self, obj, value): 2832 obj.section5[0+2] = value 2833 2834class TypeOfCompression: 2835 """[Type of Compression](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-40.shtml)""" 2836 def __get__(self, obj, objtype=None): 2837 return Grib2Metadata(obj.section5[5+2],table='5.40') 2838 def __set__(self, obj, value): 2839 obj.section5[5+2] = value 2840 2841class TargetCompressionRatio: 2842 """Target Compression Ratio""" 2843 def __get__(self, obj, objtype=None): 2844 return obj.section5[6+2] 2845 def __set__(self, obj, value): 2846 pass 2847 2848class RealOfCoefficient: 2849 """Real of Coefficient""" 2850 def __get__(self, obj, objtype=None): 2851 return utils.ieee_int_to_float(obj.section5[4+2]) 2852 def __set__(self, obj, value): 2853 obj.section5[4+2] = utils.ieee_float_to_int(float(value)) 2854 2855class CompressionOptionsMask: 2856 """Compression Options Mask for AEC/CCSDS""" 2857 def __get__(self, obj, objtype=None): 2858 return obj.section5[5+2] 2859 def __set__(self, obj, value): 2860 obj.section5[5+2] = value 2861 2862class BlockSize: 2863 """Block Size for AEC/CCSDS""" 2864 def __get__(self, obj, objtype=None): 2865 return obj.section5[6+2] 2866 def __set__(self, obj, value): 2867 obj.section5[6+2] = value 2868 2869class RefSampleInterval: 2870 """Reference Sample Interval for AEC/CCSDS""" 2871 def __get__(self, obj, objtype=None): 2872 return obj.section5[7+2] 2873 def __set__(self, obj, value): 2874 obj.section5[7+2] = value 2875 2876@dataclass(init=False) 2877class DataRepresentationTemplate0: 2878 """[Data Representation Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-0.shtml)""" 2879 _len = 5 2880 _num = 0 2881 _packingScheme = 'simple' 2882 refValue: float = field(init=False, repr=False, default=RefValue()) 2883 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2884 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2885 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2886 @classmethod 2887 def _attrs(cls): 2888 return list(cls.__dataclass_fields__.keys()) 2889 2890@dataclass(init=False) 2891class DataRepresentationTemplate2: 2892 """[Data Representation Template 2](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-2.shtml)""" 2893 _len = 16 2894 _num = 2 2895 _packingScheme = 'complex' 2896 refValue: float = field(init=False, repr=False, default=RefValue()) 2897 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2898 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2899 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2900 groupSplittingMethod: Grib2Metadata = field(init=False, repr=False, default=GroupSplittingMethod()) 2901 typeOfMissingValueManagement: Grib2Metadata = field(init=False, repr=False, default=TypeOfMissingValueManagement()) 2902 priMissingValue: Union[float, int] = field(init=False, repr=False, default=PriMissingValue()) 2903 secMissingValue: Union[float, int] = field(init=False, repr=False, default=SecMissingValue()) 2904 nGroups: int = field(init=False, repr=False, default=NGroups()) 2905 refGroupWidth: int = field(init=False, repr=False, default=RefGroupWidth()) 2906 nBitsGroupWidth: int = field(init=False, repr=False, default=NBitsGroupWidth()) 2907 refGroupLength: int = field(init=False, repr=False, default=RefGroupLength()) 2908 groupLengthIncrement: int = field(init=False, repr=False, default=GroupLengthIncrement()) 2909 lengthOfLastGroup: int = field(init=False, repr=False, default=LengthOfLastGroup()) 2910 nBitsScaledGroupLength: int = field(init=False, repr=False, default=NBitsScaledGroupLength()) 2911 @classmethod 2912 def _attrs(cls): 2913 return list(cls.__dataclass_fields__.keys()) 2914 2915@dataclass(init=False) 2916class DataRepresentationTemplate3: 2917 """[Data Representation Template 3](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-3.shtml)""" 2918 _len = 18 2919 _num = 3 2920 _packingScheme = 'complex-spdiff' 2921 refValue: float = field(init=False, repr=False, default=RefValue()) 2922 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2923 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2924 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2925 groupSplittingMethod: Grib2Metadata = field(init=False, repr=False, default=GroupSplittingMethod()) 2926 typeOfMissingValueManagement: Grib2Metadata = field(init=False, repr=False, default=TypeOfMissingValueManagement()) 2927 priMissingValue: Union[float, int] = field(init=False, repr=False, default=PriMissingValue()) 2928 secMissingValue: Union[float, int] = field(init=False, repr=False, default=SecMissingValue()) 2929 nGroups: int = field(init=False, repr=False, default=NGroups()) 2930 refGroupWidth: int = field(init=False, repr=False, default=RefGroupWidth()) 2931 nBitsGroupWidth: int = field(init=False, repr=False, default=NBitsGroupWidth()) 2932 refGroupLength: int = field(init=False, repr=False, default=RefGroupLength()) 2933 groupLengthIncrement: int = field(init=False, repr=False, default=GroupLengthIncrement()) 2934 lengthOfLastGroup: int = field(init=False, repr=False, default=LengthOfLastGroup()) 2935 nBitsScaledGroupLength: int = field(init=False, repr=False, default=NBitsScaledGroupLength()) 2936 spatialDifferenceOrder: Grib2Metadata = field(init=False, repr=False, default=SpatialDifferenceOrder()) 2937 nBytesSpatialDifference: int = field(init=False, repr=False, default=NBytesSpatialDifference()) 2938 @classmethod 2939 def _attrs(cls): 2940 return list(cls.__dataclass_fields__.keys()) 2941 2942@dataclass(init=False) 2943class DataRepresentationTemplate4: 2944 """[Data Representation Template 4](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-4.shtml)""" 2945 _len = 1 2946 _num = 4 2947 _packingScheme = 'ieee-float' 2948 precision: Grib2Metadata = field(init=False, repr=False, default=Precision()) 2949 @classmethod 2950 def _attrs(cls): 2951 return list(cls.__dataclass_fields__.keys()) 2952 2953@dataclass(init=False) 2954class DataRepresentationTemplate40: 2955 """[Data Representation Template 40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-40.shtml)""" 2956 _len = 7 2957 _num = 40 2958 _packingScheme = 'jpeg' 2959 refValue: float = field(init=False, repr=False, default=RefValue()) 2960 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2961 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2962 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2963 typeOfCompression: Grib2Metadata = field(init=False, repr=False, default=TypeOfCompression()) 2964 targetCompressionRatio: int = field(init=False, repr=False, default=TargetCompressionRatio()) 2965 @classmethod 2966 def _attrs(cls): 2967 return list(cls.__dataclass_fields__.keys()) 2968 2969@dataclass(init=False) 2970class DataRepresentationTemplate41: 2971 """[Data Representation Template 41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-41.shtml)""" 2972 _len = 5 2973 _num = 41 2974 _packingScheme = 'png' 2975 refValue: float = field(init=False, repr=False, default=RefValue()) 2976 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2977 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2978 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2979 @classmethod 2980 def _attrs(cls): 2981 return list(cls.__dataclass_fields__.keys()) 2982 2983@dataclass(init=False) 2984class DataRepresentationTemplate42: 2985 """[Data Representation Template 42](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-42.shtml)""" 2986 _len = 8 2987 _num = 42 2988 _packingScheme = 'aec' 2989 refValue: float = field(init=False, repr=False, default=RefValue()) 2990 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2991 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2992 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2993 compressionOptionsMask: int = field(init=False, repr=False, default=CompressionOptionsMask()) 2994 blockSize: int = field(init=False, repr=False, default=BlockSize()) 2995 refSampleInterval: int = field(init=False, repr=False, default=RefSampleInterval()) 2996 @classmethod 2997 def _attrs(cls): 2998 return list(cls.__dataclass_fields__.keys()) 2999 3000@dataclass(init=False) 3001class DataRepresentationTemplate50: 3002 """[Data Representation Template 50](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-50.shtml)""" 3003 _len = 5 3004 _num = 0 3005 _packingScheme = 'spectral-simple' 3006 refValue: float = field(init=False, repr=False, default=RefValue()) 3007 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 3008 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 3009 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 3010 realOfCoefficient: float = field(init=False, repr=False, default=RealOfCoefficient()) 3011 @classmethod 3012 def _attrs(cls): 3013 return list(cls.__dataclass_fields__.keys()) 3014 3015_drt_by_drtn = { 3016 0: DataRepresentationTemplate0, 3017 2: DataRepresentationTemplate2, 3018 3: DataRepresentationTemplate3, 3019 4: DataRepresentationTemplate4, 3020 40: DataRepresentationTemplate40, 3021 41: DataRepresentationTemplate41, 3022 42: DataRepresentationTemplate42, 3023 50: DataRepresentationTemplate50, 3024 } 3025 3026def drt_class_by_drtn(drtn: int): 3027 """ 3028 Provide a Data Representation Template class via the template number. 3029 3030 Parameters 3031 ---------- 3032 drtn 3033 Data Representation template number. 3034 3035 Returns 3036 ------- 3037 drt_class_by_drtn 3038 Data Representation template class object (not an instance). 3039 """ 3040 return _drt_by_drtn[drtn]
57class Grib2Metadata: 58 """ 59 Class to hold GRIB2 metadata. 60 61 Stores both numeric code value as stored in GRIB2 and its plain language 62 definition. 63 64 Attributes 65 ---------- 66 value : int 67 GRIB2 metadata integer code value. 68 table : str, optional 69 GRIB2 table to lookup the `value`. Default is None. 70 definition : str 71 Plain language description of numeric metadata. 72 """ 73 __slots__ = ('value','table') 74 def __init__(self, value, table=None): 75 self.value = value 76 self.table = table 77 def __call__(self): 78 return self.value 79 def __hash__(self): 80 # AS- added hash() to self.value as pandas was raising error about some 81 # non integer returns from hash method 82 return hash(self.value) 83 def __repr__(self): 84 return f"{self.__class__.__name__}({self.value}, table = '{self.table}')" 85 def __str__(self): 86 return f'{self.value} - {self.definition}' 87 def __eq__(self,other): 88 return self.value == other or self.definition[0] == other 89 def __gt__(self,other): 90 return self.value > other 91 def __ge__(self,other): 92 return self.value >= other 93 def __lt__(self,other): 94 return self.value < other 95 def __le__(self,other): 96 return self.value <= other 97 def __contains__(self,other): 98 return other in self.definition 99 def __hash__(self): 100 return hash(self.value) 101 def __index__(self): 102 return int(self.value) 103 @property 104 def definition(self): 105 """Provide the definition of the numeric metadata.""" 106 return tables.get_value_from_table(self.value,self.table) 107 def show_table(self): 108 """Provide the table related to this metadata.""" 109 return tables.get_table(self.table)
Class to hold GRIB2 metadata.
Stores both numeric code value as stored in GRIB2 and its plain language 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.
134class IdentificationSection: 135 """ 136 GRIB2 Section 1, [Identification Section](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect1.shtml) 137 """ 138 def __get__(self, obj, objtype=None): 139 return obj.section1 140 def __set__(self, obj, value): 141 obj.section1 = value
GRIB2 Section 1, Identification Section
150class OriginatingSubCenter: 151 """[Originating SubCenter](https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablec.html)""" 152 def __get__(self, obj, objtype=None): 153 return Grib2Metadata(obj.section1[1],table='originating_subcenters') 154 def __set__(self, obj, value): 155 obj.section1[1] = value
157class MasterTableInfo: 158 """[GRIB2 Master Table Version](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-0.shtml)""" 159 def __get__(self, obj, objtype=None): 160 return Grib2Metadata(obj.section1[2],table='1.0') 161 def __set__(self, obj, value): 162 obj.section1[2] = value
164class LocalTableInfo: 165 """[GRIB2 Local Tables Version Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-1.shtml)""" 166 def __get__(self, obj, objtype=None): 167 return Grib2Metadata(obj.section1[3],table='1.1') 168 def __set__(self, obj, value): 169 obj.section1[3] = value
171class SignificanceOfReferenceTime: 172 """[Significance of Reference Time](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-2.shtml)""" 173 def __get__(self, obj, objtype=None): 174 return Grib2Metadata(obj.section1[4],table='1.2') 175 def __set__(self, obj, value): 176 obj.section1[4] = value
178class Year: 179 """Year of reference time""" 180 def __get__(self, obj, objtype=None): 181 return obj.section1[5] 182 def __set__(self, obj, value): 183 rd = copy.copy(obj.section1[5:11]) 184 rd[0] = value 185 # Test validity of datetime values 186 _ = datetime.datetime(*rd) 187 obj.section1[5] = value
Year of reference time
189class Month: 190 """Month of reference time""" 191 def __get__(self, obj, objtype=None): 192 return obj.section1[6] 193 def __set__(self, obj, value): 194 rd = copy.copy(obj.section1[5:11]) 195 rd[1] = value 196 # Test validity of datetime values 197 _ = datetime.datetime(*rd) 198 obj.section1[6] = value
Month of reference time
200class Day: 201 """Day of reference time""" 202 def __get__(self, obj, objtype=None): 203 return obj.section1[7] 204 def __set__(self, obj, value): 205 rd = copy.copy(obj.section1[5:11]) 206 rd[2] = value 207 # Test validity of datetime values 208 _ = datetime.datetime(*rd) 209 #obj.section1[7] = value
Day of reference time
211class Hour: 212 """Hour of reference time""" 213 def __get__(self, obj, objtype=None): 214 return obj.section1[8] 215 def __set__(self, obj, value): 216 rd = copy.copy(obj.section1[5:11]) 217 rd[3] = value 218 # Test validity of datetime values 219 _ = datetime.datetime(*rd) 220 obj.section1[8] = value
Hour of reference time
222class Minute: 223 """Minute of reference time""" 224 def __get__(self, obj, objtype=None): 225 return obj.section1[9] 226 def __set__(self, obj, value): 227 rd = copy.copy(obj.section1[5:11]) 228 rd[4] = value 229 # Test validity of datetime values 230 _ = datetime.datetime(*rd) 231 obj.section1[9] = value
Minute of reference time
233class Second: 234 """Second of reference time""" 235 def __get__(self, obj, objtype=None): 236 return obj.section1[10] 237 def __set__(self, obj, value): 238 rd = copy.copy(obj.section1[5:11]) 239 rd[5] = value 240 # Test validity of datetime values 241 _ = datetime.datetime(*rd) 242 obj.section1[10] = value
Second of reference time
244class RefDate: 245 """Reference Date. NOTE: This is a `datetime.datetime` object.""" 246 def __get__(self, obj, objtype=None): 247 return datetime.datetime(*obj.section1[5:11]) 248 def __set__(self, obj, value): 249 if isinstance(value, np.datetime64): 250 timestamp = (value - np.datetime64("1970-01-01T00:00:00")) / np.timedelta64( 251 1, "s" 252 ) 253 try: 254 # Python >= 3.10 255 value = datetime.datetime.fromtimestamp(timestamp, datetime.UTC) 256 except(AttributeError): 257 # Python < 3.10 258 value = datetime.datetime.utcfromtimestamp(timestamp) 259 if isinstance(value, datetime.datetime): 260 obj.section1[5] = value.year 261 obj.section1[6] = value.month 262 obj.section1[7] = value.day 263 obj.section1[8] = value.hour 264 obj.section1[9] = value.minute 265 obj.section1[10] = value.second 266 # IMPORTANT: Update validDate components when message is time interval 267 if obj.pdtn in _timeinterval_pdtns: 268 vd = value + obj.leadTime + obj.duration 269 obj.yearOfEndOfTimePeriod = vd.year 270 obj.monthOfEndOfTimePeriod = vd.month 271 obj.dayOfEndOfTimePeriod = vd.day 272 obj.hourOfEndOfTimePeriod = vd.hour 273 obj.minuteOfEndOfTimePeriod = vd.minute 274 obj.secondOfEndOfTimePeriod = vd.second 275 else: 276 msg = "Reference date must be a datetime.datetime or np.datetime64 object." 277 raise TypeError(msg)
Reference Date. NOTE: This is a datetime.datetime object.
279class ProductionStatus: 280 """[Production Status of Processed Data](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-3.shtml)""" 281 def __get__(self, obj, objtype=None): 282 return Grib2Metadata(obj.section1[11],table='1.3') 283 def __set__(self, obj, value): 284 obj.section1[11] = value
286class TypeOfData: 287 """[Type of Processed Data in this GRIB message](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table1-4.shtml)""" 288 def __get__(self, obj, objtype=None): 289 return Grib2Metadata(obj.section1[12],table='1.4') 290 def __set__(self, obj, value): 291 obj.section1[12] = value
300class GridDefinitionSection: 301 """ 302 GRIB2 Section 3, [Grid Definition Section](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_sect3.shtml) 303 """ 304 def __get__(self, obj, objtype=None): 305 return obj.section3[0:5] 306 def __set__(self, obj, value): 307 raise RuntimeError
GRIB2 Section 3, Grid Definition Section
309class SourceOfGridDefinition: 310 """[Source of Grid Definition](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-0.shtml)""" 311 def __get__(self, obj, objtype=None): 312 return Grib2Metadata(obj.section3[0],table='3.0') 313 def __set__(self, obj, value): 314 raise RuntimeError
316class NumberOfDataPoints: 317 """Number of Data Points""" 318 def __get__(self, obj, objtype=None): 319 return obj.section3[1] 320 def __set__(self, obj, value): 321 raise RuntimeError
Number of Data Points
323class InterpretationOfListOfNumbers: 324 """Interpretation of List of Numbers""" 325 def __get__(self, obj, objtype=None): 326 return Grib2Metadata(obj.section3[3],table='3.11') 327 def __set__(self, obj, value): 328 raise RuntimeError
Interpretation of List of Numbers
330class GridDefinitionTemplateNumber: 331 """[Grid Definition Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-1.shtml)""" 332 def __get__(self, obj, objtype=None): 333 return Grib2Metadata(obj.section3[4],table='3.1') 334 def __set__(self, obj, value): 335 raise RuntimeError
337class GridDefinitionTemplate: 338 """Grid definition template""" 339 def __get__(self, obj, objtype=None): 340 return obj.section3[5:] 341 def __set__(self, obj, value): 342 raise RuntimeError
Grid definition template
344class EarthParams: 345 """Metadata about the shape of the Earth""" 346 def __get__(self, obj, objtype=None): 347 if obj.section3[5] in {50,51,52,1200}: 348 return None 349 return tables.get_table('earth_params')[str(obj.section3[5])] 350 def __set__(self, obj, value): 351 raise RuntimeError
Metadata about the shape of the Earth
353class DxSign: 354 """Sign of Grid Length in X-Direction""" 355 def __get__(self, obj, objtype=None): 356 if obj.section3[4] in {0,1,203,205,32768,32769} and \ 357 obj.section3[17] > obj.section3[20]: 358 return -1.0 359 return 1.0 360 def __set__(self, obj, value): 361 raise RuntimeError
Sign of Grid Length in X-Direction
363class DySign: 364 """Sign of Grid Length in Y-Direction""" 365 def __get__(self, obj, objtype=None): 366 if obj.section3[4] in {0,1,203,205,32768,32769} and \ 367 obj.section3[16] > obj.section3[19]: 368 return -1.0 369 return 1.0 370 def __set__(self, obj, value): 371 raise RuntimeError
Sign of Grid Length in Y-Direction
373class LLScaleFactor: 374 """Scale Factor for Lats/Lons""" 375 def __get__(self, obj, objtype=None): 376 if obj.section3[4] in {0,1,40,41,203,205,32768,32769}: 377 llscalefactor = float(obj.section3[14]) 378 if llscalefactor == 0: 379 return 1 380 return llscalefactor 381 return 1 382 def __set__(self, obj, value): 383 raise RuntimeError
Scale Factor for Lats/Lons
385class LLDivisor: 386 """Divisor Value for scaling Lats/Lons""" 387 def __get__(self, obj, objtype=None): 388 if obj.section3[4] in {0,1,40,41,203,205,32768,32769}: 389 lldivisor = float(obj.section3[15]) 390 if lldivisor <= 0: 391 return 1.e6 392 return lldivisor 393 return 1.e6 394 def __set__(self, obj, value): 395 raise RuntimeError
Divisor Value for scaling Lats/Lons
397class XYDivisor: 398 """Divisor Value for scaling grid lengths""" 399 def __get__(self, obj, objtype=None): 400 if obj.section3[4] in {0,1,40,41,203,205,32768,32769}: 401 return obj._lldivisor 402 return 1.e3 403 def __set__(self, obj, value): 404 raise RuntimeError
Divisor Value for scaling grid lengths
406class ShapeOfEarth: 407 """[Shape of the Reference System](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-2.shtml)""" 408 def __get__(self, obj, objtype=None): 409 return Grib2Metadata(obj.section3[5],table='3.2') 410 def __set__(self, obj, value): 411 obj.section3[5] = value
413class EarthShape: 414 """Description of the shape of the Earth""" 415 def __get__(self, obj, objtype=None): 416 return obj._earthparams['shape'] 417 def __set__(self, obj, value): 418 raise RuntimeError
Description of the shape of the Earth
420class EarthRadius: 421 """Radius of the Earth (Assumes "spherical")""" 422 def __get__(self, obj, objtype=None): 423 ep = obj._earthparams 424 if ep['shape'] == 'spherical': 425 if ep['radius'] is None: 426 return obj.section3[7]/(10.**obj.section3[6]) 427 else: 428 return ep['radius'] 429 elif ep['shape'] in {'ellipsoid','oblateSpheriod'}: 430 return None 431 def __set__(self, obj, value): 432 raise RuntimeError
Radius of the Earth (Assumes "spherical")
434class EarthMajorAxis: 435 """Major Axis of the Earth (Assumes "oblate spheroid" or "ellipsoid")""" 436 def __get__(self, obj, objtype=None): 437 ep = obj._earthparams 438 if ep['shape'] == 'spherical': 439 return None 440 elif ep['shape'] in {'ellipsoid','oblateSpheriod'}: 441 if ep['major_axis'] is None and ep['minor_axis'] is None: 442 return obj.section3[9]/(10.**obj.section3[8]) 443 else: 444 return ep['major_axis'] 445 def __set__(self, obj, value): 446 raise RuntimeError
Major Axis of the Earth (Assumes "oblate spheroid" or "ellipsoid")
448class EarthMinorAxis: 449 """Minor Axis of the Earth (Assumes "oblate spheroid" or "ellipsoid")""" 450 def __get__(self, obj, objtype=None): 451 ep = obj._earthparams 452 if ep['shape'] == 'spherical': 453 return None 454 if ep['shape'] in {'ellipsoid','oblateSpheriod'}: 455 if ep['major_axis'] is None and ep['minor_axis'] is None: 456 return obj.section3[11]/(10.**section3[10]) 457 else: 458 return ep['minor_axis'] 459 def __set__(self, obj, value): 460 raise RuntimeError
Minor Axis of the Earth (Assumes "oblate spheroid" or "ellipsoid")
462class Nx: 463 """Number of grid points in the X-direction (generally East-West)""" 464 def __get__(self, obj, objtype=None): 465 return obj.section3[12] 466 def __set__(self, obj, value): 467 obj.section3[12] = value 468 obj.section3[1] = value * obj.section3[13]
Number of grid points in the X-direction (generally East-West)
470class Ny: 471 """Number of grid points in the Y-direction (generally North-South)""" 472 def __get__(self, obj, objtype=None): 473 return obj.section3[13] 474 def __set__(self, obj, value): 475 obj.section3[13] = value 476 obj.section3[1] = value * obj.section3[12]
Number of grid points in the Y-direction (generally North-South)
478class ScanModeFlags: 479 """[Scanning Mode](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-4.shtml)""" 480 _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} 481 def __get__(self, obj, objtype=None): 482 if obj.gdtn == 50: 483 return [None, None, None, None] 484 else: 485 return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list)[0:8] 486 def __set__(self, obj, value): 487 obj.section3[self._key[obj.gdtn]+5] = value
489class ResolutionAndComponentFlags: 490 """[Resolution and Component Flags](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-3.shtml)""" 491 _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} 492 def __get__(self, obj, objtype=None): 493 if obj.gdtn == 50: 494 return [None for i in range(8)] 495 else: 496 return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list) 497 def __set__(self, obj, value): 498 obj.section3[self._key[obj.gdtn]+5] = value
500class LatitudeFirstGridpoint: 501 """Latitude of first gridpoint""" 502 _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} 503 def __get__(self, obj, objtype=None): 504 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 505 def __set__(self, obj, value): 506 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Latitude of first gridpoint
508class LongitudeFirstGridpoint: 509 """Longitude of first gridpoint""" 510 _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} 511 def __get__(self, obj, objtype=None): 512 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 513 def __set__(self, obj, value): 514 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Longitude of first gridpoint
516class LatitudeLastGridpoint: 517 """Latitude of last gridpoint""" 518 _key = {0:14, 1:14, 10:13, 40:14, 41:14, 203:14, 204:14, 205:14, 32768:14, 32769:19} 519 def __get__(self, obj, objtype=None): 520 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 521 def __set__(self, obj, value): 522 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Latitude of last gridpoint
524class LongitudeLastGridpoint: 525 """Longitude of last gridpoint""" 526 _key = {0:15, 1:15, 10:14, 40:15, 41:15, 203:15, 204:15, 205:15, 32768:15, 32769:20} 527 def __get__(self, obj, objtype=None): 528 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 529 def __set__(self, obj, value): 530 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Longitude of last gridpoint
532class LatitudeCenterGridpoint: 533 """Latitude of center gridpoint""" 534 _key = {32768:14, 32769:14} 535 def __get__(self, obj, objtype=None): 536 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 537 def __set__(self, obj, value): 538 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Latitude of center gridpoint
540class LongitudeCenterGridpoint: 541 """Longitude of center gridpoint""" 542 _key = {32768:15, 32769:15} 543 def __get__(self, obj, objtype=None): 544 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 545 def __set__(self, obj, value): 546 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Longitude of center gridpoint
548class GridlengthXDirection: 549 """Grid lenth in the X-Direction""" 550 _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} 551 def __get__(self, obj, objtype=None): 552 return (obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._xydivisor)*obj._dxsign 553 def __set__(self, obj, value): 554 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._xydivisor/obj._llscalefactor)
Grid lenth in the X-Direction
556class GridlengthYDirection: 557 """Grid lenth in the Y-Direction""" 558 _key = {0:17, 1:17, 10:18, 20:15, 30:15, 31:15, 203:17, 204:17, 205:17, 32768:17, 32769:17} 559 def __get__(self, obj, objtype=None): 560 if obj.gdtn in {40, 41}: 561 return obj.gridlengthXDirection 562 else: 563 return (obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._xydivisor)*obj._dysign 564 def __set__(self, obj, value): 565 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._xydivisor/obj._llscalefactor)
Grid lenth in the Y-Direction
567class NumberOfParallels: 568 """Number of parallels between a pole and the equator""" 569 _key = {40:17, 41:17} 570 def __get__(self, obj, objtype=None): 571 return obj.section3[self._key[obj.gdtn]+5] 572 def __set__(self, obj, value): 573 raise RuntimeError
Number of parallels between a pole and the equator
575class LatitudeSouthernPole: 576 """Latitude of the Southern Pole for a Rotated Lat/Lon Grid""" 577 _key = {1:19, 30:20, 31:20, 41:19} 578 def __get__(self, obj, objtype=None): 579 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 580 def __set__(self, obj, value): 581 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Latitude of the Southern Pole for a Rotated Lat/Lon Grid
583class LongitudeSouthernPole: 584 """Longitude of the Southern Pole for a Rotated Lat/Lon Grid""" 585 _key = {1:20, 30:21, 31:21, 41:20} 586 def __get__(self, obj, objtype=None): 587 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 588 def __set__(self, obj, value): 589 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Longitude of the Southern Pole for a Rotated Lat/Lon Grid
591class AnglePoleRotation: 592 """Angle of Pole Rotation for a Rotated Lat/Lon Grid""" 593 _key = {1:21, 41:21} 594 def __get__(self, obj, objtype=None): 595 return obj.section3[self._key[obj.gdtn]+5] 596 def __set__(self, obj, value): 597 obj.section3[self._key[obj.gdtn]+5] = int(value)
Angle of Pole Rotation for a Rotated Lat/Lon Grid
599class LatitudeTrueScale: 600 """Latitude at which grid lengths are specified""" 601 _key = {10:12, 20:12, 30:12, 31:12} 602 def __get__(self, obj, objtype=None): 603 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 604 def __set__(self, obj, value): 605 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Latitude at which grid lengths are specified
607class GridOrientation: 608 """Longitude at which the grid is oriented""" 609 _key = {10:16, 20:13, 30:13, 31:13} 610 def __get__(self, obj, objtype=None): 611 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 612 def __set__(self, obj, value): 613 if obj.gdtn == 10 and (value < 0 or value > 90): 614 raise ValueError("Grid orientation is limited to range of 0 to 90 degrees.") 615 obj.section3[self._key[obj.gdtn]+5] = int(value*obj._lldivisor/obj._llscalefactor)
Longitude at which the grid is oriented
617class ProjectionCenterFlag: 618 """[Projection Center](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table3-5.shtml)""" 619 _key = {20:16, 30:16, 31:16} 620 def __get__(self, obj, objtype=None): 621 return utils.int2bin(obj.section3[self._key[obj.gdtn]+5],output=list)[0] 622 def __set__(self, obj, value): 623 obj.section3[self._key[obj.gdtn]+5] = value
625class StandardLatitude1: 626 """First Standard Latitude (from the pole at which the secant cone cuts the sphere)""" 627 _key = {30:18, 31:18} 628 def __get__(self, obj, objtype=None): 629 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 630 def __set__(self, obj, value): 631 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)
633class StandardLatitude2: 634 """Second Standard Latitude (from the pole at which the secant cone cuts the sphere)""" 635 _key = {30:19, 31:19} 636 def __get__(self, obj, objtype=None): 637 return obj._llscalefactor*obj.section3[self._key[obj.gdtn]+5]/obj._lldivisor 638 def __set__(self, obj, value): 639 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)
641class SpectralFunctionParameters: 642 """Spectral Function Parameters""" 643 def __get__(self, obj, objtype=None): 644 return obj.section3[0:3] 645 def __set__(self, obj, value): 646 obj.section3[0:3] = value[0:3]
Spectral Function Parameters
648class ProjParameters: 649 """PROJ Parameters to define the reference system""" 650 def __get__(self, obj, objtype=None): 651 projparams = {} 652 projparams['a'] = 1.0 653 projparams['b'] = 1.0 654 if obj.earthRadius is not None: 655 projparams['a'] = obj.earthRadius 656 projparams['b'] = obj.earthRadius 657 else: 658 if obj.earthMajorAxis is not None: projparams['a'] = obj.earthMajorAxis 659 if obj.earthMajorAxis is not None: projparams['b'] = obj.earthMinorAxis 660 if obj.gdtn == 0: 661 projparams['proj'] = 'longlat' 662 elif obj.gdtn == 1: 663 projparams['o_proj'] = 'longlat' 664 projparams['proj'] = 'ob_tran' 665 projparams['o_lat_p'] = -1.0*obj.latitudeSouthernPole 666 projparams['o_lon_p'] = obj.anglePoleRotation 667 projparams['lon_0'] = obj.longitudeSouthernPole 668 elif obj.gdtn == 10: 669 projparams['proj'] = 'merc' 670 projparams['lat_ts'] = obj.latitudeTrueScale 671 projparams['lon_0'] = 0.5*(obj.longitudeFirstGridpoint+obj.longitudeLastGridpoint) 672 elif obj.gdtn == 20: 673 if obj.projectionCenterFlag == 0: 674 lat0 = 90.0 675 elif obj.projectionCenterFlag == 1: 676 lat0 = -90.0 677 projparams['proj'] = 'stere' 678 projparams['lat_ts'] = obj.latitudeTrueScale 679 projparams['lat_0'] = lat0 680 projparams['lon_0'] = obj.gridOrientation 681 elif obj.gdtn == 30: 682 projparams['proj'] = 'lcc' 683 projparams['lat_1'] = obj.standardLatitude1 684 projparams['lat_2'] = obj.standardLatitude2 685 projparams['lat_0'] = obj.latitudeTrueScale 686 projparams['lon_0'] = obj.gridOrientation 687 elif obj.gdtn == 31: 688 projparams['proj'] = 'aea' 689 projparams['lat_1'] = obj.standardLatitude1 690 projparams['lat_2'] = obj.standardLatitude2 691 projparams['lat_0'] = obj.latitudeTrueScale 692 projparams['lon_0'] = obj.gridOrientation 693 elif obj.gdtn == 40: 694 projparams['proj'] = 'eqc' 695 elif obj.gdtn == 32769: 696 projparams['proj'] = 'aeqd' 697 projparams['lon_0'] = obj.longitudeCenterGridpoint 698 projparams['lat_0'] = obj.latitudeCenterGridpoint 699 return projparams 700 def __set__(self, obj, value): 701 raise RuntimeError
PROJ Parameters to define the reference system
703@dataclass(init=False) 704class GridDefinitionTemplate0: 705 """[Grid Definition Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-0.shtml)""" 706 _len = 19 707 _num = 0 708 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 709 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 710 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 711 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 712 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 713 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 714 715 @classmethod 716 def _attrs(cls): 717 return list(cls.__dataclass_fields__.keys())
719@dataclass(init=False) 720class GridDefinitionTemplate1: 721 """[Grid Definition Template 1](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-1.shtml)""" 722 _len = 22 723 _num = 1 724 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 725 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 726 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 727 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 728 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 729 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 730 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 731 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 732 anglePoleRotation: float = field(init=False, repr=False, default=AnglePoleRotation()) 733 @classmethod 734 def _attrs(cls): 735 return list(cls.__dataclass_fields__.keys())
737@dataclass(init=False) 738class GridDefinitionTemplate10: 739 """[Grid Definition Template 10](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-10.shtml)""" 740 _len = 19 741 _num = 10 742 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 743 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 744 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 745 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 746 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 747 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 748 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 749 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 750 projParameters: dict = field(init=False, repr=False, default=ProjParameters()) 751 @classmethod 752 def _attrs(cls): 753 return list(cls.__dataclass_fields__.keys())
755@dataclass(init=False) 756class GridDefinitionTemplate20: 757 """[Grid Definition Template 20](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-20.shtml)""" 758 _len = 18 759 _num = 20 760 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 761 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 762 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 763 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 764 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 765 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 766 projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag()) 767 projParameters: dict = field(init=False, repr=False, default=ProjParameters()) 768 @classmethod 769 def _attrs(cls): 770 return list(cls.__dataclass_fields__.keys())
772@dataclass(init=False) 773class GridDefinitionTemplate30: 774 """[Grid Definition Template 30](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-30.shtml)""" 775 _len = 22 776 _num = 30 777 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 778 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 779 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 780 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 781 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 782 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 783 projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag()) 784 standardLatitude1: float = field(init=False, repr=False, default=StandardLatitude1()) 785 standardLatitude2: float = field(init=False, repr=False, default=StandardLatitude2()) 786 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 787 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 788 projParameters: dict = field(init=False, repr=False, default=ProjParameters()) 789 @classmethod 790 def _attrs(cls): 791 return list(cls.__dataclass_fields__.keys())
First Standard Latitude (from the pole at which the secant cone cuts the sphere)
793@dataclass(init=False) 794class GridDefinitionTemplate31: 795 """[Grid Definition Template 31](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-31.shtml)""" 796 _len = 22 797 _num = 31 798 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 799 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 800 latitudeTrueScale: float = field(init=False, repr=False, default=LatitudeTrueScale()) 801 gridOrientation: float = field(init=False, repr=False, default=GridOrientation()) 802 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 803 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 804 projectionCenterFlag: list = field(init=False, repr=False, default=ProjectionCenterFlag()) 805 standardLatitude1: float = field(init=False, repr=False, default=StandardLatitude1()) 806 standardLatitude2: float = field(init=False, repr=False, default=StandardLatitude2()) 807 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 808 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 809 @classmethod 810 def _attrs(cls): 811 return list(cls.__dataclass_fields__.keys())
First Standard Latitude (from the pole at which the secant cone cuts the sphere)
813@dataclass(init=False) 814class GridDefinitionTemplate40: 815 """[Grid Definition Template 40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-40.shtml)""" 816 _len = 19 817 _num = 40 818 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 819 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 820 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 821 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 822 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 823 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 824 numberOfParallels: int = field(init=False, repr=False, default=NumberOfParallels()) 825 @classmethod 826 def _attrs(cls): 827 return list(cls.__dataclass_fields__.keys())
829@dataclass(init=False) 830class GridDefinitionTemplate41: 831 """[Grid Definition Template 41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-41.shtml)""" 832 _len = 22 833 _num = 41 834 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 835 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 836 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 837 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 838 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 839 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 840 numberOfParallels: int = field(init=False, repr=False, default=NumberOfParallels()) 841 latitudeSouthernPole: float = field(init=False, repr=False, default=LatitudeSouthernPole()) 842 longitudeSouthernPole: float = field(init=False, repr=False, default=LongitudeSouthernPole()) 843 anglePoleRotation: float = field(init=False, repr=False, default=AnglePoleRotation()) 844 @classmethod 845 def _attrs(cls): 846 return list(cls.__dataclass_fields__.keys())
848@dataclass(init=False) 849class GridDefinitionTemplate50: 850 """[Grid Definition Template 50](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-50.shtml)""" 851 _len = 5 852 _num = 50 853 spectralFunctionParameters: list = field(init=False, repr=False, default=SpectralFunctionParameters()) 854 @classmethod 855 def _attrs(cls): 856 return list(cls.__dataclass_fields__.keys())
858@dataclass(init=False) 859class GridDefinitionTemplate32768: 860 """[Grid Definition Template 32768](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32768.shtml)""" 861 _len = 19 862 _num = 32768 863 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 864 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 865 latitudeCenterGridpoint: float = field(init=False, repr=False, default=LatitudeCenterGridpoint()) 866 longitudeCenterGridpoint: float = field(init=False, repr=False, default=LongitudeCenterGridpoint()) 867 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 868 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 869 @classmethod 870 def _attrs(cls): 871 return list(cls.__dataclass_fields__.keys())
873@dataclass(init=False) 874class GridDefinitionTemplate32769: 875 """[Grid Definition Template 32769](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32769.shtml)""" 876 _len = 19 877 _num = 32769 878 latitudeFirstGridpoint: float = field(init=False, repr=False, default=LatitudeFirstGridpoint()) 879 longitudeFirstGridpoint: float = field(init=False, repr=False, default=LongitudeFirstGridpoint()) 880 latitudeCenterGridpoint: float = field(init=False, repr=False, default=LatitudeCenterGridpoint()) 881 longitudeCenterGridpoint: float = field(init=False, repr=False, default=LongitudeCenterGridpoint()) 882 gridlengthXDirection: float = field(init=False, repr=False, default=GridlengthXDirection()) 883 gridlengthYDirection: float = field(init=False, repr=False, default=GridlengthYDirection()) 884 latitudeLastGridpoint: float = field(init=False, repr=False, default=LatitudeLastGridpoint()) 885 longitudeLastGridpoint: float = field(init=False, repr=False, default=LongitudeLastGridpoint()) 886 @classmethod 887 def _attrs(cls): 888 return list(cls.__dataclass_fields__.keys())
903def gdt_class_by_gdtn(gdtn: int): 904 """ 905 Provides a Grid Definition Template class via the template number 906 907 Parameters 908 ---------- 909 gdtn 910 Grid definition template number. 911 912 Returns 913 ------- 914 gdt_class_by_gdtn 915 Grid definition template class object (not an instance). 916 """ 917 return _gdt_by_gdtn[gdtn]
Provides a Grid Definition Template class via the template number
Parameters
- gdtn: Grid definition template number.
Returns
- gdt_class_by_gdtn: Grid definition template class object (not an instance).
922class ProductDefinitionTemplateNumber: 923 """[Product Definition Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-0.shtml)""" 924 def __get__(self, obj, objtype=None): 925 return Grib2Metadata(obj.section4[1],table='4.0') 926 def __set__(self, obj, value): 927 raise RuntimeError
930class ProductDefinitionTemplate: 931 """Product Definition Template""" 932 def __get__(self, obj, objtype=None): 933 return obj.section4[2:] 934 def __set__(self, obj, value): 935 raise RuntimeError
Product Definition Template
937class ParameterCategory: 938 """[Parameter Category](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-1.shtml)""" 939 _key = defaultdict(lambda: 0) 940 def __get__(self, obj, objtype=None): 941 return obj.section4[0+2] 942 def __set__(self, obj, value): 943 obj.section4[self._key[obj.pdtn]+2] = value
945class ParameterNumber: 946 """[Parameter Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-2.shtml)""" 947 _key = defaultdict(lambda: 1) 948 def __get__(self, obj, objtype=None): 949 return obj.section4[1+2] 950 def __set__(self, obj, value): 951 obj.section4[self._key[obj.pdtn]+2] = value
953class VarInfo: 954 """ 955 Variable Information. 956 957 These are the metadata returned for a specific variable according to 958 discipline, parameter category, and parameter number. 959 """ 960 def __get__(self, obj, objtype=None): 961 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD) 962 def __set__(self, obj, value): 963 raise RuntimeError
Variable Information.
These are the metadata returned for a specific variable according to discipline, parameter category, and parameter number.
965class FullName: 966 """Full name of the Variable.""" 967 def __get__(self, obj, objtype=None): 968 full_name = [] 969 970 # Get aerosol type from table 4.233 971 if not hasattr(obj, 'typeOfAerosol'): 972 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[0] 973 elif obj.typeOfAerosol is not None: 974 aero_type = str(obj.typeOfAerosol.value) 975 if aero_type in tables.table_4_233: 976 full_name.append(tables.table_4_233[aero_type][0]) 977 978 # Get base name from GRIB2 table 979 base_name = tables.get_varinfo_from_table( 980 obj.section0[2], 981 *obj.section4[2:4], 982 isNDFD=obj._isNDFD 983 )[0] 984 full_name.append(base_name) 985 986 # Add optical properties with wavelengths if present 987 if hasattr(obj, 'scaledValueOfFirstWavelength'): 988 optical_type = str(obj.parameterNumber) 989 first_wl = obj.scaledValueOfFirstWavelength 990 second_wl = getattr(obj, 'scaledValueOfSecondWavelength', None) 991 992 # Special case for AE between 440-870nm 993 if optical_type == '111' and first_wl == 440 and second_wl == 870: 994 full_name.append("at 440-870nm") 995 996 # Handle wavelength-specific optical properties 997 elif optical_type in ['102', '103', '104', '105', '106']: 998 wavelength = f"{first_wl}nm" 999 if second_wl: 1000 wavelength = f"{first_wl}-{second_wl}nm" 1001 full_name.append(f"at {wavelength}") 1002 1003 final = " ".join(full_name) 1004 1005 return final.replace('Aerosol Aerosol', 'Aerosol') 1006 1007 def __set__(self, obj, value): 1008 raise RuntimeError( 1009 "Cannot set the fullName of the message. Instead set shortName OR set the appropriate discipline, " 1010 "parameterCategory, and parameterNumber. The fullName will be set automatically from these other attributes." 1011 )
Full name of the Variable.
1013class Units: 1014 """Units of the Variable.""" 1015 def __get__(self, obj, objtype=None): 1016 return tables.get_varinfo_from_table(obj.section0[2],*obj.section4[2:4],isNDFD=obj._isNDFD)[1] 1017 def __set__(self, obj, value): 1018 raise RuntimeError( 1019 "Cannot set the units of the message. Instead set shortName OR set the appropriate discipline, parameterCategory, and parameterNumber. The units will be set automatically from these other attributes." 1020 )
Units of the Variable.
1022class ShortName: 1023 """Short name of the variable (i.e. the variable abbreviation).""" 1024 def __get__(self, obj, objtype=None): 1025 if hasattr(obj, 'typeOfAerosol'): 1026 return tables._build_aerosol_shortname(obj) 1027 else: 1028 return tables.get_varinfo_from_table(obj.section0[2], *obj.section4[2:4], isNDFD=obj._isNDFD)[2] 1029 def __set__(self, obj, value): 1030 metadata = tables.get_metadata_from_shortname(value) 1031 if len(metadata) > 1: 1032 raise ValueError( 1033 f"shortName={value} is ambiguous within the GRIB2 standard and you have to set instead with discipline, parameterCategory, and parameterNumber.\n{metadata}" 1034 ) 1035 for attr, val in metadata[0].items(): 1036 if attr in ["fullName", "units"]: 1037 continue 1038 setattr(obj, attr, val)
Short name of the variable (i.e. the variable abbreviation).
1040class TypeOfGeneratingProcess: 1041 """[Type of Generating Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-3.shtml)""" 1042 _key = defaultdict(lambda: 2, {48:13}) 1043 #_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} 1044 def __get__(self, obj, objtype=None): 1045 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.3') 1046 def __set__(self, obj, value): 1047 obj.section4[self._key[obj.pdtn]+2] = value
1049class BackgroundGeneratingProcessIdentifier: 1050 """Background Generating Process Identifier""" 1051 _key = defaultdict(lambda: 3, {48:14}) 1052 #_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} 1053 def __get__(self, obj, objtype=None): 1054 return obj.section4[self._key[obj.pdtn]+2] 1055 def __set__(self, obj, value): 1056 obj.section4[self._key[obj.pdtn]+2] = value
Background Generating Process Identifier
1058class GeneratingProcess: 1059 """[Generating Process](https://www.nco.ncep.noaa.gov/pmb/docs/on388/tablea.html)""" 1060 _key = defaultdict(lambda: 4, {48:15}) 1061 #_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} 1062 def __get__(self, obj, objtype=None): 1063 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='generating_process') 1064 def __set__(self, obj, value): 1065 obj.section4[self._key[obj.pdtn]+2] = value
1067class HoursAfterDataCutoff: 1068 """Hours of observational data cutoff after reference time.""" 1069 _key = defaultdict(lambda: 5, {48:16}) 1070 def __get__(self, obj, objtype=None): 1071 return obj.section4[self._key[obj.pdtn]+2] 1072 def __set__(self, obj, value): 1073 obj.section4[self._key[obj.pdtn]+2] = value
Hours of observational data cutoff after reference time.
1075class MinutesAfterDataCutoff: 1076 """Minutes of observational data cutoff after reference time.""" 1077 _key = defaultdict(lambda: 6, {48:17}) 1078 def __get__(self, obj, objtype=None): 1079 return obj.section4[self._key[obj.pdtn]+2] 1080 def __set__(self, obj, value): 1081 obj.section4[self._key[obj.pdtn]+2] = value
Minutes of observational data cutoff after reference time.
1083class UnitOfForecastTime: 1084 """[Units of Forecast Time](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-4.shtml)""" 1085 _key = defaultdict(lambda: 7, {48:18}) 1086 #_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} 1087 def __get__(self, obj, objtype=None): 1088 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.4') 1089 def __set__(self, obj, value): 1090 obj.section4[self._key[obj.pdtn]+2] = value
1092class ValueOfForecastTime: 1093 """Value of forecast time in units defined by `UnitofForecastTime`.""" 1094 _key = defaultdict(lambda: 8, {48:19}) 1095 def __get__(self, obj, objtype=None): 1096 return obj.section4[self._key[obj.pdtn]+2] 1097 def __set__(self, obj, value): 1098 obj.section4[self._key[obj.pdtn]+2] = value
Value of forecast time in units defined by UnitofForecastTime.
1100class LeadTime: 1101 """Forecast Lead Time. NOTE: This is a `datetime.timedelta` object.""" 1102 _key = ValueOfForecastTime._key 1103 def __get__(self, obj, objtype=None): 1104 return utils.get_leadtime(obj.section4[1], obj.section4[2:]) 1105 def __set__(self, obj, value): 1106 if isinstance(value, np.timedelta64): 1107 # Allows setting from xarray 1108 value = datetime.timedelta( 1109 seconds=int(value/np.timedelta64(1, 's'))) 1110 obj.section4[self._key[obj.pdtn]+2] = int(value.total_seconds()/3600) 1111 # IMPORTANT: Update validDate components when message is time interval 1112 if obj.pdtn in _timeinterval_pdtns: 1113 vd = obj.refDate + value + obj.duration 1114 obj.yearOfEndOfTimePeriod = vd.year 1115 obj.monthOfEndOfTimePeriod = vd.month 1116 obj.dayOfEndOfTimePeriod = vd.day 1117 obj.hourOfEndOfTimePeriod = vd.hour 1118 obj.minuteOfEndOfTimePeriod = vd.minute 1119 obj.secondOfEndOfTimePeriod = vd.second
Forecast Lead Time. NOTE: This is a datetime.timedelta object.
1121class FixedSfc1Info: 1122 """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)""" 1123 _key = defaultdict(lambda: 9, {48:20}) 1124 #_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} 1125 def __get__(self, obj, objtype=None): 1126 if obj.section4[self._key[obj.pdtn]+2] == 255: 1127 return [None, None] 1128 return tables.get_value_from_table(obj.section4[self._key[obj.pdtn]+2],'4.5') 1129 def __set__(self, obj, value): 1130 raise NotImplementedError
Information of the first fixed surface via table 4.5
1132class FixedSfc2Info: 1133 """Information of the second fixed surface via [table 4.5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)""" 1134 _key = defaultdict(lambda: 12, {48:23}) 1135 #_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} 1136 def __get__(self, obj, objtype=None): 1137 if obj.section4[self._key[obj.pdtn]+2] == 255: 1138 return [None, None] 1139 return tables.get_value_from_table(obj.section4[self._key[obj.pdtn]+2],'4.5') 1140 def __set__(self, obj, value): 1141 raise NotImplementedError
Information of the second fixed surface via table 4.5
1143class TypeOfFirstFixedSurface: 1144 """[Type of First Fixed Surface](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)""" 1145 _key = defaultdict(lambda: 9, {48:20}) 1146 #_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} 1147 def __get__(self, obj, objtype=None): 1148 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.5') 1149 def __set__(self, obj, value): 1150 obj.section4[self._key[obj.pdtn]+2] = value
1152class ScaleFactorOfFirstFixedSurface: 1153 """Scale Factor of First Fixed Surface""" 1154 _key = defaultdict(lambda: 10, {48:21}) 1155 #_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} 1156 def __get__(self, obj, objtype=None): 1157 return obj.section4[self._key[obj.pdtn]+2] 1158 def __set__(self, obj, value): 1159 obj.section4[self._key[obj.pdtn]+2] = value
Scale Factor of First Fixed Surface
1161class ScaledValueOfFirstFixedSurface: 1162 """Scaled Value Of First Fixed Surface""" 1163 _key = defaultdict(lambda: 11, {48:22}) 1164 #_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} 1165 def __get__(self, obj, objtype=None): 1166 return obj.section4[self._key[obj.pdtn]+2] 1167 def __set__(self, obj, value): 1168 obj.section4[self._key[obj.pdtn]+2] = value
Scaled Value Of First Fixed Surface
1170class UnitOfFirstFixedSurface: 1171 """Units of First Fixed Surface""" 1172 def __get__(self, obj, objtype=None): 1173 return obj._fixedsfc1info[1] 1174 def __set__(self, obj, value): 1175 pass
Units of First Fixed Surface
1177class ValueOfFirstFixedSurface: 1178 """Value of First Fixed Surface""" 1179 def __get__(self, obj, objtype=None): 1180 scale_factor = getattr(obj, "scaleFactorOfFirstFixedSurface") 1181 scaled_value = getattr(obj, "scaledValueOfFirstFixedSurface") 1182 return scaled_value / (10.**scale_factor) 1183 def __set__(self, obj, value): 1184 scale = _calculate_scale_factor(value) 1185 setattr(obj, "scaleFactorOfFirstFixedSurface", scale) 1186 setattr(obj, "scaledValueOfFirstFixedSurface", value * 10**scale)
Value of First Fixed Surface
1188class TypeOfSecondFixedSurface: 1189 """[Type of Second Fixed Surface](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml)""" 1190 _key = defaultdict(lambda: 12, {48:23}) 1191 #_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} 1192 def __get__(self, obj, objtype=None): 1193 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.5') 1194 def __set__(self, obj, value): 1195 obj.section4[self._key[obj.pdtn]+2] = value
1197class ScaleFactorOfSecondFixedSurface: 1198 """Scale Factor of Second Fixed Surface""" 1199 _key = defaultdict(lambda: 13, {48:24}) 1200 #_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} 1201 def __get__(self, obj, objtype=None): 1202 return obj.section4[self._key[obj.pdtn]+2] 1203 def __set__(self, obj, value): 1204 obj.section4[self._key[obj.pdtn]+2] = value
Scale Factor of Second Fixed Surface
1206class ScaledValueOfSecondFixedSurface: 1207 """Scaled Value Of Second Fixed Surface""" 1208 _key = defaultdict(lambda: 14, {48:25}) 1209 #_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} 1210 def __get__(self, obj, objtype=None): 1211 return obj.section4[self._key[obj.pdtn]+2] 1212 def __set__(self, obj, value): 1213 obj.section4[self._key[obj.pdtn]+2] = value
Scaled Value Of Second Fixed Surface
1215class UnitOfSecondFixedSurface: 1216 """Units of Second Fixed Surface""" 1217 def __get__(self, obj, objtype=None): 1218 return obj._fixedsfc2info[1] 1219 def __set__(self, obj, value): 1220 pass
Units of Second Fixed Surface
1222class ValueOfSecondFixedSurface: 1223 """Value of Second Fixed Surface""" 1224 def __get__(self, obj, objtype=None): 1225 scale_factor = getattr(obj, "scaleFactorOfSecondFixedSurface") 1226 scaled_value = getattr(obj, "scaledValueOfSecondFixedSurface") 1227 return scaled_value / (10.**scale_factor) 1228 def __set__(self, obj, value): 1229 scale = _calculate_scale_factor(value) 1230 setattr(obj, "scaleFactorOfSecondFixedSurface", scale) 1231 setattr(obj, "scaledValueOfSecondFixedSurface", value * 10**scale)
Value of Second Fixed Surface
1233class Level: 1234 """Level (same as provided by [wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Level.c))""" 1235 def __get__(self, obj, objtype=None): 1236 return tables.get_wgrib2_level_string(obj.pdtn,obj.section4[2:]) 1237 def __set__(self, obj, value): 1238 pass
Level (same as provided by wgrib2)
1240class TypeOfEnsembleForecast: 1241 """[Type of Ensemble Forecast](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-6.shtml)""" 1242 _key = {1:15, 11:15} 1243 def __get__(self, obj, objtype=None): 1244 pdtn = obj.section4[1] 1245 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.6') 1246 def __set__(self, obj, value): 1247 pdtn = obj.section4[1] 1248 obj.section4[self._key[pdtn]+2] = value
1250class PerturbationNumber: 1251 """Ensemble Perturbation Number""" 1252 _key = {1:16, 11:16} 1253 def __get__(self, obj, objtype=None): 1254 pdtn = obj.section4[1] 1255 return obj.section4[self._key[pdtn]+2] 1256 def __set__(self, obj, value): 1257 pdtn = obj.section4[1] 1258 obj.section4[self._key[pdtn]+2] = value
Ensemble Perturbation Number
1260class NumberOfEnsembleForecasts: 1261 """Total Number of Ensemble Forecasts""" 1262 _key = {1:17, 2:16, 11:17, 12:16} 1263 def __get__(self, obj, objtype=None): 1264 pdtn = obj.section4[1] 1265 return obj.section4[self._key[pdtn]+2] 1266 def __set__(self, obj, value): 1267 pdtn = obj.section4[1] 1268 obj.section4[self._key[pdtn]+2] = value
Total Number of Ensemble Forecasts
1270class TypeOfDerivedForecast: 1271 """[Type of Derived Forecast](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-7.shtml)""" 1272 _key = {2:15, 12:15} 1273 def __get__(self, obj, objtype=None): 1274 pdtn = obj.section4[1] 1275 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.7') 1276 def __set__(self, obj, value): 1277 pdtn = obj.section4[1] 1278 obj.section4[self._key[pdtn]+2] = value
1280class ForecastProbabilityNumber: 1281 """Forecast Probability Number""" 1282 _key = {5:15, 9:15} 1283 def __get__(self, obj, objtype=None): 1284 pdtn = obj.section4[1] 1285 return obj.section4[self._key[pdtn]+2] 1286 def __set__(self, obj, value): 1287 pdtn = obj.section4[1] 1288 obj.section4[self._key[pdtn]+2] = value
Forecast Probability Number
1290class TotalNumberOfForecastProbabilities: 1291 """Total Number of Forecast Probabilities""" 1292 _key = {5:16, 9:16} 1293 def __get__(self, obj, objtype=None): 1294 pdtn = obj.section4[1] 1295 return obj.section4[self._key[pdtn]+2] 1296 def __set__(self, obj, value): 1297 pdtn = obj.section4[1] 1298 obj.section4[self._key[pdtn]+2] = value
Total Number of Forecast Probabilities
1300class TypeOfProbability: 1301 """[Type of Probability](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-9.shtml)""" 1302 _key = {5:17, 9:17} 1303 def __get__(self, obj, objtype=None): 1304 pdtn = obj.section4[1] 1305 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.9') 1306 def __set__(self, obj, value): 1307 pdtn = obj.section4[1] 1308 obj.section4[self._key[pdtn]+2] = value
1310class ScaleFactorOfThresholdLowerLimit: 1311 """Scale Factor of Threshold Lower Limit""" 1312 _key = {5:18, 9:18} 1313 def __get__(self, obj, objtype=None): 1314 pdtn = obj.section4[1] 1315 return obj.section4[self._key[pdtn]+2] 1316 def __set__(self, obj, value): 1317 pdtn = obj.section4[1] 1318 obj.section4[self._key[pdtn]+2] = value
Scale Factor of Threshold Lower Limit
1320class ScaledValueOfThresholdLowerLimit: 1321 """Scaled Value of Threshold Lower Limit""" 1322 _key = {5:19, 9:19} 1323 def __get__(self, obj, objtype=None): 1324 pdtn = obj.section4[1] 1325 return obj.section4[self._key[pdtn]+2] 1326 def __set__(self, obj, value): 1327 pdtn = obj.section4[1] 1328 obj.section4[self._key[pdtn]+2] = value
Scaled Value of Threshold Lower Limit
1330class ScaleFactorOfThresholdUpperLimit: 1331 """Scale Factor of Threshold Upper Limit""" 1332 _key = {5:20, 9:20} 1333 def __get__(self, obj, objtype=None): 1334 pdtn = obj.section4[1] 1335 return obj.section4[self._key[pdtn]+2] 1336 def __set__(self, obj, value): 1337 pdtn = obj.section4[1] 1338 obj.section4[self._key[pdtn]+2] = value
Scale Factor of Threshold Upper Limit
1340class ScaledValueOfThresholdUpperLimit: 1341 """Scaled Value of Threshold Upper Limit""" 1342 _key = {5:21, 9:21} 1343 def __get__(self, obj, objtype=None): 1344 pdtn = obj.section4[1] 1345 return obj.section4[self._key[pdtn]+2] 1346 def __set__(self, obj, value): 1347 pdtn = obj.section4[1] 1348 obj.section4[self._key[pdtn]+2] = value
Scaled Value of Threshold Upper Limit
1350class ThresholdLowerLimit: 1351 """Threshold Lower Limit""" 1352 def __get__(self, obj, objtype=None): 1353 scale_factor = getattr(obj, "scaleFactorOfThresholdLowerLimit") 1354 scaled_value = getattr(obj, "scaledValueOfThresholdLowerLimit") 1355 if scale_factor == -127 and scaled_value == 255: 1356 return 0.0 1357 return scaled_value / (10.**scale_factor) 1358 def __set__(self, obj, value): 1359 scale = _calculate_scale_factor(value) 1360 setattr(obj, "scaleFactorOfThresholdLowerLimit", scale) 1361 setattr(obj, "scaledValueOfThresholdLowerLimit", value * 10**scale)
Threshold Lower Limit
1363class ThresholdUpperLimit: 1364 """Threshold Upper Limit""" 1365 def __get__(self, obj, objtype=None): 1366 scale_factor = getattr(obj, "scaleFactorOfThresholdUpperLimit") 1367 scaled_value = getattr(obj, "scaledValueOfThresholdUpperLimit") 1368 if scale_factor == -127 and scaled_value == 255: 1369 return 0.0 1370 return scaled_value / (10.**scale_factor) 1371 def __set__(self, obj, value): 1372 scale = _calculate_scale_factor(value) 1373 setattr(obj, "scaleFactorOfThresholdUpperLimit", scale) 1374 setattr(obj, "scaledValueOfThresholdUpperLimit", value * 10**scale)
Threshold Upper Limit
1376class Threshold: 1377 """Threshold string (same as [wgrib2](https://github.com/NOAA-EMC/NCEPLIBS-wgrib2/blob/develop/wgrib2/Prob.c))""" 1378 def __get__(self, obj, objtype=None): 1379 return utils.get_wgrib2_prob_string(*obj.section4[17+2:22+2]) 1380 def __set__(self, obj, value): 1381 pass
Threshold string (same as wgrib2)
1383class PercentileValue: 1384 """Percentile Value""" 1385 _key = {6:15, 10:15} 1386 def __get__(self, obj, objtype=None): 1387 pdtn = obj.section4[1] 1388 return obj.section4[self._key[pdtn]+2] 1389 def __set__(self, obj, value): 1390 pdtn = obj.section4[1] 1391 obj.section4[self._key[pdtn]+2] = value
Percentile Value
1393class YearOfEndOfTimePeriod: 1394 """Year of End of Forecast Time Period""" 1395 _key = {8:15, 9:22, 10:16, 11:18, 12:17} 1396 def __get__(self, obj, objtype=None): 1397 pdtn = obj.section4[1] 1398 return obj.section4[self._key[pdtn]+2] 1399 def __set__(self, obj, value): 1400 pdtn = obj.section4[1] 1401 obj.section4[self._key[pdtn]+2] = value
Year of End of Forecast Time Period
1403class MonthOfEndOfTimePeriod: 1404 """Month Year of End of Forecast Time Period""" 1405 _key = {8:16, 9:23, 10:17, 11:19, 12:18} 1406 def __get__(self, obj, objtype=None): 1407 pdtn = obj.section4[1] 1408 return obj.section4[self._key[pdtn]+2] 1409 def __set__(self, obj, value): 1410 pdtn = obj.section4[1] 1411 obj.section4[self._key[pdtn]+2] = value
Month Year of End of Forecast Time Period
1413class DayOfEndOfTimePeriod: 1414 """Day Year of End of Forecast Time Period""" 1415 _key = {8:17, 9:24, 10:18, 11:20, 12:19} 1416 def __get__(self, obj, objtype=None): 1417 pdtn = obj.section4[1] 1418 return obj.section4[self._key[pdtn]+2] 1419 def __set__(self, obj, value): 1420 pdtn = obj.section4[1] 1421 obj.section4[self._key[pdtn]+2] = value
Day Year of End of Forecast Time Period
1423class HourOfEndOfTimePeriod: 1424 """Hour Year of End of Forecast Time Period""" 1425 _key = {8:18, 9:25, 10:19, 11:21, 12:20} 1426 def __get__(self, obj, objtype=None): 1427 pdtn = obj.section4[1] 1428 return obj.section4[self._key[pdtn]+2] 1429 def __set__(self, obj, value): 1430 pdtn = obj.section4[1] 1431 obj.section4[self._key[pdtn]+2] = value
Hour Year of End of Forecast Time Period
1433class MinuteOfEndOfTimePeriod: 1434 """Minute Year of End of Forecast Time Period""" 1435 _key = {8:19, 9:26, 10:20, 11:22, 12:21} 1436 def __get__(self, obj, objtype=None): 1437 pdtn = obj.section4[1] 1438 return obj.section4[self._key[pdtn]+2] 1439 def __set__(self, obj, value): 1440 pdtn = obj.section4[1] 1441 obj.section4[self._key[pdtn]+2] = value
Minute Year of End of Forecast Time Period
1443class SecondOfEndOfTimePeriod: 1444 """Second Year of End of Forecast Time Period""" 1445 _key = {8:20, 9:27, 10:21, 11:23, 12:22} 1446 def __get__(self, obj, objtype=None): 1447 pdtn = obj.section4[1] 1448 return obj.section4[self._key[pdtn]+2] 1449 def __set__(self, obj, value): 1450 pdtn = obj.section4[1] 1451 obj.section4[self._key[pdtn]+2] = value
Second Year of End of Forecast Time Period
1453class Duration: 1454 """Duration of time period. NOTE: This is a `datetime.timedelta` object.""" 1455 def __get__(self, obj, objtype=None): 1456 return utils.get_duration(obj.section4[1],obj.section4[2:]) 1457 def __set__(self, obj, value): 1458 if obj.pdtn in _continuous_pdtns: 1459 pass 1460 elif obj.pdtn in _timeinterval_pdtns: 1461 _key = TimeRangeOfStatisticalProcess._key 1462 if isinstance(value, np.timedelta64): 1463 # Allows setting from xarray 1464 value = datetime.timedelta( 1465 seconds=int(value/np.timedelta64(1, 's'))) 1466 obj.section4[_key[obj.pdtn]+2] = int(value.total_seconds()/3600) 1467 # IMPORTANT: Update validDate components when message is time interval 1468 if obj.pdtn in _timeinterval_pdtns: 1469 print(obj.refDate, value, obj.leadTime) 1470 vd = obj.refDate + value + obj.leadTime 1471 obj.yearOfEndOfTimePeriod = vd.year 1472 obj.monthOfEndOfTimePeriod = vd.month 1473 obj.dayOfEndOfTimePeriod = vd.day 1474 obj.hourOfEndOfTimePeriod = vd.hour 1475 obj.minuteOfEndOfTimePeriod = vd.minute 1476 obj.secondOfEndOfTimePeriod = vd.second
Duration of time period. NOTE: This is a datetime.timedelta object.
1478class ValidDate: 1479 """Valid Date of the forecast. NOTE: This is a `datetime.datetime` object.""" 1480 _key = {8:slice(15,21), 9:slice(22,28), 10:slice(16,22), 11:slice(18,24), 12:slice(17,23)} 1481 def __get__(self, obj, objtype=None): 1482 pdtn = obj.section4[1] 1483 try: 1484 s = slice(self._key[pdtn].start+2,self._key[pdtn].stop+2) 1485 return datetime.datetime(*obj.section4[s]) 1486 except(KeyError): 1487 return obj.refDate + obj.leadTime 1488 def __set__(self, obj, value): 1489 warnings.warn(f"validDate attribute is read-only.")
Valid Date of the forecast. NOTE: This is a datetime.datetime object.
1491class NumberOfTimeRanges: 1492 """Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field""" 1493 _key = {8:21, 9:28, 10:22, 11:24, 12:23, 46:27} 1494 def __get__(self, obj, objtype=None): 1495 pdtn = obj.section4[1] 1496 return obj.section4[self._key[pdtn]+2] 1497 def __set__(self, obj, value): 1498 pdtn = obj.section4[1] 1499 obj.section4[self._key[pdtn]+2] = value
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
1501class NumberOfMissingValues: 1502 """Total number of data values missing in statistical process""" 1503 _key = {8:22, 9:29, 10:23, 11:25, 12:24, 46:28} 1504 def __get__(self, obj, objtype=None): 1505 pdtn = obj.section4[1] 1506 return obj.section4[self._key[pdtn]+2] 1507 def __set__(self, obj, value): 1508 pdtn = obj.section4[1] 1509 obj.section4[self._key[pdtn]+2] = value
Total number of data values missing in statistical process
1511class StatisticalProcess: 1512 """[Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-10.shtml)""" 1513 _key = { 1514 8: 23, 1515 9: 30, 1516 10: 24, 1517 11: 26, 1518 12: 25, 1519 15: 15, 1520 46: 30, 1521 47: 30, 1522 49: 30, 1523 80: 30, 1524 81: 30, 1525 82: 30, 1526 83: 30, 1527 84: 30, 1528 85: 30 1529 } 1530 1531 def __get__(self, obj, objtype=None): 1532 pdtn = obj.section4[1] 1533 return Grib2Metadata(obj.section4[self._key[pdtn]+2], table='4.10') 1534 1535 def __set__(self, obj, value): 1536 pdtn = obj.section4[1] 1537 obj.section4[self._key[pdtn]+2] = value
1539class TypeOfTimeIncrementOfStatisticalProcess: 1540 """[Type of Time Increment of Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-11.shtml)""" 1541 _key = { 1542 4: 31, 1543 8: 24, 1544 9: 31, 1545 10: 25, 1546 11: 27, 1547 12: 26, 1548 46: 31, 1549 47: 31, 1550 49: 31, 1551 80: 31, 1552 81: 31, 1553 82: 31, 1554 83: 31, 1555 84: 31, 1556 85: 31 1557 } 1558 1559 def __get__(self, obj, objtype=None): 1560 pdtn = obj.section4[1] 1561 return Grib2Metadata(obj.section4[self._key[pdtn]+2], table='4.11') 1562 1563 def __set__(self, obj, value): 1564 pdtn = obj.section4[1] 1565 obj.section4[self._key[pdtn]+2] = value
1566class UnitOfTimeRangeOfStatisticalProcess: 1567 """[Unit of Time Range of Statistical Process](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-11.shtml)""" 1568 _key = { 1569 4: 32, 1570 8: 25, 1571 9: 32, 1572 10: 26, 1573 11: 28, 1574 12: 27, 1575 46: 32, 1576 47: 32, 1577 49: 32, 1578 80: 32, 1579 81: 32, 1580 82: 32, 1581 83: 32, 1582 84: 32, 1583 85: 32 1584 } 1585 1586 def __get__(self, obj, objtype=None): 1587 pdtn = obj.section4[1] 1588 return Grib2Metadata(obj.section4[self._key[pdtn]+2], table='4.4') 1589 1590 def __set__(self, obj, value): 1591 pdtn = obj.section4[1] 1592 obj.section4[self._key[pdtn]+2] = value
1594class TimeRangeOfStatisticalProcess: 1595 """Time Range of Statistical Process""" 1596 _key = { 1597 4: 33, 1598 8: 26, 1599 9: 33, 1600 10: 27, 1601 11: 29, 1602 12: 28, 1603 46: 33, 1604 47: 33, 1605 49: 33, 1606 80: 33, 1607 81: 33, 1608 82: 33, 1609 83: 33, 1610 84: 33, 1611 85: 33 1612 } 1613 1614 def __get__(self, obj, objtype=None): 1615 pdtn = obj.section4[1] 1616 return obj.section4[self._key[pdtn]+2] 1617 1618 def __set__(self, obj, value): 1619 pdtn = obj.section4[1] 1620 obj.section4[self._key[pdtn]+2] = value
Time Range of Statistical Process
1622class UnitOfTimeRangeOfSuccessiveFields: 1623 """[Unit of Time Range of Successive Fields](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-4.shtml)""" 1624 _key = { 1625 4: 34, 1626 8: 27, 1627 9: 34, 1628 10: 28, 1629 11: 30, 1630 12: 29, 1631 46: 34, 1632 47: 34, 1633 49: 34, 1634 80: 34, 1635 81: 34, 1636 82: 34, 1637 83: 34, 1638 84: 34, 1639 85: 34 1640 } 1641 1642 def __get__(self, obj, objtype=None): 1643 pdtn = obj.section4[1] 1644 return Grib2Metadata(obj.section4[self._key[pdtn]+2], table='4.4') 1645 1646 def __set__(self, obj, value): 1647 pdtn = obj.section4[1] 1648 obj.section4[self._key[pdtn]+2] = value
1650class TimeIncrementOfSuccessiveFields: 1651 """Time Increment of Successive Fields""" 1652 _key = { 1653 4: 35, 1654 8: 28, 1655 9: 35, 1656 10: 29, 1657 11: 31, 1658 12: 30, 1659 46: 67, 1660 47: 67, 1661 49: 67, 1662 80: 35, 1663 81: 35, 1664 82: 35, 1665 83: 35, 1666 84: 35, 1667 85: 35 1668 } 1669 1670 def __get__(self, obj, objtype=None): 1671 pdtn = obj.section4[1] 1672 return obj.section4[self._key[pdtn]+2] 1673 1674 def __set__(self, obj, value): 1675 pdtn = obj.section4[1] 1676 obj.section4[self._key[pdtn]+2] = value
Time Increment of Successive Fields
1677class TypeOfStatisticalProcessing: 1678 """[Type of Statistical Processing](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-15.shtml)""" 1679 _key = {15:16} 1680 def __get__(self, obj, objtype=None): 1681 pdtn = obj.section4[1] 1682 return Grib2Metadata(obj.section4[self._key[pdtn]+2],table='4.15') 1683 def __set__(self, obj, value): 1684 pdtn = obj.section4[1] 1685 obj.section4[self._key[pdtn]+2] = value
1687class NumberOfDataPointsForSpatialProcessing: 1688 """Number of Data Points for Spatial Processing""" 1689 _key = {15:17} 1690 def __get__(self, obj, objtype=None): 1691 pdtn = obj.section4[1] 1692 return obj.section4[self._key[pdtn]+2] 1693 def __set__(self, obj, value): 1694 pdtn = obj.section4[1] 1695 obj.section4[self._key[pdtn]+2] = value
Number of Data Points for Spatial Processing
1697class NumberOfContributingSpectralBands: 1698 """Number of Contributing Spectral Bands (NB)""" 1699 _key = {32:9} 1700 def __get__(self, obj, objtype=None): 1701 pdtn = obj.section4[1] 1702 return obj.section4[self._key[pdtn]+2] 1703 def __set__(self, obj, value): 1704 pdtn = obj.section4[1] 1705 obj.section4[self._key[pdtn]+2] = value
Number of Contributing Spectral Bands
1707class SatelliteSeries: 1708 """Satellte Series of band nb, where nb=1,NB if NB > 0""" 1709 _key = {32:10} 1710 def __get__(self, obj, objtype=None): 1711 pdtn = obj.section4[1] 1712 return obj.section4[self._key[pdtn]+2::5][:obj.section4[9+2]] 1713 def __set__(self, obj, value): 1714 pass
Satellite Series
1716class SatelliteNumber: 1717 """Satellte Number of band nb, where nb=1,NB if NB > 0""" 1718 _key = {32:11} 1719 def __get__(self, obj, objtype=None): 1720 pdtn = obj.section4[1] 1721 return obj.section4[self._key[pdtn]+2::5][:obj.section4[9+2]] 1722 def __set__(self, obj, value): 1723 pass
Satellte Number of band nb, where nb=1,NB if NB > 0
1725class InstrumentType: 1726 """Instrument Type of band nb, where nb=1,NB if NB > 0""" 1727 _key = {32:12} 1728 def __get__(self, obj, objtype=None): 1729 pdtn = obj.section4[1] 1730 return obj.section4[self._key[pdtn]+2::5][:obj.section4[9+2]] 1731 def __set__(self, obj, value): 1732 pass
Instrument Type of band nb, where nb=1,NB if NB > 0
1734class ScaleFactorOfCentralWaveNumber: 1735 """Scale Factor Of Central WaveNumber of band nb, where nb=1,NB if NB > 0""" 1736 _key = {32:13} 1737 def __get__(self, obj, objtype=None): 1738 pdtn = obj.section4[1] 1739 return obj.section4[self._key[pdtn]+2::5][:obj.section4[9+2]] 1740 def __set__(self, obj, value): 1741 pass
Scale Factor Of Central WaveNumber of band nb, where nb=1,NB if NB > 0
1743class ScaledValueOfCentralWaveNumber: 1744 """Scaled Value Of Central WaveNumber of band NB""" 1745 _key = {32:14} 1746 def __get__(self, obj, objtype=None): 1747 pdtn = obj.section4[1] 1748 return obj.section4[self._key[pdtn]+2::5][:obj.section4[9+2]] 1749 def __set__(self, obj, value): 1750 pass
Scaled Value Of Central WaveNumber of band NB
1752class TypeOfAerosol: 1753 """[Type of Aerosol](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-233.shtml)""" 1754 _key = {46:2, 48:2} 1755 def __get__(self, obj, objtype=None): 1756 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.233') 1757 def __set__(self, obj, value): 1758 obj.section4[self._key[obj.pdtn]+2] = value
1760class TypeOfIntervalForAerosolSize: 1761 """[Type of Interval for Aerosol Size](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-91.shtml)""" 1762 _key = {46:3, 48:3} 1763 def __get__(self, obj, objtype=None): 1764 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.91') 1765 def __set__(self, obj, value): 1766 obj.section4[self._key[obj.pdtn]+2] = value
1768class ScaleFactorOfFirstSize: 1769 """Scale Factor of First Size""" 1770 _key = {46:4, 48:4} 1771 def __get__(self, obj, objtype=None): 1772 return obj.section4[self._key[obj.pdtn]+2] 1773 def __set__(self, obj, value): 1774 obj.section4[self._key[obj.pdtn]+2] = value
Scale Factor of First Size
1776class ScaledValueOfFirstSize: 1777 """Scaled Value of First Size""" 1778 _key = {46:5, 48:5} 1779 def __get__(self, obj, objtype=None): 1780 return obj.section4[self._key[obj.pdtn]+2] 1781 def __set__(self, obj, value): 1782 obj.section4[self._key[obj.pdtn]+2] = value
Scaled Value of First Size
1784class ScaleFactorOfSecondSize: 1785 """Scale Factor of Second Size""" 1786 _key = {46:6, 48:6} 1787 def __get__(self, obj, objtype=None): 1788 return obj.section4[self._key[obj.pdtn]+2] 1789 def __set__(self, obj, value): 1790 obj.section4[self._key[obj.pdtn]+2] = value
Scale Factor of Second Size
1792class ScaledValueOfSecondSize: 1793 """Scaled Value of Second Size""" 1794 _key = {46:6, 48:7} 1795 def __get__(self, obj, objtype=None): 1796 return obj.section4[self._key[obj.pdtn]+2] 1797 def __set__(self, obj, value): 1798 obj.section4[self._key[obj.pdtn]+2] = value
Scaled Value of Second Size
1800class TypeOfIntervalForAerosolWavelength: 1801 """[Type of Interval for Aerosol Wavelength](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-91.shtml)""" 1802 _key = {48:8} 1803 def __get__(self, obj, objtype=None): 1804 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2],table='4.91') 1805 def __set__(self, obj, value): 1806 obj.section4[self._key[obj.pdtn]+2] = value
1808class ScaleFactorOfFirstWavelength: 1809 """Scale Factor of First Wavelength""" 1810 _key = {48:9} 1811 def __get__(self, obj, objtype=None): 1812 return obj.section4[self._key[obj.pdtn]+2] 1813 def __set__(self, obj, value): 1814 obj.section4[self._key[obj.pdtn]+2] = value
Scale Factor of First Wavelength
1816class ScaledValueOfFirstWavelength: 1817 """Scaled Value of First Wavelength""" 1818 _key = {48:10} 1819 def __get__(self, obj, objtype=None): 1820 return obj.section4[self._key[obj.pdtn]+2] 1821 def __set__(self, obj, value): 1822 obj.section4[self._key[obj.pdtn]+2] = value
Scaled Value of First Wavelength
1824class ScaleFactorOfSecondWavelength: 1825 """Scale Factor of Second Wavelength""" 1826 _key = {48:11} 1827 def __get__(self, obj, objtype=None): 1828 return obj.section4[self._key[obj.pdtn]+2] 1829 def __set__(self, obj, value): 1830 obj.section4[self._key[obj.pdtn]+2] = value
Scale Factor of Second Wavelength
1832class ScaledValueOfSecondWavelength: 1833 """Scaled Value of Second Wavelength""" 1834 _key = {48:12} 1835 def __get__(self, obj, objtype=None): 1836 return obj.section4[self._key[obj.pdtn]+2] 1837 def __set__(self, obj, value): 1838 obj.section4[self._key[obj.pdtn]+2] = value
Scaled Value of Second Wavelength
1840class SourceSinkIndicator: 1841 """[Source/Sink Indicator](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-238.shtml)""" 1842 _key = {80:3, 81:3, 82:3, 83:3, 84:3, 85:3} 1843 def __get__(self, obj, objtype=None): 1844 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2], table='4.238') 1845 def __set__(self, obj, value): 1846 obj.section4[self._key[obj.pdtn]+2] = value
1855class ConstituentType: 1856 """[Constituent Type](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-230.shtml)""" 1857 _key = defaultdict(lambda: 10) 1858 def __get__(self, obj, objtype=None): 1859 return Grib2Metadata(obj.section4[self._key[obj.pdtn]+2], table='4.230') 1860 def __set__(self, obj, value): 1861 obj.section4[self._key[obj.pdtn]+2] = value
1891@dataclass(init=False) 1892class ProductDefinitionTemplateBase: 1893 """Base attributes for Product Definition Templates""" 1894 _varinfo: list = field(init=False, repr=False, default=VarInfo()) 1895 fullName: str = field(init=False, repr=False, default=FullName()) 1896 units: str = field(init=False, repr=False, default=Units()) 1897 shortName: str = field(init=False, repr=False, default=ShortName()) 1898 leadTime: datetime.timedelta = field(init=False,repr=False,default=LeadTime()) 1899 duration: datetime.timedelta = field(init=False,repr=False,default=Duration()) 1900 validDate: datetime.datetime = field(init=False,repr=False,default=ValidDate()) 1901 level: str = field(init=False, repr=False, default=Level()) 1902 # Begin template here... 1903 parameterCategory: int = field(init=False,repr=False,default=ParameterCategory()) 1904 parameterNumber: int = field(init=False,repr=False,default=ParameterNumber()) 1905 typeOfGeneratingProcess: Grib2Metadata = field(init=False,repr=False,default=TypeOfGeneratingProcess()) 1906 generatingProcess: Grib2Metadata = field(init=False, repr=False, default=GeneratingProcess()) 1907 backgroundGeneratingProcessIdentifier: int = field(init=False,repr=False,default=BackgroundGeneratingProcessIdentifier()) 1908 hoursAfterDataCutoff: int = field(init=False,repr=False,default=HoursAfterDataCutoff()) 1909 minutesAfterDataCutoff: int = field(init=False,repr=False,default=MinutesAfterDataCutoff()) 1910 unitOfForecastTime: Grib2Metadata = field(init=False,repr=False,default=UnitOfForecastTime()) 1911 valueOfForecastTime: int = field(init=False,repr=False,default=ValueOfForecastTime()) 1912 @classmethod 1913 def _attrs(cls): 1914 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Base attributes for Product Definition Templates
1916@dataclass(init=False) 1917class ProductDefinitionTemplateSurface: 1918 """Surface attributes for Product Definition Templates""" 1919 _fixedsfc1info: list = field(init=False, repr=False, default=FixedSfc1Info()) 1920 _fixedsfc2info: list = field(init=False, repr=False, default=FixedSfc2Info()) 1921 typeOfFirstFixedSurface: Grib2Metadata = field(init=False,repr=False,default=TypeOfFirstFixedSurface()) 1922 scaleFactorOfFirstFixedSurface: int = field(init=False,repr=False,default=ScaleFactorOfFirstFixedSurface()) 1923 scaledValueOfFirstFixedSurface: int = field(init=False,repr=False,default=ScaledValueOfFirstFixedSurface()) 1924 typeOfSecondFixedSurface: Grib2Metadata = field(init=False,repr=False,default=TypeOfSecondFixedSurface()) 1925 scaleFactorOfSecondFixedSurface: int = field(init=False,repr=False,default=ScaleFactorOfSecondFixedSurface()) 1926 scaledValueOfSecondFixedSurface: int = field(init=False,repr=False,default=ScaledValueOfSecondFixedSurface()) 1927 unitOfFirstFixedSurface: str = field(init=False,repr=False,default=UnitOfFirstFixedSurface()) 1928 valueOfFirstFixedSurface: int = field(init=False,repr=False,default=ValueOfFirstFixedSurface()) 1929 unitOfSecondFixedSurface: str = field(init=False,repr=False,default=UnitOfSecondFixedSurface()) 1930 valueOfSecondFixedSurface: int = field(init=False,repr=False,default=ValueOfSecondFixedSurface()) 1931 @classmethod 1932 def _attrs(cls): 1933 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Surface attributes for Product Definition Templates
1935@dataclass(init=False) 1936class ProductDefinitionTemplate0(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 1937 """[Product Definition Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-0.shtml)""" 1938 _len = 15 1939 _num = 0 1940 @classmethod 1941 def _attrs(cls): 1942 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
1944@dataclass(init=False) 1945class ProductDefinitionTemplate1(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 1946 """[Product Definition Template 1](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-1.shtml)""" 1947 _len = 18 1948 _num = 1 1949 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 1950 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 1951 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 1952 @classmethod 1953 def _attrs(cls): 1954 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
1956@dataclass(init=False) 1957class ProductDefinitionTemplate2(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 1958 """[Product Definition Template 2](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-2.shtml)""" 1959 _len = 17 1960 _num = 2 1961 typeOfDerivedForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfDerivedForecast()) 1962 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 1963 @classmethod 1964 def _attrs(cls): 1965 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
1967@dataclass(init=False) 1968class ProductDefinitionTemplate5(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 1969 """[Product Definition Template 5](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-5.shtml)""" 1970 _len = 22 1971 _num = 5 1972 forecastProbabilityNumber: int = field(init=False, repr=False, default=ForecastProbabilityNumber()) 1973 totalNumberOfForecastProbabilities: int = field(init=False, repr=False, default=TotalNumberOfForecastProbabilities()) 1974 typeOfProbability: Grib2Metadata = field(init=False, repr=False, default=TypeOfProbability()) 1975 scaleFactorOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdLowerLimit()) 1976 scaledValueOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdLowerLimit()) 1977 scaleFactorOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdUpperLimit()) 1978 scaledValueOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdUpperLimit()) 1979 thresholdLowerLimit: float = field(init=False, repr=False, default=ThresholdLowerLimit()) 1980 thresholdUpperLimit: float = field(init=False, repr=False, default=ThresholdUpperLimit()) 1981 threshold: str = field(init=False, repr=False, default=Threshold()) 1982 @classmethod 1983 def _attrs(cls): 1984 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
1986@dataclass(init=False) 1987class ProductDefinitionTemplate6(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 1988 """[Product Definition Template 6](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-6.shtml)""" 1989 _len = 16 1990 _num = 6 1991 percentileValue: int = field(init=False, repr=False, default=PercentileValue()) 1992 @classmethod 1993 def _attrs(cls): 1994 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
1996@dataclass(init=False) 1997class ProductDefinitionTemplate8(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 1998 """[Product Definition Template 8](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-8.shtml)""" 1999 _len = 29 2000 _num = 8 2001 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2002 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2003 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2004 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2005 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2006 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2007 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2008 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2009 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2010 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2011 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2012 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2013 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2014 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2015 @classmethod 2016 def _attrs(cls): 2017 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2019@dataclass(init=False) 2020class ProductDefinitionTemplate9(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 2021 """[Product Definition Template 9](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-9.shtml)""" 2022 _len = 36 2023 _num = 9 2024 forecastProbabilityNumber: int = field(init=False, repr=False, default=ForecastProbabilityNumber()) 2025 totalNumberOfForecastProbabilities: int = field(init=False, repr=False, default=TotalNumberOfForecastProbabilities()) 2026 typeOfProbability: Grib2Metadata = field(init=False, repr=False, default=TypeOfProbability()) 2027 scaleFactorOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdLowerLimit()) 2028 scaledValueOfThresholdLowerLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdLowerLimit()) 2029 scaleFactorOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaleFactorOfThresholdUpperLimit()) 2030 scaledValueOfThresholdUpperLimit: float = field(init=False, repr=False, default=ScaledValueOfThresholdUpperLimit()) 2031 thresholdLowerLimit: float = field(init=False, repr=False, default=ThresholdLowerLimit()) 2032 thresholdUpperLimit: float = field(init=False, repr=False, default=ThresholdUpperLimit()) 2033 threshold: str = field(init=False, repr=False, default=Threshold()) 2034 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2035 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2036 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2037 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2038 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2039 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2040 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2041 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2042 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2043 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2044 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2045 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2046 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2047 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2048 @classmethod 2049 def _attrs(cls): 2050 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2052@dataclass(init=False) 2053class ProductDefinitionTemplate10(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 2054 """[Product Definition Template 10](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-10.shtml)""" 2055 _len = 30 2056 _num = 10 2057 percentileValue: int = field(init=False, repr=False, default=PercentileValue()) 2058 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2059 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2060 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2061 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2062 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2063 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2064 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2065 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2066 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2067 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2068 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2069 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2070 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2071 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2072 @classmethod 2073 def _attrs(cls): 2074 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2076@dataclass(init=False) 2077class ProductDefinitionTemplate11(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 2078 """[Product Definition Template 11](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-11.shtml)""" 2079 _len = 32 2080 _num = 11 2081 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2082 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2083 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2084 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2085 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2086 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2087 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2088 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2089 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2090 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2091 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2092 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2093 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2094 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2095 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2096 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2097 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2098 @classmethod 2099 def _attrs(cls): 2100 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2102@dataclass(init=False) 2103class ProductDefinitionTemplate12(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 2104 """[Product Definition Template 12](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-12.shtml)""" 2105 _len = 31 2106 _num = 12 2107 typeOfDerivedForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfDerivedForecast()) 2108 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2109 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2110 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2111 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2112 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2113 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2114 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2115 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2116 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2117 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2118 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2119 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2120 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2121 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2122 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2123 @classmethod 2124 def _attrs(cls): 2125 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2127@dataclass(init=False) 2128class ProductDefinitionTemplate13(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2129 """[Product Definition Template 13](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-13.shtml)""" 2130 _len = 18 2131 _num = 13 2132 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2133 typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing()) 2134 numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing()) 2135 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2136 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2137 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2138 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2139 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2140 @classmethod 2141 def _attrs(cls): 2142 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2144@dataclass(init=False) 2145class ProductDefinitionTemplate14(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2146 """[Product Definition Template 14](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-14.shtml)""" 2147 _len = 18 2148 _num = 14 2149 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2150 typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing()) 2151 numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing()) 2152 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2153 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2154 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2155 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2156 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2157 @classmethod 2158 def _attrs(cls): 2159 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2161@dataclass(init=False) 2162class ProductDefinitionTemplate15(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 2163 """[Product Definition Template 15](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-15.shtml)""" 2164 _len = 18 2165 _num = 15 2166 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2167 typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing()) 2168 numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing()) 2169 @classmethod 2170 def _attrs(cls): 2171 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2189@dataclass(init=False) 2190class ProductDefinitionTemplate31: 2191 """[Product Definition Template 31](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-31.shtml)""" 2192 _len = 5 2193 _num = 31 2194 parameterCategory: int = field(init=False,repr=False,default=ParameterCategory()) 2195 parameterNumber: int = field(init=False,repr=False,default=ParameterNumber()) 2196 typeOfGeneratingProcess: Grib2Metadata = field(init=False,repr=False,default=TypeOfGeneratingProcess()) 2197 generatingProcess: Grib2Metadata = field(init=False, repr=False, default=GeneratingProcess()) 2198 numberOfContributingSpectralBands: int = field(init=False,repr=False,default=NumberOfContributingSpectralBands()) 2199 satelliteSeries: list = field(init=False,repr=False,default=SatelliteSeries()) 2200 satelliteNumber: list = field(init=False,repr=False,default=SatelliteNumber()) 2201 instrumentType: list = field(init=False,repr=False,default=InstrumentType()) 2202 scaleFactorOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaleFactorOfCentralWaveNumber()) 2203 scaledValueOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaledValueOfCentralWaveNumber()) 2204 @classmethod 2205 def _attrs(cls): 2206 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
2208@dataclass(init=False) 2209class ProductDefinitionTemplate32(ProductDefinitionTemplateBase): 2210 """[Product Definition Template 32](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-32.shtml)""" 2211 _len = 10 2212 _num = 32 2213 numberOfContributingSpectralBands: int = field(init=False,repr=False,default=NumberOfContributingSpectralBands()) 2214 satelliteSeries: list = field(init=False,repr=False,default=SatelliteSeries()) 2215 satelliteNumber: list = field(init=False,repr=False,default=SatelliteNumber()) 2216 instrumentType: list = field(init=False,repr=False,default=InstrumentType()) 2217 scaleFactorOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaleFactorOfCentralWaveNumber()) 2218 scaledValueOfCentralWaveNumber: list = field(init=False,repr=False,default=ScaledValueOfCentralWaveNumber()) 2219 @classmethod 2220 def _attrs(cls): 2221 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Scale Factor Of Central WaveNumber of band nb, where nb=1,NB if NB > 0
Inherited Members
2300@dataclass(init=False) 2301class ProductDefinitionTemplate48(ProductDefinitionTemplateBase,ProductDefinitionTemplateSurface): 2302 """[Product Definition Template 48](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-48.shtml)""" 2303 _len = 26 2304 _num = 48 2305 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2306 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2307 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2308 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2309 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2310 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2311 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2312 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2313 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2314 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2315 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2316 @classmethod 2317 def _attrs(cls): 2318 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2320@dataclass(init=False) 2321class ProductDefinitionTemplate46(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2322 """[Product Definition Template 4.46](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-46.shtml)""" 2323 _len = 38 # Total number of octets 2324 _num = 46 2325 2326 # Aerosol-specific parameters 2327 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2328 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2329 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2330 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2331 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2332 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2333 # Time interval parameters 2334 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2335 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2336 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2337 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2338 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2339 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2340 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2341 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2342 # Statistical processing parameters 2343 typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing()) 2344 numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing()) 2345 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2346 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2347 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2348 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2349 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2350 @classmethod 2351 def _attrs(cls): 2352 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2356@dataclass(init=False) 2357class ProductDefinitionTemplate47(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2358 """[Product Definition Template 4.47](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-47.shtml)""" 2359 _len = 41 # Total number of octets for base template 2360 _num = 47 2361 2362 # Aerosol parameters 2363 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2364 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2365 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2366 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2367 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2368 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2369 2370 # Ensemble parameters 2371 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2372 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2373 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2374 2375 # Time interval parameters 2376 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2377 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2378 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2379 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2380 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2381 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2382 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2383 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2384 # Statistical processing parameters 2385 typeOfStatisticalProcessing: Grib2Metadata = field(init=False, repr=False, default=TypeOfStatisticalProcessing()) 2386 numberOfDataPointsForSpatialProcessing: int = field(init=False, repr=False, default=NumberOfDataPointsForSpatialProcessing()) 2387 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2388 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2389 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2390 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2391 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields()) 2392 @classmethod 2393 def _attrs(cls): 2394 return [key for key in cls.__dataclass_fields__.keys() if not key.startswith('_')]
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2396@dataclass(init=False) 2397class ProductDefinitionTemplate49(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2398 """[Product Definition Template 4.49](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-49.shtml)""" 2399 _len = 28 2400 _num = 49 2401 2402 # Aerosol parameters 2403 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2404 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2405 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2406 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2407 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2408 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2409 2410 # Wavelength parameters 2411 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2412 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2413 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2414 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2415 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2416 2417 # Ensemble parameters 2418 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2419 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2420 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts())
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2422@dataclass(init=False) 2423class ProductDefinitionTemplate80(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2424 """[Product Definition Template 4.80](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-80.shtml)""" 2425 _len = 26 2426 _num = 80 2427 2428 # Aerosol parameters 2429 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2430 sourceSinkIndicator: Grib2Metadata = field(init=False, repr=False, default=SourceSinkIndicator()) 2431 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2432 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2433 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2434 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2435 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2436 2437 # Wavelength parameters 2438 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2439 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2440 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2441 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2442 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength())
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2444@dataclass(init=False) 2445class ProductDefinitionTemplate81(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2446 """[Product Definition Template 4.81](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-81.shtml)""" 2447 _len = 31 2448 _num = 81 2449 2450 # Aerosol parameters 2451 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2452 sourceSinkIndicator: Grib2Metadata = field(init=False, repr=False, default=SourceSinkIndicator()) 2453 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2454 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2455 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2456 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2457 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2458 2459 # Wavelength parameters 2460 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2461 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2462 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2463 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2464 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2465 2466 # Ensemble parameters 2467 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2468 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2469 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts())
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2471@dataclass(init=False) 2472class ProductDefinitionTemplate82(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2473 """[Product Definition Template 4.82](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-82.shtml)""" 2474 _len = 41 2475 _num = 82 2476 2477 # Aerosol parameters 2478 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2479 sourceSinkIndicator: Grib2Metadata = field(init=False, repr=False, default=SourceSinkIndicator()) 2480 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2481 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2482 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2483 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2484 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2485 2486 # Wavelength parameters 2487 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2488 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2489 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2490 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2491 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2492 2493 # Time interval parameters 2494 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2495 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2496 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2497 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2498 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2499 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2500 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2501 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2502 2503 # Statistical processing parameters 2504 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2505 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2506 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2507 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2508 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2509 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2510 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2511 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields())
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2513@dataclass(init=False) 2514class ProductDefinitionTemplate83(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2515 """[Product Definition Template 4.83](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-83.shtml)""" 2516 _len = 44 2517 _num = 83 2518 2519 # Aerosol parameters 2520 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2521 sourceSinkIndicator: Grib2Metadata = field(init=False, repr=False, default=SourceSinkIndicator()) 2522 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2523 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2524 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2525 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2526 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2527 2528 # Wavelength parameters 2529 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2530 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2531 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2532 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2533 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2534 2535 # Ensemble parameters 2536 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2537 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2538 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2539 2540 # Time interval parameters 2541 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2542 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2543 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2544 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2545 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2546 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2547 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2548 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues())
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2550@dataclass(init=False) 2551class ProductDefinitionTemplate84(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2552 """[Product Definition Template 4.84](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-84.shtml)""" 2553 _len = 44 2554 _num = 84 2555 2556 # Aerosol parameters 2557 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2558 sourceSinkIndicator: Grib2Metadata = field(init=False, repr=False, default=SourceSinkIndicator()) 2559 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2560 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2561 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2562 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2563 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2564 2565 # Wavelength parameters 2566 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2567 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2568 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2569 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2570 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2571 2572 # Ensemble parameters 2573 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2574 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2575 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts()) 2576 2577 # Time interval parameters 2578 yearOfEndOfTimePeriod: int = field(init=False, repr=False, default=YearOfEndOfTimePeriod()) 2579 monthOfEndOfTimePeriod: int = field(init=False, repr=False, default=MonthOfEndOfTimePeriod()) 2580 dayOfEndOfTimePeriod: int = field(init=False, repr=False, default=DayOfEndOfTimePeriod()) 2581 hourOfEndOfTimePeriod: int = field(init=False, repr=False, default=HourOfEndOfTimePeriod()) 2582 minuteOfEndOfTimePeriod: int = field(init=False, repr=False, default=MinuteOfEndOfTimePeriod()) 2583 secondOfEndOfTimePeriod: int = field(init=False, repr=False, default=SecondOfEndOfTimePeriod()) 2584 2585 # Statistical processing parameters 2586 numberOfTimeRanges: int = field(init=False, repr=False, default=NumberOfTimeRanges()) 2587 numberOfMissingValues: int = field(init=False, repr=False, default=NumberOfMissingValues()) 2588 statisticalProcess: Grib2Metadata = field(init=False, repr=False, default=StatisticalProcess()) 2589 typeOfTimeIncrementOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=TypeOfTimeIncrementOfStatisticalProcess()) 2590 unitOfTimeRangeOfStatisticalProcess: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfStatisticalProcess()) 2591 timeRangeOfStatisticalProcess: int = field(init=False, repr=False, default=TimeRangeOfStatisticalProcess()) 2592 unitOfTimeRangeOfSuccessiveFields: Grib2Metadata = field(init=False, repr=False, default=UnitOfTimeRangeOfSuccessiveFields()) 2593 timeIncrementOfSuccessiveFields: int = field(init=False, repr=False, default=TimeIncrementOfSuccessiveFields())
Number of time ranges specifications describing the time intervals used to calculate the statistically-processed field
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2595@dataclass(init=False) 2596class ProductDefinitionTemplate85(ProductDefinitionTemplateBase, ProductDefinitionTemplateSurface): 2597 """[Product Definition Template 4.85](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-85.shtml)""" 2598 _len = 33 2599 _num = 85 2600 2601 # Aerosol parameters 2602 typeOfAerosol: Grib2Metadata = field(init=False, repr=False, default=TypeOfAerosol()) 2603 sourceSinkIndicator: Grib2Metadata = field(init=False, repr=False, default=SourceSinkIndicator()) 2604 typeOfIntervalForAerosolSize: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolSize()) 2605 scaleFactorOfFirstSize: int = field(init=False, repr=False, default=ScaleFactorOfFirstSize()) 2606 scaledValueOfFirstSize: int = field(init=False, repr=False, default=ScaledValueOfFirstSize()) 2607 scaleFactorOfSecondSize: int = field(init=False, repr=False, default=ScaleFactorOfSecondSize()) 2608 scaledValueOfSecondSize: int = field(init=False, repr=False, default=ScaledValueOfSecondSize()) 2609 2610 # Wavelength parameters 2611 typeOfIntervalForAerosolWavelength: Grib2Metadata = field(init=False, repr=False, default=TypeOfIntervalForAerosolWavelength()) 2612 scaleFactorOfFirstWavelength: int = field(init=False, repr=False, default=ScaleFactorOfFirstWavelength()) 2613 scaledValueOfFirstWavelength: int = field(init=False, repr=False, default=ScaledValueOfFirstWavelength()) 2614 scaleFactorOfSecondWavelength: int = field(init=False, repr=False, default=ScaleFactorOfSecondWavelength()) 2615 scaledValueOfSecondWavelength: int = field(init=False, repr=False, default=ScaledValueOfSecondWavelength()) 2616 2617 # Ensemble parameters 2618 typeOfEnsembleForecast: Grib2Metadata = field(init=False, repr=False, default=TypeOfEnsembleForecast()) 2619 perturbationNumber: int = field(init=False, repr=False, default=PerturbationNumber()) 2620 numberOfEnsembleForecasts: int = field(init=False, repr=False, default=NumberOfEnsembleForecasts())
Inherited Members
- ProductDefinitionTemplateBase
- fullName
- units
- shortName
- leadTime
- duration
- validDate
- level
- parameterCategory
- parameterNumber
- typeOfGeneratingProcess
- generatingProcess
- backgroundGeneratingProcessIdentifier
- hoursAfterDataCutoff
- minutesAfterDataCutoff
- unitOfForecastTime
- valueOfForecastTime
- ProductDefinitionTemplateSurface
- typeOfFirstFixedSurface
- scaleFactorOfFirstFixedSurface
- scaledValueOfFirstFixedSurface
- typeOfSecondFixedSurface
- scaleFactorOfSecondFixedSurface
- scaledValueOfSecondFixedSurface
- unitOfFirstFixedSurface
- valueOfFirstFixedSurface
- unitOfSecondFixedSurface
- valueOfSecondFixedSurface
2648def pdt_class_by_pdtn(pdtn: int): 2649 """ 2650 Provide a Product Definition Template class via the template number. 2651 2652 Parameters 2653 ---------- 2654 pdtn 2655 Product definition template number. 2656 2657 Returns 2658 ------- 2659 pdt_class_by_pdtn 2660 Product definition template class object (not an instance). 2661 """ 2662 return _pdt_by_pdtn[pdtn]
Provide a Product Definition Template class via the template number.
Parameters
- pdtn: Product definition template number.
Returns
- pdt_class_by_pdtn: Product definition template class object (not an instance).
2667class NumberOfPackedValues: 2668 """Number of Packed Values""" 2669 def __get__(self, obj, objtype=None): 2670 return obj.section5[0] 2671 def __set__(self, obj, value): 2672 pass
Number of Packed Values
2674class DataRepresentationTemplateNumber: 2675 """[Data Representation Template Number](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-0.shtml)""" 2676 def __get__(self, obj, objtype=None): 2677 return Grib2Metadata(obj.section5[1],table='5.0') 2678 def __set__(self, obj, value): 2679 pass
2681class DataRepresentationTemplate: 2682 """Data Representation Template""" 2683 def __get__(self, obj, objtype=None): 2684 return obj.section5[2:] 2685 def __set__(self, obj, value): 2686 raise NotImplementedError
Data Representation Template
2688class RefValue: 2689 """Reference Value (represented as an IEEE 32-bit floating point value)""" 2690 def __get__(self, obj, objtype=None): 2691 return utils.ieee_int_to_float(obj.section5[0+2]) 2692 def __set__(self, obj, value): 2693 pass
Reference Value (represented as an IEEE 32-bit floating point value)
2695class BinScaleFactor: 2696 """Binary Scale Factor""" 2697 def __get__(self, obj, objtype=None): 2698 return obj.section5[1+2] 2699 def __set__(self, obj, value): 2700 obj.section5[1+2] = value
Binary Scale Factor
2702class DecScaleFactor: 2703 """Decimal Scale Factor""" 2704 def __get__(self, obj, objtype=None): 2705 return obj.section5[2+2] 2706 def __set__(self, obj, value): 2707 obj.section5[2+2] = value
Decimal Scale Factor
2709class NBitsPacking: 2710 """Minimum number of bits for packing""" 2711 def __get__(self, obj, objtype=None): 2712 return obj.section5[3+2] 2713 def __set__(self, obj, value): 2714 obj.section5[3+2] = value
Minimum number of bits for packing
2716class TypeOfValues: 2717 """[Type of Original Field Values](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-1.shtml)""" 2718 def __get__(self, obj, objtype=None): 2719 return Grib2Metadata(obj.section5[4+2],table='5.1') 2720 def __set__(self, obj, value): 2721 obj.section5[4+2] = value
2723class GroupSplittingMethod: 2724 """[Group Splitting Method](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-4.shtml)""" 2725 def __get__(self, obj, objtype=None): 2726 return Grib2Metadata(obj.section5[5+2],table='5.4') 2727 def __set__(self, obj, value): 2728 obj.section5[5+2] = value
2730class TypeOfMissingValueManagement: 2731 """[Type of Missing Value Management](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-5.shtml)""" 2732 def __get__(self, obj, objtype=None): 2733 return Grib2Metadata(obj.section5[6+2],table='5.5') 2734 def __set__(self, obj, value): 2735 obj.section5[6+2] = value
2737class PriMissingValue: 2738 """Primary Missing Value""" 2739 def __get__(self, obj, objtype=None): 2740 if obj.typeOfValues == 0: 2741 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 2742 elif obj.typeOfValues == 1: 2743 return obj.section5[7+2] if obj.section5[6+2] in [1,2] else None 2744 def __set__(self, obj, value): 2745 if obj.typeOfValues == 0: 2746 obj.section5[7+2] = utils.ieee_float_to_int(value) 2747 elif self.typeOfValues == 1: 2748 obj.section5[7+2] = int(value) 2749 obj.section5[6+2] = 1
Primary Missing Value
2751class SecMissingValue: 2752 """Secondary Missing Value""" 2753 def __get__(self, obj, objtype=None): 2754 if obj.typeOfValues == 0: 2755 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 2756 elif obj.typeOfValues == 1: 2757 return obj.section5[8+2] if obj.section5[6+2] in {1,2} else None 2758 def __set__(self, obj, value): 2759 if obj.typeOfValues == 0: 2760 obj.section5[8+2] = utils.ieee_float_to_int(value) 2761 elif self.typeOfValues == 1: 2762 obj.section5[8+2] = int(value) 2763 obj.section5[6+2] = 2
Secondary Missing Value
2765class NGroups: 2766 """Number of Groups""" 2767 def __get__(self, obj, objtype=None): 2768 return obj.section5[9+2] 2769 def __set__(self, obj, value): 2770 pass
Number of Groups
2772class RefGroupWidth: 2773 """Reference Group Width""" 2774 def __get__(self, obj, objtype=None): 2775 return obj.section5[10+2] 2776 def __set__(self, obj, value): 2777 pass
Reference Group Width
2779class NBitsGroupWidth: 2780 """Number of bits for Group Width""" 2781 def __get__(self, obj, objtype=None): 2782 return obj.section5[11+2] 2783 def __set__(self, obj, value): 2784 pass
Number of bits for Group Width
2786class RefGroupLength: 2787 """Reference Group Length""" 2788 def __get__(self, obj, objtype=None): 2789 return obj.section5[12+2] 2790 def __set__(self, obj, value): 2791 pass
Reference Group Length
2793class GroupLengthIncrement: 2794 """Group Length Increment""" 2795 def __get__(self, obj, objtype=None): 2796 return obj.section5[13+2] 2797 def __set__(self, obj, value): 2798 pass
Group Length Increment
2800class LengthOfLastGroup: 2801 """Length of Last Group""" 2802 def __get__(self, obj, objtype=None): 2803 return obj.section5[14+2] 2804 def __set__(self, obj, value): 2805 pass
Length of Last Group
2807class NBitsScaledGroupLength: 2808 """Number of bits of Scaled Group Length""" 2809 def __get__(self, obj, objtype=None): 2810 return obj.section5[15+2] 2811 def __set__(self, obj, value): 2812 pass
Number of bits of Scaled Group Length
2814class SpatialDifferenceOrder: 2815 """[Spatial Difference Order](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-6.shtml)""" 2816 def __get__(self, obj, objtype=None): 2817 return Grib2Metadata(obj.section5[16+2],table='5.6') 2818 def __set__(self, obj, value): 2819 obj.section5[16+2] = value
2821class NBytesSpatialDifference: 2822 """Number of bytes for Spatial Differencing""" 2823 def __get__(self, obj, objtype=None): 2824 return obj.section5[17+2] 2825 def __set__(self, obj, value): 2826 pass
Number of bytes for Spatial Differencing
2828class Precision: 2829 """[Precision for IEEE Floating Point Data](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-7.shtml)""" 2830 def __get__(self, obj, objtype=None): 2831 return Grib2Metadata(obj.section5[0+2],table='5.7') 2832 def __set__(self, obj, value): 2833 obj.section5[0+2] = value
2835class TypeOfCompression: 2836 """[Type of Compression](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table5-40.shtml)""" 2837 def __get__(self, obj, objtype=None): 2838 return Grib2Metadata(obj.section5[5+2],table='5.40') 2839 def __set__(self, obj, value): 2840 obj.section5[5+2] = value
2842class TargetCompressionRatio: 2843 """Target Compression Ratio""" 2844 def __get__(self, obj, objtype=None): 2845 return obj.section5[6+2] 2846 def __set__(self, obj, value): 2847 pass
Target Compression Ratio
2849class RealOfCoefficient: 2850 """Real of Coefficient""" 2851 def __get__(self, obj, objtype=None): 2852 return utils.ieee_int_to_float(obj.section5[4+2]) 2853 def __set__(self, obj, value): 2854 obj.section5[4+2] = utils.ieee_float_to_int(float(value))
Real of Coefficient
2856class CompressionOptionsMask: 2857 """Compression Options Mask for AEC/CCSDS""" 2858 def __get__(self, obj, objtype=None): 2859 return obj.section5[5+2] 2860 def __set__(self, obj, value): 2861 obj.section5[5+2] = value
Compression Options Mask for AEC/CCSDS
2863class BlockSize: 2864 """Block Size for AEC/CCSDS""" 2865 def __get__(self, obj, objtype=None): 2866 return obj.section5[6+2] 2867 def __set__(self, obj, value): 2868 obj.section5[6+2] = value
Block Size for AEC/CCSDS
2870class RefSampleInterval: 2871 """Reference Sample Interval for AEC/CCSDS""" 2872 def __get__(self, obj, objtype=None): 2873 return obj.section5[7+2] 2874 def __set__(self, obj, value): 2875 obj.section5[7+2] = value
Reference Sample Interval for AEC/CCSDS
2877@dataclass(init=False) 2878class DataRepresentationTemplate0: 2879 """[Data Representation Template 0](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-0.shtml)""" 2880 _len = 5 2881 _num = 0 2882 _packingScheme = 'simple' 2883 refValue: float = field(init=False, repr=False, default=RefValue()) 2884 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2885 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2886 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2887 @classmethod 2888 def _attrs(cls): 2889 return list(cls.__dataclass_fields__.keys())
2891@dataclass(init=False) 2892class DataRepresentationTemplate2: 2893 """[Data Representation Template 2](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-2.shtml)""" 2894 _len = 16 2895 _num = 2 2896 _packingScheme = 'complex' 2897 refValue: float = field(init=False, repr=False, default=RefValue()) 2898 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2899 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2900 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2901 groupSplittingMethod: Grib2Metadata = field(init=False, repr=False, default=GroupSplittingMethod()) 2902 typeOfMissingValueManagement: Grib2Metadata = field(init=False, repr=False, default=TypeOfMissingValueManagement()) 2903 priMissingValue: Union[float, int] = field(init=False, repr=False, default=PriMissingValue()) 2904 secMissingValue: Union[float, int] = field(init=False, repr=False, default=SecMissingValue()) 2905 nGroups: int = field(init=False, repr=False, default=NGroups()) 2906 refGroupWidth: int = field(init=False, repr=False, default=RefGroupWidth()) 2907 nBitsGroupWidth: int = field(init=False, repr=False, default=NBitsGroupWidth()) 2908 refGroupLength: int = field(init=False, repr=False, default=RefGroupLength()) 2909 groupLengthIncrement: int = field(init=False, repr=False, default=GroupLengthIncrement()) 2910 lengthOfLastGroup: int = field(init=False, repr=False, default=LengthOfLastGroup()) 2911 nBitsScaledGroupLength: int = field(init=False, repr=False, default=NBitsScaledGroupLength()) 2912 @classmethod 2913 def _attrs(cls): 2914 return list(cls.__dataclass_fields__.keys())
2916@dataclass(init=False) 2917class DataRepresentationTemplate3: 2918 """[Data Representation Template 3](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-3.shtml)""" 2919 _len = 18 2920 _num = 3 2921 _packingScheme = 'complex-spdiff' 2922 refValue: float = field(init=False, repr=False, default=RefValue()) 2923 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2924 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2925 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2926 groupSplittingMethod: Grib2Metadata = field(init=False, repr=False, default=GroupSplittingMethod()) 2927 typeOfMissingValueManagement: Grib2Metadata = field(init=False, repr=False, default=TypeOfMissingValueManagement()) 2928 priMissingValue: Union[float, int] = field(init=False, repr=False, default=PriMissingValue()) 2929 secMissingValue: Union[float, int] = field(init=False, repr=False, default=SecMissingValue()) 2930 nGroups: int = field(init=False, repr=False, default=NGroups()) 2931 refGroupWidth: int = field(init=False, repr=False, default=RefGroupWidth()) 2932 nBitsGroupWidth: int = field(init=False, repr=False, default=NBitsGroupWidth()) 2933 refGroupLength: int = field(init=False, repr=False, default=RefGroupLength()) 2934 groupLengthIncrement: int = field(init=False, repr=False, default=GroupLengthIncrement()) 2935 lengthOfLastGroup: int = field(init=False, repr=False, default=LengthOfLastGroup()) 2936 nBitsScaledGroupLength: int = field(init=False, repr=False, default=NBitsScaledGroupLength()) 2937 spatialDifferenceOrder: Grib2Metadata = field(init=False, repr=False, default=SpatialDifferenceOrder()) 2938 nBytesSpatialDifference: int = field(init=False, repr=False, default=NBytesSpatialDifference()) 2939 @classmethod 2940 def _attrs(cls): 2941 return list(cls.__dataclass_fields__.keys())
2943@dataclass(init=False) 2944class DataRepresentationTemplate4: 2945 """[Data Representation Template 4](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-4.shtml)""" 2946 _len = 1 2947 _num = 4 2948 _packingScheme = 'ieee-float' 2949 precision: Grib2Metadata = field(init=False, repr=False, default=Precision()) 2950 @classmethod 2951 def _attrs(cls): 2952 return list(cls.__dataclass_fields__.keys())
2954@dataclass(init=False) 2955class DataRepresentationTemplate40: 2956 """[Data Representation Template 40](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-40.shtml)""" 2957 _len = 7 2958 _num = 40 2959 _packingScheme = 'jpeg' 2960 refValue: float = field(init=False, repr=False, default=RefValue()) 2961 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2962 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2963 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2964 typeOfCompression: Grib2Metadata = field(init=False, repr=False, default=TypeOfCompression()) 2965 targetCompressionRatio: int = field(init=False, repr=False, default=TargetCompressionRatio()) 2966 @classmethod 2967 def _attrs(cls): 2968 return list(cls.__dataclass_fields__.keys())
2970@dataclass(init=False) 2971class DataRepresentationTemplate41: 2972 """[Data Representation Template 41](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-41.shtml)""" 2973 _len = 5 2974 _num = 41 2975 _packingScheme = 'png' 2976 refValue: float = field(init=False, repr=False, default=RefValue()) 2977 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2978 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2979 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2980 @classmethod 2981 def _attrs(cls): 2982 return list(cls.__dataclass_fields__.keys())
2984@dataclass(init=False) 2985class DataRepresentationTemplate42: 2986 """[Data Representation Template 42](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-42.shtml)""" 2987 _len = 8 2988 _num = 42 2989 _packingScheme = 'aec' 2990 refValue: float = field(init=False, repr=False, default=RefValue()) 2991 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 2992 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 2993 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 2994 compressionOptionsMask: int = field(init=False, repr=False, default=CompressionOptionsMask()) 2995 blockSize: int = field(init=False, repr=False, default=BlockSize()) 2996 refSampleInterval: int = field(init=False, repr=False, default=RefSampleInterval()) 2997 @classmethod 2998 def _attrs(cls): 2999 return list(cls.__dataclass_fields__.keys())
3001@dataclass(init=False) 3002class DataRepresentationTemplate50: 3003 """[Data Representation Template 50](https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp5-50.shtml)""" 3004 _len = 5 3005 _num = 0 3006 _packingScheme = 'spectral-simple' 3007 refValue: float = field(init=False, repr=False, default=RefValue()) 3008 binScaleFactor: int = field(init=False, repr=False, default=BinScaleFactor()) 3009 decScaleFactor: int = field(init=False, repr=False, default=DecScaleFactor()) 3010 nBitsPacking: int = field(init=False, repr=False, default=NBitsPacking()) 3011 realOfCoefficient: float = field(init=False, repr=False, default=RealOfCoefficient()) 3012 @classmethod 3013 def _attrs(cls): 3014 return list(cls.__dataclass_fields__.keys())
3027def drt_class_by_drtn(drtn: int): 3028 """ 3029 Provide a Data Representation Template class via the template number. 3030 3031 Parameters 3032 ---------- 3033 drtn 3034 Data Representation template number. 3035 3036 Returns 3037 ------- 3038 drt_class_by_drtn 3039 Data Representation template class object (not an instance). 3040 """ 3041 return _drt_by_drtn[drtn]
Provide a Data Representation Template class via the template number.
Parameters
- drtn: Data Representation template number.
Returns
- drt_class_by_drtn: Data Representation template class object (not an instance).