updated downloader

This commit is contained in:
straitz 2026-03-22 16:29:53 +09:00
parent ca95e06ab7
commit 8e9f117799
30 changed files with 1209 additions and 698 deletions

55
scripts/test_wind.go Normal file
View file

@ -0,0 +1,55 @@
package main
import (
"context"
"fmt"
"time"
"git.intra.yksa.space/gsn/predictor/internal/pkg/grib"
)
func main() {
ctx := context.Background()
cfg := &grib.Config{
Dir: "C:/tmp/grib",
TTL: 48 * time.Hour,
CacheTTL: 1 * time.Hour,
Parallel: 8,
}
svc, err := grib.New(cfg)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
if err := svc.Update(ctx); err != nil {
fmt.Printf("Update error: %v\n", err)
return
}
// Test wind at lat=52.2, lon=0.1 at various altitudes
// Run is 2026-02-12T12:00Z, request time 21:00Z = +9 hours
ts := time.Date(2026, 2, 12, 21, 0, 0, 0, time.UTC)
lat, lon := 52.2, 0.1
fmt.Println("Wind at (52.2°N, 0.1°E) at 2026-02-12T21:00Z:")
fmt.Printf("%8s %8s %8s\n", "Alt(m)", "U(m/s)", "V(m/s)")
for _, alt := range []float64{0, 1000, 3000, 5000, 7000, 10000, 15000, 20000, 25000, 30000} {
w, err := svc.Extract(ctx, lat, lon, alt, ts)
if err != nil {
fmt.Printf("%8.0f Error: %v\n", alt, err)
continue
}
fmt.Printf("%8.0f %8.2f %8.2f\n", alt, w[0], w[1])
}
// Also test at a few nearby points to check spatial consistency
fmt.Println("\nWind at 10km altitude, varying longitude:")
for _, testLon := range []float64{0.0, 0.25, 0.5, 1.0, 2.0, 5.0, 10.0, 350.0, 359.75} {
w, _ := svc.Extract(ctx, lat, testLon, 10000, ts)
fmt.Printf(" lon=%6.2f: U=%8.2f V=%8.2f\n", testLon, w[0], w[1])
}
}