forked from gsn/predictor
38 lines
797 B
Go
38 lines
797 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/nilsmagnus/grib/griblib"
|
|
)
|
|
|
|
func main() {
|
|
f, err := os.Open("C:/tmp/grib/gfs.t18z.pgrb2.0p25.f000")
|
|
if err != nil {
|
|
fmt.Printf("Error opening file: %v\n", err)
|
|
return
|
|
}
|
|
defer f.Close()
|
|
|
|
messages, err := griblib.ReadMessages(f)
|
|
if err != nil {
|
|
fmt.Printf("Error reading GRIB: %v\n", err)
|
|
return
|
|
}
|
|
|
|
fmt.Printf("Found %d messages\n\n", len(messages))
|
|
|
|
for i, m := range messages {
|
|
product := m.Section4.ProductDefinitionTemplate
|
|
if product.ParameterCategory != 2 || product.ParameterNumber != 2 {
|
|
continue // only u-wind
|
|
}
|
|
fmt.Printf("UGRD Msg %d: SurfType=%d SurfValue=%d SurfScale=%d DataLen=%d\n",
|
|
i,
|
|
product.FirstSurface.Type,
|
|
product.FirstSurface.Value,
|
|
product.FirstSurface.Scale,
|
|
len(m.Data()))
|
|
}
|
|
}
|