inmap: Index | Files

package aeputil

import ""

Package aeputil provides commonly used configuration and functions for the AEP library.


Package Files

doc.go excel.go inventory.go iterator.go scale.go spatial.go speciate.go

func Scale Uses

func Scale(emis map[string][]aep.Record, f ScaleFunc) error

Scale applies scaling factors to the given emissions records.

type InventoryConfig Uses

type InventoryConfig struct {
    // NEIFiles lists National Emissions Inventory emissions files to use
    // for making SCC-based spatial surrogates. The file names can include
    // environment variables. The format is map[sector name][list of files].
    NEIFiles map[string][]string

    // PolsToKeep lists pollutants from the NEI that should be kept.
    PolsToKeep aep.Speciation

    // InputUnits specifies the units of input data. Acceptable
    // values are `tons', `tonnes', `kg', `g', and `lbs'.
    InputUnits string

    // FilterFunc specifies which records should be kept.
    // If it is nil, all records are kept.
    FilterFunc aep.RecFilter

InventoryConfig holds emissions inventory configuration information.

func (*InventoryConfig) ReadEmissions Uses

func (c *InventoryConfig) ReadEmissions() (map[string][]aep.Record, *aep.InventoryReport, error)

ReadEmissions returns emissions records for the files specified in the NEIFiles field in the receiver. The returned records are split up by sector.

type Iterator Uses

type Iterator interface {
    // Next returns the next record.
    Next() (aep.Record, error)

    // Report returns an emissions report on the records that have been
    // processed by this iterator.
    Report() *aep.InventoryReport

Iterator is an iterface for types that can iterate through a list of emissions records and return totals at the end.

func IteratorFromMap Uses

func IteratorFromMap(emissions map[string][]aep.Record) Iterator

IteratorFromMap creates an Iterator from a map of emissions. This function is meant to be temporary until Inventory.ReadEmissions is replaced with an iterator.

type ScaleFunc Uses

type ScaleFunc func(aep.Record, aep.Pollutant) (float64, error)

ScaleFunc returns an emissions scaling factor for the given pollutant in the given record.

func ScaleNEIStateTrends Uses

func ScaleNEIStateTrends(summaryFile string, sccDescriptions io.Reader, baseYear, scaleYear int) (ScaleFunc, error)

ScaleNEIStateTrends provides an emissions scaling function to scale NEI emissions from baseYear to the specified scaleYear using EPA emissions summaries by year, state, SCC code, and pollutant available from The "xls" file must be converted to an "xlsx" file before opening.

type SpatialConfig Uses

type SpatialConfig struct {
    // SrgSpec gives the location of the surrogate specification file.
    SrgSpec string

    // SrgShapefileDirectory gives the location of the directory holding
    // the shapefiles used for creating spatial surrogates.
    SrgShapefileDirectory string

    // SCCExactMatch specifies whether SCC codes must match exactly when processing
    // emissions.
    SCCExactMatch bool

    // GridRef specifies the locations of the spatial surrogate gridding
    // reference files used for processing the NEI.
    GridRef []string

    // OutputSR specifies the output spatial reference in Proj4 format.
    OutputSR string

    // InputSR specifies the input spatial reference in Proj4 format.
    InputSR string

    // SimplifyTolerance is the tolerance for simplifying spatial surrogate
    // geometry, in units of OutputSR.
    SimplifyTolerance float64

    // SpatialCache specifies the location for storing spatial emissions
    // data for quick access. If this is left empty, no cache will be used.
    SpatialCache string

    // MaxCacheEntries specifies the maximum number of emissions and concentrations
    // surrogates to hold in a memory cache. Larger numbers can result in faster
    // processing but increased memory usage.
    MaxCacheEntries int

    // GridCells specifies the geometry of the spatial grid.
    GridCells []geom.Polygonal

    // GridName specifies a name for the grid which is used in the names
    // of intermediate and output files.
    GridName string
    // contains filtered or unexported fields

SpatialConfig holds emissions spatialization configuration information.

func (*SpatialConfig) Iterator Uses

func (c *SpatialConfig) Iterator(parent Iterator, gridIndex int) *SpatialIterator

Iterator creates a SpatialIterator from the given parent iterator for the given gridIndex.

func (*SpatialConfig) SpatialProcessor Uses

func (c *SpatialConfig) SpatialProcessor() (*aep.SpatialProcessor, error)

SpatialProcessor returns the spatial processor associated with the receiver.

type SpatialIterator Uses

type SpatialIterator struct {
    // contains filtered or unexported fields

SpatialIterator is an Iterator that spatializes the records that it processes.

func (*SpatialIterator) Next Uses

func (si *SpatialIterator) Next() (aep.Record, error)

Next spatializes a record from the

func (*SpatialIterator) Report Uses

func (si *SpatialIterator) Report() *aep.InventoryReport

Report returns an emissions report on the records that have been processed by this iterator.

func (*SpatialIterator) SpatialTotals Uses

func (si *SpatialIterator) SpatialTotals() (emissions map[aep.Pollutant]*sparse.SparseArray, units map[aep.Pollutant]unit.Dimensions)

SpatialTotals returns spatial arrays of the total emissions for each pollutant, as well as their units.

type SpeciateConfig Uses

type SpeciateConfig struct {
    // These variables specify the locations of files used for
    // chemical speciation.
    SpecRef, SpecRefCombo, SpeciesProperties, GasProfile   string
    GasSpecies, OtherGasSpecies, PMSpecies, MechAssignment string
    MolarWeight, SpeciesInfo                               string

    // ChemicalMechanism specifies which chemical mechanism to
    // use for speciation.
    ChemicalMechanism string

    // MassSpeciation specifies whether to use mass speciation.
    // If false, speciation will convert values to moles.
    MassSpeciation bool

    // SCCExactMatch specifies whether SCCs should be expected to match
    // exactly with the the speciation reference, or if partial matches
    // are acceptable.
    SCCExactMatch bool

    Speciation aep.Speciation
    // contains filtered or unexported fields

SpeciateConfig holds speciation configuration information.

func (*SpeciateConfig) Iterator Uses

func (c *SpeciateConfig) Iterator(parent Iterator) Iterator

Iterator creates a new iterator that consumes records from the given iterators and chemically speciates them.

func (*SpeciateConfig) Speciate Uses

func (c *SpeciateConfig) Speciate(r aep.Record) (*SpeciatedRecord, error)

Speciate chemically speciates the given record.

type SpeciatedRecord Uses

type SpeciatedRecord struct {
    // contains filtered or unexported fields

SpeciatedRecord is an emissions record where chemical speciation has been performed. It should be created using SpeciateConfig.Speciate().

func (*SpeciatedRecord) CombineEmissions Uses

func (r *SpeciatedRecord) CombineEmissions(r2 aep.Record)

CombineEmissions combines emissions from r2 with the receiver.

func (*SpeciatedRecord) DroppedEmissions Uses

func (r *SpeciatedRecord) DroppedEmissions() *aep.Emissions

DroppedEmissions returns emissions that were dropped from the analysis during speciation to avoid double counting.

func (*SpeciatedRecord) GetEmissions Uses

func (r *SpeciatedRecord) GetEmissions() *aep.Emissions

GetEmissions returns the speciated emissions.

func (*SpeciatedRecord) PeriodTotals Uses

func (r *SpeciatedRecord) PeriodTotals(begin, end time.Time) map[aep.Pollutant]*unit.Unit

PeriodTotals returns total emissions for the given time period.

func (*SpeciatedRecord) Totals Uses

func (r *SpeciatedRecord) Totals() map[aep.Pollutant]*unit.Unit

Totals returns emissions totals.

Package aeputil imports 19 packages (graph) and is imported by 1 packages. Updated 2018-12-04. Refresh now. Tools for package owners.