Documentation ¶
Overview ¶
Package aeputil provides commonly used configuration and functions for the AEP library.
Index ¶
- func Scale(emis map[string][]aep.Record, f ScaleFunc) error
- type InventoryConfig
- type Iterator
- type ScaleFunc
- type SpatialConfig
- type SpatialIterator
- type SpeciateConfig
- type SpeciatedRecord
- func (r *SpeciatedRecord) CombineEmissions(r2 aep.Record)
- func (r *SpeciatedRecord) DroppedEmissions() *aep.Emissions
- func (r *SpeciatedRecord) GetEmissions() *aep.Emissions
- func (r *SpeciatedRecord) PeriodTotals(begin, end time.Time) map[aep.Pollutant]*unit.Unit
- func (r *SpeciatedRecord) Totals() map[aep.Pollutant]*unit.Unit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type InventoryConfig ¶
type InventoryConfig struct { // NEIFiles lists National Emissions Inventory emissions files. // The file names can include environment variables. // The format is map[sector name][list of files]. NEIFiles map[string][]string // COARDSFiles lists COARDS-compliant NetCDF emission files // (NetCDF 4 and greater not supported). // Information regarding the COARDS NetCDF conventions are // available here: https://ferret.pmel.noaa.gov/Ferret/documentation/coards-netcdf-conventions. // The file names can include environment variables. // The format is map[sector name][list of files]. // For COARDS files, the sector name will also be used // as the SCC code. COARDSFiles map[string][]string // COARDSYear specifies the year of emissions for COARDS emissions files. // COARDS emissions are assumed to be in units of mass of emissions per year. // The year will not be used for NEI emissions files. COARDSYear int // 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 // SrgSpecSMOKE gives the location of the SMOKE-formatted // surrogate specification file, if any. SrgSpecSMOKE string // SrgSpecOSM gives the location of the OSM-formatted // surrogate specification file, if any. SrgSpecOSM string // SrgShapefileDirectory gives the location of the directory holding // the shapefiles used for creating spatial surrogates. // It is used for assigning spatial locations to emissions records. // It is only used when SrgSpecType == "SMOKE". SrgShapefileDirectory string // GridRef specifies the locations of the spatial surrogate gridding // reference files used for processing emissions. // It is used for assigning spatial locations to emissions records. GridRef []string // SCCExactMatch specifies whether SCC codes must match exactly when processing // emissions. SCCExactMatch bool // 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 ¶
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 ¶
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.
type ScaleFunc ¶
ScaleFunc returns an emissions scaling factor for the given pollutant in the given record.
func ScaleNEIStateTrends ¶
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 https://www.epa.gov/sites/production/files/2016-12/state_tier1_90-16.xls. The "xls" file must be converted to an "xlsx" file before opening.
type SpatialConfig ¶
type SpatialConfig struct { // SrgSpecSMOKE gives the location of the SMOKE-formatted // surrogate specification file, if any. SrgSpecSMOKE string // SrgSpecOSM gives the location of the OSM-formatted // surrogate specification file, if any. SrgSpecOSM 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 emissions 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 // SrgDataCache specifies the location for caching spatial surrogate input data. // If it is empty, the input surrogate data will be stored in SpatialCache. SrgDataCache 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. // Changes to the geometry of the grid must be accompanied by either a // a change in GridName or the deletion of all the files in the // SpatialCache directory. GridName string // contains filtered or unexported fields }
SpatialConfig holds emissions spatialization configuration information.
func (*SpatialConfig) Iterator ¶
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 ¶
func (c *SpatialConfig) SpatialProcessor() (*aep.SpatialProcessor, error)
SpatialProcessor returns the spatial processor associated with the receiver.
type SpatialIterator ¶
type SpatialIterator struct {
// contains filtered or unexported fields
}
SpatialIterator is an Iterator that spatializes the records that it processes.
func (*SpatialIterator) Next ¶
func (si *SpatialIterator) Next() (aep.Record, error)
Next returns a spatialized a record from the parent iterator to fulfill the iterator interface.
func (*SpatialIterator) NextGridded ¶ added in v1.7.0
func (si *SpatialIterator) NextGridded() (aep.RecordGridded, error)
NextGridded returns a spatialized a record from the parent iterator.
func (*SpatialIterator) Report ¶
func (si *SpatialIterator) Report() *aep.InventoryReport
Report returns an emissions report on the records that have been processed by this iterator.
func (*SpatialIterator) SpatialTotals ¶
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 ¶
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 ¶
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 ¶
func (c *SpeciateConfig) Speciate(r aep.Record) (*SpeciatedRecord, error)
Speciate chemically speciates the given record.
type SpeciatedRecord ¶
SpeciatedRecord is an emissions record where chemical speciation has been performed. It should be created using SpeciateConfig.Speciate().
func (*SpeciatedRecord) CombineEmissions ¶
func (r *SpeciatedRecord) CombineEmissions(r2 aep.Record)
CombineEmissions combines emissions from r2 with the receiver.
func (*SpeciatedRecord) DroppedEmissions ¶
func (r *SpeciatedRecord) DroppedEmissions() *aep.Emissions
DroppedEmissions returns emissions that were dropped from the analysis during speciation to avoid double counting.
func (*SpeciatedRecord) GetEmissions ¶
func (r *SpeciatedRecord) GetEmissions() *aep.Emissions
GetEmissions returns the speciated emissions.
func (*SpeciatedRecord) PeriodTotals ¶
PeriodTotals returns total emissions for the given time period.