26 lines
528 B
Go
26 lines
528 B
Go
package grib
|
|
|
|
import (
|
|
"fmt"
|
|
"hash/fnv"
|
|
"time"
|
|
)
|
|
|
|
var steps = []int{0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48}
|
|
|
|
func nearestRun(t time.Time) time.Time {
|
|
h := t.UTC().Hour() - t.UTC().Hour()%6
|
|
return time.Date(t.Year(), t.Month(), t.Day(), h, 0, 0, 0, time.UTC)
|
|
}
|
|
|
|
func fileName(run time.Time, step int) string {
|
|
return fmt.Sprintf("gfs.t%02dz.pgrb2.0p50.f%03d", run.Hour(), step)
|
|
}
|
|
|
|
func encodeKey(a ...any) uint64 {
|
|
h := fnv.New64a()
|
|
for _, v := range a {
|
|
fmt.Fprint(h, v)
|
|
}
|
|
return h.Sum64()
|
|
}
|