Documentation ¶
Index ¶
- Constants
- func EmissionsTotal(recs []Record) map[Pollutant]*unit.Unit
- 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 NAICSDesc(filename string) (map[string]string, error)
- func SCCDescription(r io.Reader) (map[string]string, error)
- func SICDesc(filename string) (map[string]string, error)
- type ControlData
- type Country
- type EconomicData
- 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 InputUnits
- type InventoryFile
- type InventoryFrequency
- type InventoryReport
- type Location
- type Mechanisms
- type Period
- type PointRecord
- type PointSourceData
- type Pollutant
- type PolygonRecord
- type Raster
- 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 RecordElevated
- type RecordGridded
- type RecordGriddedAdjusted
- type RecordSpatialSurrogate
- type SearchIntersecter
- type SourceData
- type SourceDataLocation
- type SpatialAdjuster
- type SpatialProcessor
- type SpecRef
- type SpeciateDB
- type Speciation
- type SpeciationType
- type Speciator
- type SrgSpec
- type SrgSpecOSM
- type SrgSpecSMOKE
- type SrgSpecs
- type Status
- type SurrogateFilter
- type Table
- type Totaler
- 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 Global = 7 Unknown = -1 )
These are the currently supported countries.
Variables ¶
This section is empty.
Functions ¶
func EmissionsTotal ¶
EmissionsTotal returns the total combined emissions in recs.
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.
func MatchCodeDouble ¶
func MatchCodeDouble(code1, code2 string, matchmap map[string]map[string]interface{}) (matchedCode1, matchedCode2 string, matchVal interface{}, err error)
MatchCodeDouble finds code1 and code2 in matchmap.
func NAICSDesc ¶
NAICSDesc reads a NAICS description file, which gives descriptions for each NAICS code.
func SCCDescription ¶
SCCDescription reads a SMOKE sccdesc file, which gives descriptions for each SCC code. The returned data is in the form map[SCC]description.
Types ¶
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 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, gr *GridRef, sp *SrgSpecs) (*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'. gr and sp are used to reference emissions records to geographic locations; if they are both nil, the location referencing is skipped.
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 ¶
func (grid *GridDef) GetIndex(g geom.Geom) (rows, cols []int, fracs []float64, inGrid, coveredByGrid bool)
GetIndex gets the returns the row and column indices of geometry g in the grid. withinGrid is false if point (X,Y) is not within the grid. g can be a Point, Line, or Polygon. For lines and polygons, the fraction of g that is in each grid cell is returned as fracs. If g is a point, 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 ¶
type GridRef struct {
// contains filtered or unexported fields
}
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. sccExactMatch specifies whether SCC codes must match exactly, or if partial matches are allowed.
func (GridRef) GetSrgCode ¶
GetSrgCode returns the surrogate code appropriate for the given SCC code, country and FIPS.
type GriddedSrgData ¶
type GriddedSrgData struct { InputLocation *Location Cells []*GridCell SingleShapeSrgWeight float64 CoveredByGrid bool Nx, Ny int }
GriddedSrgData holds the data for a single input shape of a gridding surrogate.
func (*GriddedSrgData) ToGrid ¶ added in v1.7.0
func (gs *GriddedSrgData) ToGrid() (*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.
func (*GriddedSrgData) WriteToShp ¶
func (g *GriddedSrgData) WriteToShp(file string) error
WriteToShp write an individual gridding surrogate to a shapefile.
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 )
func ParseInputUnits ¶ added in v1.7.0
func ParseInputUnits(units string) (InputUnits, error)
ParseInputUnits parses a string representation of an input unit type. Currently supported options are "tons", "tonnes", "kg", "lbs", and "g".
func (InputUnits) Conversion ¶ added in v1.7.0
func (u InputUnits) Conversion(factor float64) func(v float64) *unit.Unit
Conversion returns a function that converts a value to units of kilograms. factor reprents an additional factor the value should be multiplied by.
type InventoryFile ¶
type InventoryFile struct { io.ReadSeeker // Period is the time period that the emissions in this file apply to. Period // 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.
func (*InventoryFile) DroppedTotals ¶
func (f *InventoryFile) DroppedTotals() map[Pollutant]*unit.Unit
DroppedTotals returns the total emissions in this file that are not being kept for analysis.
func (*InventoryFile) Group ¶
func (f *InventoryFile) Group() string
Group is a label for the group of files this is part of. It is used for reporting.
func (*InventoryFile) Name ¶
func (f *InventoryFile) Name() string
Name is the name of this file. It can be the path to the file or something else.
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 {
Data []Totaler
}
An InventoryReport report holds information about inventory data.
func (*InventoryReport) AddData ¶
func (ir *InventoryReport) AddData(data ...Totaler)
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 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.
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) Location ¶ added in v1.7.0
func (r *PointSourceData) Location() *Location
func (*PointSourceData) StackParameters ¶ added in v1.7.0
func (r *PointSourceData) StackParameters() (StackHeight, StackDiameter, StackTemp, StackFlow, StackVelocity *unit.Unit)
StackParameters describes the parameters of the emissions release from a elevated stack.
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 { SourceDataLocation 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 Raster ¶ added in v1.9.0
type Raster struct {
// contains filtered or unexported fields
}
Raster is a holder for gridded data.
func ReadCOARDSFile ¶ added in v1.7.0
func ReadCOARDSFile(file string, begin, end time.Time, units InputUnits, sourceData SourceData) (*Raster, error)
ReadCOARDSFile reads a COARDS-compliant NetCDF file (NetCDF 4 and greater not supported) and returns a record generator. The generator will return io.EOF after the last record. All floating point variables that have dimensions [lat, lon] are assumed to be emissions variables. begin and end specify the time period when the emissions occur. units represents the input units of the emissions. SourceData specifies additional information to be included in each emissions record. Data in the COARDS file are assumed to be row-major (i.e., latitude-major). Information regarding the COARDS NetCDF conventions are available here: https://ferret.pmel.noaa.gov/Ferret/documentation/coards-netcdf-conventions.
type RecFilter ¶
RecFilter is a class of functions that return true if a record should be kept and processed.
type Record ¶
type Record interface { // Key returns a unique identifier for this record. Key() string // Location returns the polygon representing the location of emissions. Location() *Location // 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 }
A Record holds data from a parsed emissions inventory record.
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 RecordElevated ¶ added in v1.7.0
type RecordElevated interface { Record // StackParameters describes the parameters of the emissions release // from a elevated stack. StackParameters() (StackHeight, StackDiameter, StackTemp, StackFlow, StackVelocity *unit.Unit) // GroundLevel returns true if the receiver emissions are // at ground level and false if they are elevated. GroundLevel() bool }
RecordElevated describes emissions that are released from above ground.
type RecordGridded ¶ added in v1.7.0
type RecordGridded interface { Record // Parent returns the record that this record was created from. Parent() Record // GridFactors returns the normalized fractions of emissions in each // grid cell (gridSrg) of grid index gi. // coveredByGrid indicates whether the emissions source is completely // covered by the grid, and inGrid indicates whether it is in the // grid at all. GridFactors(gi int) (gridSrg *sparse.SparseArray, coveredByGrid, inGrid bool, err error) // GriddedEmissions returns gridded emissions of the receiver for a given grid index and period. GriddedEmissions(begin, end time.Time, gi int) ( emis map[Pollutant]*sparse.SparseArray, units map[Pollutant]unit.Dimensions, err error) }
RecordGridded represents an emissions record that can be allocated to a spatial grid.
type RecordGriddedAdjusted ¶ added in v1.7.0
type RecordGriddedAdjusted struct { // RecordGridded is the record to be adjusted. RecordGridded // SpatialAdjuster specifies the adjustment to occur. SpatialAdjuster }
RecordGriddedAdjusted wraps around a RecordGridded to provide a spatially-explicit adjustment.
func (*RecordGriddedAdjusted) GridFactors ¶ added in v1.7.0
func (r *RecordGriddedAdjusted) GridFactors(gi int) ( gridSrg *sparse.SparseArray, coveredByGrid, inGrid bool, err error)
GridFactors calls the GridFactors method of the contained Record and adjusts the output using the SpatialAdjuster field.
func (*RecordGriddedAdjusted) GriddedEmissions ¶ added in v1.7.0
func (r *RecordGriddedAdjusted) GriddedEmissions(begin, end time.Time, gi int) ( emis map[Pollutant]*sparse.SparseArray, units map[Pollutant]unit.Dimensions, err error)
GriddedEmissions calls the GriddedEmissions method of the contained Record and adjusts the output using the SpatialAdjuster field.
type RecordSpatialSurrogate ¶ added in v1.7.0
type RecordSpatialSurrogate interface { Record // Parent returns the record that this record was created from. Parent() Record // SurrogateSpecification returns the specification of the spatial surrogate // associated with an area emissions source. SurrogateSpecification() (SrgSpec, error) }
RecordSpatialSurrogate describes emissions that need to be allocated to a grid using a spatial surrogate.
type SearchIntersecter ¶ added in v1.9.0
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.
type SourceDataLocation ¶ added in v1.7.0
type SourceDataLocation struct { SourceData // contains filtered or unexported fields }
func (*SourceDataLocation) Location ¶ added in v1.7.0
func (r *SourceDataLocation) Location() *Location
Location returns the polygon representing the location of emissions.
func (*SourceDataLocation) SurrogateSpecification ¶ added in v1.7.0
func (r *SourceDataLocation) SurrogateSpecification(sp *SpatialProcessor) (SrgSpec, error)
SurrogateSpecification returns the specification of the spatial surrogate associated with an area emissions source.
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 *SrgSpecs Grids []*GridDef GridRef *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 // SrgCellRatio is the number of surrogate shapes to process per // grid cell for each input shape. Larger numbers require // longer to compute. If srgCellRatio > 1, all surrogate // shapes will be processed. SrgCellRatio int MsgChan chan string // 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) AddSurrogate ¶ added in v1.7.0
func (sp *SpatialProcessor) AddSurrogate(r Record) RecordSpatialSurrogate
AddSurrogate adds a spatial surrogate to a record to increase its spatial resolution.
func (*SpatialProcessor) GridRecord ¶ added in v1.7.0
func (sp *SpatialProcessor) GridRecord(r Record) RecordGridded
GridRecord returns a record that can allocate the emissions to a grid.
func (*SpatialProcessor) Surrogate ¶
func (sp *SpatialProcessor) Surrogate(srgSpec SrgSpec, grid *GridDef, loc *Location) (*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 SrgSpecOSM ¶ added in v1.7.0
type SrgSpecOSM struct { Region Country `json:"region"` Name string `json:"name"` Code string `json:"code"` // The name of the PostGIS table that contains the surrogate data. // The default osm2pgsql table names are: planet_osm_line, // planet_osm_roads, planet_osm_polygon, and planet_osm_point. OSMTable string `json:"osm_table"` Tags map[string][]string `json:"tags"` // BackupSurrogateNames specifies names of surrogates to use if this // one doesn't have data for the desired location. BackupSurrogateNames []string `json:"backup_surrogate_names"` // MergeNames specify names of other surrogates that should be combined // to create this surrogate. MergeNames []string `json:"merge_names"` // MergeMultipliers specifies multipliers associated with the surrogates // in MergeNames. MergeMultipliers []float64 `json:"merge_multipliers"` // contains filtered or unexported fields }
SrgSpecOSM holds OpenStreetMap spatial surrogate specification information.
type SrgSpecSMOKE ¶ added in v1.7.0
type SrgSpecSMOKE 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 }
SrgSpecSMOKE holds SMOKE-formatted spatial surrogate specification information. See the SMOKE emissions model technical documentation for additional information.
func (*SrgSpecSMOKE) InputShapes ¶ added in v1.7.0
func (srg *SrgSpecSMOKE) InputShapes() (map[string]*Location, error)
InputShapes returns the input shapes associated with the receiver.
type SrgSpecs ¶
type SrgSpecs struct {
// contains filtered or unexported fields
}
SrgSpecs holds a group of surrogate specifications
func ReadSrgSpecOSM ¶ added in v1.7.0
ReadSrgSpec reads a OpenStreetMap surrogate specification formated as a JSON array of SrgSpecOSM objects. postGISURL specifies the URL to use to connect to a PostGIS database with the OpenStreetMap data loaded. The URL should be in the format: postgres://username:password@hostname:port/databasename".
The OpenStreetMap data can be loaded into the database using the osm2pgsql program, for example with the command: osm2pgsql -l --hstore-all --hstore-add-index --database=databasename --host=hostname --port=port --username=username --create planet_latest.osm.pbf
The -l and --hstore-all flags for the osm2pgsql command are both necessary, and the PostGIS database should have the "hstore" extension installed before loading the data.
func ReadSrgSpecSMOKE ¶ added in v1.7.0
func ReadSrgSpecSMOKE(fid io.Reader, shapefileDir string, checkShapefiles bool, diskCachePath string, memCacheSize int) (*SrgSpecs, error)
ReadSrgSpecSMOKE 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. diskCachePath specifies a path to a directory where an on-disk cache should be created (if "", no cache will be created), and memCacheSize specifies the number of surrogate data entries to hold in an in-memory cache.
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 Totaler ¶
type Totaler interface { Totals() map[Pollutant]*unit.Unit DroppedTotals() map[Pollutant]*unit.Unit // Group returns the group that the receiver belongs to. Group() string // Name returns the name of the receiver. Name() string }
Totaler is an interface for types than can return emissions totals and dropped emissions totals.
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.
Source Files ¶
- coards_record.go
- controldata.go
- economicdata.go
- emissions.go
- ff10.go
- grid.go
- ida.go
- inventory.go
- inventoryfile.go
- orl.go
- period.go
- pointsourcedata.go
- report.go
- sourcedata.go
- spatial_adjust.go
- spatialize.go
- speciate.go
- speciate_db.go
- specmechanisms.go
- specref.go
- srgspec.go
- srgspec_osm.go
- surrogate.go
- utilities.go
- wrf.go