From 261c68e05739ce025cb15f3a05a2b38fb810e6d0 Mon Sep 17 00:00:00 2001 From: Chris Tessum Date: Mon, 11 Nov 2019 22:13:07 -0600 Subject: [PATCH] aep: Log error message for missing input shape --- emissions/aep/inventory.go | 5 ++++- emissions/aep/sourcedata.go | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/emissions/aep/inventory.go b/emissions/aep/inventory.go index 0def96adf..639826765 100644 --- a/emissions/aep/inventory.go +++ b/emissions/aep/inventory.go @@ -22,6 +22,7 @@ import ( "encoding/gob" "fmt" "io" + "log" "os" "strconv" "strings" @@ -397,7 +398,9 @@ func (e *EmissionsReader) ReadFiles(files []*InventoryFile, f RecFilter) ([]Reco 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 diff --git a/emissions/aep/sourcedata.go b/emissions/aep/sourcedata.go index 5a1c6ffc8..5e4888bc6 100644 --- a/emissions/aep/sourcedata.go +++ b/emissions/aep/sourcedata.go @@ -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.