From 5a6377ff04e849b7ba0427d4bc01077c48bc91fb Mon Sep 17 00:00:00 2001 From: Christopher Tessum Date: Sat, 29 Jan 2022 09:50:14 -0600 Subject: [PATCH] Don't generate surrogates if emis==0 (second try) --- inmaputil/inmap.go | 8 ++++++++ io.go | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/inmaputil/inmap.go b/inmaputil/inmap.go index 20145fad0..a25ced9c6 100644 --- a/inmaputil/inmap.go +++ b/inmaputil/inmap.go @@ -22,6 +22,7 @@ import ( "fmt" "io" "log" + "math" "os" "runtime" "sync" @@ -362,6 +363,13 @@ func setEmissionsAEP(inventoryConfig *aeputil.InventoryConfig, spatialConfig *ae } else if err != nil { return err } + var totalEmis float64 + for _, v := range rec.Totals() { + totalEmis += math.Abs(v.Value()) + } + if totalEmis == 0 { + continue + } spatialRecs = append(spatialRecs, rec.(aep.RecordGridded)) } diff --git a/io.go b/io.go index a5e4b339e..61721a057 100644 --- a/io.go +++ b/io.go @@ -274,13 +274,6 @@ func FromAEP(r []aep.RecordGridded, grids []*aep.GridDef, gi int, VOC, NOx, NH3, groundERecs := make(map[int]*EmisRecord) for _, rec := range r { - var totalEmis float64 - for _, v := range rec.Totals() { - totalEmis += math.Abs(v.Value()) - } - if totalEmis == 0 { - continue - } gridSrg, _, inGrid, err := rec.GridFactors(gi) if err != nil { return nil, err