Skip to content

Commit

Permalink
aep: Check sorting in COARDs file
Browse files Browse the repository at this point in the history
  • Loading branch information
ctessum committed Feb 28, 2022
1 parent e77719b commit 7b66574
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions emissions/aep/coards_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ func (r *Raster) RecordGenerator(b *geom.Bounds) func() (Record, error) {
panic(err)
}

if !sort.Float64sAreSorted(r.lats) {
panic(fmt.Errorf("in COARDS file: lats are not sorted"))
}
if !sort.Float64sAreSorted(r.lons) {
panic(fmt.Errorf("in COARDS file: lons are not sorted"))
}
j := sort.SearchFloat64s(r.lats, b.Min.Y)
i := sort.SearchFloat64s(r.lons, b.Min.X)
jEnd := maxInt(sort.SearchFloat64s(r.lats, b.Max.Y), len(r.lats))
Expand Down

0 comments on commit 7b66574

Please sign in to comment.