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

package inmap

import "github.com/spatialmodel/inmap"

Package inmap is an air quality model for predicting health impacts of air pollutant emissions.

Index

Package Files

framework.go gendoc.go geoschem.go io.go list.go mechanism.go neighbors.go plumerise.go preproc.go run.go save.go science.go testdata.go vargrid.go wrfchem.go

Constants

const (
    // Version gives the version number.
    Version = "1.6.0"

    // VarGridDataVersion gives the version of the variable grid data reuquired by
    // this version of the software.
    VarGridDataVersion = "1.3.0"

    // InMAPDataVersion is the version of the InMAP data required by this version
    // of the software.
    InMAPDataVersion = "1.2.0"
)
const (
    MWa = 28.97 // g/mol, molar mass of air

    // Chemical mass conversions [ratios]
    NOxToN = mwN / mwNOx
    NtoNO3 = mwNO3 / mwN
    SOxToS = mwSO2 / mwS
    StoSO4 = mwS / mwSO4
    NH3ToN = mwN / mwNH3
    NtoNH4 = mwNH4 / mwN
)

physical constants

const (
    TestGridSR = "" /* 434 byte string literal not displayed */

    TestPopulationShapefile = "tempPopulation.shp"

    TestMortalityShapefile = "tempMortality.shp"

    TestCTMDataFile = "tempCTMData.ncf"
)

Variables

var PolNames = []string{"gOrg", "pOrg",
    "PM2_5",
    "gNH", "pNH",
    "gS", "pS",
    "gNO", "pNO",
}

PolNames are the names of pollutants within the model

var USGSseinfeld = []seinfeld.LandUseCategory{
    seinfeld.Desert,
    seinfeld.Grass,
    seinfeld.Grass,
    seinfeld.Grass,
    seinfeld.Grass,
    seinfeld.Grass,
    seinfeld.Grass,
    seinfeld.Shrubs,
    seinfeld.Shrubs,
    seinfeld.Grass,
    seinfeld.Deciduous,
    seinfeld.Evergreen,
    seinfeld.Deciduous,
    seinfeld.Evergreen,
    seinfeld.Deciduous,
    seinfeld.Desert,
    seinfeld.Grass,
    seinfeld.Deciduous,
    seinfeld.Desert,
    seinfeld.Shrubs,
    seinfeld.Deciduous,
    seinfeld.Shrubs,
    seinfeld.Desert,
    seinfeld.Desert,
    seinfeld.Desert,
    seinfeld.Desert,
    seinfeld.Desert,
}

USGSseinfeld lookup table to go from USGS land classes to land classes for particle dry deposition.

var USGSwesely = []wesely1989.LandUseCategory{
    wesely1989.Urban,
    wesely1989.RangeAg,
    wesely1989.RangeAg,
    wesely1989.RangeAg,
    wesely1989.RangeAg,
    wesely1989.Agricultural,
    wesely1989.Range,
    wesely1989.RockyShrubs,
    wesely1989.RangeAg,
    wesely1989.Range,
    wesely1989.Deciduous,
    wesely1989.Coniferous,
    wesely1989.Deciduous,
    wesely1989.Coniferous,
    wesely1989.MixedForest,
    wesely1989.Water,
    wesely1989.Wetland,
    wesely1989.Wetland,
    wesely1989.Barren,
    wesely1989.RockyShrubs,
    wesely1989.MixedForest,
    wesely1989.RockyShrubs,
    wesely1989.Barren,
    wesely1989.Barren,
    wesely1989.Barren,
    wesely1989.Barren,
    wesely1989.Barren,
}

USGSwesely lookup table to go from USGS land classes to land classes for gas dry deposition.

var USGSz0 = []float64{.50, .1, .06, .1, 0.095, .20, .11,
    .03, .035, .15, .50, .50, .50, .50, .35, 0.0001, .20, .40,
    .01, .10, .30, .15, .075, 0.001, .01, .15, .01}

USGSz0 holds Roughness lengths for USGS land classes ([m]), from WRF file VEGPARM.TBL.

var WriteTestPopShapefile = func() {
    // holder for test population data.
    type pop struct {
        geom.Polygon
        TotalPop, WhiteNoLat, Black, Native, Asian, Latino float64
    }

    popData := []pop{
        {
            Polygon: []geom.Path{{
                geom.Point{X: -3999, Y: -3999},
                geom.Point{X: -3899, Y: -3999},
                geom.Point{X: -3899, Y: -3899},
                geom.Point{X: -3999, Y: -3899},
                geom.Point{X: -3999, Y: -3999},
            }},
            TotalPop:   100000.,
            WhiteNoLat: 50000.,
            Black:      20000.,
            Asian:      8000.,
            Native:     2000.,
            Latino:     20000.,
        },
        {
            Polygon: []geom.Path{{
                geom.Point{X: -3499, Y: -3001},
                geom.Point{X: -3501, Y: -3001},
                geom.Point{X: -3501, Y: -2999},
                geom.Point{X: -3499, Y: -2999},
                geom.Point{X: -3499, Y: -3001},
            }},
            TotalPop:   0.,
            WhiteNoLat: 0.,
            Black:      0.,
            Asian:      0.,
            Native:     0.,
            Latino:     10000.,
        },
    }
    e, err := shp.NewEncoder(TestPopulationShapefile, pop{})
    if err != nil {
        panic(err)
    }
    for _, p := range popData {
        if err = e.Encode(p); err != nil {
            panic(err)
        }
    }
    e.Close()
    f, err := os.Create(strings.TrimRight(TestPopulationShapefile, ".shp") + ".prj")
    if err != nil {
        panic(err)
    }
    if _, err = f.Write([]byte(TestGridSR)); err != nil {
        panic(err)
    }
    f.Close()
}

WriteTestPopShapefile writes out a population shapefile for testing.

func CreateTestCTMData Uses

func CreateTestCTMData() (VarGridConfig, *CTMData)

CreateTestCTMData creates example CTMData for testing.

func DeleteShapefile Uses

func DeleteShapefile(fname string)

DeleteShapefile deletes the named shapefile.

func Regrid Uses

func Regrid(oldGeom, newGeom []geom.Polygonal, oldData []float64) (newData []float64, err error)

Regrid regrids concentration data from one spatial grid to a different one.

func VarGridTestData Uses

func VarGridTestData() (*VarGridConfig, *CTMData, *Population, PopIndices, *MortalityRates, MortIndices)

VarGridTestData returns some test data for variable grid generation.

func WriteTestMortalityShapefile Uses

func WriteTestMortalityShapefile()

WriteTestMortalityShapefile writes out a mortality rate shapefile for testing.

type CTMData Uses

type CTMData struct {

    // Data is a map of information about processed CTM variables,
    // with the keys being the variable names.
    Data map[string]struct {
        Dims        []string           // netcdf dimensions for this variable
        Description string             // variable description
        Units       string             // variable units
        Data        *sparse.DenseArray // variable data
    }
    // contains filtered or unexported fields
}

CTMData holds processed data from a chemical transport model

func Preprocess Uses

func Preprocess(p Preprocessor) (*CTMData, error)

Preprocess returns preprocessed InMAP input data based on the information available from the given preprocessor.

func (*CTMData) AddVariable Uses

func (d *CTMData) AddVariable(name string, dims []string, description, units string, data *sparse.DenseArray)

AddVariable adds data for a new variable to d.

func (*CTMData) Write Uses

func (d *CTMData) Write(w *os.File, x0, y0, dx, dy float64) error

Write writes d to w. x0 and y0 are the left and y coordinates of the lower-left corner of the domain, and dx and dy are the x and y edge lengths of the grid cells, respectively.

type Cell Uses

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]
    MortData []float64 // Baseline mortality rates for multiple demographics [Deaths per 100,000 people per year/grid cell]

    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 Uses

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.

func (*Cell) String Uses

func (c *Cell) String() string

type CellManipulator Uses

type CellManipulator func(c *Cell, Dt float64)

CellManipulator is a class of functions that operate on a single grid cell, using the given timestep Dt [seconds].

func AddEmissionsFlux Uses

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 MeanderMixing Uses

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 Uses

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 Uses

func UpwindAdvection() CellManipulator

UpwindAdvection returns a function that calculates advection in the cell based on the upwind differences scheme.

type ConvergenceStatus Uses

type ConvergenceStatus struct {
    // contains filtered or unexported fields
}

ConvergenceStatus holds the percent difference for each pollutant between the last convergence check and this one.

func (ConvergenceStatus) String Uses

func (c ConvergenceStatus) String() string

type DomainManipulator Uses

type DomainManipulator func(d *InMAP) error

DomainManipulator is a class of functions that operate on the entire InMAP domain.

func Calculations Uses

func Calculations(calculators ...CellManipulator) DomainManipulator

Calculations returns a function that concurrently runs a series of calculations on all of the model grid cells.

func Load Uses

func Load(r io.Reader, config *VarGridConfig, emis *Emissions, m Mechanism) DomainManipulator

Load returns a function that loads the data from a previously Saved file into an InMAP object.

func Log Uses

func Log(c chan *SimulationStatus) DomainManipulator

Log sends simulation status messages to c.

func ResetCells Uses

func ResetCells() DomainManipulator

ResetCells clears concentration and emissions information from all of the grid cells and boundary cells.

func RunPeriodically Uses

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 Uses

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 Uses

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 Uses

func SteadyStateConvergenceCheck(numIterations int, popGridColumn string, m Mechanism, 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 Uses

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.

func FromAEP Uses

func FromAEP(r []aep.Record, sp *aep.SpatialProcessor, gi int, VOC, NOx, NH3, SOx, PM25 []aep.Pollutant) ([]*EmisRecord, error)

FromAEP converts the given AEP (github.com/spatialmodel/inmap/emissions/aep) records to EmisRecords using the given SpatialProcessor and the SpatialProcessor grid index gi. VOC, NOx, NH3, SOx, and PM25 are lists of AEP Polluants that should be mapped to those InMAP species. The returned EmisRecords will be grouped as much as possible to minimize the number of records.

type Emissions Uses

type Emissions struct {
    // contains filtered or unexported fields
}

Emissions is a holder for input emissions data.

func NewEmissions Uses

func NewEmissions() *Emissions

NewEmissions Initializes a new emissions holder.

func ReadEmissionShapefiles Uses

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, kg/year, ug/s, and μg/s. 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 Uses

func (e *Emissions) Add(er *EmisRecord)

Add adds an emissions record to e.

func (*Emissions) EmisRecords Uses

func (e *Emissions) EmisRecords() []*EmisRecord

EmisRecords returns all EmisRecords stored in the receiver.

type GEOSChem Uses

type GEOSChem struct {
    // contains filtered or unexported fields
}

GEOSChem is an InMAP preprocessor for GEOS-Chem output. Information regarding GEOS-Chem output variables is available from http://wiki.seas.harvard.edu/geos-chem/index.php/List_of_GEOS-FP_met_fields and http://wiki.seas.harvard.edu/geos-chem/index.php/Species_in_GEOS-Chem.

func NewGEOSChem Uses

func NewGEOSChem(GEOSA1, GEOSA3Cld, GEOSA3Dyn, GEOSI3, GEOSA3MstE, GEOSApBp, GEOSChemOut, OlsonLandMap, startDate, endDate string, dash bool, chemRecordStr, chemFileStr string, noChemHour bool, msgChan chan string) (*GEOSChem, error)

NewGEOSChem initializes a GEOS-Chem preprocessor from the given configuration information.

GEOSA1 is the location of the GEOS 1-hour time average files. [DATE] should be used as a wild card for the simulation date.

GEOSA3Cld is the location of the GEOS 3-hour average cloud parameter files. [DATE] should be used as a wild card for the simulation date.

GEOSA3Cld is the location of the GEOS 3-hour average dynamical parameter files. [DATE] should be used as a wild card for the simulation date.

GEOSI3 is the location of the GEOS 3-hour instantaneous parameter files. [DATE] should be used as a wild card for the simulation date.

GEOSA3MstE is the location of the GEOS 3-hour average moist parameters on level edges files. [DATE] should be used as a wild card for the simulation date.

geosApBp is the location of the pressure level variable file. It is optional; if it is not specified the Ap and Bp information will be extracted from the geosChem file.

GEOSChemOut is the location of GEOS-Chem output files. [DATE] should be used as a wild card for the simulation date.

OlsonLandMap is the location of the GEOS-Chem Olson land use map file, which is described here: http://wiki.seas.harvard.edu/geos-chem/index.php/Olson_land_map

startDate and endDate are the dates of the beginning and end of the simulation, respectively, in the format "YYYYMMDD".

If dash is true, GEOS-Chem chemical variable names are assumed to be in the form 'IJ-AVG-S__xxx'. If dash is false, they are assumed to be in the form 'IJ_AVG_S_xxx'.

If msgChan is not nil, status messages will be sent to it.

chemRecordInterval is the time interval between different records in the GEOS-Chem output. It is specified by the user as a string (chemRecordStr), e.g. "3h" for 3 hours.

chemFileInterval is the time interval of each file. It is specified as a string (chemFileStr), e.g. "3h" for 3 hours.

If noChemHour is true, then the GEOS-Chem output files will be assumed to not contain a time dimension.

func (*GEOSChem) ALT Uses

func (gc *GEOSChem) ALT() NextData

ALT helps fulfill the Preprocessor interface, returning inverse air density [m3/kg].

func (*GEOSChem) ASOA Uses

func (gc *GEOSChem) ASOA() NextData

ASOA helps fulfill the Preprocessor interface.

func (*GEOSChem) AVOC Uses

func (gc *GEOSChem) AVOC() NextData

AVOC helps fulfill the Preprocessor interface.

func (*GEOSChem) BSOA Uses

func (gc *GEOSChem) BSOA() NextData

BSOA helps fulfill the Preprocessor interface.

func (*GEOSChem) BVOC Uses

func (gc *GEOSChem) BVOC() NextData

BVOC helps fulfill the Preprocessor interface.

func (*GEOSChem) CloudFrac Uses

func (gc *GEOSChem) CloudFrac() NextData

CloudFrac helps fulfill the Preprocessor interface by returning the cloud volume fraction.

func (*GEOSChem) DX Uses

func (gc *GEOSChem) DX() (float64, error)

DX returns the longitude grid spacing.

func (*GEOSChem) DY Uses

func (gc *GEOSChem) DY() (float64, error)

DY returns the latitude grid spacing.

func (*GEOSChem) H2O2 Uses

func (gc *GEOSChem) H2O2() NextData

H2O2 helps fulfill the Preprocessor interface by returning hydrogen peroxide concentration [ppmv].

func (*GEOSChem) HO Uses

func (gc *GEOSChem) HO() NextData

HO helps fulfill the Preprocessor interface by returning hydroxyl radical concentration [ppmv].

func (*GEOSChem) Height Uses

func (gc *GEOSChem) Height() NextData

Height returns a functions that calculates layer heights at each time step using the hyposometric equation.

func (*GEOSChem) NH3 Uses

func (gc *GEOSChem) NH3() NextData

NH3 helps fulfill the Preprocessor interface.

func (*GEOSChem) NOx Uses

func (gc *GEOSChem) NOx() NextData

NOx helps fulfill the Preprocessor interface.

func (*GEOSChem) Nx Uses

func (gc *GEOSChem) Nx() (int, error)

Nx helps fulfill the Preprocessor interface by returning the number of grid cells in the West-East direction.

func (*GEOSChem) Ny Uses

func (gc *GEOSChem) Ny() (int, error)

Ny helps fulfill the Preprocessor interface by returning the number of grid cells in the South-North direction.

func (*GEOSChem) Nz Uses

func (gc *GEOSChem) Nz() (int, error)

Nz helps fulfill the Preprocessor interface by returning the number of grid cells in the below-above direction.

func (*GEOSChem) P Uses

func (gc *GEOSChem) P() NextData

P helps fulfill the Preprocessor interface by returning pressure [Pa].

func (*GEOSChem) PBLH Uses

func (gc *GEOSChem) PBLH() NextData

PBLH helps fulfill the Preprocessor interface.

func (*GEOSChem) PNH Uses

func (gc *GEOSChem) PNH() NextData

PNH helps fulfill the Preprocessor interface.

func (*GEOSChem) PNO Uses

func (gc *GEOSChem) PNO() NextData

PNO helps fulfill the Preprocessor interface.

func (*GEOSChem) PS Uses

func (gc *GEOSChem) PS() NextData

PS helps fulfill the Preprocessor interface.

func (*GEOSChem) QCloud Uses

func (gc *GEOSChem) QCloud() NextData

QCloud helps fulfill the Preprocessor interface by returning the cloud mass fraction.

func (*GEOSChem) QRain Uses

func (gc *GEOSChem) QRain() NextData

QRain helps fulfill the Preprocessor interface by returning rain mass fraction based on the GEOS precipitation rate [kg m-2 s-1] and the assumption (from the EMEP model wet deposition algorithm) that raindrops are falling at 5 m/s.

func (*GEOSChem) RadiationDown Uses

func (gc *GEOSChem) RadiationDown() NextData

RadiationDown helps fulfill the Preprocessor interface by returning downwelling radiation [W m-2].

func (*GEOSChem) SOx Uses

func (gc *GEOSChem) SOx() NextData

SOx helps fulfill the Preprocessor interface.

func (*GEOSChem) SeinfeldLandUse Uses

func (gc *GEOSChem) SeinfeldLandUse() NextData

SeinfeldLandUse helps fulfill the Preprocessor interface by returning land use categories as specified in github.com/ctessum/atmos/seinfeld.

func (*GEOSChem) SurfaceHeatFlux Uses

func (gc *GEOSChem) SurfaceHeatFlux() NextData

SurfaceHeatFlux helps fulfill the Preprocessor interface by returning sensible heat flux from turbulence [W/m2].

func (*GEOSChem) T Uses

func (gc *GEOSChem) T() NextData

T helps fulfill the Preprocessor interface by returning temperature [K].

func (*GEOSChem) TotalPM25 Uses

func (gc *GEOSChem) TotalPM25() NextData

TotalPM25 helps fulfill the Preprocessor interface.

func (*GEOSChem) U Uses

func (gc *GEOSChem) U() NextData

U helps fulfill the Preprocessor interface.

func (*GEOSChem) UStar Uses

func (gc *GEOSChem) UStar() NextData

UStar helps fulfill the Preprocessor interface by returning friction velocity [m/s].

func (*GEOSChem) V Uses

func (gc *GEOSChem) V() NextData

V helps fulfill the Preprocessor interface.

func (*GEOSChem) W Uses

func (gc *GEOSChem) W() NextData

W helps fulfill the Preprocessor interface.

func (*GEOSChem) WeselyLandUse Uses

func (gc *GEOSChem) WeselyLandUse() NextData

WeselyLandUse helps fulfill the Preprocessor interface by returning land use categories as specified in github.com/ctessum/atmos/wesely1989.

func (*GEOSChem) Xo Uses

func (gc *GEOSChem) Xo() (float64, error)

Xo returns the minimum longitude value in the grid

func (*GEOSChem) Yo Uses

func (gc *GEOSChem) Yo() (float64, error)

Xo returns the minimum latitude value in the grid

func (*GEOSChem) Z0 Uses

func (gc *GEOSChem) Z0() NextData

Z0 helps fulfill the Preprocessor interface by returning momentum roughness length [m].

type GridMutator Uses

type GridMutator func(cell *Cell, totalMass, totalPopulation float64) bool

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 Uses

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 Uses

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

    // PopIndices gives the array index of each population type in the PopData
    // field in each Cell.
    PopIndices map[string]int
    // contains filtered or unexported fields
}

InMAP holds the current state of the model.

func (*InMAP) CellIntersections Uses

func (d *InMAP) CellIntersections(g geom.Geom) (cells []*Cell, fractions []float64)

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) Cells Uses

func (d *InMAP) Cells() []*Cell

Cells returns the InMAP grid cells as an array.

func (*InMAP) Cleanup Uses

func (d *InMAP) Cleanup() error

Cleanup finishes the simulation by running d.CleanupFuncs.

func (*InMAP) GetGeometry Uses

func (d *InMAP) GetGeometry(layer int, webMap bool) []geom.Polygonal

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) Init Uses

func (d *InMAP) Init() error

Init initializes the simulation by running d.InitFuncs.

func (*InMAP) InsertCell Uses

func (d *InMAP) InsertCell(c *Cell, m Mechanism)

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) OutputOptions Uses

func (d *InMAP) OutputOptions(m Mechanism) (names []string, descriptions []string, units []string)

OutputOptions returns the options for output variable names and their descriptions.

func (*InMAP) Results Uses

func (d *InMAP) Results(o *Outputter) (map[string][]float64, error)

Results returns the simulation results. Output is in the form of map[variable][row]concentration.

func (*InMAP) Run Uses

func (d *InMAP) Run() error

Run carries out the simulation by running d.RunFuncs until d.Done is true.

func (*InMAP) VerticalProfile Uses

func (d *InMAP) VerticalProfile(variable string, p geom.Point, m Mechanism) (height, vals []float64, err error)

VerticalProfile retrieves the vertical profile for a given variable at the given location p in the native grid projection.

type Mechanism Uses

type Mechanism interface {
    // AddEmisFlux adds emissions flux to Cell c based on the given
    // pollutant name and amount in units of μg/s. The units of
    // the resulting flux may vary for different chemical mechanisms.
    AddEmisFlux(c *Cell, name string, val float64) error

    // DryDep returns a dry deposition function of the type indicated by
    // name that is compatible with this chemical mechanism.
    // Valid options may vary for different chemical mechanisms.
    DryDep(name string) (CellManipulator, error)

    // WetDep returns a dry deposition function of the type indicated by
    // name that is compatible with this chemical mechanism.
    // Valid options may vary for different chemical mechanisms.
    WetDep(name string) (CellManipulator, error)

    // Species returns the names of the emission and concentration pollutant
    // species that are used by this chemical mechanism.
    Species() []string

    // Value returns the concentration or emissions value of
    // the given variable in the given Cell. It returns an
    // error if given an invalid variable name.
    Value(c *Cell, variable string) (float64, error)

    // Units returns the units of the given variable, or an
    // error if the variable name is invalid.
    Units(variable string) (string, error)

    // Chemistry returns a function that simulates chemical reactions.
    Chemistry() CellManipulator

    // Len returns the number of pollutants in the chemical mechanism.
    Len() int
}

Mechanism is an interface for atmospheric chemical mechanisms.

type MortIndices Uses

type MortIndices map[string]int

MortIndices gives the array indices of each mortality rate.

type MortalityRates Uses

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 NextData Uses

type NextData func() (*sparse.DenseArray, error)

NextData is a type of function that returns data for the next time step. If there are no more time steps, it should return the io.EOF error.

type Outputter Uses

type Outputter struct {
    // contains filtered or unexported fields
}

Outputter is a holder for output parameters.

fileName contains the path where the output will be saved.

If allLayers is true, output will contain data for all of the vertical layers, otherwise only the ground-level layer is returned.

outputVariables maps the names of the variables for which data should be returned to expressions that define how the requested data should be calculated. These expressions can utilize variables built into the model, user-defined variables, and functions.

modelVariables is automatically generated based on the model variables that are required to calculate the requested output variables.

Functions are defined in the outputFunctions variable.

func NewOutputter Uses

func NewOutputter(fileName string, allLayers bool, outputVariables map[string]string, outputFunctions map[string]govaluate.ExpressionFunction, m Mechanism) (*Outputter, error)

NewOutputter initializes a new Outputter holder and adds a set of default output functions. Default functions include:

'exp(x)' which applies the exponental function e^x.

'log(x)' which applies the natural logarithm function log(e).

'log10(x)' which applies the base-10 logarithm function log10(e).

'sum(x)' which sums a variable across all grid cells.

func (*Outputter) CheckOutputVars Uses

func (o *Outputter) CheckOutputVars(m Mechanism) DomainManipulator

CheckOutputVars ensures that the requested output variables are all valid.

func (*Outputter) Output Uses

func (o *Outputter) Output(sr *proj.SR) DomainManipulator

Output writes the simulation results to a shapefile. SR is the spatial reference of the model grid.

type PopConcMutator Uses

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 Uses

func NewPopConcMutator(config *VarGridConfig, popIndices PopIndices) *PopConcMutator

NewPopConcMutator initializes a new PopConcMutator object.

func (*PopConcMutator) Mutate Uses

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 Uses

type PopIndices map[string]int

PopIndices gives the array indices of each population type.

type Population Uses

type Population struct {
    // contains filtered or unexported fields
}

Population is a holder for information about the human population in the model domain.

type Preprocessor Uses

type Preprocessor interface {
    // Nx is the number of grid cells in the West-East direction.
    Nx() (int, error)
    // Ny is the number of grid cells in the South-North direction.
    Ny() (int, error)
    // Nz is the number of grid cells in the below-above direction.
    Nz() (int, error)

    // PBLH is planetary boundary layer height [m].
    PBLH() NextData
    // Height is vertical layer height above ground [m].
    Height() NextData
    // ALT is inverse air density [m3/kg].
    ALT() NextData
    // T temperature [K].
    T() NextData
    // P is pressure [Pa].
    P() NextData

    // UStar is friction velocity [m/s].
    UStar() NextData
    // SeinfeldLandUse is land use categories as
    // specified in github.com/ctessum/atmos/seinfeld.
    SeinfeldLandUse() NextData
    // WeselyLandUse is land use categories as
    // specified in github.com/ctessum/atmos/wesely1989.
    WeselyLandUse() NextData
    // Z0 is surface roughness length [m].
    Z0() NextData

    // QRain is the mass fraction of rain [mass/mass].
    QRain() NextData
    // QCloud is the mass fraction of cloud water in each grid cell [mass/mass].
    QCloud() NextData
    // CloudFrac is the fraction of each grid cell filled with clouds [volume/volume].
    CloudFrac() NextData

    // SurfaceHeatFlux is heat flux at the surface [W/m2].
    SurfaceHeatFlux() NextData
    // RadiationDown is total downwelling radiation [W m-2].
    RadiationDown() NextData

    // U is West-East wind speed [m/s].
    U() NextData
    // V is South-North wind speed [m/s].
    V() NextData
    // W is below-above wind speed [m/s].
    W() NextData

    // AVOC is total concentration of anthropogenic
    // secondary organic aerosol precursors (VOCs) [μg/m3].
    AVOC() NextData
    // AVOC is total concentration of biogenic
    // secondary organic aerosol precursors (VOCs) [μg/m3].
    BVOC() NextData
    // ASOA is total concentration of anthropogenic
    // secondary organic aerosol [μg/m3].
    ASOA() NextData
    // BSOA is total concentration of biogenic
    // secondary organic aerosol [μg/m3].
    BSOA() NextData
    // NOx is concentration of oxides of Nitrogen [μg/m3].
    NOx() NextData
    // PNO is concentration of particulate nitrate [μg/m3].
    PNO() NextData
    // SOx is concentration of Sulfur oxides [μg/m3].
    SOx() NextData
    // PS is concentration of particulate sulfate [μg/m3].
    PS() NextData
    // NH3 is concentration of ammonia [μg/m3].
    NH3() NextData
    // PNH is concentration of particulate ammonium [μg/m3].
    PNH() NextData
    // TotalPM25 is total concentration of fine particulate matter (PM2.5) [μg/m3].
    TotalPM25() NextData
    // HO is hydroxyl radical concentration [ppmv].
    HO() NextData
    // H2O2 is hydrogen peroxide concentration [ppmv].
    H2O2() NextData
}

Preprocessor specifies the methods that are necessary for a variable to act as a preprocessor for InMAP inputs.

type SimulationStatus Uses

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 Uses

func (s SimulationStatus) String() string

type VarGridConfig Uses

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

    // MortalityRateColumns give the columns in the mortality rate
    // shapefile containing mortality rates, and the population groups that
    // should be used for population-weighting each mortality rate.
    MortalityRateColumns map[string]string

    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 Uses

func (config *VarGridConfig) LoadCTMData(rw cdf.ReaderWriterAt) (*CTMData, error)

LoadCTMData loads CTM data from a netcdf file.

func (*VarGridConfig) LoadPopMort Uses

func (config *VarGridConfig) LoadPopMort() (*Population, PopIndices, *MortalityRates, MortIndices, error)

LoadPopMort loads the population and mortality rate data from the shapefiles specified in config.

func (*VarGridConfig) MutateGrid Uses

func (config *VarGridConfig) MutateGrid(divideRule GridMutator, data *CTMData, pop *Population, mortRates *MortalityRates, emis *Emissions, m Mechanism, 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 Uses

func (config *VarGridConfig) RegularGrid(data *CTMData, pop *Population, popIndex PopIndices, mortRates *MortalityRates, mortIndex MortIndices, emis *Emissions, m Mechanism) DomainManipulator

RegularGrid returns a function that creates a new regular (i.e., not variable resolution) grid as specified by the information in c.

type WRFChem Uses

type WRFChem struct {
    // contains filtered or unexported fields
}

WRFChem is an InMAP preprocessor for WRF-Chem output.

func NewWRFChem Uses

func NewWRFChem(WRFOut, startDate, endDate string, msgChan chan string) (*WRFChem, error)

NewWRFChem initializes a WRF-Chem preprocessor from the given configuration information. WRFOut is the location of WRF-Chem output files. [DATE] should be used as a wild card for the simulation date. startDate and endDate are the dates of the beginning and end of the simulation, respectively, in the format "YYYYMMDD". If msgChan is not nil, status messages will be sent to it.

func (*WRFChem) ALT Uses

func (w *WRFChem) ALT() NextData

ALT helps fulfill the Preprocessor interface by returning inverse air density [m3/kg].

func (*WRFChem) ASOA Uses

func (w *WRFChem) ASOA() NextData

ASOA helps fulfill the Preprocessor interface.

func (*WRFChem) AVOC Uses

func (w *WRFChem) AVOC() NextData

AVOC helps fulfill the Preprocessor interface.

func (*WRFChem) BSOA Uses

func (w *WRFChem) BSOA() NextData

BSOA helps fulfill the Preprocessor interface.

func (*WRFChem) BVOC Uses

func (w *WRFChem) BVOC() NextData

BVOC helps fulfill the Preprocessor interface.

func (*WRFChem) CloudFrac Uses

func (w *WRFChem) CloudFrac() NextData

CloudFrac helps fulfill the Preprocessor interface by returning the fraction of each grid cell filled with clouds [volume/volume].

func (*WRFChem) GLW Uses

func (w *WRFChem) GLW() NextData

GLW helps fulfill the Preprocessor interface by returning downwelling long wave radiation at ground level [W/m2].

func (*WRFChem) H2O2 Uses

func (w *WRFChem) H2O2() NextData

H2O2 helps fulfill the Preprocessor interface by returning hydrogen peroxide concentration [ppmv].

func (*WRFChem) HO Uses

func (w *WRFChem) HO() NextData

HO helps fulfill the Preprocessor interface by returning hydroxyl radical concentration [ppmv].

func (*WRFChem) Height Uses

func (w *WRFChem) Height() NextData

Height helps fulfill the Preprocessor interface by returning layer heights above ground level calculated based on geopotential height. For more information, refer to http://www.openwfm.org/wiki/How_to_interpret_WRF_variables.

func (*WRFChem) NH3 Uses

func (w *WRFChem) NH3() NextData

NH3 helps fulfill the Preprocessor interface.

func (*WRFChem) NOx Uses

func (w *WRFChem) NOx() NextData

NOx helps fulfill the Preprocessor interface.

func (*WRFChem) Nx Uses

func (w *WRFChem) Nx() (int, error)

Nx helps fulfill the Preprocessor interface by returning the number of grid cells in the West-East direction.

func (*WRFChem) Ny Uses

func (w *WRFChem) Ny() (int, error)

Ny helps fulfill the Preprocessor interface by returning the number of grid cells in the South-North direction.

func (*WRFChem) Nz Uses

func (w *WRFChem) Nz() (int, error)

Nz helps fulfill the Preprocessor interface by returning the number of grid cells in the below-above direction.

func (*WRFChem) P Uses

func (w *WRFChem) P() NextData

P helps fulfill the Preprocessor interface by returning pressure [Pa].

func (*WRFChem) PBLH Uses

func (w *WRFChem) PBLH() NextData

PBLH helps fulfill the Preprocessor interface by returning planetary boundary layer height [m].

func (*WRFChem) PNH Uses

func (w *WRFChem) PNH() NextData

PNH helps fulfill the Preprocessor interface.

func (*WRFChem) PNO Uses

func (w *WRFChem) PNO() NextData

PNO helps fulfill the Preprocessor interface.

func (*WRFChem) PS Uses

func (w *WRFChem) PS() NextData

PS helps fulfill the Preprocessor interface.

func (*WRFChem) QCloud Uses

func (w *WRFChem) QCloud() NextData

QCloud helps fulfill the Preprocessor interface by returning the mass fraction of cloud water in each grid cell [mass/mass].

func (*WRFChem) QRain Uses

func (w *WRFChem) QRain() NextData

QRain helps fulfill the Preprocessor interface by returning rain mass fraction.

func (*WRFChem) RadiationDown Uses

func (w *WRFChem) RadiationDown() NextData

RadiationDown helps fulfill the Preprocessor interface by returning total downwelling radiation at ground level [W/m2].

func (*WRFChem) SOx Uses

func (w *WRFChem) SOx() NextData

SOx helps fulfill the Preprocessor interface.

func (*WRFChem) SWDown Uses

func (w *WRFChem) SWDown() NextData

SWDown helps fulfill the Preprocessor interface by returning downwelling short wave radiation at ground level [W/m2].

func (*WRFChem) SeinfeldLandUse Uses

func (w *WRFChem) SeinfeldLandUse() NextData

SeinfeldLandUse helps fulfill the Preprocessor interface by returning land use categories as specified in github.com/ctessum/atmos/seinfeld.

func (*WRFChem) SurfaceHeatFlux Uses

func (w *WRFChem) SurfaceHeatFlux() NextData

SurfaceHeatFlux helps fulfill the Preprocessor interface by returning heat flux at the surface [W/m2].

func (*WRFChem) T Uses

func (w *WRFChem) T() NextData

T helps fulfill the Preprocessor interface by returning temperature [K].

func (*WRFChem) TotalPM25 Uses

func (w *WRFChem) TotalPM25() NextData

TotalPM25 helps fulfill the Preprocessor interface.

func (*WRFChem) U Uses

func (w *WRFChem) U() NextData

U helps fulfill the Preprocessor interface by returning West-East wind speed [m/s].

func (*WRFChem) UStar Uses

func (w *WRFChem) UStar() NextData

UStar helps fulfill the Preprocessor interface by returning friction velocity [m/s].

func (*WRFChem) V Uses

func (w *WRFChem) V() NextData

V helps fulfill the Preprocessor interface by returning South-North wind speed [m/s].

func (*WRFChem) W Uses

func (w *WRFChem) W() NextData

W helps fulfill the Preprocessor interface by returning below-above wind speed [m/s].

func (*WRFChem) WeselyLandUse Uses

func (w *WRFChem) WeselyLandUse() NextData

WeselyLandUse helps fulfill the Preprocessor interface by returning land use categories as specified in github.com/ctessum/atmos/wesely1989.

func (*WRFChem) Z0 Uses

func (w *WRFChem) Z0() NextData

Z0 helps fulfill the Preprocessor interface by returning roughness length.

Directories

PathSynopsis
cloudPackage cloud contains utilities for distributed InMAP simulations.
cloud/cloudrpc
cloud/cloudrpc/cloudrpcgojsPackage cloudrpc is a generated protocol buffer package.
emissions/aep
emissions/aep/aeputilPackage aeputil provides commonly used configuration and functions for the AEP library.
emissions/slca
emissions/slca/eieioPackage eieio implements an Extended InMAP Economic Input-Output (EIEIO) life cycle assessment model based on the US Bureau of Economic Analysis (BEA) Annual Input-Output Accounts Data from https://www.gov/industry/io_annual.htm.
emissions/slca/eieio/cesPackage ces translates Consumer Expenditure Survey (CES) demographic data to EIO categories.
emissions/slca/eieio/eieiorpc
emissions/slca/eieio/eieiorpc/eieiorpcjsPackage eieiorpc is a generated protocol buffer package.
emissions/slca/eieio/gui
emissions/slca/greet
epiPackage epi holds a collection of functions for calculating the health impacts of air pollution.
inmaputilPackage inmaputil contains configuration and utility functions for commonly-used operations with the InMAP model.
internal
science/chem/simplechemPackage simplechem contains a simplified atmospheric chemistry mechanism.
science/drydep/simpledrydepPackage simpledrydep provides a atmospheric dry deposition algorithm for a small number of chemical species.
science/wetdep/emepwetdepPackage emepwetdep provides a atmospheric wet deposition algorithm from the EMEP model.
srPackage sr contains functions for creating a source-receptor (SR) matrix from the InMAP air pollution model and interacting with it.

Package inmap imports 34 packages (graph) and is imported by 10 packages. Updated 2019-07-23. Refresh now. Tools for package owners.