Hello,
I am experiencing some difficulty reading some data sets in grib2 format and
I’m hoping someone can point out what I am doing wrong.
I have been working with several MRMS grid tables (
https://mrms.ncep.noaa.gov/data/2D/ ) and most of them are working just fine.
However, I have run into some trouble with the Model_WetBulbTemp data table
where NetCDF-Java seems to be returning spurious data.
I have written a function in Kotlin which illustrates the issue, showing the
number of unique values in the data set and a subset of the range:
fun examineWetBulb() {
val wetBulb = NetcdfFile.open("/tmp/MRMS_Model_WetBulbTemp.latest.grib2")
val valueSet = mutableSetOf<Float>()
val variable = wetBulb.findVariable("ModelWetBulbTemp_altitude_above_msl")
val varArray = variable.read()
for (x in 0 until variable.dimensions[2].length) {
for (y in 0 until variable.dimensions[3].length) {
val degC = varArray.getFloat(varArray.index.set(0, 0, x, y))
valueSet.add(degC)
}
}
println(valueSet.size)
println(valueSet.filterIndexed { i, _ -> i % 25 == 0 })
}
When I execute this function, I see the following output:
256
[-999.0, -997.19, -998.65, -997.73, -997.48, -997.36, -997.13, -998.47,
-998.56, -996.51, -998.86]
However, if I use an alternate implementation such as PyGRIB, I see values
which look more likely to be correct:
>>> import pygrib
>>> wet_bulb = pygrib.open('/tmp/MRMS_Model_WetBulbTemp.latest.grib2')[1]
>>> uniq_vals = sorted(set(wet_bulb.values.flatten()))
>>> len(uniq_vals)
5168
>>> uniq_vals[0:-1:500]
[-999.0, -20.78, -15.780000000000001, -10.78, -5.78, -0.78, 4.22, 9.22, 14.22,
19.22, 24.22]
For what it's worth, when I plot this grib2 file using Panoply, I get a similar
result as for the NetCDF-Java case: https://i.imgur.com/xnLtxOD.png
I am using Java 8, Kotlin 1.3, and in my pom.xml file I have the following
dependency:
<dependency>
<groupId>edu.ucar</groupId>
<artifactId>grib</artifactId>
<version>5.2.0</version>
</dependency>
</dependencies>
Has anyone seen this kind of problem before?
Thanks,
--Jeramey
--
Jeramey Crawford
Vaisala Digital
Vaisala, Inc., Seattle, WA