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 s to start listening for requests over RPCPort
Types ¶
type Cluster ¶
type Cluster struct { // StartupTime specifies how long a worker is expected to take to initialize. // The default is 10 seconds. 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 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 ¶
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(e *inmap.EmisRecord) ([]float64, error)
Concentrations returns the change in Total PM2.5 concentrations caused by the emissions specified by e, after accounting for plume rise.
As specified in the EmisRecord documentation
emission units should be in μg/s.
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 GridGeom []geom.Polygonal // Geometry of the output grid. }
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, error)
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.