Skip to content

Commit 7b66574

Browse files
committed
aep: Check sorting in COARDs file
1 parent e77719b commit 7b66574

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

emissions/aep/coards_record.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ func (r *Raster) RecordGenerator(b *geom.Bounds) func() (Record, error) {
119119
panic(err)
120120
}
121121

122+
if !sort.Float64sAreSorted(r.lats) {
123+
panic(fmt.Errorf("in COARDS file: lats are not sorted"))
124+
}
125+
if !sort.Float64sAreSorted(r.lons) {
126+
panic(fmt.Errorf("in COARDS file: lons are not sorted"))
127+
}
122128
j := sort.SearchFloat64s(r.lats, b.Min.Y)
123129
i := sort.SearchFloat64s(r.lons, b.Min.X)
124130
jEnd := maxInt(sort.SearchFloat64s(r.lats, b.Max.Y), len(r.lats))

0 commit comments

Comments
 (0)