Skip to content

Commit

Permalink
aep: Log error message for missing input shape
Browse files Browse the repository at this point in the history
  • Loading branch information
ctessum committed Nov 12, 2019
1 parent 0e457f0 commit 5191b4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 6 additions & 5 deletions emissions/aep/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"encoding/gob"
"fmt"
"io"
"log"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -392,16 +393,16 @@ func (e *EmissionsReader) ReadFiles(files []*InventoryFile, f RecFilter) ([]Reco
for _, file := range files {
report.AddData(file)
}
recordList := make([]Record, len(records))
i := 0
recordList := make([]Record, 0, len(records))
for _, r := range records {
if ar, ok := r.(sourceDataLocationer); ok {
if err := e.sourceDataLocator.Locate(ar.getSourceDataLocation()); err != nil {
return nil, nil, err
log.Println(err)
continue // Drop records we can't find a location for.
// return nil, nil, err
}
}
recordList[i] = r
i++
recordList = append(recordList, r)
}
return recordList, report, nil
}
Expand Down
7 changes: 5 additions & 2 deletions emissions/aep/sourcedata.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@ func (sdl *sourceDataLocator) Locate(sd *SourceDataLocation) error {
return err
}
}
sd.location = sdl.inputShapes[srgSpec][sd.FIPS]
return nil
if l, ok := sdl.inputShapes[srgSpec][sd.FIPS]; ok {
sd.location = l
return nil
}
return fmt.Errorf("aep: missing input shape for spatial surrogate %s%s FIPS %s", srgSpec.region(), srgSpec.code(), sd.FIPS)
}

// Location returns the polygon representing the location of emissions.
Expand Down

0 comments on commit 5191b4f

Please sign in to comment.