Documentation ¶
Index ¶
- Constants
- func EmisAtTime(r Record, t time.Time, tp *TemporalProcessor, partialMatch bool) (map[Pollutant]*unit.Unit, error)
- func EmissionsGriddedAtTime(recs []Record, t time.Time, o Outputter, sp *SpatialProcessor, ...) (map[Pollutant][]*sparse.SparseArray, error)
- func EmissionsTotal(recs []Record) map[Pollutant]*unit.Unit
- func GriddedEmissions(r Record, begin, end time.Time, sp *SpatialProcessor, gi int) (emis map[Pollutant]*sparse.SparseArray, units map[Pollutant]unit.Dimensions, ...)
- func IsStringInArray(a []string, s string) bool
- func MatchCode(code string, matchmap map[string]interface{}) (matchedCode string, matchVal interface{}, err error)
- func MatchCodeDouble(code1, code2 string, matchmap map[string]map[string]interface{}) (matchedCode1, matchedCode2 string, matchVal interface{}, err error)
- func SCCDescription(r io.Reader) (map[string]string, error)
- type Context
- type ControlData
- type Country
- type EconomicData
- type EconomicRecord
- type Emissions
- func (e *Emissions) Add(begin, end time.Time, pollutant, polPrefix string, rate *unit.Unit)
- func (e *Emissions) Clone() *Emissions
- func (e *Emissions) CombineEmissions(r2 Record)
- func (e *Emissions) DropPols(polsToKeep Speciation) map[Pollutant]*unit.Unit
- func (e *Emissions) GetEmissions() *Emissions
- func (e *Emissions) PeriodTotals(begin, end time.Time) map[Pollutant]*unit.Unit
- func (e *Emissions) Scale(f func(Pollutant) (float64, error)) error
- func (e Emissions) String() string
- func (e *Emissions) Totals() map[Pollutant]*unit.Unit
- type EmissionsReader
- type GridCell
- type GridDef
- type GridRef
- type GriddedSrgData
- type GriddingSurrogate
- type InputUnits
- type InventoryFile
- type InventoryFrequency
- type InventoryReport
- type Mechanisms
- type MetData
- type Outputter
- type Period
- type PointRecord
- type PointSourceData
- type Pollutant
- type PolygonRecord
- type RecFilter
- type Record
- func NewFF10DailyPoint(rec []string, annualBegin, annualEnd time.Time, periods [12]*monthPeriod, ...) (Record, error)
- func NewFF10Nonpoint(rec []string, annualBegin, annualEnd time.Time, periods [12]*monthPeriod, ...) (Record, error)
- func NewFF10Point(rec []string, annualBegin, annualEnd time.Time, periods [12]*monthPeriod, ...) (Record, error)
- func NewIDAArea(rec string, pollutants []string, country Country, begin, end time.Time, ...) (Record, error)
- func NewIDAMobile(rec string, pollutants []string, country Country, begin, end time.Time, ...) (Record, error)
- func NewIDAPoint(rec string, pollutants []string, country Country, begin, end time.Time, ...) (Record, error)
- func NewORLMobile(rec []string, country Country, begin, end time.Time, ...) (Record, error)
- func NewORLNonpoint(rec []string, country Country, begin, end time.Time, ...) (Record, error)
- func NewORLNonroad(rec []string, country Country, begin, end time.Time, ...) (Record, error)
- func NewORLPoint(rec []string, country Country, begin, end time.Time, ...) (Record, error)
- type SourceData
- func (r SourceData) GetCountry() Country
- func (r SourceData) GetFIPS() string
- func (r SourceData) GetSCC() string
- func (r SourceData) GetSourceData() *SourceData
- func (r *SourceData) Key() string
- func (r *SourceData) Spatialize(sp *SpatialProcessor, gi int) (gridSrg *sparse.SparseArray, coveredByGrid, inGrid bool, err error)
- type SpatialAdjustRecord
- type SpatialAdjuster
- type SpatialProcessor
- type SpecRef
- type SpeciateDB
- type Speciation
- type SpeciationType
- type Speciator
- type SrgSpec
- type SrgSpecs
- type Status
- type SurrogateFilter
- type Table
- type TemporalProcessor
- type WRFOutputter
- type WRFconfigData
Constants ¶
const ( VOC SpeciationType = "VOC" VOCUngrouped = "VOCUngrouped" // Do not group VOCs into a chemical mechanism. NOx = "NOx" PM25 = "PM2.5" SingleSpecies = "Single" // This pollutant is already speciated. Direct = "Direct" // The speciation profile is directly specified in the configuration. )
These are the currently supported speciation types.
const ( USA Country = 0 Canada = 1 Mexico = 2 Cuba = 3 Bahamas = 4 Haiti = 5 DominicanRepublic = 6 Unknown = -1 )
These are the currently supported countries.
const Version = "0.1.0"
Version give the current version of AEP. The versioning scheme is at: http://semver.org/.
const Website = "http://github.com/ctessum/aep/"
Website gives the location of the AEP website.
Variables ¶
This section is empty.
Functions ¶
func EmisAtTime ¶
func EmisAtTime(r Record, t time.Time, tp *TemporalProcessor, partialMatch bool) (map[Pollutant]*unit.Unit, error)
EmisAtTime returns the emissions from the given Record occurring during the hour after t, after being adjusted with the temporal profiles in tp. If partialMatch is true, temporal profiles will be used for SCC codes partially matching the SCC code of the given record if no exact match is found.
func EmissionsGriddedAtTime ¶
func EmissionsGriddedAtTime(recs []Record, t time.Time, o Outputter, sp *SpatialProcessor, tp *TemporalProcessor, partialMatch bool) (map[Pollutant][]*sparse.SparseArray, error)
EmissionsGriddedAtTime returns the sum of the emissions in recs at the given time.
func EmissionsTotal ¶
EmissionsTotal returns the total combined emissions in recs.
func GriddedEmissions ¶
func GriddedEmissions(r Record, begin, end time.Time, sp *SpatialProcessor, gi int) (emis map[Pollutant]*sparse.SparseArray, units map[Pollutant]unit.Dimensions, err error)
GriddedEmissions returns gridded emissions of record r for a given grid index and period.
func IsStringInArray ¶
IsStringInArray returns whether s is a member of a.
func MatchCode ¶
func MatchCode(code string, matchmap map[string]interface{}) (matchedCode string, matchVal interface{}, err error)
MatchCode finds code in matchmap. For cases where a specific code needs to be matched with a more general code. For instance, if code is "10101" and matchmap is {"10102":"xxx","10100":"yyyy"}, "10100" will be returned as the closest match to the input code. "10102" will never be returned, even if the "10100" item didn't exist. Returns an error if there is no match.
Types ¶
type Context ¶
type Context struct { ShapefileDir string // Directory where input shapefiles are stored GriddedSrgs string // Directory where gridded spatial surrogate shapefiles are to be created Sector string // Name of the sector SectorType string // Type of sector (point, area) RunSpeciate bool // Whether to speciate data RunSpatialize bool // Whether to spatialize data RunTemporal bool // Whether to temporalize data StartDate string // Date for which to begin processing emissions EndDate string // Date for which to end processing emissions Tstep string // Timestep between emissions outputs. Currently, it is recommended to set this to "1h". TstepsPerFile int // Number of output timesteps in each file. Currently, it is recommended to set this to "24". OutputType string // Type of output file. Currently the only available option is "WRF". SccDesc string // name of file with SCC code descriptions SicDesc string // name of file with SIC code descriptions NaicsDesc string // name of file with NAICS code descriptions SpecRefFile string // Location of the speciation code reference file. SpecRefComboFile string // Location of the county specific speciation code reference file, if any. SpecProFile string // Location of the SPECIATE database in sqlite format. SpecType string // Type of speciation to perform. Either "mol" or "mass". ChemicalMechanism string // name for chemical species grouping scheme (needs to be present in SPECIATE database as columns with "_GROUP" and "_FACTOR" appended) MechAssignmentFile string // Path to the mechanism assignment file. Can be downloaded from http://www.cert.ucr.edu/~carter/emitdb/ MechanismMWFile string // Path to the mechanism molecular weight file. Can be compiled from information from http://www.cert.ucr.edu/~carter/emitdb/ SpeciesInfoFile string // Path to the VOC species info file. Can be downloaded from http://www.cert.ucr.edu/~carter/emitdb/ //PolsToKeep map[string]*PolHolder // List and characteristics of pollutants to extract from the inventory and process InputProj4 string // Proj4 specification of the spatial projection of the input emissions data. GridRefFile string // Location of the gridding reference file SrgSpecFile string // Location of the surrogate specification file TemporalRefFile string // Location of the temporal reference file TemporalProFile string // Location of the temporal profile file HolidayFile string // Location of the file specifying which days are holidays InventoryFreq InventoryFrequency // The temporal frequency of the inventory data files. Currently the options are "annual", "monthly", and "cem". RunPeriods []Period // Periods (annual, or individual months, etc.) to be run for this sector MatchFullSCC bool // Whether to only match codes which are identical, or to accept partial matches. DebugLevel int // Sets the volume of output printed to the screen. Set to 0 for least output, 3 for most output. Also, if DebugLevel > 0, any errors encountered will cause the entire program to crash with a stack trace, rather than just printing an error message and continuing. Ncpus int // Number of processors available for use InputUnits string // Units of emissions in input file InputConv float64 ForceWesternHemisphere bool // If all data is in the western hemisphere, fix any errors where the minus sign was left out of the longitude. InvFileNames []string // List of input files. "[month]" can be used as a wildcard for the month name. CEMFileNames []string // List of input files with CEM data (needs to be a whole year's worth of data EarthRadius float64 // in meters WPSnamelist string // Path to WPS namelist file WRFnamelist string // Path to WPS namelist file OldWRFout string // Path to old WRF output files for plume rise calculations. //[DOMAIN] and [DATE] can be used as wildcards. If kemit > 1 in the WRF namelist.input file, these files // will be needed to calculate plume rise for point sources. Otherwise, these files will not be necessary. RegenerateSpatialData bool // Whether or not to delete surrogates and ShapefileDir generated by previous run and start over. If the model has not been previously run with the current "SimuationName", this does nothing. If the model did not sucessfully complete the last time it was run, the model may crash again if this is set to `false`. SimulationName string // Name for the simulation: user choice ErrorFlag bool // whether this sector has already encountered an error CheckSrgs bool // Should we check the surrogate shapefiles before running? // contains filtered or unexported fields }
Context is a container for the configuration and report info
func (*Context) NAICSDesc ¶
NAICSDesc reads a NAICS description file, which gives descriptions for each NAICS code.
func (*Context) NewTemporalProcessor ¶
func (c *Context) NewTemporalProcessor(holidays, tref, tpro io.Reader, cem []io.Reader, useCEM bool) (*TemporalProcessor, error)
NewTemporalProcessor initializes a new TemporalProcessor.
type ControlData ¶
type ControlData struct { // Maximum Available Control Technology Code // (6 characters maximum) (optional) MACT string // Control efficiency percentage (give value of 0-100) (recommended, // if left blank, default is 0). CEff float64 // Rule Effectiveness percentage (give value of 0-100) (recommended, // if left blank, default is 100) REff float64 // Rule Penetration percentage (give value of 0-100) (optional; // if missing will result in default of 100) RPen float64 }
ControlData holds information about how emissions from this source can be controlled.
type EconomicData ¶
type EconomicData struct { // SIC is the Standard Industrial Classification Code (recommended) SIC string // North American Industrial Classification System Code // (6 characters maximum) (optional) NAICS string }
EconomicData holds industry information about an emissions source
func (*EconomicData) GetEconomicData ¶
func (r *EconomicData) GetEconomicData() *EconomicData
GetEconomicData returns r.
type EconomicRecord ¶
type EconomicRecord interface { // GetEconomicData returns the economic information associated with this record. GetEconomicData() *EconomicData }
EconomicRecord is any record that contains economic information.
type Emissions ¶
type Emissions struct {
// contains filtered or unexported fields
}
Emissions holds information about the rate of emissions from a source of different pollutants and potentially at different times.
func (*Emissions) Add ¶
Add adds emissions beginning and ending at times begin and end, respectively, of pollutant 'pollutant' with prefix 'polPrefix' (e.g., BRK, TIR, etc), and of total amount 'amount'. Emissions are expected to be in units of g/s.
func (*Emissions) CombineEmissions ¶
CombineEmissions combines emissions from r2 into this record.
func (*Emissions) DropPols ¶
func (e *Emissions) DropPols(polsToKeep Speciation) map[Pollutant]*unit.Unit
DropPols removes the pollutants that are not in polsToKeep and returns the total emissions removed, in units of [mass]. If polsToKeep is nil, all pollutants are kept.
func (*Emissions) GetEmissions ¶
GetEmissions returns the emissions associated with this record
func (*Emissions) PeriodTotals ¶
PeriodTotals returns the total emissions from this emissions source between the times begin and end.
type EmissionsReader ¶
type EmissionsReader struct { // Group specifies a group name for files read by this reader. // It is used for report creation Group string // contains filtered or unexported fields }
An EmissionsReader reads SMOKE formatted emissions files.
func NewEmissionsReader ¶
func NewEmissionsReader(polsToKeep Speciation, freq InventoryFrequency, InputUnits InputUnits) (*EmissionsReader, error)
NewEmissionsReader creates a new EmissionsReader. polsToKeep specifies which pollutants from the inventory to keep. If it is nil, all pollutants are kept. InputUnits is the units of input data. Acceptable values are `tons', `tonnes', `kg', `g', and `lbs'.
func (*EmissionsReader) OpenFilesFromTemplate ¶
func (e *EmissionsReader) OpenFilesFromTemplate(filetemplate string) ([]*InventoryFile, error)
OpenFilesFromTemplate opens the files that match the template.
func (*EmissionsReader) ReadFiles ¶
func (e *EmissionsReader) ReadFiles(files []*InventoryFile, f RecFilter) ([]Record, *InventoryReport, error)
ReadFiles reads emissions associated with period p from the specified files, and returns emissions records and a summary report. The specified filenames are only used for reporting. If multiple files have data for the same specific facility (for instance, if one file has CAPs emissions and the other has HAPs emissions) they need to be processed in this function together to avoid double counting in speciation. (If you will not be speciating the emissions, then it doesn't matter.) f is an optional filter function to determine which records should be kept. If f is nil, all records will be kept. The caller is responsible for closing the files.
type GridDef ¶
type GridDef struct { Name string Nx, Ny int Dx, Dy float64 X0, Y0 float64 Cells []*GridCell SR *proj.SR Extent geom.Polygon IrregularGrid bool // whether the grid is a regular grid // contains filtered or unexported fields }
GridDef specifies the grid that we are allocating the emissions to.
func NewGridIrregular ¶
func NewGridIrregular(Name string, g []geom.Polygonal, inputSR, outputSR *proj.SR) (grid *GridDef, err error)
NewGridIrregular creates a new irregular grid. g is the grid geometry. Irregular grids have 1 column and n rows, where n is the number of shapes in g. inputSR is the spatial reference of g, and outputSR is the desired spatial reference of the grid.
func NewGridRegular ¶
NewGridRegular creates a new regular grid, where all grid cells are the same size.
func (*GridDef) GetIndex ¶
GetIndex gets the returns the row and column indices of point p in the grid. withinGrid is false if point (X,Y) is not within the grid. Usually there will be only one row and column for each point, but it the point lies on a shared edge among multiple grid cells, all of the overlapping grid cells will be returned.
func (*GridDef) WriteToShp ¶
WriteToShp writes the grid definition to a shapefile in directory outdir.
type GridRef ¶
GridRef specifies the grid surrogates the correspond with combinations of country (first map), SCC (second map), and FIPS or spatial ID (third map).
func ReadGridRef ¶
ReadGridRef reads the SMOKE gref file, which maps FIPS and SCC codes to grid surrogates
func (GridRef) GetSrgCode ¶
GetSrgCode returns the surrogate code appropriate for the given SCC code, country and FIPS.
type GriddedSrgData ¶
type GriddedSrgData struct { InputID string InputGeom geom.Polygonal Cells []*GridCell SingleShapeSrgWeight float64 CoveredByGrid bool }
GriddedSrgData holds the data for a single input shape of a gridding surrogate.
func (*GriddedSrgData) WriteToShp ¶
func (g *GriddedSrgData) WriteToShp(s *shp.Encoder) error
WriteToShp write an individual gridding surrogate to a shapefile.
type GriddingSurrogate ¶
type GriddingSurrogate struct { // Srg holds surrogate data associated with individual input locations. Srg map[string]*GriddedSrgData // Nx and Ny are the number of columns and rows in the grid Nx, Ny int }
GriddingSurrogate holds generated gridding surrogate data, and can be used to allocate emissions attributed to a relatively large area, such as a county, to the grid cells within that area.
func (*GriddingSurrogate) ToGrid ¶
func (gs *GriddingSurrogate) ToGrid(shapeID string) (*sparse.SparseArray, bool)
ToGrid allocates the 1 unit of emissions associated with shapeID to a grid based on gs. It will return nil if there is no surrogate for the specified shapeID or if the sum of the surrogate is zero. The second returned value indicates whether the shape corresponding to shapeID is completely covered by the grid.
type InputUnits ¶
type InputUnits int
InputUnits specify available options for emissions input units.
const ( // Ton is short tons Ton InputUnits = iota // Tonne is metric tons Tonne // Kg is kilograms Kg // G is grams G // Lb is pounds Lb )
type InventoryFile ¶
type InventoryFile struct { io.ReadSeeker // Name is the name of this file. It can be the path to the file or something else. Name string // Group is a label for the group of files this is part of. It is used for reporting. Group string // Period is the time period that the emissions in this file apply to. Period // Totals holds the total emissions in this file, disaggregated by pollutant. Totals map[Pollutant]*unit.Unit // DroppedTotals holds the total emissions in this file that are not being // kept for analysis. DroppedTotals map[Pollutant]*unit.Unit // contains filtered or unexported fields }
An InventoryFile reads information from and stores information about an emissions inventory file.
func NewInventoryFile ¶
func NewInventoryFile(name string, r io.ReadSeeker, p Period, inputConverter func(float64) *unit.Unit) (*InventoryFile, error)
NewInventoryFile sets up a new InventoryFile with name name and reader r. p specifies the time period that the emissions are effective during, and inputConverter is a function to convert the input data to SI units.
type InventoryFrequency ¶
type InventoryFrequency string
InventoryFrequency describes how many often new inventory files are required.
const ( Annually InventoryFrequency = "annual" Monthly InventoryFrequency = "monthly" )
Inventory frequencies can either be annual or monthly
type InventoryReport ¶
type InventoryReport struct {
Files []*InventoryFile
}
An InventoryReport report holds information about raw inventory data.
func (*InventoryReport) AddData ¶
func (ir *InventoryReport) AddData(files ...*InventoryFile)
AddData adds file(s) to the report.
func (*InventoryReport) DroppedTotalsTable ¶
func (ir *InventoryReport) DroppedTotalsTable() Table
DroppedTotalsTable returns a table of the total emissions in this report, where the rows are the files and the columns are the pollutants, arranged alphabetically.
func (*InventoryReport) TotalsTable ¶
func (ir *InventoryReport) TotalsTable() Table
TotalsTable returns a table of the total emissions in this report, where the rows are the files and the columns are the pollutants, arranged alphabetically.
type Mechanisms ¶
type Mechanisms struct { // MechAssigment holds chemical mechanism assignment information // for individiaul chemical species. // Data should be in the format: // map[mechanism][SPECIATE ID][mechanism group]ratio. MechAssignment map[string]map[string]map[string]float64 // MechMW holds molecular weight information for chemical // mechanism species. Data should be in the format: // map[mechanism][mechanism group]{massOrMol,MW} MechMW map[string]map[string]mechData // SpecInfo holds name and molecular weight information // for individual chemical species. // Data should be in the format: // map[SPECIATE ID]{name, MW} SpecInfo map[string]specInfo }
Mechanisms holds information on chemical speciation mechanisms as specified at http://www.cert.ucr.edu/~carter/emitdb/.
func NewMechanisms ¶
func NewMechanisms(mechAssignment, molarWeight, speciesInfo io.Reader) (*Mechanisms, error)
NewMechanisms returns a new Mechanisms variable initialized with information from mechanism assignment, molecular weight, and species information files in the format specified at http://www.cert.ucr.edu/~carter/emitdb/. (The files on the website must first be converted from Microsoft Excel to CSV format before being read by this function.)
func (*Mechanisms) GroupFactors ¶
func (m *Mechanisms) GroupFactors(mechanism, speciesID string, mass bool) (map[string]float64, error)
GroupFactors returns the factors by which to multiply the given chemical species by to convert it to the given chemical mechanism. If mass is true, the multipliers will be adjusted so as to conserve the mass of the input species, so the units will be mass/mass. Otherwise, the factors will be computed so as to convert the chemical amount to a molar basis and the units will be mol/gram. The species to chemical mechanism conversion database (http://www.cert.ucr.edu/~carter/emitdb/) is designed to (attempt to) conserve reactivity rather than moles or mass, so for molar speciation the total number of moles may not be conserved.
type MetData ¶
type MetData struct { LayerHeights [][][][]float32 // [grid][i][j][k] Uspd [][][][]float32 // [grid][i][j][k] Temp [][][][]float32 // temperature S1 [][][][]float32 // stability parameter Sclass [][][][]string // Stability class Kemit int // number of levels in emissions file // contains filtered or unexported fields }
MetData is a WRF meteorology data holder.
type Outputter ¶
type Outputter interface { Output(recs []Record, sp *SpatialProcessor, tp *TemporalProcessor, partialMatch bool, startTime, endTime time.Time, timeStep time.Duration) error PlumeRise(point Record, sp *SpatialProcessor, gi int) (int, error) Layers() int }
Outputter specifies a form for variables that can be used to output spatiotemporal emissions data.
type Period ¶
type Period int
Period specifies the time period of the emissions data.
The Periods are the months of the year, annual, or Cem which is hourly continuous emissions monitoring data.
func PeriodFromTimeInterval ¶
PeriodFromTimeInterval returns the period associated with the given time interval.
type PointRecord ¶
type PointRecord struct { SourceData PointSourceData EconomicData ControlData Emissions }
PointRecord holds information about an emissions source that has a point location.
func (*PointRecord) Key ¶
func (r *PointRecord) Key() string
Key returns a unique key for this record.
func (*PointRecord) Spatialize ¶
func (r *PointRecord) Spatialize(sp *SpatialProcessor, gi int) ( gridSrg *sparse.SparseArray, coveredByGrid, inGrid bool, err error)
Spatialize takes a spatial processor (sp) and a grid index number (gi) and returns a gridded spatial surrogate (gridSrg) for a point emissions source, as well as whether the emissions source is completely covered by the grid (coveredByGrid) and whether it is in the grid all all (inGrid).
type PointSourceData ¶
type PointSourceData struct { // PlantID is the Plant Identification Code (15 characters maximum) (required, // this is the same as the State Facility Identifier in the NIF) PlantID string // PointID is the Point Identification Code (15 characters maximum) (required, // this is the same as the Emission Unit ID in the NIF) PointID string // StackID is the Stack Identification Code (15 characters maximum) (recommended, // this is the same as the Emissions Release Point ID in the NIF) StackID string // Segement is the DOE Plant ID (15 characters maximum) (recommended, this is the // same as the Process ID in the NIF) Segment string // Plant Name (40 characters maximum) (recommended) Plant string // DOE Plant ID (generally recommended, and required if matching // to hour-specific CEM data) ORISFacilityCode string // Boiler Identification Code (recommended) ORISBoilerID string // Stack Height (m) (required) StackHeight *unit.Unit // Stack Diameter (m) (required) StackDiameter *unit.Unit // Stack Gas Exit Temperature (K) (required) StackTemp *unit.Unit // Stack Gas Flow Rate (m3/sec) (optional) StackFlow *unit.Unit // Stack Gas Exit Velocity (m/sec) (required) StackVelocity *unit.Unit // Point holds the location of the emissions source geom.Point // SR holds the spatial reference system of the coordinates of this point SR *proj.SR }
PointSourceData holds information specific to point emissions sources.
func (*PointSourceData) GroundLevel ¶
func (r *PointSourceData) GroundLevel() bool
GroundLevel returns true if the receiver emissions are at ground level and false if they are elevated.
func (*PointSourceData) Key ¶
func (r *PointSourceData) Key() string
Key returns a unique key for this record.
func (*PointSourceData) PointData ¶
func (r *PointSourceData) PointData() *PointSourceData
PointData returns the data specific to point sources.
func (*PointSourceData) Spatialize ¶
func (r *PointSourceData) Spatialize(sp *SpatialProcessor, gi int) ( gridSrg *sparse.SparseArray, coveredByGrid, inGrid bool, err error)
Spatialize takes a spatial processor (sp) and a grid index number (gi) and returns a gridded spatial surrogate (gridSrg) for a point emissions source, as well as whether the emissions source is completely covered by the grid (coveredByGrid) and whether it is in the grid all all (inGrid).
type Pollutant ¶
type Pollutant struct { // Name is the name of the pollutant. Name string // Prefix holds information about the pollutant prefix, such as BRK, TIR, etc. Prefix string }
Pollutant holds information about a pollutant.
type PolygonRecord ¶
type PolygonRecord struct { SourceData EconomicData ControlData Emissions }
PolygonRecord holds information about an emissions source that has an area (i.e., polygon) location. The polygon is designated by the SourceData.FIPS code.
func (*PolygonRecord) PointData ¶
func (r *PolygonRecord) PointData() *PointSourceData
PointData exists to fulfill the Record interface but always returns nil because this is not a point source.
type RecFilter ¶
RecFilter is a class of functions that return true if a record should be kept and processed.
type Record ¶
type Record interface { // GetSCC returns the SCC associated with this record. GetSCC() string // GetFIPS returns the FIPS associated with this record. GetFIPS() string // GetCountry returns the Country associated with this record. GetCountry() Country // GetEmissions returns the emissions associated with this record GetEmissions() *Emissions // CombineEmissions combines emissions from r2 into this record. CombineEmissions(r2 Record) // Totals returns the total emissions in units of grams. Totals() map[Pollutant]*unit.Unit // PeriodTotals returns the total emissions from this emissions source between // the times begin and end. PeriodTotals(begin, end time.Time) map[Pollutant]*unit.Unit // DropPols removes the pollutants that are not in polsToKeep // and returns the total emissions removed, in units of grams. // If polsToKeep is nil, all pollutants are kept. DropPols(polsToKeep Speciation) map[Pollutant]*unit.Unit // Spatialize takes a spatial processor (sp) and a grid index number (gi) and // returns a gridded spatial surrogate (gridSrg) for an emissions source, // as well as whether the emissions source is completely covered by the grid // (coveredByGrid) and whether it is in the grid all all (inGrid). Spatialize(sp *SpatialProcessor, gi int) (gridSrg *sparse.SparseArray, coveredByGrid, inGrid bool, err error) // GetSourceData returns the source information associated with this record. GetSourceData() *SourceData // PointData returns the data specific to point sources. If the record is // not a point source, it should return nil. PointData() *PointSourceData // Key returns a unique identifier for this record. Key() string }
A Record holds data from a parsed emissions inventory record. Two types that implement this interface are PointRecord and PolygonRecord.
func NewFF10DailyPoint ¶
func NewFF10DailyPoint(rec []string, annualBegin, annualEnd time.Time, periods [12]*monthPeriod, inputConv func(float64) *unit.Unit) (Record, error)
NewFF10DailyPoint creates a new record from the FF10 daily point record rec, where periods specify the periods when the emissions occur (the 12 months) and inputConv specifies the factor to multiply emissions by to convert them to SI units.
func NewFF10Nonpoint ¶
func NewFF10Nonpoint(rec []string, annualBegin, annualEnd time.Time, periods [12]*monthPeriod, inputConv func(float64) *unit.Unit) (Record, error)
NewFF10Nonpoint creates a new record from the FF10 nonpoint record rec, where annualBegin and annualEnd specify the period that annual total emissions occur over, 'periods' specifies the periods when the monthly emissions occur
and inputConv specifies the factor
to multiply emissions by to convert them to SI units.
func NewFF10Point ¶
func NewFF10Point(rec []string, annualBegin, annualEnd time.Time, periods [12]*monthPeriod, inputConv func(float64) *unit.Unit) (Record, error)
NewFF10Point creates a new record from the FF10 point record rec, where annualBegin and annualEnd specify the period that annual total emissions occur over, 'periods' specifies the periods when the monthly emissions occur
and inputConv specifies the factor
to multiply emissions by to convert them to SI units.
func NewIDAArea ¶
func NewIDAArea(rec string, pollutants []string, country Country, begin, end time.Time, inputConv func(float64) *unit.Unit) (Record, error)
NewIDAArea creates a new record from the IDA area record rec, where pollutants are the names of the pollutants in the record, country is the country and year of the emissions, begin and end specify the time period this record covers, and inputConv specifies the factor to multiply emissions by to convert them to SI units.
func NewIDAMobile ¶
func NewIDAMobile(rec string, pollutants []string, country Country, begin, end time.Time, inputConv func(float64) *unit.Unit) (Record, error)
NewIDAMobile creates a new record from the IDA mobile record rec, where pollutants are the names of the pollutants in the record, country is the country and year of the emissions, begin and end specify the time period this record covers, and inputConv specifies the factor to multiply emissions by to convert them to SI units.
func NewIDAPoint ¶
func NewIDAPoint(rec string, pollutants []string, country Country, begin, end time.Time, inputConv func(float64) *unit.Unit) (Record, error)
NewIDAPoint creates a new record from the IDA point record rec, where pollutants are the names of the pollutants in the record, country is the country and year of the emissions, begin and end specify the time period this record covers, and inputConv specifies the factor to multiply emissions by to convert them to SI units.
func NewORLMobile ¶
func NewORLMobile(rec []string, country Country, begin, end time.Time, inputConv func(float64) *unit.Unit) (Record, error)
NewORLMobile creates a new record from the ORL mobile record rec, where country is the country and year of the emissions, begin and end specify the time period this record covers, inputConv specifies the factor to multiply emissions by to convert them to SI units.
func NewORLNonpoint ¶
func NewORLNonpoint(rec []string, country Country, begin, end time.Time, inputConv func(float64) *unit.Unit) (Record, error)
NewORLNonpoint creates a new record from the ORL nonpoint record rec, where country is the country and year of the emissions, begin and end specify the time period this record covers, and inputConv specifies the factor to multiply emissions by to convert them to SI units.
func NewORLNonroad ¶
func NewORLNonroad(rec []string, country Country, begin, end time.Time, inputConv func(float64) *unit.Unit) (Record, error)
NewORLNonroad creates a new record from the ORL nonroad record rec, where country is the country and year of the emissions, begin and end specify the time period this record covers, inputConv specifies the factor to multiply emissions by to convert them to SI units.
func NewORLPoint ¶
func NewORLPoint(rec []string, country Country, begin, end time.Time, inputConv func(float64) *unit.Unit) (Record, error)
NewORLPoint creates a new record from the ORL point record rec, where country is the country and year of the emissions, begin and end specify the time period this record covers, and inputConv specifies the factor to multiply emissions by to convert them to SI units.
type SourceData ¶
type SourceData struct { // Five digit FIPS code for state and county (required) FIPS string // Ten character Source Classification Code (required) SCC string // Source type (2 characters maximum), used by SMOKE in determining // applicable MACT-based controls (required) // 01 = major // 02 = Section 12 area source // 03 = nonroad // 04 = onroad SourceType string // The country that this record applies to. Country Country }
SourceData holds information about the type of an emissions source.
func (SourceData) GetCountry ¶
func (r SourceData) GetCountry() Country
GetCountry returns the Country associated with this record.
func (SourceData) GetFIPS ¶
func (r SourceData) GetFIPS() string
GetFIPS returns the FIPS associated with this record.
func (SourceData) GetSCC ¶
func (r SourceData) GetSCC() string
GetSCC returns the SCC associated with this record.
func (SourceData) GetSourceData ¶
func (r SourceData) GetSourceData() *SourceData
GetSourceData returns r.
func (*SourceData) Key ¶
func (r *SourceData) Key() string
Key returns a unique key for this record.
func (*SourceData) Spatialize ¶
func (r *SourceData) Spatialize(sp *SpatialProcessor, gi int) ( gridSrg *sparse.SparseArray, coveredByGrid, inGrid bool, err error)
Spatialize takes a spatial processor (sp) and a grid index number (gi) and returns a gridded spatial surrogate (gridSrg) for an area emissions source, as well as whether the emissions source is completely covered by the grid (coveredByGrid) and whether it is in the grid all all (inGrid).
type SpatialAdjustRecord ¶
type SpatialAdjustRecord struct { // Record is the record to be adjusted. Record // SpatialAdjuster specifies the adjustment to occur. SpatialAdjuster }
SpatialAdjustRecord wraps around a Record to provide a spatially-explicit adjustment.
func (*SpatialAdjustRecord) Spatialize ¶
func (r *SpatialAdjustRecord) Spatialize(sp *SpatialProcessor, gi int) ( gridSrg *sparse.SparseArray, coveredByGrid, inGrid bool, err error)
Spatialize calls the Spatialize method of the contained Record and adjusts the output using the SpatialAdjuster field.
type SpatialAdjuster ¶
type SpatialAdjuster interface {
Adjustment() (*sparse.DenseArray, error)
}
SpatialAdjuster is an interface for types that provide gridded adjustments to Records.
type SpatialProcessor ¶
type SpatialProcessor struct { SrgSpecs Grids []*GridDef GridRef // DiskCachePath specifies a directory to cache surrogate files in. If it is // empty or invalid, surrogates will not be stored on the disk for later use. DiskCachePath string // MemCacheSize specifies the number of surrogates to hold in the memory cache. // A larger number results in potentially faster performance but more memory use. // The default is 100. MemCacheSize int // MaxMergeDepth is the maximum number of nested merged surrogates. // For example, if surrogate 100 is a combination of surrogates 110 and 120, // and surrogate 110 is a combination of surrogates 130 and 140, then // MaxMergeDepth should be set to 3, because 100 depends on 110 and 110 // depends on 130. If MaxMergeDepth is set too low, the program may hang // when attempting to create a merged surrogate. // The default value is 10. MaxMergeDepth int // SimplifyTolerance specifies the length of features up to which to remove // when simplifying shapefiles for spatial surrogate creation. The default is // 0 (i.e., no simplification). Simplifying decreases processing time and // memory use. The value should be in the units of the output grid // (e.g., meters or degrees). SimplifyTolerance float64 // contains filtered or unexported fields }
SpatialProcessor spatializes emissions records.
func NewSpatialProcessor ¶
func NewSpatialProcessor(srgSpecs *SrgSpecs, grids []*GridDef, gridRef *GridRef, inputSR *proj.SR, matchFullSCC bool) *SpatialProcessor
NewSpatialProcessor creates a new spatial processor.
func (*SpatialProcessor) Surrogate ¶
func (sp *SpatialProcessor) Surrogate(srgSpec *SrgSpec, grid *GridDef, fips string) (*sparse.SparseArray, bool, error)
Surrogate gets the specified spatial surrogate. It is important not to edit the returned surrogate in place, because the same copy is used over and over again. The second return value indicates whether the shape corresponding to fips is completely covered by the grid.
type SpecRef ¶
type SpecRef struct {
// contains filtered or unexported fields
}
SpecRef holds speciation reference information extracted from SMOKE model gsref files.
func NewSpecRef ¶
NewSpecRef returns a new SpecRef variable created from the information in the given readers.
func (*SpecRef) Codes ¶
func (sp *SpecRef) Codes(SCC string, pol Pollutant, start, end time.Time, c Country, FIPS string, partialMatch bool) (map[string]float64, error)
Codes returns the speciation profile code(s) that match the given SCC code, pollutant (pol), time period (start and end), country, and FIPS location code, along with the fraction of speciation that should be attributed to each code. If partialMatch is false, only codes exactly matching the given SCC will be returned, otherwise if no match is found an attempt will be made to return a code matching a more general SCC. If no direct match is found for pol, an attempt will be made to find a match for a version of pol without its prefix.
type SpeciateDB ¶
type SpeciateDB struct { // SpeciesProperties maps speciate IDs to chemical names and // molecular weights. SpeciesProperties map[string]struct { Name string MW float64 } // VOCToTOG holds the conversion factor from VOC mass to TOG mass // for VOCs in different speciation profiles. VOCToTOG map[string]float64 // VOCProfiles maps aggregated VOCs to individual VOC species. // Format: map[speciation code][species ID]weight VOCProfiles map[string]map[string]float64 // OtherGasProfiles maps aggregated non-VOC gases // such as NOx to individual chemical species. // Format: map[speciation code][species ID]weight OtherGasProfiles map[string]map[string]float64 // PMProfiles maps aggregated particulate matter species // to individual chemical species. // Format: map[speciation code][species ID]weight PMProfiles map[string]map[string]float64 }
SpeciateDB holds information extracted from the SPECIATE database. (https://www.epa.gov/air-emissions-modeling/tools-related-air-emissions-modeling)
func NewSpeciateDB ¶
func NewSpeciateDB(speciesProperties, gasProfile, gasSpecies, otherGasSpecies, pmSpecies io.Reader) (*SpeciateDB, error)
NewSpeciateDB returns a new SpeciateDB variable filled with information from the SPECIATE database, where the arguments are readers of the similarly named tables in the database, exported to CSV format. The SPECIATE database is available at: https://www.epa.gov/air-emissions-modeling/speciate-version-45-through-32. To export the tables in CSV format in Linux, use the mdb-export command:
mdb-export SPECIATE.mdb SPECIES_PROPERTIES > SPECIES_PROPERTIES.csv mdb-export SPECIATE.mdb GAS_PROFILE > GAS_PROFILE.csv mdb-export SPECIATE.mdb GAS_SPECIES > GAS_SPECIES.csv mdb-export SPECIATE.mdb OTHER\ GASES_SPECIES > OTHER_GASES_SPECIES.csv mdb-export SPECIATE.mdb PM_SPECIES > PM_SPECIES.csv
func (*SpeciateDB) IDFromName ¶
func (s *SpeciateDB) IDFromName(name string) (string, error)
IDFromName returns the SPECIATE ID associated with the given species name.
func (*SpeciateDB) Speciation ¶
func (s *SpeciateDB) Speciation(code string, Type SpeciationType) (map[string]float64, error)
Speciation returns the speciation fractions for the given speciation profile code and specition type. Valid Type options are "VOC", "NOx", and "PM2.5". The output is in the format map[SPECIATE ID]fraction.
type Speciation ¶
type Speciation map[string]struct { // SpecType specifies a type of speciation to be applied. // Options are "VOC","PM2.5", and "NOx". // If empty, the pollutant will be carried through to // the output without speciation, or grouped as // if it were the pollutants in "SpecNames". SpecType SpeciationType // SpecNames contains names of pollutants in the SPECIATE // database which are equivalent to this pollutant. // For records containing this pollutant, the pollutants // included in "SpecNames.Names" will be left out of any // speciation that occurs to avoid double counting. SpecNames struct { // Names are the SPECIATE names that are equivalent to this // pollutant. Names []string // Group specifies whether this pollutant should be // grouped into a chemical mechanism. Group bool } // SpecProf can be used to directly specify speciation // factors. Conversion from mass to moles, if required, // must be included in the provided factors. // // BUG: The current implementation won't change the units of the emissions, so // if a unit conversion was included in the factor it won't be reflected // in the speciated result. SpecProf map[string]float64 }
Speciation specifies the pollutant names that should be kept for analysis and information about how to chemically speciate each one. PolInfo holds the configuration of chemical speciation settings for individual pollutants. Only one of the fields should be used for each pollutant.
func (Speciation) Names ¶
func (s Speciation) Names(p Pollutant) ([]string, bool, error)
Names returns the equivalent SPECIATE names of p and whether they should each be grouped into a chemical mechanism. If there is not an exact match for p, it will return the speciation type of p without its prefix. If that fails, or if the SpeciationType of p is not SingleSpecies, it will return an error.
func (Speciation) Profile ¶
func (s Speciation) Profile(p Pollutant) (map[string]float64, error)
Profile returns the directly specified speciation profile for p. If there is not an exact match, it will return the speciation profile for p without its prefix. If that fails, or if the SpeciationType of p is not Direct, it will return an error.
func (Speciation) Type ¶
func (s Speciation) Type(p Pollutant) (SpeciationType, error)
Type returns the SpeciationType of p. If there is not an exact match, it will return the speciation type of p without its prefix. If that fails, it will return an error.
type SpeciationType ¶
type SpeciationType string
SpeciationType specifies the available speciation types.
type Speciator ¶
type Speciator struct { SpecRef *SpecRef SpeciateDB *SpeciateDB Mechanisms *Mechanisms Speciation Speciation }
Speciator speciates emissions in Records from more aggregated chemical groups to more specific chemical groups.
func NewSpeciator ¶
func NewSpeciator(specRef, specRefCombo, speciesProperties, gasProfile, gasSpecies, otherGasSpecies, pmSpecies, mechAssignment, molarWeight, speciesInfo io.Reader, speciation Speciation) (*Speciator, error)
NewSpeciator returns a new Speciator variable.
func (*Speciator) Speciate ¶
func (s *Speciator) Speciate(r Record, mechanism string, mass, partialMatch bool) (emis, dropped *Emissions, err error)
Speciate disaggregates the lumped emissions species in the given Record into the species groups in the given chemical mechanism. If mass is true, speciation is done on a mass basis, otherwise emissions will be converted to molar units for gases (but not for particulates). If partialMatch is true, matches to speciation profile codes will be made based on parital matches to SCC codes if full matches are not available.
type SrgSpec ¶
type SrgSpec struct { Region Country Name string Code string DATASHAPEFILE string DATAATTRIBUTE string WEIGHTSHAPEFILE string Details string // BackupSurrogateNames specifies names of surrogates to use if this // one doesn't have data for the desired location. BackupSurrogateNames []string // WeightColumns specify the fields of the surogate shapefile that // should be used to weight the output locations. WeightColumns []string // WeightFactors are factors by which each of the WeightColumns should // be multiplied. WeightFactors []float64 // FilterFunction specifies which rows in the surrogate shapefile should // be used to create this surrogate. FilterFunction *SurrogateFilter // MergeNames specify names of other surrogates that should be combined // to create this surrogate. MergeNames []string // MergeMultipliers specifies multipliers associated with the surrogates // in MergeNames. MergeMultipliers []float64 // contains filtered or unexported fields }
SrgSpec holds spatial surrogate specification information.
type SrgSpecs ¶
type SrgSpecs struct {
// contains filtered or unexported fields
}
SrgSpecs holds a group of surrogate specifications
func ReadSrgSpec ¶
ReadSrgSpec reads a SMOKE formatted spatial surrogate specification file. Results are returned as a map of surrogate specifications as indexed by their unique ID, which is Region+SurrogateCode. shapefileDir specifies the location of all the required shapefiles, and checkShapeFiles specifies whether to check if the required shapefiles actually exist. If checkShapeFiles is true, then it is okay for the shapefiles to be in any subdirectory of shapefileDir, otherwise all shapefiles must be in shapefileDir itself and not a subdirectory.
type Status ¶
type Status struct {
// Name and Code hold information about the job
Name, Code string
// Status holds information about the status of the job.
Status string
// Progress holds information about how close the job is to completion.
Progress float64
}
Status holds information on the progress or status of a job.
type SurrogateFilter ¶
SurrogateFilter can be used to limit which rows in a shapefile are used to create a gridding surrogate.
func ParseSurrogateFilter ¶
func ParseSurrogateFilter(filterFunction string) *SurrogateFilter
ParseSurrogateFilter creates a new surrogate filter object from a SMOKE-format spatial surrogate filter definition.
type TemporalProcessor ¶
type TemporalProcessor struct { // TimeZones hold the time zone code that each FIPS code // belongs to. TimeZones map[string]*time.Location // contains filtered or unexported fields }
TemporalProcessor calculates emissions at specific times.
type WRFOutputter ¶
type WRFOutputter struct {
// contains filtered or unexported fields
}
WRFOutputter outputs emissions in WRF-Chem format.
func (*WRFOutputter) Layers ¶
func (w *WRFOutputter) Layers() int
Layers returns the number of vertical emission layers being used.
func (*WRFOutputter) Output ¶
func (w *WRFOutputter) Output(recs []Record, sp *SpatialProcessor, tp *TemporalProcessor, partialMatch bool, startTime, endTime time.Time, timeStep time.Duration) error
Output outputs the emissions in recs for every timeStep between startTime and endTime.
func (*WRFOutputter) PlumeRise ¶
func (w *WRFOutputter) PlumeRise(point Record, sp *SpatialProcessor, gi int) (int, error)
PlumeRise calculation, ASME (1973), as described in Sienfeld and Pandis, “Atmospheric Chemistry and Physics - From Air Pollution to Climate Change Uses meteorology from WRF output from a previous run. It returns the layer index of the plume.
type WRFconfigData ¶
type WRFconfigData struct { MaxDom int ParentID []int ParentGridRatio []float64 IParentStart []int JParentStart []int EWE []int ESN []int Dx0 float64 Dy0 float64 MapProj string RefLat float64 RefLon float64 TrueLat1 float64 TrueLat2 float64 StandLon float64 RefX float64 RefY float64 S []float64 W []float64 Dx []float64 Dy []float64 Nx []int Ny []int DomainNames []string FramesPerAuxInput5 []int Kemit int Nocolons bool // contains filtered or unexported fields }
WRFconfigData hold information about a WRF simulation configuration.
func ParseWRFConfig ¶
func ParseWRFConfig(wpsnamelist, wrfnamelist string) (d *WRFconfigData, err error)
ParseWRFConfig extracts configuration information from a set of WRF namelists.
func (*WRFconfigData) Grids ¶
func (d *WRFconfigData) Grids() []*GridDef
Grids creates grid definitions for the grids in WRF configuration d, where tzFile is a shapefile containing timezone information, and tzColumn is the data attribute column within that shapefile that contains the timezone offsets in hours.
func (*WRFconfigData) NewOutputter ¶
func (d *WRFconfigData) NewOutputter(outputDir, oldWRFOut string) *WRFOutputter
NewOutputter creates a new WRF-formatted file outputter.
Source Files ¶
- configure.go
- controldata.go
- economicdata.go
- emissions.go
- ff10.go
- grid.go
- ida.go
- inventory.go
- inventoryfile.go
- orl.go
- output.go
- pointsourcedata.go
- report.go
- sourcedata.go
- spatial_adjust.go
- spatialize.go
- speciate.go
- speciate_db.go
- specmechanisms.go
- specref.go
- surrogate.go
- temporal.go
- utilities.go
- wrf.go
Directories ¶
Path | Synopsis |
---|---|
Package aeputil provides commonly used configuration and functions for the AEP library.
|
Package aeputil provides commonly used configuration and functions for the AEP library. |
data
|
|
Package megan holds v3beta of the MEGAN biogenic emissions model.
|
Package megan holds v3beta of the MEGAN biogenic emissions model. |