weech / GRIB.jl

GRIB Interface for Julia
Apache License 2.0
22 stars 2 forks source link

Key not found when parsing a message #7

Closed rustyconover closed 4 years ago

rustyconover commented 4 years ago

Hi @weech,

I'm continuing on my HRRR workflow but it seems I'm missing a field from the parsed messages:

Some wgrib2 output for table of contents:

72:40679141:d=2020091100:VGRD V-Component of Wind [m/s]:10 m above ground:anl:
73:41660035:d=2020091100:WIND Wind Speed [m/s]:10 m above ground:0-0 day max fcst:
74:42680300:d=2020091100:MAXUW U Component of Hourly Maximum 10m Wind Speed [m/s]:10 m above ground:0-0 day max fcst:
75:43686727:d=2020091100:MAXVW V Component of Hourly Maximum 10m Wind Speed [m/s]:10 m above ground:0-0 day max fcst:

Do you see that field that contains "anl' or "0-0 day max fcst" parsing out all of the fields from a messages that doesn't appear to be included. Here are the values that I did find omitting a few large values:

7777 7777
alternativeRowScanning 0
angleSubdivisions 1000000
average 11.78039109366541
backgroundProcess 0
binaryScaleFactor -4
bitMapIndicator 255
bitsPerValue 10
bottomLevel 250
centre kwbc
centreDescription US National Weather Service - NCEP 
cfName eastward_wind
cfNameECMF eastward_wind
cfVarName u
cfVarNameECMF u
changeDecimalPrecision 0
dataDate 20200911
dataRepresentationTemplateNumber 3
dataTime 0
day 11
decimalPrecision 0
decimalScaleFactor 0
deleteCalendarId 0
deleteLocalDefinition 0
deletePV 1
discipline 0
Dx 3000000
DxInMetres 3000.0
Dy 3000000
DyInMetres 3000.0
editionNumber 2
endStep 0
forecastTime 0
generatingProcessIdentifier 83
genVertHeightCoords 0
getNumberOfValues 1905141
globalDomain g
grib2divider 1000000
grib2LocalSectionPresent 0
GRIBEditionNumber 2
gridDefinitionDescription Lambert Conformal can be secant or tangent, conical or bipolar
gridDefinitionTemplateNumber 30
gridDescriptionSectionPresent 1
gridType lambert
groupSplittingMethodUsed 1
hour 0
hoursAfterDataCutoff 0
identifier GRIB
iDirectionIncrementGiven 0
ieeeFloats 1
ifsParam 131
ijDirectionIncrementGiven 0
indicatorOfUnitOfTimeRange 1
interpretationOfNumberOfPoints 0
is_aerosol 0
is_aerosol_optical 0
is_chemical 0
is_chemical_distfn 0
is_efas 0
is_uerra 0
iScansNegatively 0
iScansPositively 1
isConstant 0.0
isHindcast 0
jDirectionIncrementGiven 0
jPointsAreConsecutive 0
jScansPositively 1
julianDay 2.4591035e6
kurtosis 0.8099556435428337
LaD 38500000
LaDInDegrees 38.5
Latin1 38500000
Latin1InDegrees 38.5
Latin2 38500000
Latin2InDegrees 38.5
latitudeOfFirstGridPoint 21138123
latitudeOfFirstGridPointInDegrees 21.138123
latitudeOfSouthernPole 0
latitudeOfSouthernPoleInDegrees 0.0
lengthIncrementForTheGroupLengths 1
lengthOfHeaders 136
level 250
localDir grib2/tables/local/[centre]/[localTablesVersion]
localTablesVersion 1
longitudeOfFirstGridPoint 237280472
longitudeOfFirstGridPointInDegrees 237.280472
longitudeOfSouthernPole 0
longitudeOfSouthernPoleInDegrees 0.0
LoV 262500000
LoVInDegrees 262.5
masterDir grib2/tables/[tablesVersion]
maximum 66.19209671020508
md5Headers 005af0e7d154499c1609d525546854ea
md5Section1 189d5f7438ba6a4f10c886fd7f5894ae
md5Section3 78367561440d7c7b608b8532a02e4780
md5Section4 59e73b254567ff9ee7e06a4b9757a230
md5Section5 3b99042055a1d5f7d4e2bda677133b6f
md5Section6 01522c0fd43e4befb347e7995baa0167
md5Section7 a2d80a3012d6586a0eb4e978ba24a042
minimum -21.370403289794922
minute 0
minutesAfterDataCutoff 0
missingValue 9999
missingValueManagementUsed 0
missingValuesPresent [0, 0]
modelName unknown
month 9
name U component of wind
nameECMF U component of wind
nameOfFirstFixedSurface Isobaric surface 
nameOfSecondFixedSurface Missing
neitherPresent 0
numberOfBitsForScaledGroupLengths 7
numberOfBitsUsedForTheGroupWidths 4
numberOfDataPoints 1905141
numberOfGroupsOfDataValues 62618
numberOfMissing 0
numberOfOctectsForNumberOfPoints 0
numberOfOctetsExtraDescriptors 2
numberOfSection [1, 3, 4, 5, 6, 7]
numberOfValues 1905141
NV 0
Nx 1799
Ny 1059
offsetValuesBy 0.0
optimizeScaleFactor 0
orderOfSpatialDifferencing 2
packingType grid_complex_spatial_differencing
parameterCategory 2
parameterName u-component of wind 
parameterNumber 2
parameterUnits m s-1
paramId 131
paramIdECMF 131
PLPresent 0
pressureUnits hPa
primaryMissingValueSubstitute 0
productDefinitionTemplateNumber 0
productionStatusOfProcessedData 0
productType unknown
projectionCentreFlag 0
PVPresent 0
radius 6371229
referenceForGroupLengths 1
referenceForGroupWidths 0
referenceValue -21.370403289794922
referenceValueError 1.9073486328125e-6
resolutionAndComponentFlags 8
resolutionAndComponentFlags1 0
resolutionAndComponentFlags2 0
resolutionAndComponentFlags6 0
resolutionAndComponentFlags7 0
resolutionAndComponentFlags8 0
scaledValueOfEarthMajorAxis 0
scaledValueOfEarthMinorAxis 0
scaledValueOfFirstFixedSurface 25000
scaledValueOfRadiusOfSphericalEarth 0
scaledValueOfSecondFixedSurface 0
scaleFactorOfEarthMajorAxis 0
scaleFactorOfEarthMinorAxis 0
scaleFactorOfFirstFixedSurface 0
scaleFactorOfRadiusOfSphericalEarth 0
scaleFactorOfSecondFixedSurface 0
scaleValuesBy 1.0
scanningMode 64
scanningMode5 0
scanningMode6 0
scanningMode7 0
scanningMode8 0
second 0
secondaryMissingValueSubstitute 0
section0Length 16
section1Length 21
section3Length 81
section3Padding UInt8[]
section4Length 34
section5Length 49
section6Length 6
section7Length 635589
section8Length 4
sectionNumber [1, 3, 3, 4, 5, 6, 7]
selectStepTemplateInstant 1
selectStepTemplateInterval 1
setBitsPerValue 10
setCalendarId 0
shapeOfTheEarth 6
shortName u
shortNameECMF u
significanceOfReferenceTime 1
skewness 1.0168379773898042
sourceOfGridDefinition 0
standardDeviation 16.274422744167317
startStep 0
stepRange 0
stepType instant
stepTypeInternal instant
stepUnits 1
subCentre 0
tablesVersion 2
tablesVersionLatest 25
tempPressureUnits hPa
topLevel 250
totalLength 635800
trueLengthOfLastGroup 27
typeOfFirstFixedSurface pl
typeOfGeneratingProcess 2
typeOfLevel isobaricInhPa
typeOfOriginalFieldValues 0
typeOfProcessedData fc
typeOfSecondFixedSurface 255
units m s**-1
unitsECMF m s**-1
unitsOfFirstFixedSurface Pa
unitsOfSecondFixedSurface unknown
uvRelativeToGrid 1
validityDate 20200911
validityTime 0
year 2020
weech commented 4 years ago

It looks like that piece of information is a function of productDefinitionTemplateNumber and the special values in the product definition template. The equivalent information is in stepType and stepRange. In the stepType key, wgrib2 uses "anl" for analysis and ecCodes uses "instant". They both use "max" for maximum. The stepRange should always be zero for an analysis product type, and in this file the statistical product types are all just 0 (the first time step only). wgrib2 reports this as "0-0 fcst", and ecCodes just gives "0". I presume that when more time steps are integrated ecCodes gives a range (like "0-6"). That is if I'm interpreting what wgrib2 is printing correctly. It could also being doing math to include how far out the forecast is, in which case the forecastTime would be added to it.

rustyconover commented 4 years ago

I hate to be a real bother with these questions thanks for your reply.

Reading through the wgrib2 source code is an adventure.

rustyconover commented 4 years ago

Right now I can work around this... later on when I start using different GRIBs with different forecast time windows I'll revisit it.

weech commented 4 years ago

I'm glad to help!