inmap: github.com/spatialmodel/inmap/emissions/slca Index | Files | Directories

package slca

import "github.com/spatialmodel/inmap/emissions/slca"

Index

Package Files

cache.go enduse.go inmap.go lcaserver.go mapserver.go onsiteresults.go pollutant_string.go population.go results.go slca.go spatialize.go spatialresults.go speciate.go types.go

type CSTConfig Uses

type CSTConfig struct {
    // PolTrans translates between GREET pollutants and InMAP pollutants.
    // Format is map[GREET pollution]InMAP pollutant. There must be an
    // entry for each GREET pollutant. GREET pollutants that do not have
    // a corresponding InMAP species should be set equal to "none".
    PolTrans map[string]string

    // SRFile gives the location of the InMAP SR matrix data file.
    SRFile string

    // SRCacheSize specifies the number of SR records to hold in an in-memory
    // cache to speed up air pollution computations. 1 GB of RAM is required for
    // approximately every 1,000 records.
    SRCacheSize int

    // CensusFile specifies the location of the shapefile holding
    // population counts for each analysis year.
    CensusFile map[string]string

    // CensusPopColumns specifies the names of the population attribute
    // columns in CensusFile.
    CensusPopColumns []string

    // MortalityRateFile specifies the location of the shapefile holding
    // baseline mortality rate information for each analysis year.
    MortalityRateFile map[string]string

    // MortalityRateColumns maps population groups to fields in the mortality rate
    // shapefile containing their respective the mortality rates.
    MortalityRateColumns map[string]string

    // InventoryConfig specifies the configuration of the emissions inventory
    // data used for spatial surrogates.
    InventoryConfig aeputil.InventoryConfig

    // FugitiveDustSector specifies the name of the sectors, if any,
    // that should have a fugitive dust adjustment applied to them.
    FugitiveDustSectors []string

    // FugitiveDustAdjustment specifies the path to the file that contains
    // grid-cell specific fugitive dust adjustment factors.
    FugitiveDustAdjustment string

    // InventoryConfig specifies the configuration of the emissions inventory
    // data used for air quality model evaluation and calculating average
    // concentration response.
    EvaluationInventoryConfig aeputil.InventoryConfig

    // AdditionalEmissionsShapefilesForEvaluation specifies additional emissions
    // shapefiles to be used for model evaluation. This field will be removed
    // when a better way of doing biogenic emissions is completed. Units = tons/year.
    AdditionalEmissionsShapefilesForEvaluation []string

    // SpatialConfig specifies the spatial configuration used for
    // creating spatial surrogates and for air quality model evaluation and
    // calculating average concentration response.
    SpatialConfig aeputil.SpatialConfig

    // NEIData holds information needed for processing the NEI.
    NEIData 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 bool
    }

    // NEIBaseYear specifies the year the input NEI emissions data is for,
    // for use in scaling emissions for other years.
    NEIBaseYear int

    // NEITrends specifies the file holding trends in NEI  emissions, downloadable
    // from https://www.epa.gov/air-emissions-inventories/air-pollutant-emissions-trends-data.
    NEITrends string

    // SCCReference specifies the file holding cross references between SCC
    // codes and tier 1 summary codes, for use in scaling emissions for other
    // years, downloadable from https://ofmpub.epa.gov/sccsearch/.
    SCCReference string

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

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

    // 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

    // DefaultFIPS specifies the default FIPS code to use when retrieving gridding
    // surrogates.
    DefaultFIPS string
    // contains filtered or unexported fields
}

CSTConfig holds Chemical, spatial, and temporal (CST) configuration

func (*CSTConfig) ConcentrationResponseAverage Uses

func (c *CSTConfig) ConcentrationResponseAverage(ctx context.Context, request *eieiorpc.ConcentrationResponseAverageInput) (*eieiorpc.Vector, error)

ConcentrationResponseAverage calculates the average concentration response for PM2.5 (deaths per year per ug/m3 per capita) for a non-linear concentration- response function. hr specifies the function used to calculate the hazard ratio.

func (*CSTConfig) ConcentrationSurrogate Uses

func (c *CSTConfig) ConcentrationSurrogate(ctx context.Context, spatialRef *SpatialRef) (*sr.Concentrations, error)

ConcentrationSurrogate calculates the pollutant concentration impacts of spatialRef, accounting for the effects of elevated emissions plumes.

func (*CSTConfig) EmissionsSurrogate Uses

func (c *CSTConfig) EmissionsSurrogate(ctx context.Context, pol Pollutant, spatialRef *SpatialRef) (*sparse.SparseArray, error)

EmissionsSurrogate returns the spatially-explicit emissions caused by spatialRef.

func (*CSTConfig) EvaluationConcentrations Uses

func (c *CSTConfig) EvaluationConcentrations(ctx context.Context, request *eieiorpc.EvaluationConcentrationsInput) (*eieiorpc.Vector, error)

EvaluationConcentrations returns an array of concentrations calculated using the EvaluationInventoryConfig and AdditionalEmissionsShapefilesForEvaluation fields of the receiver, adjusting emissions to the specified year.

func (*CSTConfig) EvaluationEmissions Uses

func (c *CSTConfig) EvaluationEmissions(ctx context.Context, year int) ([]*inmap.EmisRecord, error)

EvaluationEmissions returns an array of emissions records calculated using the EvaluationInventoryConfig and AdditionalEmissionsShapefilesForEvaluation fields of the receiver, adjusting emissions to the specified year.

func (*CSTConfig) EvaluationHealth Uses

func (c *CSTConfig) EvaluationHealth(ctx context.Context, request *eieiorpc.EvaluationHealthInput) (*eieiorpc.Vector, error)

EvaluationHealth returns an array of health impacts calculated using the EvaluationInventoryConfig and AdditionalEmissionsShapefilesForEvaluation fields of the receiver, adjusting emissions to the specified year. HR specifies the function used to calculate the hazard ratio. Output format = map[popType][pol]values

func (*CSTConfig) Geometry Uses

func (c *CSTConfig) Geometry() ([]geom.Polygonal, error)

Geometry returns the air quality model grid cell geometry.

func (*CSTConfig) HealthSurrogate Uses

func (c *CSTConfig) HealthSurrogate(ctx context.Context, spatialRef *SpatialRef, HR string) (map[string]map[string]*sparse.DenseArray, error)

HealthSurrogate calculates the health impact of the given spatial reference. HR specifies the function used to calculate the hazard ratio. Output format = map[popType][pol]values

func (*CSTConfig) PopulationIncidence Uses

func (c *CSTConfig) PopulationIncidence(ctx context.Context, request *eieiorpc.PopulationIncidenceInput) (*eieiorpc.PopulationIncidenceOutput, error)

PopulationIncidence returns gridded population counts and underlying mortality incidence rates for the type specified by popType. Valid population types are specified by the CensusPopColumns attribute of the receiver. The returned value Population is population counts and Incidence is underlying incidence rates. hr specifies the function used to calculate the hazard ratio.

func (*CSTConfig) Setup Uses

func (c *CSTConfig) Setup(hr ...epi.HRer) error

setup sets up the chemical, spatial, and temporal configuration, where hr specifies the hazard ratio functions that should be included.

type DB Uses

type DB struct {
    LCADB

    *http.ServeMux

    // Chemical, spatial, and temporal (CST) configuration
    CSTConfig *CSTConfig
}

DB is a holder for an SLCA database.

func (*DB) RegisterHTTPHandlers Uses

func (db *DB) RegisterHTTPHandlers(prefix, staticFileDir string)

RegisterHTTPHandlers configures the HTML user interface. Prefix is a URL prefix: e.g. xxx.com/prefix/xxx.html. staticFileDir is the path to the directory containing the static files, i.e. this directory.

func (*DB) Speciate Uses

func (db *DB) Speciate(r *Results) (*Results, error)

Speciate returns a chemically speciated copy of r.

type Gas Uses

type Gas interface {
    // GetName returns the name of this gas.
    GetName() string

    // GetID returns the ID of this gas.
    GetID() string
}

Gas represents a type of emission.

type Guid Uses

type Guid string

Guid is a globally unique ID

type LCADB Uses

type LCADB interface {
    // EndUses returns the potential end Pathways and their names.
    EndUses() ([]Pathway, []string)

    // EndUseFromID returns an end use Pathway when given its ID.
    EndUseFromID(ID string) (Pathway, error)

    // SpatialSCCs returns a list of all SCC codes used by processes in the
    // receiver.
    SpatialSCCs() []SCC

    // GetYear returns the analysis year.
    GetYear() float64
}

LCADB specifies the methods that an LCA database must have to work with this framework.

type OnsiteResults Uses

type OnsiteResults struct {
    Emissions    map[SubProcess]map[Gas]*unit.Unit
    Resources    map[SubProcess]map[Resource]*unit.Unit
    Requirements map[Process]map[Pathway]map[Output]*unit.Unit
    // contains filtered or unexported fields
}

OnsiteResults is a holder for emissions, resource use, and requirements for a single process.

func NewOnsiteResults Uses

func NewOnsiteResults(db LCADB) *OnsiteResults

NewOnsiteResults initializes a new instance of OnsiteResults.

func (*OnsiteResults) Add Uses

func (or *OnsiteResults) Add(r *OnsiteResults)

Add adds values from another OnsiteResults to this OnsiteResults.

func (*OnsiteResults) AddEmission Uses

func (or *OnsiteResults) AddEmission(sp SubProcess, g Gas, val *unit.Unit)

AddEmission adds an amount of a resource to the results.

func (*OnsiteResults) AddRequirement Uses

func (or *OnsiteResults) AddRequirement(proc Process, path Pathway, o Output, amount *unit.Unit, db LCADB)

AddRequirement adds a requirement of the current process for another process.

func (*OnsiteResults) AddResource Uses

func (or *OnsiteResults) AddResource(sp SubProcess, r Resource, val *unit.Unit, db LCADB)

AddResource adds an amount of a resource to the results.

func (*OnsiteResults) Clone Uses

func (or *OnsiteResults) Clone() *OnsiteResults

Clone returns a copy of or.

func (*OnsiteResults) Div Uses

func (or *OnsiteResults) Div(v *unit.Unit)

Div divides the results by a constant.

func (*OnsiteResults) FilterEmissions Uses

func (or *OnsiteResults) FilterEmissions() *OnsiteResults

FilterEmissions returns an OnsiteResults object that only contains emissions.

func (*OnsiteResults) FilterRequirements Uses

func (or *OnsiteResults) FilterRequirements() *OnsiteResults

FilterRequirements returns an OnsiteResults object that only contains Requirements.

func (*OnsiteResults) FilterResources Uses

func (or *OnsiteResults) FilterResources() *OnsiteResults

FilterResources returns an OnsiteResults object that only contains resource use.

func (*OnsiteResults) FlattenSubprocess Uses

func (or *OnsiteResults) FlattenSubprocess() *OnsiteResultsNoSubprocess

FlattenSubprocess returns a version of the results with the resource use and emissions from all subprocesses combined.

func (*OnsiteResults) Mul Uses

func (or *OnsiteResults) Mul(v *unit.Unit)

Mul multiplies the results by a constant.

func (*OnsiteResults) ScaleCopy Uses

func (or *OnsiteResults) ScaleCopy(factor *unit.Unit) *OnsiteResults

ScaleCopy returns a copy of or, multiplying the values in or by factor.

func (*OnsiteResults) SortOrder Uses

func (or *OnsiteResults) SortOrder() (subProcesses []SubProcess, gases []Gas, resources []Resource)

SortOrder returns the gases emitted and resources used by the sub processes in the receiver in alphabetical order.

func (*OnsiteResults) String Uses

func (or *OnsiteResults) String() string

func (*OnsiteResults) SubEmission Uses

func (or *OnsiteResults) SubEmission(sp SubProcess, g Gas, val *unit.Unit)

SubEmission subtracts an amount of a resource from the results.

func (*OnsiteResults) SubResource Uses

func (or *OnsiteResults) SubResource(sp SubProcess, r Resource, val *unit.Unit, db LCADB)

SubResource subtracts an amount of a resource from the results.

type OnsiteResultsNoSubprocess Uses

type OnsiteResultsNoSubprocess struct {
    Emissions map[Gas]*unit.Unit
    Resources map[Resource]*unit.Unit
}

OnsiteResultsNoSubprocess holds onsite results without any subprocess information.

func (*OnsiteResultsNoSubprocess) SortOrder Uses

func (r *OnsiteResultsNoSubprocess) SortOrder() (gases []Gas, resources []Resource)

SortOrder returns the gases emitted and resources used in the receiver in alphabetical order.

func (*OnsiteResultsNoSubprocess) String Uses

func (or *OnsiteResultsNoSubprocess) String() string

type Output Uses

type Output interface {
    // GetResource returns the Resource that is output by the receiver.
    GetResource(LCADB) Resource

    // GetID returns the ID of the receiver.
    GetID() OutputID
}

Output represents an output from a process or pathway.

type OutputID Uses

type OutputID Guid

OutputID holds the ID code for an output

type Pathway Uses

type Pathway interface {
    // GetName gets the name of this Pathway.
    GetName() string

    // GetIDStr returns the ID of the receiver in string format.
    GetIDStr() string

    // MainProcessAndOutput returns the process that outputs the main
    // output of the receiver, and also returns that output.
    MainProcessAndOutput(LCADB) (Process, Output)
}

Pathway represents a series of processes in a life cycle.

type Pollutant Uses

type Pollutant int

Pollutant specifies air pollutant names

const (
    PM25 Pollutant = iota
    NH3
    NOx
    SOx
    VOC
)

These are the valid air pollutant names.

func (Pollutant) String Uses

func (i Pollutant) String() string

type Process Uses

type Process interface {
    // Type returns the ProcessType of the reciever.
    Type() ProcessType

    // SpatialRef returns the spatial reference information associated
    // with the receiver.
    SpatialRef() *SpatialRef

    // GetName returns the name of the receiver.
    GetName() string

    // GetIDStr returns the ID of the receiver in string format.
    GetIDStr() string

    GetOutput(Resource, LCADB) Output
    GetMainOutput(LCADB) Output

    // OnsiteResults returns the onsite emissions and input resource
    // requirements per unit of the specified Output, as part
    // of the specified Pathway.
    OnsiteResults(Pathway, Output, LCADB) *OnsiteResults
}

Process represents a process in a life cycle.

type ProcessType Uses

type ProcessType int

ProcessType specifies a type of a Process.

const (
    // Stationary specifies a process is one that is at
    // a fixed location or locations.
    Stationary ProcessType = iota + 1

    // Transportation specifies a process is one that needs to be routed from a
    // source to a destination.
    Transportation

    // Vehicle specifies an end-use vehicle.
    Vehicle

    // NoSpatial represents a process that does not have any spatial information.
    NoSpatial
)

type Resource Uses

type Resource interface {
    // GetName returns the name of this resource.
    GetName() string

    // GetID returns the ID of this resource.
    GetID() string

    // ConvertToDefaultUnits converts the speceified amount to the
    // default units of the receiver.
    ConvertToDefaultUnits(amount *unit.Unit, db LCADB) *unit.Unit
}

Resource represents a material that can be input to or output from a process.

type ResultEdge Uses

type ResultEdge struct {
    FromID, ToID, ID string
    FromResults      *OnsiteResults
}

ResultEdge is a holder for information about the relation between two Nodes and the emissions created and resources used by the From process to supply the To process.

type ResultNode Uses

type ResultNode struct {
    ID      string
    Process Process
    Pathway Pathway
    Output  Output
    // contains filtered or unexported fields
}

ResultNode is a holder for information about a single pathway/process/output combination.

type Results Uses

type Results struct {
    Nodes map[string]*ResultNode
    Edges []*ResultEdge
    // contains filtered or unexported fields
}

Results is a holder for life cycle process requirements, emissions, and resource use. It allows the determination of which downstream processes are causing the resource use and emissions of the upstream process.

func NewResults Uses

func NewResults(db LCADB) *Results

NewResults initializes a new instance of results.

func SolveGraph Uses

func SolveGraph(path Pathway, amount *unit.Unit, db *DB) *Results

SolveGraph calculates the life cycle resource use and emissions of the specified amount of the specified pathway, using a graph-based solving method.

func (*Results) GetEdge Uses

func (r *Results) GetEdge(from, to *ResultNode) *ResultEdge

GetEdge returns the edge connecting from and to if it exist, otherwise a new edge is created, added to the results, and returned.

func (*Results) GetFromNode Uses

func (r *Results) GetFromNode(e *ResultEdge) *ResultNode

GetFromNode gets the upstream node associated with this edge.

func (*Results) GetNode Uses

func (r *Results) GetNode(proc Process, path Pathway, o Output) *ResultNode

GetNode checks whether the Results already have a node for the given process, pathway, and output. If the node exists, it is returned, otherwise a new node is created, added to the results, and returned.

func (*Results) GetToNode Uses

func (r *Results) GetToNode(e *ResultEdge) *ResultNode

GetToNode gets the downstream node associated with this edge.

func (*Results) Len Uses

func (r *Results) Len() int

func (*Results) Less Uses

func (r *Results) Less(i, j int) bool

func (*Results) String Uses

func (r *Results) String() string

String prints the results in sorted format, so they are the same every time.

func (Results) Sum Uses

func (r Results) Sum() *OnsiteResultsNoSubprocess

Sum returns a sum of the results.

func (*Results) SumFor Uses

func (r *Results) SumFor(n *ResultNode) *OnsiteResults

SumFor sums all of the results for the node.

func (*Results) Swap Uses

func (r *Results) Swap(i, j int)

func (*Results) Table Uses

func (r *Results) Table() ([][]string, error)

Table creates a table from the results, suitable for outputting to a CSV file.

type SCC Uses

type SCC string

SCC is an EPA source classification code

type SpatialRef Uses

type SpatialRef struct {
    // EPA Source Classification codes corresponding to this process.
    SCCs []SCC `xml:"scc"`

    // SCCFractions specifies adjustment factors to multiply emissions by
    // for each SCC code in SCCs. If SCCFractions is nil, no adjustments
    // are applied.
    SCCFractions []float64

    // EmisYear specifies the year to adjust emissions amounts to
    // for the SCCs codes corresponding to this process.
    EmisYear int

    // Surrogate code for this process.
    Surrogate string `xml:"spatial_srg"`

    // The FIPS code to be used with Surrogate for this process.
    SurrogateFIPS string `xml:"spatial_srg_fips"`

    // NoSpatial is true if this process is intentionally lacking spatial information.
    NoSpatial bool

    Type ProcessType

    // NoNormalization specifies whether the spatial surrogate
    // should be normalized so that its sum==1. The default is
    // to perform normalization.
    NoNormalization bool
}

SpatialRef holds reference information about the spatial location of this process.

func (*SpatialRef) Key Uses

func (sr *SpatialRef) Key() string

Key returns a unique identifier for this SpatialRef.

type SpatialResults Uses

type SpatialResults struct {
    *Results
    // contains filtered or unexported fields
}

SpatialResults is a wrapper for Results that can do spatial calculations.

func NewSpatialResults Uses

func NewSpatialResults(res *Results, db *DB) *SpatialResults

NewSpatialResults returns a new SpatialResults variable.

func (*SpatialResults) Concentrations Uses

func (sr *SpatialResults) Concentrations() (map[string]*sparse.DenseArray, error)

Concentrations gets the total change in concentrations of PM2.5 and its subspecies caused by life cycle sr.

func (*SpatialResults) EdgeConcentrations Uses

func (sr *SpatialResults) EdgeConcentrations(e *ResultEdge) (map[SubProcess]map[string]*sparse.DenseArray, error)

EdgeConcentrations gets the change in concentrations of PM2.5 and its subspecies caused by the emissions in e.

func (*SpatialResults) EdgeEmissions Uses

func (sr *SpatialResults) EdgeEmissions(e *ResultEdge) (map[SubProcess]map[Gas]*sparse.SparseArray, error)

EdgeEmissions returns the spatialized emissions associated with edge e.

func (*SpatialResults) EdgeHealth Uses

func (sr *SpatialResults) EdgeHealth(e *ResultEdge, HR string) (map[SubProcess]map[string]map[string]*sparse.DenseArray, error)

EdgeHealth gets the spatialized health impacts caused by the emissions in edge e. It calculates the number of deaths in each demographic group caused by these emissions. The format of the output is map[population][pollutant]effects. HR specifies the function used to calculate the hazard ratio.

func (*SpatialResults) EdgeHealthTotals Uses

func (sr *SpatialResults) EdgeHealthTotals(e *ResultEdge, HR string) (map[SubProcess]map[string]map[string]float64, error)

EdgeHealthTotals gets the total (non-spatialized) health impacts caused by the emissions in edge e. It calculates the number of deaths in each demographic group caused by these emissions. HR specifies the function used to calculate the hazard ratio. The format of the output is map[population][pollutant]total effects.

func (*SpatialResults) EdgeResourceUse Uses

func (sr *SpatialResults) EdgeResourceUse(e *ResultEdge) (map[SubProcess]map[Resource]*sparse.SparseArray, error)

EdgeResourceUse returns the spatialized resource use associated with edge e.

func (*SpatialResults) Emissions Uses

func (sr *SpatialResults) Emissions() (map[Gas]*sparse.SparseArray, error)

Emissions gets the total spatially explicit emissions caused by life cycle sr.

func (*SpatialResults) Health Uses

func (sr *SpatialResults) Health(HR string) (map[string]map[string]*sparse.DenseArray, error)

Health gets the total PM2.5 health impacts caused by life cycle sr. The format of the output is map[population][pollutant]impacts. HR specifies the function used to calculate the hazard ratio.

func (*SpatialResults) ResourceUse Uses

func (sr *SpatialResults) ResourceUse() (map[Resource]*sparse.SparseArray, error)

ResourceUse gets the total spatially explicit resource use caused by life cycle sr.

func (*SpatialResults) Sum Uses

func (sr *SpatialResults) Sum() *OnsiteResultsNoSubprocess

Sum returns a sum of the (non-spatial) results.

func (*SpatialResults) Table Uses

func (sr *SpatialResults) Table(HR string) ([][]string, error)

Table creates a table from the results, suitable for outputting to a CSV file. HR specifies the function used to calculate the hazard ratio.

type SubProcess Uses

type SubProcess interface {
    GetName() string
    GetSCC() SCC
}

SubProcess gives information about the specific source of emissions or resource use within a process.

Directories

PathSynopsis
eieioPackage eieio implements an Extended InMAP Economic Input-Output (EIEIO) life cycle assessment model based on the US Bureau of Economic Analysis (BEA) Annual Input-Output Accounts Data from https://www.gov/industry/io_annual.htm.
eieio/cesPackage ces translates Consumer Expenditure Survey (CES) demographic data to EIO categories.
eieio/eieiorpc
eieio/eieiorpc/eieiorpcjsPackage eieiorpc is a generated protocol buffer package.
eieio/gui
greet

Package slca imports 42 packages (graph) and is imported by 2 packages. Updated 2019-02-27. Refresh now. Tools for package owners.