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 ¶
var RPCPort = "6060"
RPCPort specifies the port for RPC communications. The default is 6060.
Functions ¶
func WorkerListen ¶
WorkerListen directs the Worker to start listening for requests over RPCPort. It is a top-level function rather than a method of s to avoid problems with RPC registration.
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 Cluster ¶
type Cluster struct { // StartupTime specifies how long a worker is expected to take to initialize. // The default is 3 minutes. StartupTime time.Duration // contains filtered or unexported fields }
Cluster manages and distributes work to a group of workers.
func NewCluster ¶
NewCluster creates a new cluster of workers where log output will be directed to logDir. exitService is the name of the RPC service that should be called to shut down each worker, which will not be be sent any input data. RPCPort is the port over which RPC communication will occur.
func (*Cluster) NewRequest ¶
NewRequest creates a new request where service is the RPC service that should be called and requestPayload is the input data that will be used to generate the results. The result of the RPC call must be of the same type as the request payload.
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 IOData ¶
type IOData struct { Emis []*inmap.EmisRecord Output map[string][]float64 Row, Layer int }
IOData holds the input to and output from a simulation request.
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 ¶
Geometry returns the SR matrix grid geometry in the native grid projection.
func (*Reader) Source ¶ added in v1.2.1
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.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request holds information about a request that is to be handled by a cluster
type SR ¶
type SR struct {
// contains filtered or unexported fields
}
SR can be used to create a source-receptor matrix.
func NewSR ¶
func NewSR(varGridFile, inmapDataFile, command, logDir string, config *inmap.VarGridConfig, nodes []string) (*SR, error)
NewSR initializes an SR object. varGridFile specifies the location of the InMAP variable grid data. inmapDataFile specifies the location of the InMAP regular grid data. command is the command that should be executed to start slave processes. nodes specify unique addresses of the machines that the simulations should be carried out on. If len(nodes) == 0, then calculations will be carried out locally instead of on a cluster.
func (*SR) Run ¶
Run runs the simulations necessary to create a source-receptor matrix and writes out the results. 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. 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.
type Worker ¶
type Worker struct { Config *inmap.VarGridConfig CTMData *inmap.CTMData Pop *inmap.Population PopIndices inmap.PopIndices MR *inmap.MortalityRates MortIndices inmap.MortIndices GridGeom []geom.Polygonal // Geometry of the output grid. InMAPDataFile string // inmapDataFile is the path to the input data file in .gob format. }
Worker is a worker for performing InMAP simulations. It should not be interacted with directly, but it is exported to meet RPC requirements.
func NewWorker ¶
func NewWorker(config *inmap.VarGridConfig, InMAPDataFile string, GridGeom []geom.Polygonal) *Worker
NewWorker sets up an RPC listener for performing simulations. InMAPDataFile specifies the location of the inmap regular-gridded data, and GridGeom specifies the output grid geometry.
func (*Worker) Calculate ¶
Calculate performs an InMAP simulation. It meets the requirements for use with rpc.Call.