Source Receptor Matrix Tools

InMAPSourceReceptorMatrices.run_srFunction
run_sr(source_emis::DataFrame, [cell_variables]) -> receptor_emis::DataFrame

Runs the source receptor matrix for the given source emissions, where each row represents an emitter. Note that source_emis must have the following columns:

  • latitude <: Number - latitude of the source
  • longitude <: Number - longitude of the source
  • layer_idx <: Integer - layer index ∈ {1,2,3}, for effective emission heights at ground level (emissions between 0 and 57 m), low level (57–379 m), and high level (>379 m) respectively
  • <emis_type> <: Number - the average emissions rate, in μg / s, for emission type <emis_type>{PM2_5, NOx, SO2, VOC, NH3}. There can be between 1 and 5 of these columns.
  • (optional) source_idx <: Int64 - which grid cell index corresponds to the source. If given, latitude and longitude no longer used.

Returns the receptor_emis table which contains columns for each of the PM types created by the source emissions, as well as columns for each of the variables in cell_variables, and a column for geometry_longlat, which contains the (lon, lat) geometry of each grid cell.

source
InMAPSourceReceptorMatrices.SRMFunction
SRM(emis_type) -> srm::Array{Float32, 3}

Returns source receptor matrix retrieved from fs, with emis_type ∈ ("PrimaryPM25", "SOA", "pNO3", "pSO4", "pNH4")

Note that these are huge (52411 x 52411 x 3) and will require ~60-70GB of RAM to hold onto. Index via (receptor, source, layer). Care should be taken if multiple stored in memory. May take 5-10 minutes to fetch from AWS.

To create a sparse SRM for only a select group of source locations, see make_sparse_srm. (that will still call SRM, but will call garbage collection before returning the sparse matrix)

source
InMAPSourceReceptorMatrices.SparseSRMFunction
SparseSRM(emis_type, source_idxs, [layer_idxs]; threshold=0.0)

Make a sparse source receptor matrix, indexable via (receptor, source, layer).

  • emis_type - The emission type for which to make the sparse matrix, ∈ ("PrimaryPM25", "SOA", "pNO3", "pSO4", "pNH4")
  • source_idxs - A vector of source indexes for which to add the pollution effects to the matrix
  • layer_idxs - A vector of layer_idxs for which to
  • threshold=0.0 - The threshold, in units (μg / m³) / (μg / s), above which to add the value to the sparse matrix. Adds every nonzero value by default.
source
SparseSRM(srm, source_idxs, [layer_idxs]; threshold=0.0)

Make a sparse source receptor matrix from an SRM (Array{Float32, 3}).

  • emis_type - The emission type for which to make the sparse matrix.
  • source_idxs - A vector of source indexes for which to add the pollution effects to the matrix
  • layer_idxs - A vector of layer_idxs for which to
  • threshold=0.0 - The threshold, in units (μg / m³) / (μg / s), above which to add the value to the sparse matrix. Adds every nonzero value by default.
source
InMAPSourceReceptorMatrices.compute_receptor_emisFunction
compute_receptor_emis(srm, source_idx(s), layer_idx(s), val(s)) -> receptor_emis::Vector

Compute the emissions at each receptor from srm for each source specified by source_idx and layer_idx, which correspond to val(s)

compute_receptor_emis(srm, source_emis::Matrix) -> receptor_emis::Vector

Compute the emissions at each receptor from srm for source_emis, a NSR x 3 matrix containing annual average emission rates at each grid cell and layer, in units of micrograms per second.

srm can be any of the following types:

  • Array{Float64, 3} - returned by SRM
  • SparseSRM
  • String - pm emission type ∈ ("PrimaryPM25", "SOA", "pNO3", "pSO4", "pNH4")
source

Cell Data

Geometry

InMAPSourceReceptorMatrices.longlat2isrmFunction
longlat2isrm() -> trans

Returns a Proj.Transformation for converting from (lon, lat) to the LCC coordinate system used by ISRM:

+proj=lcc +lat_1=33.000000 +lat_2=45.000000 +lat_0=40.000000 +lon_0=-97.000000 +x_0=0 +y_0=0 +a=6370997.000000 +b=6370997.000000 +to_meter=1.
source
InMAPSourceReceptorMatrices.isrm2longlatFunction
isrm2longlat() -> trans

Returns a Proj.Transformation for converting to (lon, lat) from the LCC coordinate system used by ISRM:

+proj=lcc +lat_1=33.000000 +lat_2=45.000000 +lat_0=40.000000 +lon_0=-97.000000 +x_0=0 +y_0=0 +a=6370997.000000 +b=6370997.000000 +to_meter=1.
source
InMAPSourceReceptorMatrices.get_cell_idxsFunction
get_cell_idxs(longlats, cell_geom::Vector; threshold = 1000) -> cell_idxs

get_cell_idxs(longs, lats, cell_geom::Vector; threshold = 1000) -> cell_idxs

Return the indices of the closest cells (in cell_geom) for each of the longs and lats supplied. If there is no grid cell within threshold meters from the point in cell_geom, gives an index of 0. cell_geom can either be the original geometry (represented as Boxes), or the longlat geometry (represented as Quadrangles).

source