Documentation ¶
Overview ¶
Package inmap is an air quality model for predicting health impacts of air pollutant emissions.
Index ¶
- Constants
- Variables
- func Regrid(oldGeom, newGeom []geom.Polygonal, oldData []float64) (newData []float64, err error)
- type CTMData
- type Cell
- type CellManipulator
- type ConvergenceStatus
- type DomainManipulator
- func Calculations(calculators ...CellManipulator) DomainManipulator
- func HTMLUI(address string) DomainManipulator
- func Load(r io.Reader, config *VarGridConfig, emis *Emissions) DomainManipulator
- func Log(c chan *SimulationStatus) DomainManipulator
- func Output(fileName string, allLayers bool, outputVariables ...string) DomainManipulator
- func ResetCells() DomainManipulator
- func RunPeriodically(period float64, f DomainManipulator) DomainManipulator
- func Save(w io.Writer) DomainManipulator
- func SetTimestepCFL() DomainManipulator
- func SteadyStateConvergenceCheck(numIterations int, popGridColumn string, c chan ConvergenceStatus) DomainManipulator
- type EmisRecord
- type Emissions
- type GridMutator
- type InMAP
- func (d *InMAP) CellIntersections(g geom.Geom) (cells []*Cell, fractions []float64)
- func (d *InMAP) Cells() []*Cell
- func (d *InMAP) Cleanup() error
- func (d *InMAP) GetGeometry(layer int, webMap bool) []geom.Polygonal
- func (d *InMAP) Init() error
- func (d *InMAP) InsertCell(c *Cell)
- func (d *InMAP) IntakeFraction(breathingRate float64) map[string]map[string]float64
- func (d *InMAP) LegendHandler(w http.ResponseWriter, r *http.Request)
- func (d *InMAP) OutputOptions() (names []string, descriptions []string, units []string)
- func (d *InMAP) Results(allLayers bool, outputVariables ...string) (map[string][]float64, error)
- func (d *InMAP) Run() error
- func (d *InMAP) VerticalProfile(variable string, p geom.Point) (height, vals []float64, err error)
- type MortalityRates
- type PopConcMutator
- type PopIndices
- type Population
- type SimulationStatus
- type VarGridConfig
- func (config *VarGridConfig) LoadCTMData(rw cdf.ReaderWriterAt) (*CTMData, error)
- func (config *VarGridConfig) LoadPopMort() (*Population, PopIndices, *MortalityRates, error)
- func (config *VarGridConfig) MutateGrid(divideRule GridMutator, data *CTMData, pop *Population, mort *MortalityRates, ...) DomainManipulator
- func (config *VarGridConfig) RegularGrid(data *CTMData, pop *Population, popIndex PopIndices, mort *MortalityRates, ...) DomainManipulator
Constants ¶
const ( // Version gives the version number. Version = "1.2.0" // VarGridDataVersion gives the version of the variable grid data reuquired by // this version of the software. VarGridDataVersion = "1.2.0" // InMAPDataVersion is the version of the InMAP data required by this version // of the software. InMAPDataVersion = "1.2.0" )
const ( NOxToN = mwN / mwNOx NtoNO3 = mwNO3 / mwN SOxToS = mwSO2 / mwS StoSO4 = mwS / mwSO4 NH3ToN = mwN / mwNH3 NtoNH4 = mwNH4 / mwN )
Chemical mass conversions [ratios]
Variables ¶
var EmisNames = []string{"VOC", "NOx", "NH3", "SOx", "PM2_5"}
EmisNames are the names of pollutants accepted as emissions [μg/s]
var PolLabels = map[string]polConv{ "Total PM2.5": {[]int{iPM2_5, ipOrg, ipNH, ipS, ipNO}, []float64{1, 1, NtoNH4, StoSO4, NtoNO3}}, "VOC": {[]int{igOrg}, []float64{1.}}, "SOA": {[]int{ipOrg}, []float64{1.}}, "Primary PM2.5": {[]int{iPM2_5}, []float64{1.}}, "NH3": {[]int{igNH}, []float64{1. / NH3ToN}}, "pNH4": {[]int{ipNH}, []float64{NtoNH4}}, "SOx": {[]int{igS}, []float64{1. / SOxToS}}, "pSO4": {[]int{ipS}, []float64{StoSO4}}, "NOx": {[]int{igNO}, []float64{1. / NOxToN}}, "pNO3": {[]int{ipNO}, []float64{NtoNO3}}, }
PolLabels are labels and conversions for InMAP pollutants.
var PolNames = []string{"gOrg", "pOrg",
"PM2_5",
"gNH", "pNH",
"gS", "pS",
"gNO", "pNO",
}
PolNames are the names of pollutants within the model
Functions ¶
Types ¶
type CTMData ¶ added in v1.2.0
type CTMData struct {
// contains filtered or unexported fields
}
CTMData holds processed data from a chemical transport model
func (*CTMData) AddVariable ¶ added in v1.2.0
func (d *CTMData) AddVariable(name string, dims []string, description, units string, data *sparse.DenseArray)
AddVariable adds data for a new variable to d.
type Cell ¶
type Cell struct { geom.Polygonal // Cell geometry WebMapGeom geom.Polygonal // Cell geometry in web map (mercator) coordinate system UAvg float64 `desc:"Average East-West wind speed" units:"m/s"` VAvg float64 `desc:"Average North-South wind speed" units:"m/s"` WAvg float64 `desc:"Average up-down wind speed" units:"m/s"` UDeviation float64 `desc:"Average deviation from East-West velocity" units:"m/s"` VDeviation float64 `desc:"Average deviation from North-South velocity" units:"m/s"` AOrgPartitioning float64 `desc:"Organic particle partitioning" units:"fraction particles"` BOrgPartitioning float64 // particle fraction SPartitioning float64 `desc:"Sulfur particle partitioning" units:"fraction particles"` NOPartitioning float64 `desc:"Nitrate particle partitioning" units:"fraction particles"` NHPartitioning float64 `desc:"Ammonium particle partitioning" units:"fraction particles"` SO2oxidation float64 `desc:"SO2 oxidation to SO4 by HO and H2O2" units:"1/s"` ParticleWetDep float64 `desc:"Particle wet deposition" units:"1/s"` SO2WetDep float64 `desc:"SO2 wet deposition" units:"1/s"` OtherGasWetDep float64 `desc:"Wet deposition: other gases" units:"1/s"` ParticleDryDep float64 `desc:"Particle dry deposition" units:"m/s"` NH3DryDep float64 `desc:"Ammonia dry deposition" units:"m/s"` SO2DryDep float64 `desc:"SO2 dry deposition" units:"m/s"` VOCDryDep float64 `desc:"VOC dry deposition" units:"m/s"` NOxDryDep float64 `desc:"NOx dry deposition" units:"m/s"` Kzz float64 `desc:"Grid center vertical diffusivity after applying convective fraction" units:"m²/s"` Kxxyy float64 `desc:"Grid center horizontal diffusivity" units:"m²/s"` M2u float64 `desc:"ACM2 upward mixing (Pleim 2007)" units:"1/s"` M2d float64 `desc:"ACM2 downward mixing (Pleim 2007)" units:"1/s"` PopData []float64 // Population for multiple demographics [people/grid cell] MortalityRate float64 `desc:"Baseline mortality rate" units:"Deaths per 100,000 people per year"` Dx float64 `desc:"Cell x length" units:"m"` Dy float64 `desc:"Cell y length" units:"m"` Dz float64 `desc:"Cell z length" units:"m"` Volume float64 `desc:"Cell volume" units:"m³"` Ci []float64 // concentrations at beginning of time step [μg/m³] Cf []float64 // concentrations at end of time step [μg/m³] EmisFlux []float64 // emissions [μg/m³/s] CBaseline []float64 // Total baseline PM2.5 concentration. Layer int `desc:"Vertical layer index" units:"-"` LayerHeight float64 `desc:"Height at layer bottom" units:"m"` Temperature float64 `desc:"Average temperature" units:"K"` WindSpeed float64 `desc:"RMS wind speed" units:"m/s"` WindSpeedInverse float64 `desc:"RMS wind speed inverse" units:"(m/s)^(-1)"` WindSpeedMinusThird float64 `desc:"RMS wind speed^(-1/3)" units:"(m/s)^(-1/3)"` WindSpeedMinusOnePointFour float64 `desc:"RMS wind speed^(-1.4)" units:"(m/s)^(-1.4)"` S1 float64 `desc:"Stability parameter" units:"?"` SClass float64 `desc:"Stability class" units:"0=Unstable; 1=Stable"` Index [][2]int // Index gives this cell's place in the nest structure. AboveDensityThreshold bool // contains filtered or unexported fields }
Cell holds the state of a single grid cell.
func (*Cell) IsPlumeIn ¶ added in v1.2.0
func (c *Cell) IsPlumeIn(stackHeight, stackDiam, stackTemp, stackVel float64) (bool, float64, error)
IsPlumeIn calculates whether the plume rise from an emission is at the height of c when given stack information (see github.com/ctessum/atmos/plumerise for required units). The return values are whether the plume rise ends within the current cell, the height of the plume rise in meters, and whether there was an error.
type CellManipulator ¶ added in v1.2.0
CellManipulator is a class of functions that operate on a single grid cell, using the given timestep Dt.
func AddEmissionsFlux ¶ added in v1.2.0
func AddEmissionsFlux() CellManipulator
AddEmissionsFlux adds emissions to c.Cf and sets c.Ci equal to c.Cf. It should be run once for each timestep, and it should not be run in parallel with other CellManipulators.
func Chemistry ¶ added in v1.2.0
func Chemistry() CellManipulator
Chemistry returns a function that calculates the secondary formation of PM2.5. It explicitly calculates formation of particulate sulfate from gaseous and aqueous SO2. It partitions organic matter ("gOrg" and "pOrg"), the nitrogen in nitrate ("gNO and pNO"), and the nitrogen in ammonia ("gNH" and "pNH) between gaseous and particulate phase based on the spatially explicit partioning present in the baseline data.
func DryDeposition ¶ added in v1.2.0
func DryDeposition() CellManipulator
DryDeposition returns a function that calculates particle removal by dry deposition.
func MeanderMixing ¶ added in v1.2.0
func MeanderMixing() CellManipulator
MeanderMixing returns a function that calculates changes in concentrations caused by meanders: adevection that is resolved by the underlying comprehensive chemical transport model but is not resolved by InMAP.
func Mixing ¶ added in v1.2.0
func Mixing() CellManipulator
Mixing returns a function that calculates vertical mixing based on Pleim (2007), which is combined local-nonlocal closure scheme, for boundary layer and based on Wilson (2004) for above the boundary layer. Also calculate horizontal mixing.
func UpwindAdvection ¶ added in v1.2.0
func UpwindAdvection() CellManipulator
UpwindAdvection returns a function that calculates advection in the cell based on the upwind differences scheme.
func WetDeposition ¶ added in v1.2.0
func WetDeposition() CellManipulator
WetDeposition returns a function that calculates particle removal by wet deposition.
type ConvergenceStatus ¶ added in v1.2.0
type ConvergenceStatus []float64
ConvergenceStatus holds the percent difference for each pollutant between the last convergence check and this one.
func (ConvergenceStatus) String ¶ added in v1.2.0
func (c ConvergenceStatus) String() string
type DomainManipulator ¶ added in v1.2.0
DomainManipulator is a class of functions that operate on the entire InMAP domain.
func Calculations ¶ added in v1.2.0
func Calculations(calculators ...CellManipulator) DomainManipulator
Calculations returns a function that concurrently runs a series of calculations on all of the model grid cells.
func HTMLUI ¶ added in v1.2.0
func HTMLUI(address string) DomainManipulator
HTMLUI returns a function that serves an HTML user interface at address. If address is "", then the server won't run.
func Load ¶ added in v1.2.0
func Load(r io.Reader, config *VarGridConfig, emis *Emissions) DomainManipulator
Load returns a function that loads the data from a previously Saved file into an InMAP object.
func Log ¶ added in v1.2.0
func Log(c chan *SimulationStatus) DomainManipulator
Log sends simulation status messages to c.
func Output ¶ added in v1.2.0
func Output(fileName string, allLayers bool, outputVariables ...string) DomainManipulator
Output returns a function that writes simulation results to a shapefile or shapefiles. If allLayers` is true, the function writes out data for all of the vertical layers, otherwise only the ground-level layer is written. outputVariables is a list of the names of the variables to be output.
func ResetCells ¶ added in v1.2.0
func ResetCells() DomainManipulator
ResetCells clears concentration and emissions information from all of the grid cells and boundary cells.
func RunPeriodically ¶ added in v1.2.0
func RunPeriodically(period float64, f DomainManipulator) DomainManipulator
RunPeriodically runs f periodically during the simulation, with the time in seconds between runs specified by period.
func Save ¶ added in v1.2.0
func Save(w io.Writer) DomainManipulator
Save returns a function that saves the data in d to a gob file (format description at https://golang.org/pkg/encoding/gob/).
func SetTimestepCFL ¶ added in v1.2.0
func SetTimestepCFL() DomainManipulator
SetTimestepCFL returns a function that sets the time step using the Courant–Friedrichs–Lewy (CFL) condition for advection or Von Neumann stability analysis (http://en.wikipedia.org/wiki/Von_Neumann_stability_analysis) for diffusion, whichever one yields a smaller time step.
func SteadyStateConvergenceCheck ¶ added in v1.2.0
func SteadyStateConvergenceCheck(numIterations int, popGridColumn string, c chan ConvergenceStatus) DomainManipulator
SteadyStateConvergenceCheck checks whether a steady-state simulation is finished and sets the Done flag if it is. If numIterations > 0, the simulation is finished after that number of iterations have completed. Otherwise, the simulation has finished if the change in mass and population-weighted concentration of each pollutant in the domain since the last check are both less than 0.1%. Checks occur every 3 hours of simulation time. popGridColumn is the name of the population type used to determine grid cell sizes as in VarGridConfig.PopGridColumn. c is a channel over which the percent change between checks is sent. If c is nil, no status updates will be sent.
type EmisRecord ¶ added in v1.2.0
type EmisRecord struct { geom.Geom VOC, NOx, NH3, SOx float64 // emissions [μg/s] PM25 float64 `shp:"PM2_5"` // emissions [μg/s] Height float64 // stack height [m] Diam float64 // stack diameter [m] Temp float64 // stack temperature [K] Velocity float64 // stack velocity [m/s] }
EmisRecord is a holder for an emissions record.
type Emissions ¶ added in v1.2.0
type Emissions struct {
// contains filtered or unexported fields
}
Emissions is a holder for input emissions data.
func NewEmissions ¶ added in v1.2.0
func NewEmissions() *Emissions
NewEmissions Initializes a new emissions holder.
func ReadEmissionShapefiles ¶ added in v1.2.0
func ReadEmissionShapefiles(gridSR *proj.SR, units string, c chan string, shapefiles ...string) (*Emissions, error)
ReadEmissionShapefiles returns the emissions data in the specified shapefiles, and converts them to the spatial reference gridSR. Input units are specified by units; options are tons/year and kg/year. Output units = μg/s. c is a channel over which status updates will be sent. If c is nil, no updates will be sent.
func (*Emissions) Add ¶ added in v1.2.0
func (e *Emissions) Add(er *EmisRecord)
Add adds an emissions record to e.
type GridMutator ¶ added in v1.2.0
A GridMutator is a function whether a Cell should be mutated (i.e., either divided or combined with other cells), where totalMass is absolute value of the total mass of pollution in the system and totalPopulation is the total population in the system.
func PopulationMutator ¶ added in v1.2.0
func PopulationMutator(config *VarGridConfig, popIndices PopIndices) (GridMutator, error)
PopulationMutator returns a function that determines whether a grid cell should be split by determining whether either the cell population or maximum poulation density are above the thresholds specified in config.
type InMAP ¶ added in v1.2.0
type InMAP struct { // InitFuncs are functions to be called in the given order // at the beginning of the simulation. InitFuncs []DomainManipulator // RunFuncs are functions to be called in the given order repeatedly // until "Done" is true. Therefore, the simulation will not end until // one of RunFuncs sets "Done" to true. RunFuncs []DomainManipulator // CleanupFuncs are functions to be run in the given order after the // simulation has completed. CleanupFuncs []DomainManipulator Dt float64 // seconds // Done specifies whether the simulation is finished. Done bool // VariableDescriptions gives descriptions of the model variables. VariableDescriptions map[string]string // VariableUnits gives the units of the model variables. VariableUnits map[string]string // contains filtered or unexported fields }
InMAP holds the current state of the model.
func (*InMAP) CellIntersections ¶ added in v1.2.0
CellIntersections returns an array of all of the grid cells (on all vertical levels) that intersect g, and an array of the fraction of g that intersects with each cell.
func (*InMAP) GetGeometry ¶ added in v1.2.0
GetGeometry returns the cell geometry for the given layer. if WebMap is true, it returns the geometry in web mercator projection, otherwise it returns the native grid projection.
func (*InMAP) InsertCell ¶ added in v1.2.0
InsertCell adds a new cell to the grid. The function will take the necessary steps to fit the new cell in with existing cells, but it is the caller's reponsibility that the new cell doesn't overlap any existing cells.
func (*InMAP) IntakeFraction ¶ added in v1.2.0
IntakeFraction calculates intake fraction from InMAP results. The input value is average breathing rate [m³/day]. The returned value is a map structure of intake fractions by pollutant and population type (map[pollutant][population]iF). This function will only give the correct results if run after InMAP finishes calculating.
func (*InMAP) LegendHandler ¶ added in v1.2.0
func (d *InMAP) LegendHandler(w http.ResponseWriter, r *http.Request)
LegendHandler creates a legend and serves it.
func (*InMAP) OutputOptions ¶ added in v1.2.0
OutputOptions returns the options for output variable names and their descriptions.
func (*InMAP) Results ¶ added in v1.2.0
Results returns the simulation results. Output is in the form of map[variable][row]concentration. If allLayers` is true, the function returns data for all of the vertical layers, otherwise only the ground-level layer is returned. outputVariables is a list of the names of the variables for which data should be returned.
type MortalityRates ¶ added in v1.2.0
type MortalityRates struct {
// contains filtered or unexported fields
}
MortalityRates is a holder for information about the average human mortality rate (in units of deaths per 100,000 people per year) in the model domain.
type PopConcMutator ¶ added in v1.2.0
type PopConcMutator struct {
// contains filtered or unexported fields
}
PopConcMutator is a holds an algorithm for dividing grid cells based on gradients in population density and concentration. Refer to the methods for additional documentation.
func NewPopConcMutator ¶ added in v1.2.0
func NewPopConcMutator(config *VarGridConfig, popIndices PopIndices) *PopConcMutator
NewPopConcMutator initializes a new PopConcMutator object.
func (*PopConcMutator) AdjustThreshold ¶ added in v1.2.0
func (p *PopConcMutator) AdjustThreshold(finalThreshold float64, msgChan chan string) DomainManipulator
AdjustThreshold allows the model converge without out adding any grid cells, and then decreases the cell creation threshold to finalThreshold so grid cells will be added and waits for the model to converge again. This is useful because the model will converge faster with larger grid cells, so using this function will tend to decrease overall model run time as compared to initially setting the threshold to the desired value.
func (*PopConcMutator) Mutate ¶ added in v1.2.0
func (p *PopConcMutator) Mutate() GridMutator
Mutate returns a function that takes a grid cell and returns whether Σ(|ΔConcentration|)*combinedVolume*|ΔPopulation| / {Σ(|totalMass|)*totalPopulation} > a threshold between the grid cell in question and any of its horizontal neighbors, where Σ(|totalMass|) is the sum of the absolute values of the mass of all pollutants in all grid cells in the system, Σ(|ΔConcentration|) is the sum of the absolute value of the difference between pollution concentations in the cell in question and the neighbor in question, |ΔPopulation| is the absolute value of the difference in population between the two grid cells, totalPopulation is the total population in the domain, and combinedVolume is the combined volume of the cell in question and the neighbor in question.
type PopIndices ¶ added in v1.2.0
PopIndices give the array indices of each population type.
type Population ¶ added in v1.2.0
type Population struct {
// contains filtered or unexported fields
}
Population is a holder for information about the human population in the model domain.
type SimulationStatus ¶ added in v1.2.0
type SimulationStatus struct { // SimulationDays is the number of days in simulation time since the // start of the simulation. SimulationDays float64 // Iteration is the current iteration number. Iteration int // Walltime is the total wall time since the beginning of the simulation. Walltime time.Duration // StepWalltime is the wall time that elapsed during the most recent time step. StepWalltime time.Duration // Dt is the timestep in seconds. Dt float64 }
SimulationStatus holds information about the progress of a simulation.
func (SimulationStatus) String ¶ added in v1.2.0
func (s SimulationStatus) String() string
type VarGridConfig ¶ added in v1.2.0
type VarGridConfig struct { VariableGridXo float64 // lower left of output grid, x VariableGridYo float64 // lower left of output grid, y VariableGridDx float64 // m VariableGridDy float64 // m Xnests []int // Nesting multiples in the X direction Ynests []int // Nesting multiples in the Y direction HiResLayers int // number of layers to do in high resolution (layers above this will be lowest resolution. PopDensityThreshold float64 // limit for people per unit area in the grid cell PopThreshold float64 // limit for total number of people in the grid cell // PopConcThreshold is the limit for // Σ(|ΔConcentration|)*combinedVolume*|ΔPopulation| / {Σ(|totalMass|)*totalPopulation}. // See the documentation for PopConcMutator for more information. PopConcThreshold float64 CensusFile string // Path to census shapefile CensusPopColumns []string // Shapefile fields containing populations for multiple demographics PopGridColumn string // Name of field in shapefile to be used for determining variable grid resolution MortalityRateFile string // Path to the mortality rate shapefile MortalityRateColumn string // Name of field in mortality rate shapefile containing the mortality rate. GridProj string // projection info for CTM grid; Proj4 format // contains filtered or unexported fields }
VarGridConfig is a holder for the configuration information for creating a variable-resolution grid.
func (*VarGridConfig) LoadCTMData ¶ added in v1.2.0
func (config *VarGridConfig) LoadCTMData(rw cdf.ReaderWriterAt) (*CTMData, error)
LoadCTMData loads CTM data from a netcdf file.
func (*VarGridConfig) LoadPopMort ¶ added in v1.2.0
func (config *VarGridConfig) LoadPopMort() (*Population, PopIndices, *MortalityRates, error)
LoadPopMort loads the population and mortality rate data from the shapefiles specified in config.
func (*VarGridConfig) MutateGrid ¶ added in v1.2.0
func (config *VarGridConfig) MutateGrid(divideRule GridMutator, data *CTMData, pop *Population, mort *MortalityRates, emis *Emissions, logChan chan string) DomainManipulator
MutateGrid returns a function that creates a static variable resolution grid (i.e., one that does not change during the simulation) by dividing cells as determined by divideRule. Cells where divideRule is true are divided to the next nest level (up to the maximum nest level), and cells where divideRule is false are combined (down to the baseline nest level). Log messages are written to logChan if it is not nil.
func (*VarGridConfig) RegularGrid ¶ added in v1.2.0
func (config *VarGridConfig) RegularGrid(data *CTMData, pop *Population, popIndex PopIndices, mort *MortalityRates, emis *Emissions) DomainManipulator
RegularGrid returns a function that creates a new regular (i.e., not variable resolution) grid as specified by the information in c.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Command inmap is a command-line interface for the InMAP air pollution model.
|
Command inmap is a command-line interface for the InMAP air pollution model. |
cmd
Package cmd contains commands and subcommands for the InMAP command-line interface.
|
Package cmd contains commands and subcommands for the InMAP command-line interface. |
Package sr contains functions for creating a source-receptor (SR) matrix from the InMAP air pollution model and interacting with it.
|
Package sr contains functions for creating a source-receptor (SR) matrix from the InMAP air pollution model and interacting with it. |
Package wrf2inmap processes WRFChem output files into InMAP input files.
|
Package wrf2inmap processes WRFChem output files into InMAP input files. |