sr

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2021 License: GPL-3.0 Imports: 28 Imported by: 1

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AboveTopErr added in v1.4.1

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 added in v1.4.1

func (e AboveTopErr) Error() string

type Concentrations added in v1.4.1

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

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

func (*Concentrations) TotalPM25 added in v1.4.1

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

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

type Reader

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

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

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

func (*Reader) Concentrations

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

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

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

func (*Reader) Output added in v1.6.0

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 added in v1.6.0

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 added in v1.2.1

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

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

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

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

func NewSR

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 added in v1.5.0

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 added in v1.5.0

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 added in v1.5.0

func (sr *SR) Start(ctx context.Context, jobName, version 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. Version is the version of the InMAP docker container to use, e.g. "latest" or "v1.7.2".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL