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

package sr

import "github.com/spatialmodel/inmap/sr"

Package sr contains functions for creating a source-receptor (SR) matrix from the InMAP air pollution model and interacting with it.

Index

Package Files

sr.go srreader.go

type AboveTopErr Uses

type AboveTopErr struct {
    PlumeHeight float64
}

AboveTopErr is returned when the plume height of an emissions source is above the top layer in the SR matrix.

func (AboveTopErr) Error Uses

func (e AboveTopErr) Error() string

type Concentrations Uses

type Concentrations struct {
    PNH4, PNO3, PSO4, SOA, PrimaryPM25 []float64
}

Concentrations holds pollutant concentration information [μg/m3] for the PM2.5 subspecies.

func (*Concentrations) TotalPM25 Uses

func (c *Concentrations) TotalPM25() []float64

TotalPM25 returns total combined PM2.5 concentration [μg/m3].

type Reader Uses

type Reader struct {
    cdf.File

    // CacheSize specifies the number of records to be held in the memory cache.
    // Larger numbers lead to faster operation but greater memory use.
    // If the SR matrix is created from a version of InMAP with 50,000 grid cells
    // in each vertical layer, then a CacheSize of 50,000 would be the equivalent
    // of storing an entire vertical layer in the cache. The default is 100.
    // CacheSize can only be changed before the Reader has been used to read
    // concentrations for the first time.
    CacheSize int
    // contains filtered or unexported fields
}

Reader allows the interaction with a NetCDF-formatted source-receptor (SR) database.

func NewReader Uses

func NewReader(r cdf.ReaderWriterAt) (*Reader, error)

NewReader creates a new SR reader from the netcdf database specified by r.

func (*Reader) Concentrations Uses

func (sr *Reader) Concentrations(emis ...*inmap.EmisRecord) (*Concentrations, error)

Concentrations returns the change in Total PM2.5 concentrations caused by the emissions specified by e, after accounting for plume rise. If the emission plume height is above the highest layer in the SR matrix, the function will allocate the emissions to the top layer and an error of type AboveTopErr will be returned. In some cases it may be appropriate to ignore errors of this type. As specified in the EmisRecord documentation, emission units should be in μg/s.

func (*Reader) Geometry Uses

func (sr *Reader) Geometry() []geom.Polygonal

Geometry returns the SR matrix grid geometry in the native grid projection.

func (*Reader) Output Uses

func (sr *Reader) Output(shapefilePath string, variables map[string]string, funcs map[string]govaluate.ExpressionFunction, sRef *proj.SR) error

Output writes out the results specified by variables. See the documenation for inmap.Outputter for more information. This function assumes that concentrations have already been set using SetConcentrations. Note that because the SR matrix does not save gas-phase concentrations, attempts to output gas-phase equations will result in all zeros.

func (*Reader) SetConcentrations Uses

func (sr *Reader) SetConcentrations(c *Concentrations) error

SetConcentrations set the `Cf` concentration field of the underlying InMAP data structure to the specified values. This is not concurrency-safe.

func (*Reader) Source Uses

func (sr *Reader) Source(pol string, layer, index int) ([]float64, error)

Source returns concentrations in μg m-3 for emissions in μg s-1 of pollutant pol in SR layer index 'layer' and horizontal grid cell index 'index'. This function uses a cache with the size specified by the CacheSize attribute of the receiver to speed up repeated requests and is concurrency-safe. Users desiring to make changes to the returned values should make a copy first to avoid inadvertently editing the cached results which could cause subsequent results from this function to be incorrect. If the layer and index are not known, use the Concentrations method instead.

func (*Reader) Variables Uses

func (sr *Reader) Variables(names ...string) (map[string][]float64, error)

Variables returns the data for the InMAP variables named by names. Any changes to the returned data may also alter the underlying data.

type SR Uses

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

SR can be used to create a source-receptor matrix.

func NewSR Uses

func NewSR(varGridData io.Reader, varGridConfig *inmap.VarGridConfig, client cloudrpc.CloudRPCClient) (*SR, error)

NewSR initializes an SR object. varGridData specifies a reader for the variable grid data file, varGridConfig specifies the variable-resolution grid, and client specifies a client to the service for running the simulations.

func (*SR) Clean Uses

func (sr *SR) Clean(ctx context.Context, jobName string, layers []int, begin, end int) error

Clean removes intermediate files created during simulations carried out to create a source-receptor matrix. layers specifies the grid layers that SR relationships should be calculated for. begin and end are indices in the static variable grid where the computations should begin and end. if end<0, then end will be set to the last grid cell in the static grid.

func (*SR) Save Uses

func (sr *SR) Save(ctx context.Context, outfile, jobName string, layers []int, begin, end int) error

Save saves the results of the simulations that were run to create the SR matrix specified by jobName to outfile. layers specifies the grid layers that SR relationships were calculated for. begin and end are indices in the static variable grid where the computations should began and ended. if end<0, then end will be set to the last grid cell in the static grid. outfile is the location of the output file. The units of the SR matrix will be μg/m3 PM2.5 concentration at each receptor per μg/s emission at each source. If outfile already exists, the results will be written to the existing file; otherwise a new file will be created.

func (*SR) Start Uses

func (sr *SR) Start(ctx context.Context, jobName string, layers []int, begin, end int, root *cobra.Command, config *viper.Viper, cmdArgs, inputFiles []string, memoryGB int32) error

Start starts the simulations necessary to create a source-receptor matrix on a Kubernetes cluster.layers specifies the grid layers that SR relationships should be calculated for. begin and end are indices in the static variable grid where the computations should begin and end. if end<0, then end will be set to the last grid cell in the static grid.

Package sr imports 28 packages (graph) and is imported by 3 packages. Updated 2019-03-27. Refresh now. Tools for package owners.