forked from gsn/predictor
fixed wind data bug
This commit is contained in:
parent
b355b41ed2
commit
ca95e06ab7
4 changed files with 10 additions and 9 deletions
|
|
@ -28,7 +28,7 @@ func openCube(path string) (*cube, error) {
|
|||
}
|
||||
|
||||
const (
|
||||
nT = 97 // 0-96 hours with step 1 hour
|
||||
nT = 33 // 0-96 hours with step 3 hours (33 time steps)
|
||||
nP = 47 // 47 pressure levels matching tawhiri
|
||||
nLat = 361
|
||||
nLon = 720
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ func (d *dataset) uv(lat, lon, alt float64, tHours float64) (float64, float64) {
|
|||
x0 := int(math.Floor(ix)) % d.cube.lon
|
||||
x1 := (x0 + 1) % d.cube.lon
|
||||
wx := ix - float64(x0)
|
||||
// For hourly data (step = 1 hour)
|
||||
it0 := int(math.Floor(tHours))
|
||||
wt := tHours - float64(it0)
|
||||
// For 3-hourly data (step = 3 hours)
|
||||
// Convert tHours to 3-hour index (e.g., 1.5 hours -> index 0.5, interpolate between 0 and 1)
|
||||
it0 := int(math.Floor(tHours / 3.0))
|
||||
wt := (tHours - float64(it0*3)) / 3.0 // Interpolation weight within 3-hour window
|
||||
p := pressureFromAlt(alt)
|
||||
ip0 := 0
|
||||
for ip0+1 < len(pressureLevels) && pressureLevels[ip0+1] > p {
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ func (s *service) Update(ctx context.Context) error {
|
|||
}
|
||||
|
||||
func assembleCube(dir string, run time.Time, cubePath string) error {
|
||||
const sizePerVar = 97 * 47 * 361 * 720 * 4 // 97 time steps (0-96 hours), 47 pressure levels
|
||||
const sizePerVar = 33 * 47 * 361 * 720 * 4 // 33 time steps (0-96 hours, 3-hour intervals), 47 pressure levels
|
||||
total := int64(sizePerVar * 3) // 3 variables: gh, u, v
|
||||
f, err := os.Create(cubePath)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// Generate steps from 0 to 96 with step 1 hour (97 steps total)
|
||||
// GFS provides hourly data for 0-120 hours, we use first 96 hours
|
||||
// Generate steps from 0 to 96 with step 3 hours (33 steps total)
|
||||
// GFS provides 3-hourly data for 0-120 hours, we use first 96 hours (0, 3, 6, ..., 96)
|
||||
var steps = func() []int {
|
||||
result := make([]int, 0, 97)
|
||||
for i := 0; i <= 96; i++ {
|
||||
result := make([]int, 0, 33)
|
||||
for i := 0; i <= 96; i += 3 {
|
||||
result = append(result, i)
|
||||
}
|
||||
return result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue